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(
79 def add_base_node(descriptor_type
, descriptor
, node_type
, element_id
, args
):
80 if descriptor_type
== 'nsd':
81 if 'nsd-catalog' in descriptor
:
82 nsd
= descriptor
['nsd-catalog']['nsd'][0]
83 elif 'nsd:nsd-catalog' in descriptor
:
84 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]
85 if node_type
== 'ns_vl':
87 "vim-network-name": "PUBLIC",
89 "vnfd-connection-point-ref": [],
90 "mgmt-network": "true",
94 if node_type
== 'vnf':
96 for cvnfd
in nsd
['constituent-vnfd']:
97 indexes
.append(int(cvnfd
["member-vnf-index"]))
98 memberindex
= max(indexes
) + 1
99 nsd
['constituent-vnfd'].append({
100 "member-vnf-index": memberindex
,
101 "vnfd-id-ref": element_id
103 if node_type
== 'cp':
104 for vld
in nsd
['vld']:
105 if vld
['id'] == args
['vld_id']:
106 if 'vnfd-connection-point-ref' not in vld
:
107 vld
['vnfd-connection-point-ref'] = []
108 vld
['vnfd-connection-point-ref'].append(
110 "vnfd-connection-point-ref": args
['vnfd-connection-point-ref'],
111 "member-vnf-index-ref": args
['member-vnf-index-ref'],
112 "vnfd-id-ref": args
['vnfd-id-ref']
116 elif descriptor_type
== 'vnfd':
117 if 'vnfd-catalog' in descriptor
:
118 vnfd
= descriptor
['vnfd-catalog']['vnfd'][0]
119 elif 'vnfd:vnfd-catalog' in descriptor
:
120 vnfd
= descriptor
['vnfd:vnfd-catalog']['vnfd'][0]
121 if node_type
== 'vdu':
125 "monitoring-param": [],
126 "internal-connection-point": [],
128 "cloud-init-file": "",
134 if node_type
== 'cp':
135 vnfd
['connection-point'].append({
140 if node_type
== 'vnf_vl':
141 vnfd
['internal-vld'].append({
142 "short-name": element_id
,
144 "internal-connection-point": [],
146 "ip-profile-ref": "",
149 if node_type
== 'interface':
150 for vdu
in vnfd
['vdu']:
151 if vdu
['id'] == args
['vdu_id']:
152 vdu
['interface'].append({
153 "virtual-interface": {
157 "mgmt-interface": True,
159 "external-connection-point-ref": args
["external-connection-point-ref"]
161 if node_type
== 'int_cp':
162 for vdu
in vnfd
['vdu']:
163 if vdu
['id'] == args
['vdu_id']:
164 if 'internal-connection-point' not in vdu
:
165 vdu
['internal-connection-point'] = []
166 vdu
['internal-connection-point'].append({
167 "short-name": element_id
,
172 if 'interface' not in vdu
:
173 vdu
['interface'] = []
174 vdu
['interface'].append({
175 "virtual-interface": {
178 "name": "int_"+element_id
,
180 "internal-connection-point-ref": element_id
182 for int_vld
in vnfd
['internal-vld']:
183 if int_vld
['id'] == args
['vld_id']:
184 if 'internal-connection-point' not in int_vld
:
185 int_vld
['internal-connection-point'] = []
186 int_vld
['internal-connection-point'].append({
192 def update_graph_params(descriptor_type
, descriptor
, updated
):
193 if descriptor_type
== 'nsd':
194 if 'nsd-catalog' in descriptor
:
195 nsd
= descriptor
['nsd-catalog']['nsd'][0]
196 elif 'nsd:nsd-catalog' in descriptor
:
197 nsd
= descriptor
['nsd:nsd-catalog']['nsd'][0]