-
Notifications
You must be signed in to change notification settings - Fork 2
Example
Thomas Soenen edited this page Aug 23, 2019
·
2 revisions
To create an FSM, run
tng-sm new -t fsm -n demo
This will create demo-fsm
folder. Now, alter the demo-fsm/demo/demo.py
file.
def start_event(self, content):
"""
This method handles a start event.
"""
print(content['vnfd']['name'])
print(content['vnfr']['name'])
response = {'status': 'COMPLETED'}
return response
Generate a VNFR based on your VNFD:
tng-sm generate -f demo_vnfd.yaml
Merge your VNFD and VNFR together in a single yaml file, in accordance with the input for an FSM start_event
---
vnfd: <vnfd dictionary>
vnfr: <vnfr dictionary>
Execute the start_event
of your FSM
tng-sm execute -s demo-fsm -e start -p payload.yaml
Which should give you the following output, which you can now analyse to evaluate whether the test was successful or not
#######output from test event#######
INFO:son-sm-base:Starting specific manager with name: demo
INFO:son-sm-base:Starting specific manager with sfuuid:
cnf1-no-sm
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tngsdksm-0.1-py3.5.egg/tngsdksm/execute.py", line 128, in _execute_sm
met(payload)
File "demo-fsm/demo/demo.py", line 139, in start_event
print(content['vnfr']['name'])
KeyError: 'name'
####################################
In this case, the test is not successful, because the VNFR has no field name
.