1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. (c) <optionally add copywriters name>
5 Parser tosca2heat Installation
6 ============================
8 Please follow the below installation steps to install tosca2heat submodule in parser.
10 Step 1: Clone the parser project.
14 git clone https://gerrit.opnfv.org/gerrit/parser
16 Step 2: Install the heat-translator sub project.
20 # uninstall pre-installed tosca-parser
21 pip uninstall -y heat-translator
23 # change directory to heat-translator
24 cd parser/tosca2heat/heat-translator
26 # install requirements
27 pip install -r requirements.txt
29 # install heat-translator
30 python setup.py install
32 Step 3: Install the tosca-parser sub project.
36 # uninstall pre-installed tosca-parser
37 pip uninstall -y tosca-parser
39 # change directory to tosca-parser
40 cd parser/tosca2heat/tosca-parser
42 # install requirements
43 pip install -r requirements.txt
45 # install tosca-parser
46 python setup.py install
49 **Notes** It must uninstall pre-installed tosca-parser and heat-translator before install the two
50 components, and install heat-translator before installing tosca-parser, which is sure to use the
51 OPNFV version of tosca-parser and heat-translator other than openstack's components.
53 Parser tosca2heat Execution
54 ===========================
56 Step 1: Change directory to where the tosca yaml files are present, example is
57 below with vRNC definiton.
61 cd parser/tosca2heat/tosca-parser/toscaparser/extensions/nfv/tests/data/vRNC/Definitions
64 Step 2: Run the python command heat-translator with the TOSCA yaml file as an input option.
68 heat-translator --template-file=<input file> --template-type=tosca
69 --outpurt-file=<output hot file>
75 heat-translator --template-file=vRNC.yaml \
76 --template-type=tosca --output-file=vRNC_hot.yaml
78 Notes: heat-translator will call class of ToscaTemplate in tosca-parser firstly to validate and
79 parse input yaml file, then tranlate the file into hot file, if you only want to validate or
80 check the input file and don't want to translate, please use tosaca-parser as following:
84 tosca-parser --template-file=<input yaml file>
90 tosca-parser --template-file=vRNC.yaml
92 Parser tosca2heat References
93 ===========================
94 Refer two upstream components:
95 https://github.com/openstack/tosca-parser/blob/master/doc/source/usage.rst
96 https://github.com/openstack/heat-translator/blob/master/doc/source/usage.rst
101 Parser yang2tosca Execution
102 ============================
104 Step 1: Change directory to where the scripts are present.
110 Step 2: Copy the YANG file which needs to be converted into TOSCA to
111 current (parser/yang2tosca) folder.
113 Step 3: Run the python script "parser.py" with the YANG file as an input option.
117 python parser.py -n "YANG filename"
123 python parser.py -n example.yaml
125 Step 4: Verify the TOSCA YAMl which file has been created with the same name
126 as the YANG file with a “_tosca” suffix.
130 cat "YANG filename_tosca.yaml"
136 cat example_tosca.yaml
142 Parser policy2tosca Execution
143 ============================
145 Step 1: To see a list of commands available.
151 Step 2: To see help for an individual command, include the command name on the command line
155 policy2tosca help <service>
157 Step 3: To inject/remove policy types/policy definitions provide the TOSCA file as input to
158 policy2tosca command line.
162 policy2tosca <service> [arguments]
168 policy2tosca add-definition --policy_name rule2 --policy_type tosca.policies.Placement.Geolocation
169 --description "test description" --properties region:us-north-1,region:us-north-2,min_inst:2 --targets
170 VNF2,VNF4 --metadata "map of strings" --triggers "1,2,3,4" --source example.yaml
173 Step 4: Verify the TOSCA YAMl updated with the injection/removal executed.
177 cat "<source tosca file>"
183 cat example_tosca.yaml