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'] != args
['name']]
42 for vdu
in vnfd
['vdu']:
43 if 'interface' in vdu
:
44 vdu
['interface'] = [item
for item
in vdu
['interface'] if 'external-connection-point-ref' not in item
45 or ('external-connection-point-ref'in item
and item
['external-connection-point-ref'] != args
['name'])]
46 if node_type
== 'vdu':
48 for vdu
in vnfd
['vdu']:
49 if vdu
['name'] != element_id
:
52 for intcp
in vdu
['internal-connection-point']:
53 for intVld
in vnfd
['internal-vld']:
54 intVld
['internal-connection-point'] = [item
for item
in intVld
['internal-connection-point']
55 if item
['id-ref'] != intcp
['id']]
57 if node_type
== 'int_cp':
58 OsmUtil
.remove_int_cp(element_id
, vnfd
)
62 def update_node(descriptor_type
, descriptor
, node_type
, old
, updated
):
63 if descriptor_type
== 'nsd':
64 if 'nsd-catalog' in descriptor
:
65 nsd
= descriptor
['nsd-catalog']['nsd'][0]
66 elif 'nsd:nsd-catalog' in descriptor
:
67 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
69 if node_type
== 'ns_vl':
70 for k
, v
in enumerate(nsd
['vld']):
71 if v
['id'] == old
['id']:
72 nsd
['vld'][k
].update(updated
)
73 elif node_type
== 'vnf':
74 for k
, v
in enumerate(nsd
['constituent-vnfd']):
75 if str(v
['member-vnf-index']) == str(old
['member-vnf-index']) and str(v
['vnfd-id-ref']) == str(
78 elif descriptor_type
== 'vnfd':
79 if 'vnfd-catalog' in descriptor
:
80 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
81 elif 'vnfd:vnfd-catalog' in descriptor
:
82 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
84 if node_type
== 'vnf_vl':
85 for k
, v
in enumerate(vnfd
['internal-vld']):
86 if v
['id'] == old
['id']:
87 vnfd
['internal-vld'][k
].update(updated
)
89 for k
, v
in enumerate(vnfd
['connection-point']):
90 if v
['name'] == old
['name']:
91 vnfd
['connection-point'][k
].update(updated
)
92 if node_type
== 'vdu':
93 for k
, v
in enumerate(vnfd
['vdu']):
94 if v
['name'] == old
['name']:
95 vnfd
['vdu'][k
].update(updated
)
100 def add_base_node(descriptor_type
, descriptor
, node_type
, element_id
, args
):
101 if descriptor_type
== 'nsd':
102 if 'nsd-catalog' in descriptor
:
103 nsd
= descriptor
['nsd-catalog']['nsd'][0]
104 elif 'nsd:nsd-catalog' in descriptor
:
105 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
106 if node_type
== 'ns_vl':
108 "vim-network-name": "PUBLIC",
110 "vnfd-connection-point-ref": [],
111 "mgmt-network": "true",
115 if node_type
== 'vnf':
117 for cvnfd
in nsd
['constituent-vnfd']:
118 indexes
.append(int(cvnfd
["member-vnf-index"]))
119 memberindex
= max(indexes
) + 1 if len(indexes
) > 0 else 1
120 nsd
['constituent-vnfd'].append({
121 "member-vnf-index": memberindex
,
122 "vnfd-id-ref": element_id
124 if node_type
== 'cp':
125 for vld
in nsd
['vld']:
126 if vld
['id'] == args
['vld_id']:
127 if 'vnfd-connection-point-ref' not in vld
:
128 vld
['vnfd-connection-point-ref'] = []
129 vld
['vnfd-connection-point-ref'].append(
131 "vnfd-connection-point-ref": args
['vnfd-connection-point-ref'],
132 "member-vnf-index-ref": args
['member-vnf-index-ref'],
133 "vnfd-id-ref": args
['vnfd-id-ref']
137 elif descriptor_type
== 'vnfd':
138 if 'vnfd-catalog' in descriptor
:
139 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
140 elif 'vnfd:vnfd-catalog' in descriptor
:
141 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
142 if node_type
== 'vdu':
143 if 'vdu' not in vnfd
:
148 "monitoring-param": [],
149 "internal-connection-point": [],
151 "cloud-init-file": "",
157 if node_type
== 'cp':
158 if 'connection-point' not in vnfd
:
159 vnfd
['connection-point'] = []
160 vnfd
['connection-point'].append({
165 if node_type
== 'vnf_vl':
166 if 'internal-vld' not in vnfd
:
167 vnfd
['internal-vld'] = []
168 vnfd
['internal-vld'].append({
169 "short-name": element_id
,
171 "internal-connection-point": [],
173 "ip-profile-ref": "",
176 if node_type
== 'interface':
177 for vdu
in vnfd
['vdu']:
178 if vdu
['id'] == args
['vdu_id']:
179 vdu
['interface'].append({
180 "virtual-interface": {
184 "mgmt-interface": True,
186 "external-connection-point-ref": args
["external-connection-point-ref"]
188 if node_type
== 'int_cp':
189 for vdu
in vnfd
['vdu']:
190 if vdu
['id'] == args
['vdu_id']:
191 if 'internal-connection-point' not in vdu
:
192 vdu
['internal-connection-point'] = []
193 vdu
['internal-connection-point'].append({
194 "short-name": element_id
,
199 if 'interface' not in vdu
:
200 vdu
['interface'] = []
201 vdu
['interface'].append({
202 "virtual-interface": {
205 "name": "int_"+element_id
,
207 "internal-connection-point-ref": element_id
209 for int_vld
in vnfd
['internal-vld']:
210 if int_vld
['id'] == args
['vld_id']:
211 if 'internal-connection-point' not in int_vld
:
212 int_vld
['internal-connection-point'] = []
213 int_vld
['internal-connection-point'].append({
219 def update_graph_params(descriptor_type
, descriptor
, updated
):
220 if descriptor_type
== 'nsd':
221 if 'nsd-catalog' in descriptor
:
222 nsd
= descriptor
['nsd-catalog']['nsd'][0]
223 elif 'nsd:nsd-catalog' in descriptor
:
224 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
226 elif descriptor_type
== 'vnfd':
227 if 'vnfd-catalog' in descriptor
:
228 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
229 elif 'vnfd:vnfd-catalog' in descriptor
:
230 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
236 def remove_int_cp(element_id
, vnfd
):
237 for vdu
in vnfd
['vdu']:
238 if 'interface' in vdu
:
239 vdu
['interface'] = [item
for item
in vdu
['interface'] if 'internal-connection-point-ref' not in item
240 or ('internal-connection-point-ref' in item
and item
[
241 'internal-connection-point-ref'] != element_id
)]
242 if 'internal-connection-point' in vdu
:
243 vdu
['internal-connection-point'] = [item
for item
in vdu
['internal-connection-point'] if
244 item
['id'] != element_id
]
245 for intVld
in vnfd
['internal-vld']:
246 intVld
['internal-connection-point'] = [item
for item
in intVld
['internal-connection-point'] if
247 item
['id-ref'] != element_id
]