def delete_nuage_gateway_vport(self, context, nuage_vport_id, def_netpart_id): # Get the gw interface and vport info tenant_id = context.tenant_id resp = self.get_gateway_vport(context, tenant_id, None, nuage_vport_id) if not resp: return nuage_subnet_id = resp['nuage_subnet_id'] subnet_info = nuagedb.get_subnet_info_by_nuage_id( context.session, nuage_subnet_id) if not subnet_info: raise nuage_exc.NuageAPIException( msg='No subnet info could not be retrieved') # Delete the interface and vport if resp['vport_type'] == constants.BRIDGE_VPORT_TYPE: if resp['interface']: # Delete interface gw_helper.delete_nuage_interface(self.restproxy, resp['interface'], constants.BRIDGE_VPORT_TYPE) LOG.debug("Deleted bridge interface %s", resp['interface']) elif resp['vport_type'] == constants.HOST_VPORT_TYPE: if resp['interface']: # Delete the policygroup and interface gw_helper.delete_nuage_interface(self.restproxy, resp['interface'], constants.HOST_VPORT_TYPE) LOG.debug("Deleted host interface %s", resp['interface']) # Delete the vport # if 'vport_type' is not None, then 'vport_id' is not None gw_helper.delete_nuage_vport(self.restproxy, resp['vport_id']) LOG.debug("Deleted vport %s", resp['vport_id']) # Remove Ent/Tenant permissions perms = self._get_ent_permissions(resp['vlanid']) if perms and perms['permittedEntityType'] == 'enterprise': netpart_id = perms['permittedEntityID'] else: netpart_id = def_netpart_id if netpart_id != def_netpart_id: perm = gw_helper.get_tenant_perm(self.restproxy, resp['vlanid']) if perm: num_grps = self.remove_tenant_perm(resp['vlanid'], perm['permittedEntityName'], netpart_id) if num_grps == 0: # Remove permissions for the enterprise if it exists self.remove_ent_perm(resp['vlanid']) LOG.debug("Deleted ent perissions on vlan %s", resp['vlanid']) else: LOG.debug("Preserving ent permissions on default netpartition")
def delete_nuage_gateway_vport_no_usergroup(self, tenant_id, vport): intf = gw_helper.get_interface_by_vport(self.restproxy, vport['ID'], vport['type']) if intf: gw_helper.delete_nuage_interface(self.restproxy, intf['ID'], vport['type']) LOG.debug("Deleted %(itf_type)s interface %(itf)s", { 'itf_type': vport['type'], 'itf': intf['ID'] }) # Delete the vport gw_helper.delete_nuage_vport(self.restproxy, vport['ID']) LOG.debug("Deleted vport %s", vport['ID']) # Remove Ent/Tenant permissions self.remove_ent_perm(vport['VLANID']) LOG.debug("Deleted ent permissions on vlan %s", vport['VLANID'])
def delete_nuage_gateway_vport(self, context, nuage_vport_id, def_netpart_id): # Get the gw interface and vport info tenant_id = context.tenant_id resp = self.get_gateway_vport(context, tenant_id, None, nuage_vport_id) if not resp: return subnet_id = resp['nuage_subnet_id'] # Get the neutron subnet-id associated with the vport subnet_mapping = nuagedb.get_subnet_l2dom_by_nuage_id( context.session, subnet_id) # Delete the interface and vport if resp['vport_type'] == constants.BRIDGE_VPORT_TYPE: # Bridge/Host vport will always have a vlan associated with it nuage_vlan = gw_helper.get_gateway_port_vlan( self.restproxy, resp['vlanid']) # Get the gateway associated with vlan nuage_gw = gw_helper.get_gateway(self.restproxy, nuage_vlan['gatewayID']) if resp['interface']: # Delete interface gw_helper.delete_nuage_interface(self.restproxy, resp['interface'], constants.BRIDGE_VPORT_TYPE) LOG.debug("Deleted bridge interface %s", resp['interface']) # do not attempt to delete policygroup on vsd managed subnets # as we do not create it in that case if not subnet_mapping["nuage_managed_subnet"]: if subnet_mapping['nuage_l2dom_tmplt_id']: subnet_type = constants.L2DOMAIN else: subnet_type = constants.SUBNET nuage_policygroup = gw_helper.get_policygroup_for_interface( self.restproxy, subnet_mapping["subnet_id"], nuage_gw['personality'], resp['vport_type'], subnet_type) if nuage_policygroup: # Check if policygroup has more than 1 vport associated self._delete_policygroup(resp['interface'], nuage_policygroup[0]) elif resp['vport_type'] == constants.HOST_VPORT_TYPE: if resp['interface']: # Delete the policygroup and interface gw_helper.delete_nuage_interface(self.restproxy, resp['interface'], constants.HOST_VPORT_TYPE) LOG.debug("Deleted host interface %s", resp['interface']) # do not attempt to delete policygroup on vsd managed subnets # as we do not create it in that case g if not subnet_mapping["nuage_managed_subnet"]: # Delete the policugroup policy_group_id = gw_helper.get_policygroup_for_host_vport( self.restproxy, resp['vport_id']) if policy_group_id: # Check if policygroup has more than 1 vport associated self._delete_policygroup(resp['interface'], policy_group_id) # Delete the vport # if 'vport_type' is not None, then 'vport_id' is not None gw_helper.delete_nuage_vport(self.restproxy, resp['vport_id']) LOG.debug("Deleted vport %s", resp['vport_id']) # Remove Ent/Tenant permissions netpart_id = None perms = self._get_ent_permissions(resp['vlanid']) if perms and perms['permittedEntityType'] == 'enterprise': netpart_id = perms['permittedEntityID'] else: netpart_id = def_netpart_id if netpart_id != def_netpart_id: perm = gw_helper.get_tenant_perm(self.restproxy, resp['vlanid']) if perm: num_grps = self.remove_tenant_perm(resp['vlanid'], perm['permittedEntityName'], netpart_id) if num_grps == 0: # Remove permissions for the enterprise if it exists self.remove_ent_perm(resp['vlanid']) LOG.debug("Deleted ent perissions on vlan %s", resp['vlanid']) else: LOG.debug("Preserving ent permissions on default netpartition")