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
== 'ns_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 if vnfd
['mgmt-interface']['cp'] == args
['name']:
43 del vnfd
['mgmt-interface']['cp']
44 for vdu
in vnfd
['vdu']:
45 if 'interface' in vdu
:
46 vdu
['interface'] = [item
for item
in vdu
['interface'] if 'external-connection-point-ref' not in item
47 or ('external-connection-point-ref'in item
and item
['external-connection-point-ref'] != args
['name'])]
48 if node_type
== 'vdu':
50 for vdu
in vnfd
['vdu']:
51 if vdu
['name'] != element_id
:
54 for intcp
in vdu
['internal-connection-point']:
55 for intVld
in vnfd
['internal-vld']:
56 intVld
['internal-connection-point'] = [item
for item
in intVld
['internal-connection-point']
57 if item
['id-ref'] != intcp
['id']]
59 if node_type
== 'int_cp':
60 OsmUtil
.remove_int_cp(element_id
, vnfd
)
64 def update_node(descriptor_type
, descriptor
, node_type
, old
, updated
):
65 if descriptor_type
== 'nsd':
66 if 'nsd-catalog' in descriptor
:
67 nsd
= descriptor
['nsd-catalog']['nsd'][0]
68 elif 'nsd:nsd-catalog' in descriptor
:
69 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
71 if node_type
== 'ns_vl':
72 for k
, v
in enumerate(nsd
['vld']):
73 if v
['id'] == old
['id']:
74 nsd
['vld'][k
].update(updated
)
75 elif node_type
== 'vnf':
76 for k
, v
in enumerate(nsd
['constituent-vnfd']):
77 if str(v
['member-vnf-index']) == str(old
['member-vnf-index']) and str(v
['vnfd-id-ref']) == str(
80 elif descriptor_type
== 'vnfd':
81 if 'vnfd-catalog' in descriptor
:
82 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
83 elif 'vnfd:vnfd-catalog' in descriptor
:
84 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
86 if node_type
== 'vnf_vl':
87 for k
, v
in enumerate(vnfd
['internal-vld']):
88 if v
['id'] == old
['id']:
89 vnfd
['internal-vld'][k
].update(updated
)
91 for k
, v
in enumerate(vnfd
['connection-point']):
92 if v
['name'] == old
['name']:
93 vnfd
['connection-point'][k
].update(updated
)
94 for vdu
in vnfd
['vdu']:
95 if 'interface' in vdu
:
96 for intf
in vdu
['interface']:
97 if 'external-connection-point-ref' in intf
and intf
['external-connection-point-ref'] == old
['name']:
98 intf
['external-connection-point-ref'] = updated
['name']
99 if node_type
== 'vdu':
100 for k
, v
in enumerate(vnfd
['vdu']):
101 if v
['name'] == old
['name']:
102 vnfd
['vdu'][k
].update(updated
)
107 def add_base_node(descriptor_type
, descriptor
, node_type
, element_id
, args
):
108 if descriptor_type
== 'nsd':
109 if 'nsd-catalog' in descriptor
:
110 nsd
= descriptor
['nsd-catalog']['nsd'][0]
111 elif 'nsd:nsd-catalog' in descriptor
:
112 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
113 if node_type
== 'ns_vl':
115 "vim-network-name": "PUBLIC",
117 "vnfd-connection-point-ref": [],
118 "mgmt-network": "true",
122 if node_type
== 'vnf':
124 for cvnfd
in nsd
['constituent-vnfd']:
125 indexes
.append(int(cvnfd
["member-vnf-index"]))
126 memberindex
= max(indexes
) + 1 if len(indexes
) > 0 else 1
127 nsd
['constituent-vnfd'].append({
128 "member-vnf-index": memberindex
,
129 "vnfd-id-ref": element_id
131 if node_type
== 'cp':
132 for vld
in nsd
['vld']:
133 if vld
['id'] == args
['vld_id']:
134 if 'vnfd-connection-point-ref' not in vld
:
135 vld
['vnfd-connection-point-ref'] = []
136 vld
['vnfd-connection-point-ref'].append(
138 "vnfd-connection-point-ref": args
['vnfd-connection-point-ref'],
139 "member-vnf-index-ref": args
['member-vnf-index-ref'],
140 "vnfd-id-ref": args
['vnfd-id-ref']
144 elif descriptor_type
== 'vnfd':
145 if 'vnfd-catalog' in descriptor
:
146 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
147 elif 'vnfd:vnfd-catalog' in descriptor
:
148 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
149 if node_type
== 'vdu':
150 if 'vdu' not in vnfd
:
155 "monitoring-param": [],
156 "internal-connection-point": [],
158 #"cloud-init-file": "",
164 if node_type
== 'cp':
165 if 'connection-point' not in vnfd
:
166 vnfd
['connection-point'] = []
167 vnfd
['connection-point'].append({
172 if node_type
== 'vnf_vl':
173 if 'internal-vld' not in vnfd
:
174 vnfd
['internal-vld'] = []
175 vnfd
['internal-vld'].append({
176 "short-name": element_id
,
178 "internal-connection-point": [],
180 "ip-profile-ref": "",
183 if node_type
== 'interface':
184 for vdu
in vnfd
['vdu']:
185 if vdu
['id'] == args
['vdu_id']:
186 vdu
['interface'].append({
187 "virtual-interface": {
190 "name": args
["name"],
191 "mgmt-interface": True,
193 "external-connection-point-ref": args
["external-connection-point-ref"]
195 if node_type
== 'int_cp':
196 for vdu
in vnfd
['vdu']:
197 if vdu
['id'] == args
['vdu_id']:
198 if 'internal-connection-point' not in vdu
:
199 vdu
['internal-connection-point'] = []
200 vdu
['internal-connection-point'].append({
201 "short-name": element_id
,
206 if 'interface' not in vdu
:
207 vdu
['interface'] = []
208 vdu
['interface'].append({
209 "virtual-interface": {
212 "name": "int_"+element_id
,
214 "internal-connection-point-ref": element_id
216 for int_vld
in vnfd
['internal-vld']:
217 if int_vld
['id'] == args
['vld_id']:
218 if 'internal-connection-point' not in int_vld
:
219 int_vld
['internal-connection-point'] = []
220 int_vld
['internal-connection-point'].append({
226 def update_graph_params(descriptor_type
, descriptor
, updated
):
227 if descriptor_type
== 'nsd':
228 if 'nsd-catalog' in descriptor
:
229 nsd
= descriptor
['nsd-catalog']['nsd'][0]
230 elif 'nsd:nsd-catalog' in descriptor
:
231 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
233 elif descriptor_type
== 'vnfd':
234 if 'vnfd-catalog' in descriptor
:
235 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
236 elif 'vnfd:vnfd-catalog' in descriptor
:
237 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
243 def remove_int_cp(element_id
, vnfd
):
244 for vdu
in vnfd
['vdu']:
245 if 'interface' in vdu
:
246 vdu
['interface'] = [item
for item
in vdu
['interface'] if 'internal-connection-point-ref' not in item
247 or ('internal-connection-point-ref' in item
and item
[
248 'internal-connection-point-ref'] != element_id
)]
249 if 'internal-connection-point' in vdu
:
250 vdu
['internal-connection-point'] = [item
for item
in vdu
['internal-connection-point'] if
251 item
['id'] != element_id
]
252 for intVld
in vnfd
['internal-vld']:
253 intVld
['internal-connection-point'] = [item
for item
in intVld
['internal-connection-point'] if
254 item
['id-ref'] != element_id
]