def detach_nuage_group_to_nuagenet(self, tenants, nuage_subnetid, shared):
        nuagesubn = nuagelib.NuageSubnet()

        response = self.restproxy.rest_call(
            'GET', nuagesubn.get_resource(nuage_subnetid), '')
        if not nuagesubn.validate(response):
            nuagel2dom = nuagelib.NuageL2Domain()
            response = self.restproxy.rest_call(
                'GET', nuagel2dom.get_resource(nuage_subnetid), '')
            if not nuagel2dom.validate(response):
                # This is the case where the VSD-Managed subnet is deleted
                # from VSD first and then neutron subnet-delete operation
                # is performed from openstack
                # for both l2/l3 case we'll return form here
                return
            params = {'l2dom_id': nuage_subnetid}
            nuagepermission = nuagelib.NuagePermission(create_params=params)
            resource = nuagepermission.get_resource_by_l2dom_id()
        else:
            zone_id = nuagesubn.get_parentzone(response)
            params = {'zone_id': zone_id}
            nuagepermission = nuagelib.NuagePermission(create_params=params)
            resource = nuagepermission.get_resource_by_zone_id()
            nuage_dom = helper.get_nuage_domain_by_zoneid(
                self.restproxy, zone_id)

            if nuage_dom['externalID']:
                # The perm. attached to the zone when the router is deleted
                # from openstack
                return

        response = self.restproxy.rest_call('GET', resource, '')
        if not nuagepermission.validate(response):
            if response[0] == constants.RES_NOT_FOUND:
                return
            raise restproxy.RESTProxyError(nuagepermission.error_msg,
                                           nuagepermission.vsd_error_code)

        permissions = response[3]
        if shared:
            tenants.append("Everybody")
        for permission in permissions:
            if permission['permittedEntityName'] in tenants:
                self.restproxy.delete(
                    nuagepermission.delete_resource(permission['ID']))
    def detach_nuage_group_to_nuagenet(self, tenants, nuage_subnetid, shared):
        nuagesubn = nuagelib.NuageSubnet()

        try:
            subnet = self.restproxy.get(nuagesubn.get_resource(nuage_subnetid),
                                        required=True)[0]
        except restproxy.ResourceNotFoundException:
            nuagel2dom = nuagelib.NuageL2Domain()
            try:
                self.restproxy.get(nuagel2dom.get_resource(nuage_subnetid),
                                   required=True)
            except restproxy.ResourceNotFoundException:
                # This is the case where the VSD-Managed subnet is deleted
                # from VSD first and then neutron subnet-delete operation
                # is performed from openstack
                # for both l2/l3 case we'll return form here
                return
            params = {'l2dom_id': nuage_subnetid}
            nuagepermission = nuagelib.NuagePermission(create_params=params)
            resource = nuagepermission.get_resource_by_l2dom_id()
        else:
            zone_id = subnet['parentID']
            params = {'zone_id': zone_id}
            nuagepermission = nuagelib.NuagePermission(create_params=params)
            resource = nuagepermission.get_resource_by_zone_id()
            nuage_dom = helper.get_nuage_domain_by_zoneid(
                self.restproxy, zone_id)
            if nuage_dom['externalID']:
                # The perm. attached to the zone when the router is deleted
                # from openstack
                return
        try:
            permissions = self.restproxy.get(resource, required=True)
        except restproxy.ResourceNotFoundException as e:
            if e.code == constants.RES_NOT_FOUND:
                return
            raise nuagepermission.get_rest_proxy_error()

        if shared:
            tenants.append("Everybody")
        for permission in permissions:
            if permission['permittedEntityName'] in tenants:
                self.restproxy.delete(
                    nuagepermission.delete_resource(permission['ID']))
Example #3
0
 def get_nuage_domain_by_zoneid(self, zone_id):
     return helper.get_nuage_domain_by_zoneid(self.restproxy, zone_id)