Parser Release C RC1 docs final clean up
[parser.git] / docs / userguide / featureusage.rst
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>
4
5 Parser tosca2heat Installation
6 ============================
7
8 Please follow the below installation steps to install tosca2heat submodule in parser.
9
10 Step 1: Clone the parser project.
11
12 .. code-block:: bash
13
14     git clone https://gerrit.opnfv.org/gerrit/parser
15
16 Step 2: Install the heat-translator sub project.
17
18 .. code-block:: bash
19
20     # uninstall pre-installed tosca-parser
21     pip uninstall -y heat-translator
22
23     # change directory to heat-translator
24     cd parser/tosca2heat/heat-translator
25
26     # install requirements
27     pip install -r requirements.txt
28
29     # install heat-translator
30     python setup.py install
31
32 Step 3: Install the tosca-parser sub project.
33
34 .. code-block:: bash
35
36     # uninstall pre-installed tosca-parser
37     pip uninstall -y tosca-parser
38
39     # change directory to tosca-parser
40     cd parser/tosca2heat/tosca-parser
41
42     # install requirements
43     pip install -r requirements.txt
44
45     # install tosca-parser
46     python setup.py install
47
48
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.
52
53 Parser tosca2heat Execution
54 ===========================
55
56 Step 1: Change directory to where the tosca yaml files are present, example is
57 below with vRNC definiton.
58
59 .. code-block:: bash
60
61     cd parser/tosca2heat/tosca-parser/toscaparser/extensions/nfv/tests/data/vRNC/Definitions
62
63
64 Step 2: Run the python command heat-translator with the TOSCA yaml file as an input option.
65
66 .. code-block:: bash
67
68     heat-translator --template-file=<input file> --template-type=tosca
69                     --outpurt-file=<output hot file>
70
71 Example:
72
73 .. code-block:: bash
74
75     heat-translator --template-file=vRNC.yaml \
76         --template-type=tosca --output-file=vRNC_hot.yaml
77
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:
81
82 .. code-block:: bash
83
84    tosca-parser --template-file=<input yaml file>
85
86 Example:
87
88 .. code-block:: bash
89
90    tosca-parser --template-file=vRNC.yaml
91
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
97
98
99
100
101 Parser yang2tosca Execution
102 ============================
103
104 Step 1: Change directory to where the scripts are present.
105
106 .. code-block:: bash
107
108     cd parser/yang2tosca
109
110 Step 2: Copy the YANG file which needs to be converted into TOSCA to
111         current (parser/yang2tosca) folder.
112
113 Step 3: Run the python script "parser.py" with the YANG file as an input option.
114
115 .. code-block:: bash
116
117     python parser.py -n "YANG filename"
118
119 Example:
120
121 .. code-block:: bash
122
123     python parser.py -n example.yaml
124
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.
127
128 .. code-block:: bash
129
130     cat "YANG filename_tosca.yaml"
131
132 Example:
133
134 .. code-block:: bash
135
136     cat example_tosca.yaml
137
138
139
140
141
142 Parser policy2tosca Execution
143 ============================
144
145 Step 1: To see a list of commands available.
146
147 .. code-block:: bash
148
149     policy2tosca --help
150
151 Step 2: To see help for an individual command, include the command name on the command line
152
153 .. code-block:: bash
154
155     policy2tosca help <service>
156
157 Step 3: To inject/remove policy types/policy definitions provide the TOSCA file as input to
158 policy2tosca command line.
159
160 .. code-block:: bash
161
162     policy2tosca <service> [arguments]
163
164 Example:
165
166 .. code-block:: bash
167
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
171
172
173 Step 4: Verify the TOSCA YAMl updated with the injection/removal executed.
174
175 .. code-block:: bash
176
177     cat "<source tosca file>"
178
179 Example:
180
181 .. code-block:: bash
182
183     cat example_tosca.yaml
184