X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FLW-UI.git;a=blobdiff_plain;f=lib%2Fosm%2Fosm_util.py;h=8cf6a4ee98dc1af87cac0497c853e528c3d68af7;hp=49be9df0caa3d07b848a84f257a9daf188d3d576;hb=5b56a292d9d897b3a67b2e3ebe980ae2566a6186;hpb=462eec298e50b930b1b8ec9296edf34934e9312b diff --git a/lib/osm/osm_util.py b/lib/osm/osm_util.py index 49be9df..8cf6a4e 100644 --- a/lib/osm/osm_util.py +++ b/lib/osm/osm_util.py @@ -38,21 +38,24 @@ class OsmUtil(): if node_type == 'vnf_vl': vnfd['internal-vld'] = [item for item in vnfd['internal-vld'] if item['id'] != element_id] if node_type == 'cp': - vnfd['connection-point'] = [item for item in vnfd['connection-point'] if item['name'] != element_id] - if node_type == 'vdu': - # check - vnfd['vdu'] = [item for item in vnfd['vdu'] if item['name'] != element_id] - if node_type == 'int_cp': - + vnfd['connection-point'] = [item for item in vnfd['connection-point'] if item['name'] != args['name']] for vdu in vnfd['vdu']: if 'interface' in vdu: - vdu['interface'] = [item for item in vdu['interface'] if 'internal-connection-point-ref' not in item - or ('internal-connection-point-ref'in item and item['internal-connection-point-ref'] != element_id)] - if 'internal-connection-point' in vdu: - vdu['internal-connection-point'] = [item for item in vdu['internal-connection-point'] if item['id'] != element_id] - - - + vdu['interface'] = [item for item in vdu['interface'] if 'external-connection-point-ref' not in item + or ('external-connection-point-ref'in item and item['external-connection-point-ref'] != args['name'])] + if node_type == 'vdu': + vdus = [] + for vdu in vnfd['vdu']: + if vdu['name'] != element_id: + vdus.append(vdu) + else: + for intcp in vdu['internal-connection-point']: + for intVld in vnfd['internal-vld']: + intVld['internal-connection-point'] = [item for item in intVld['internal-connection-point'] + if item['id-ref'] != intcp['id']] + vnfd['vdu'] = vdus + if node_type == 'int_cp': + OsmUtil.remove_int_cp(element_id, vnfd) return descriptor @staticmethod @@ -137,6 +140,8 @@ class OsmUtil(): elif 'vnfd:vnfd-catalog' in descriptor: vnfd = descriptor['vnfd:vnfd-catalog']['vnfd'][0] if node_type == 'vdu': + if 'vdu' not in vnfd: + vnfd['vdu'] = [] vnfd['vdu'].append({ "count": "1", "description": "", @@ -150,12 +155,16 @@ class OsmUtil(): "name": element_id }) if node_type == 'cp': + if 'connection-point' not in vnfd: + vnfd['connection-point'] = [] vnfd['connection-point'].append({ "type": "VPORT", "name": element_id }) if node_type == 'vnf_vl': + if 'internal-vld' not in vnfd: + vnfd['internal-vld'] = [] vnfd['internal-vld'].append({ "short-name": element_id, "name": element_id, @@ -222,3 +231,19 @@ class OsmUtil(): vnfd.update(updated) return descriptor + + @staticmethod + def remove_int_cp(element_id, vnfd): + for vdu in vnfd['vdu']: + if 'interface' in vdu: + vdu['interface'] = [item for item in vdu['interface'] if 'internal-connection-point-ref' not in item + or ('internal-connection-point-ref' in item and item[ + 'internal-connection-point-ref'] != element_id)] + if 'internal-connection-point' in vdu: + vdu['internal-connection-point'] = [item for item in vdu['internal-connection-point'] if + item['id'] != element_id] + for intVld in vnfd['internal-vld']: + intVld['internal-connection-point'] = [item for item in intVld['internal-connection-point'] if + item['id-ref'] != element_id] + + return vnfd