4 def remove_node(descriptor_type
, descriptor
, node_type
, element_id
, args
):
5 if descriptor_type
== 'nsd':
6 if 'nsd-catalog' in descriptor
:
7 nsd
= descriptor
['nsd-catalog']['nsd'][0]
8 elif 'nsd:nsd-catalog' in descriptor
:
9 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
11 if node_type
== 'ns_vl':
12 for k
, v
in enumerate(nsd
['vld']):
13 if v
['id'] == args
['id']:
15 elif node_type
== 'vnf':
16 for k
, v
in enumerate(nsd
['constituent-vnfd']):
17 if str(v
['member-vnf-index']) == str(args
['member-vnf-index']) and str(v
['vnfd-id-ref']) == str(
19 nsd
['constituent-vnfd'].pop(k
)
20 for j
, vld
in enumerate(nsd
['vld']):
21 vld
['vnfd-connection-point-ref'] = [item
for item
in vld
['vnfd-connection-point-ref'] if
22 str(item
['member-vnf-index-ref']) != str(
23 args
['member-vnf-index']) or str(
24 item
['vnfd-id-ref']) != str(args
['vnfd-id-ref'])]
25 elif node_type
== 'cp':
26 for vld
in nsd
['vld']:
27 if vld
['id'] == args
['vld_id']:
28 vld
['vnfd-connection-point-ref'] = [item
for item
in vld
['vnfd-connection-point-ref'] if
29 str(item
['member-vnf-index-ref']) != str(
30 args
['member-vnf-index-ref']) or str(
31 item
['vnfd-id-ref']) != str(args
['vnfd-id-ref'])]
32 elif descriptor_type
== 'vnfd':
33 if 'vnfd-catalog' in descriptor
:
34 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
35 elif 'vnfd:vnfd-catalog' in descriptor
:
36 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
38 if node_type
== 'vnf_vl':
39 vnfd
['internal-vld'] = [item
for item
in vnfd
['internal-vld'] if item
['id'] != element_id
]
41 vnfd
['connection-point'] = [item
for item
in vnfd
['connection-point'] if item
['name'] != element_id
]
46 def update_node(descriptor_type
, descriptor
, node_type
, old
, updated
):
47 if descriptor_type
== 'nsd':
48 if 'nsd-catalog' in descriptor
:
49 nsd
= descriptor
['nsd-catalog']['nsd'][0]
50 elif 'nsd:nsd-catalog' in descriptor
:
51 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
53 if node_type
== 'ns_vl':
54 for k
, v
in enumerate(nsd
['vld']):
55 if v
['id'] == old
['id']:
56 nsd
['vld'][k
].update(updated
)
59 elif node_type
== 'vnf':
60 for k
, v
in enumerate(nsd
['constituent-vnfd']):
61 if str(v
['member-vnf-index']) == str(old
['member-vnf-index']) and str(v
['vnfd-id-ref']) == str(
69 def add_base_node(descriptor_type
, descriptor
, node_type
, element_id
, args
):
70 if descriptor_type
== 'nsd':
71 if 'nsd-catalog' in descriptor
:
72 nsd
= descriptor
['nsd-catalog']['nsd'][0]
73 elif 'nsd:nsd-catalog' in descriptor
:
74 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
75 if node_type
== 'ns_vl':
77 "vim-network-name": "PUBLIC",
79 "vnfd-connection-point-ref": [],
80 "mgmt-network": "true",
84 if node_type
== 'vnf':
86 for cvnfd
in nsd
['constituent-vnfd']:
87 indexes
.append(int(cvnfd
["member-vnf-index"]))
88 memberindex
= max(indexes
) + 1
89 nsd
['constituent-vnfd'].append({
90 "member-vnf-index": memberindex
,
91 "vnfd-id-ref": element_id
94 for vld
in nsd
['vld']:
95 if vld
['id'] == args
['vld_id']:
96 if 'vnfd-connection-point-ref' not in vld
:
97 vld
['vnfd-connection-point-ref'] = []
98 vld
['vnfd-connection-point-ref'].append(
100 "vnfd-connection-point-ref": args
['vnfd-connection-point-ref'],
101 "member-vnf-index-ref": args
['member-vnf-index-ref'],
102 "vnfd-id-ref": args
['vnfd-id-ref']
106 elif descriptor_type
== 'vnfd':
107 if 'vnfd-catalog' in descriptor
:
108 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
109 elif 'vnfd:vnfd-catalog' in descriptor
:
110 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
111 if node_type
== 'vdu':
115 "monitoring-param": [],
116 "internal-connection-point": [],
118 "cloud-init-file": "",
124 if node_type
== 'cp':
125 vnfd
['connection-point'].append({
130 if node_type
== 'vnf_vl':
131 vnfd
['internal-vld'].append({
132 "short-name": element_id
,
134 "internal-connection-point": [],
136 "ip-profile-ref": "",
139 if node_type
== 'interface':
140 for vdu
in vnfd
['vdu']:
141 if vdu
['id'] == args
['vdu-id']:
142 vdu
['interface'].append({
143 "virtual-interface": {
147 "mgmt-interface": True,
149 "external-connection-point-ref": args
["external-connection-point-ref"]
154 def update_graph_params(descriptor_type
, descriptor
, updated
):
155 if descriptor_type
== 'nsd':
156 if 'nsd-catalog' in descriptor
:
157 nsd
= descriptor
['nsd-catalog']['nsd'][0]
158 elif 'nsd:nsd-catalog' in descriptor
:
159 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]