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>
7 Parser tosca2heat Execution
8 ===========================
13 There only one way to call nfv-heattranslator service: CLI.
15 Step 1: Change directory to where the tosca yaml files are present, example is
16 below with vRNC definiton.
20 cd parser/tosca2heat/tosca-parser/toscaparser/extensions/nfv/tests/data/vRNC/Definitions
23 Step 2: Run the python command heat-translator with the TOSCA yaml file as an input option.
27 heat-translator --template-file=<input file> --template-type=tosca
28 --outpurt-file=<output hot file>
34 heat-translator --template-file=vRNC.yaml \
35 --template-type=tosca --output-file=vRNC_hot.yaml
37 **Notes**: nfv-heattranslator will call class of ToscaTemplate in nfv-toscaparser firstly to validate and
38 parse input yaml file, then tranlate the file into hot file.
44 Implementation of nfv-toscaparser derived from openstack tosca parser is based on the following OASIS specification:
45 TOSCA Simple Profile YAML 1.2 Referecne http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.2/TOSCA-Simple-Profile-YAML-v1.2.html
46 TOSCA Simple Profile YAML NFV 1.0 Referecne http://docs.oasis-open.org/tosca/tosca-nfv/v1.0/tosca-nfv-v1.0.html
48 There are three ways to call nfv-toscaparser service, Python Lib ,CLI and REST API.
52 Using cli, which is used to validate tosca simple based service template. It can be used as:
56 tosca-parser --template-file=<path to the YAML template> [--nrpv] [--debug]
57 tosca-parser --template-file=<path to the CSAR zip file> [--nrpv] [--debug]
58 tosca-parser --template-file=<URL to the template or CSAR> [--nrpv] [--debug]
61 --nrpv Ignore input parameter validation when parse template.
62 --debug debug mode for print more details other than raise exceptions when errors happen
68 Using api, which is used to parse and get the result of service template. it can be used as:
72 ToscaTemplate(path=None, parsed_params=None, a_file=True, yaml_dict_tpl=None,
73 sub_mapped_node_template=None,
74 no_required_paras_valid=False, debug=False)
79 Using RESTfual API, which are listed as following:
81 List template versions
82 ########################
84 PATH: /v1/template_versions
86 Decription: Lists all supported tosca template versions.
91 200 - OK Request was successful.
95 400 - Bad Request Some content in the request was invalid.
96 404 - Not Found The requested resource could not be found.
97 500 - Internal Server Error Something went wrong inside the service. This should not happen usually.
98 If it does happen, it means the server has experienced some serious problems.
106 template_versions array A list of tosca template version object each describes the type name and
107 version information for a template version.
110 Validates a service template
111 #############################
115 Decription: Validate a service template.
119 200 - OK Request was successful.
123 400 - Bad Request Some content in the request was invalid.
124 500 - Internal Server Error Something went wrong inside the service. This should not happen usually.
125 If it does happen, it means the server has experienced some serious problems.
127 environment (Optional) object A JSON environment for the template service.
128 environment_files (Optional) object An ordered list of names for environment files found in the files dict.
129 files (Optional) object
130 Supplies the contents of files referenced in the template or the environment.
132 The value is a JSON object, where each key is a relative or absolute URI which serves as the name of
133 a file, and the associated value provides the contents of the file. The following code shows the
134 general structure of this parameter.
138 "fileA.yaml": "Contents of the file",
139 "file:///usr/fileB.template": "Contents of the file",
140 "http://example.com/fileC.template": "Contents of the file"
144 ignore_errors (Optional) string List of comma separated error codes to ignore.
145 show_nested (Optional) boolean Set to true to include nested template service in the list.
146 template (Optional) object
147 The service template on which to perform the operation.
149 This parameter is always provided as a string in the JSON request body. The content of the string is
150 a JSON- or YAML-formatted service template. For example:
153 "tosca_definitions_version": "tosca_simple_yaml_1_0",
156 This parameter is required only when you omit the template_url parameter. If you specify both
157 parameters, this value overrides thetemplate_url parameter value.
159 template_url (Optional) string A URI to the location containing the service template on which to
160 perform the operation. See the description of the template parameter for information about the
161 expected template content located at the URI. This parameter is only required when you omit the
162 template parameter. If you specify both parameters, this parameter is ignored.
166 "template_url": "/PATH_TO_TOSCA_TEMPLATES/HelloWord_Instance.csar"
170 Description string The description specified in the template.
171 Error Information (Optional) string Error information
173 Parse a service template
174 #########################
178 Decription: Validate a service template.
179 Response Code: same as "Validates a service template"
180 Request Parameters: same as "Validates a service template"
182 Description string The description specified in the template.
183 Input parameters object Input parameter list.
184 Service Template object Service template body
185 Output parameters object Input parameter list.
186 Error Information (Optional) string Error information
189 Parser yang2tosca Execution
190 ===========================
192 Step 1: Change directory to where the scripts are present.
198 Step 2: Copy the YANG file which needs to be converted into TOSCA to
199 current (parser/yang2tosca) folder.
201 Step 3: Run the python script "parser.py" with the YANG file as an input option.
205 python parser.py -n "YANG filename"
211 python parser.py -n example.yaml
213 Step 4: Verify the TOSCA YAMl which file has been created with the same name
214 as the YANG file with a “_tosca” suffix.
218 cat "YANG filename_tosca.yaml"
224 cat example_tosca.yaml
227 Parser policy2tosca Execution
228 =============================
230 Step 1: To see a list of commands available.
236 Step 2: To see help for an individual command, include the command name on the command line
240 policy2tosca help <service>
242 Step 3: To inject/remove policy types/policy definitions provide the TOSCA file as input to
243 policy2tosca command line.
247 policy2tosca <service> [arguments]
253 policy2tosca add-definition \
254 --policy_name rule2 --policy_type tosca.policies.Placement.Geolocation \
255 --description "test description" \
256 --properties region:us-north-1,region:us-north-2,min_inst:2 \
257 --targets VNF2,VNF4 \
258 --metadata "map of strings" \
259 --triggers "1,2,3,4" \
260 --source example.yaml
263 Step 4: Verify the TOSCA YAMl updated with the injection/removal executed.
267 cat "<source tosca file>"
273 cat example_tosca.yaml
276 Parser verigraph Execution
277 ==========================
279 VeriGraph is accessible via both a RESTful API and a gRPC interface.
283 Step 1. Change directory to where the service graph examples are present
287 cd parser/verigraph/examples
289 Step 2. Use a REST client (e.g., cURL) to send a POST request (whose body is one of the JSON
290 file in the directory)
294 curl -X POST -d @<file_name>.json http://<server_address>:<server_port>/verify/api/graphs
295 --header "Content-Type:application/json"
297 Step 3. Use a REST client to send a GET request to check a reachability-based property between
298 two nodes of the service graph created in the previous step.
302 curl -X GET http://<server_addr>:<server_port>/verify/api/graphs/<graphID>/
303 policy?source=<srcNodeID>&destination=<dstNodeID>&type=<propertyType>
307 - <graphID> is the identifier of the service graph created at Step 2
308 - <srcNodeID> is the name of the source node
309 - <dstNodeID> is the name of the destination node
310 - <propertyType> can be ``reachability``, ``isolation`` or ``traversal``
312 Step 4. the output is a JSON with the overall result of the verification process and the partial
313 result for each path that connects the source and destination nodes in the service graph.
317 VeriGraph exposes a gRPC interface that is self-descriptive by its Protobuf file
318 (``parser/verigraph/src/main/proto/verigraph.proto``). In the current release, Verigraph
319 misses a module that receives service graphs in format of JSON and sends the proper
320 requests to the gRPC server. A testing client has been provided to have an example of how
321 to create a service graph using the gRPC interface and to trigger the verification step.
323 1. Run the testing client
328 #Client souce code in ``parser/verigraph/src/it/polito/verigraph/grpc/client/Client.java``
329 ant -f buildVeriGraph_gRPC.xml run-client