summaryrefslogtreecommitdiffstats
path: root/tosca2heat/heat-translator-0.3.0/doc/source/usage.rst
blob: c2c9b5af0b77cec6637fcad331dcf26b246ef1a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
=====
Usage
=====

Use Heat-Translator with OpenStackClient (OSC)
----------------------------------------------
Assuming that OpenStackClient (OSC) is available in your environment, you can easily install Heat-Translator to use with OSC by following three steps::

    git clone https://github.com/openstack/heat-translator
    cd heat-translator
    sudo python setup.py install

Alternatively, you can install a particular release of Heat-Translator as available at https://pypi.python.org/pypi/heat-translator.

Once installation is complete, Heat-Translator is ready to use. Currently you can use it in following three ways.

Translate and get output on command line. For example: ::

    openstack translate template --template-file /home/openstack/heat-translator/translator/tests/data/tosca_helloworld.yaml --template-type tosca

Translate and save output of translated file to a desired destination. For example: ::

    openstack translate template --template-file /home/openstack/heat-translator/translator/tests/data/tosca_helloworld.yaml --template-type tosca --output-file /tmp/hot_hello_world.yaml

Do not translate but only validate template file. For example: ::

    openstack translate template --template-file /home/openstack/heat-translator/translator/tests/data/tosca_helloworld.yaml --template-type tosca --validate-only=true

You can learn more about available options by running following help command::

    openstack help translate template


Use Heat-Translator on its own
------------------------------
Heat-Translator can be used without any specific OpenStack environment set up as below::

    git clone https://github.com/openstack/heat-translator
    python heat_translator.py --template-file==<path to the YAML template> --template-type=<type of template e.g. tosca> --parameters="purpose=test"

The heat_translator.py test program is at the root level of the project. The program has currently tested with TOSCA templates.
It requires two arguments::

1. Path to the file that needs to be translated. The file, flat yaml template or CSAR, can be specified as a local file in your
system or via URL.
2. Type of translation (e.g. tosca)

For example, a TOSCA hello world template can be translated by running the following command from the project location::

    python heat_translator.py --template-file=translator/tests/data/tosca_helloworld.yaml --template-type=tosca

This should produce a translated Heat Orchestration Template on the command line. The translated content can be saved to a desired file by setting --output-file=<path>.
For example: ::

    python heat_translator.py --template-file=translator/tests/data/tosca_helloworld.yaml --template-type=tosca --output-file=/tmp/hot_helloworld.yaml

An optional argument can be provided to handle user inputs parameters. Also, a template file can only be validated instead of translation by using --validate-only=true
optional argument. The command below shows an example usage::

    python heat_translator.py --template-file==<path to the YAML template> --template-type=<type of template e.g. tosca> --validate-only=true

Alternatively, you can install a particular release of Heat-Translator as available at https://pypi.python.org/pypi/heat-translator.
In this case, you can simply run translation via CLI entry point::
    heat-translator --template-file=translator/tests/data/tosca_helloworld.yaml --template-type=tosca

When deploy the translated template with Heat, please keep in mind that you have image registered in the Glance. The Heat-Translator
project sets flavor and image from a pre-defined set of values (as listed in /home/openstack/heat-translator/translator/hot/tosca/tosca_compute.py)
with the best possible match to the constraints defined in the TOSCA template. If there is no possible match found, a null value is set for now.
Per the future plan, an image and flavor will be provided from an online repository.