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