219bc0edf22845a1036377dceff289b10c8a62e6
[parser.git] / docs / release / userguide / feature.userguide.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
6
7 Parser tosca2heat Execution
8 ===========================
9
10 Step 1: Change directory to where the tosca yaml files are present, example is
11 below with vRNC definiton.
12
13 .. code-block:: bash
14
15     cd parser/tosca2heat/tosca-parser/toscaparser/extensions/nfv/tests/data/vRNC/Definitions
16
17
18 Step 2: Run the python command heat-translator with the TOSCA yaml file as an input option.
19
20 .. code-block:: bash
21
22     heat-translator --template-file=<input file> --template-type=tosca
23                     --outpurt-file=<output hot file>
24
25 Example:
26
27 .. code-block:: bash
28
29     heat-translator --template-file=vRNC.yaml \
30         --template-type=tosca --output-file=vRNC_hot.yaml
31
32 **Notes**: heat-translator will call class of ToscaTemplate in tosca-parser firstly to validate and
33 parse input yaml file, then tranlate the file into hot file, if you only want to validate or
34 check the input file and don't want to translate, please use tosaca-parser as following:
35
36 .. code-block:: bash
37
38     tosca-parser --template-file=<path to the YAML template>  [--nrpv]  [--debug]
39     or
40         tosca-parser --template-file=<path to the CSAR zip file> [--nrpv]  [--debug]
41     or
42         tosca-parser --template-file=<URL to the template or CSAR>  [--nrpv]  [--debug]
43     options:
44       --nrpv Ignore input parameter validation when parse template.
45       --debug debug mode for print more details other than raise exceptions when errors happen
46
47 Example:
48
49 .. code-block:: bash
50
51    tosca-parser --template-file=vRNC.yaml --nrpv
52
53 Parser tosca2heat References
54 ============================
55 Refer two upstream components:
56  https://github.com/openstack/tosca-parser/blob/master/doc/source/usage.rst
57  https://github.com/openstack/heat-translator/blob/master/doc/source/usage.rst
58
59
60
61
62 Parser yang2tosca Execution
63 ===========================
64
65 Step 1: Change directory to where the scripts are present.
66
67 .. code-block:: bash
68
69     cd parser/yang2tosca
70
71 Step 2: Copy the YANG file which needs to be converted into TOSCA to
72         current (parser/yang2tosca) folder.
73
74 Step 3: Run the python script "parser.py" with the YANG file as an input option.
75
76 .. code-block:: bash
77
78     python parser.py -n "YANG filename"
79
80 Example:
81
82 .. code-block:: bash
83
84     python parser.py -n example.yaml
85
86 Step 4: Verify the TOSCA YAMl which file has been created with the same name
87         as the YANG file with a “_tosca” suffix.
88
89 .. code-block:: bash
90
91     cat "YANG filename_tosca.yaml"
92
93 Example:
94
95 .. code-block:: bash
96
97     cat example_tosca.yaml
98
99
100
101
102
103 Parser policy2tosca Execution
104 =============================
105
106 Step 1: To see a list of commands available.
107
108 .. code-block:: bash
109
110     policy2tosca --help
111
112 Step 2: To see help for an individual command, include the command name on the command line
113
114 .. code-block:: bash
115
116     policy2tosca help <service>
117
118 Step 3: To inject/remove policy types/policy definitions provide the TOSCA file as input to
119 policy2tosca command line.
120
121 .. code-block:: bash
122
123     policy2tosca <service> [arguments]
124
125 Example:
126
127 .. code-block:: bash
128
129     policy2tosca add-definition \
130         --policy_name rule2 --policy_type  tosca.policies.Placement.Geolocation \
131         --description "test description" \
132         --properties region:us-north-1,region:us-north-2,min_inst:2 \
133         --targets VNF2,VNF4 \
134         --metadata "map of strings" \
135         --triggers "1,2,3,4" \
136         --source example.yaml
137
138
139 Step 4: Verify the TOSCA YAMl updated with the injection/removal executed.
140
141 .. code-block:: bash
142
143     cat "<source tosca file>"
144
145 Example:
146
147 .. code-block:: bash
148
149     cat example_tosca.yaml
150
151
152 Parser verigraph Execution
153 ==========================
154
155 VeriGraph is accessible via both a RESTful API and a gRPC interface.
156
157 **REST API**
158
159 Step 1. Change directory to where the service graph examples are present
160
161 .. code-block:: bash
162
163    cd parser/verigraph/examples
164
165 Step 2. Use a REST client (e.g., cURL) to send a POST request (whose body is one of the JSON
166 file in the directory)
167
168 .. code-block:: bash
169
170    curl -X POST -d @<file_name>.json http://<server_address>:<server_port>/verify/api/graphs
171    --header "Content-Type:application/json"
172
173 Step 3. Use a REST client to send a GET request to check a reachability-based property between
174 two nodes of the service graph created in the previous step.
175
176 .. code-block:: bash
177
178    curl -X GET http://<server_addr>:<server_port>/verify/api/graphs/<graphID>/
179    policy?source=<srcNodeID>&destination=<dstNodeID>&type=<propertyType>
180
181 where:
182
183 - <graphID> is the identifier of the service graph created at Step 2
184 - <srcNodeID> is the name of the source node
185 - <dstNodeID> is the name of the destination node
186 - <propertyType> can be ``reachability``, ``isolation`` or ``traversal``
187
188 Step 4. the output is a JSON with the overall result of the verification process and the partial
189 result for each path that connects the source and destination nodes in the service graph.
190
191 **gRPC API**
192
193 VeriGraph exposes a gRPC interface that is self-descriptive by its Protobuf file
194 (``parser/verigraph/src/main/proto/verigraph.proto``). In the current release, Verigraph
195 misses a module that receives service graphs in format of JSON and sends the proper
196 requests to the gRPC server. A testing client has been provided to have an example of how
197 to create a service graph using the gRPC interface and to trigger the verification step.
198
199 1. Run the testing client
200
201 .. code-block:: bash
202
203       cd parser/verigraph
204       #Client souce code in ``parser/verigraph/src/it/polito/verigraph/grpc/client/Client.java``
205       ant -f buildVeriGraph_gRPC.xml run-client