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
]
42 if node_type
== 'vdu':
44 vnfd
['vdu'] = [item
for item
in vnfd
['vdu'] if item
['name'] != element_id
]
45 if node_type
== 'int_cp':
47 for vdu
in vnfd
['vdu']:
48 if 'interface' in vdu
:
49 vdu
['interface'] = [item
for item
in vdu
['interface'] if 'internal-connection-point-ref' not in item
50 or ('internal-connection-point-ref'in item
and item
['internal-connection-point-ref'] != element_id
)]
51 if 'internal-connection-point' in vdu
:
52 vdu
['internal-connection-point'] = [item
for item
in vdu
['internal-connection-point'] if item
['id'] != element_id
]
59 def update_node(descriptor_type
, descriptor
, node_type
, old
, updated
):
60 if descriptor_type
== 'nsd':
61 if 'nsd-catalog' in descriptor
:
62 nsd
= descriptor
['nsd-catalog']['nsd'][0]
63 elif 'nsd:nsd-catalog' in descriptor
:
64 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
66 if node_type
== 'ns_vl':
67 for k
, v
in enumerate(nsd
['vld']):
68 if v
['id'] == old
['id']:
69 nsd
['vld'][k
].update(updated
)
70 elif node_type
== 'vnf':
71 for k
, v
in enumerate(nsd
['constituent-vnfd']):
72 if str(v
['member-vnf-index']) == str(old
['member-vnf-index']) and str(v
['vnfd-id-ref']) == str(
75 elif descriptor_type
== 'vnfd':
76 if 'vnfd-catalog' in descriptor
:
77 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
78 elif 'vnfd:vnfd-catalog' in descriptor
:
79 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
81 if node_type
== 'vnf_vl':
82 for k
, v
in enumerate(vnfd
['internal-vld']):
83 if v
['id'] == old
['id']:
84 vnfd
['internal-vld'][k
].update(updated
)
86 for k
, v
in enumerate(vnfd
['connection-point']):
87 if v
['name'] == old
['name']:
88 vnfd
['connection-point'][k
].update(updated
)
89 if node_type
== 'vdu':
90 for k
, v
in enumerate(vnfd
['vdu']):
91 if v
['name'] == old
['name']:
92 vnfd
['vdu'][k
].update(updated
)
97 def add_base_node(descriptor_type
, descriptor
, node_type
, element_id
, args
):
98 if descriptor_type
== 'nsd':
99 if 'nsd-catalog' in descriptor
:
100 nsd
= descriptor
['nsd-catalog']['nsd'][0]
101 elif 'nsd:nsd-catalog' in descriptor
:
102 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
103 if node_type
== 'ns_vl':
105 "vim-network-name": "PUBLIC",
107 "vnfd-connection-point-ref": [],
108 "mgmt-network": "true",
112 if node_type
== 'vnf':
114 for cvnfd
in nsd
['constituent-vnfd']:
115 indexes
.append(int(cvnfd
["member-vnf-index"]))
116 memberindex
= max(indexes
) + 1
117 nsd
['constituent-vnfd'].append({
118 "member-vnf-index": memberindex
,
119 "vnfd-id-ref": element_id
121 if node_type
== 'cp':
122 for vld
in nsd
['vld']:
123 if vld
['id'] == args
['vld_id']:
124 if 'vnfd-connection-point-ref' not in vld
:
125 vld
['vnfd-connection-point-ref'] = []
126 vld
['vnfd-connection-point-ref'].append(
128 "vnfd-connection-point-ref": args
['vnfd-connection-point-ref'],
129 "member-vnf-index-ref": args
['member-vnf-index-ref'],
130 "vnfd-id-ref": args
['vnfd-id-ref']
134 elif descriptor_type
== 'vnfd':
135 if 'vnfd-catalog' in descriptor
:
136 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
137 elif 'vnfd:vnfd-catalog' in descriptor
:
138 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
139 if node_type
== 'vdu':
143 "monitoring-param": [],
144 "internal-connection-point": [],
146 "cloud-init-file": "",
152 if node_type
== 'cp':
153 vnfd
['connection-point'].append({
158 if node_type
== 'vnf_vl':
159 vnfd
['internal-vld'].append({
160 "short-name": element_id
,
162 "internal-connection-point": [],
164 "ip-profile-ref": "",
167 if node_type
== 'interface':
168 for vdu
in vnfd
['vdu']:
169 if vdu
['id'] == args
['vdu_id']:
170 vdu
['interface'].append({
171 "virtual-interface": {
175 "mgmt-interface": True,
177 "external-connection-point-ref": args
["external-connection-point-ref"]
179 if node_type
== 'int_cp':
180 for vdu
in vnfd
['vdu']:
181 if vdu
['id'] == args
['vdu_id']:
182 if 'internal-connection-point' not in vdu
:
183 vdu
['internal-connection-point'] = []
184 vdu
['internal-connection-point'].append({
185 "short-name": element_id
,
190 if 'interface' not in vdu
:
191 vdu
['interface'] = []
192 vdu
['interface'].append({
193 "virtual-interface": {
196 "name": "int_"+element_id
,
198 "internal-connection-point-ref": element_id
200 for int_vld
in vnfd
['internal-vld']:
201 if int_vld
['id'] == args
['vld_id']:
202 if 'internal-connection-point' not in int_vld
:
203 int_vld
['internal-connection-point'] = []
204 int_vld
['internal-connection-point'].append({
210 def update_graph_params(descriptor_type
, descriptor
, updated
):
211 if descriptor_type
== 'nsd':
212 if 'nsd-catalog' in descriptor
:
213 nsd
= descriptor
['nsd-catalog']['nsd'][0]
214 elif 'nsd:nsd-catalog' in descriptor
:
215 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
217 elif descriptor_type
== 'vnfd':
218 if 'vnfd-catalog' in descriptor
:
219 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
220 elif 'vnfd:vnfd-catalog' in descriptor
:
221 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]