1 from rift
.mano
.tosca_translator
.rwmano
.syntax
.mano_resource
import ManoResource
5 TARGET_CLASS_NAME
= 'ToscaForwardingPath'
6 class ToscaForwardingPath(ManoResource
):
7 '''Translate TOSCA node type tosca.nodes.nfv.FP'''
9 toscatype
= 'tosca.nodes.nfv.FP'
12 def __init__(self
, log
, node
, metadata
=None):
13 super(ToscaForwardingPath
, self
).__init
__(log
, node
, type_
='forwarding_path', metadata
=metadata
)
14 self
.metadata
= metadata
15 self
.classifier
= None
20 def handle_forwarding_path_dependencies(self
, nodes
, vnf_type_to_capability_substitution_mapping
):
21 def get_classifier(specs
):
23 classifier_prop
['name'] = 'VNFFG -' + str(self
.name
)
24 classifier_prop
['id'] = self
.id
26 classifier_prop
['match_attributes'] = []
27 policy
= specs
['policy']
28 if 'criteria' in policy
:
30 match_prop
['id'] = str(uuid
.uuid1())
31 for criteria
in policy
['criteria']:
32 if 'ip_dst_prefix' in criteria
:
33 match_prop
['destination_ip_address'] = criteria
['ip_dst_prefix']
34 if 'ip_proto' in criteria
:
35 match_prop
['ip_proto'] = criteria
['ip_proto']
36 if 'source_port_range' in criteria
:
37 match_prop
['source_port'] = int(criteria
['source_port_range'])
38 if 'destination_port_range' in criteria
:
39 match_prop
['destination_port'] = int(criteria
['destination_port_range'])
40 classifier_prop
['match_attributes'].append(match_prop
)
42 cp_node_name
= specs
['cp']['capability']
43 cp_node
= self
.get_node_with_name(cp_node_name
, nodes
)
45 classifier_prop
['vnfd_connection_point_ref'] = cp_node
.cp_name
47 vnf_node_name
= specs
['cp']['forwarder']
48 vnf_node
= self
.get_node_with_name(vnf_node_name
, nodes
)
50 classifier_prop
['vnfd_id_ref'] = vnf_node
.id
51 classifier_prop
['member_vnf_index_ref'] = vnf_node
.get_member_vnf_index()
52 return classifier_prop
56 rsp
['id'] = str(uuid
.uuid1())
57 rsp
['name'] = 'VNFFG-RSP-' + str(self
.name
)
58 rsp
['vnfd_connection_point_ref'] = []
60 fp_connection_point
= []
63 for rsp_item
in specs
['path']:
64 vnf_node_name
= rsp_item
['forwarder']
65 conn_forwarder
= rsp_item
['capability']
66 vnf_node
= self
.get_node_with_name(vnf_node_name
, nodes
)
67 for subs_mapping
in vnf_type_to_capability_substitution_mapping
[vnf_node
.vnf_type
]:
69 if conn_forwarder
in subs_mapping
:
70 fp_connection_point
.append(subs_mapping
[conn_forwarder
])
71 cp_node_name
= subs_mapping
[conn_forwarder
]
72 cp_node
= self
.get_node_with_name(cp_node_name
, nodes
)
73 prop
['vnfd_connection_point_ref'] = cp_node
.cp_name
74 prop
['vnfd_id_ref'] = vnf_node
.id
75 prop
['member_vnf_index_ref'] = vnf_index
76 prop
['order'] = order_index
77 rsp
['vnfd_connection_point_ref'].append(prop
)
78 vnf_index
= vnf_index
+ 1
79 order_index
= order_index
+ 1
82 tosca_props
= self
.get_tosca_props()
83 self
.classifier
= get_classifier(tosca_props
)
84 self
.rsp
= get_rsp(tosca_props
)
85 if self
.classifier
and self
.rsp
:
86 self
.classifier
['rsp_id_ref'] = self
.rsp
['id']