Example #1
0
    def get_zone_by_routerid(self, neutron_router_id, shared=False):
        nuage_rtr_id = helper.get_l3domid_by_router_id(
            self.restproxy, neutron_router_id)
        l3dom_tmplt_id = helper.get_l3dom_template_id_by_dom_id(
            self.restproxy, nuage_rtr_id)

        req_params = {
            'domain_id': nuage_rtr_id
        }
        nuage_l3_domain = nuagelib.NuageL3Domain(create_params=req_params)

        if shared:
            zone_name = (plugin_constants.DEF_NUAGE_ZONE_PREFIX + '-pub-' +
                         l3dom_tmplt_id)
        else:
            zone_name = (plugin_constants.DEF_NUAGE_ZONE_PREFIX + '-' +
                         l3dom_tmplt_id)

        nuage_extra_headers = nuage_l3_domain.extra_headers_get_name(zone_name)
        zones = self.restproxy.get(nuage_l3_domain.get_all_zones(),
                                   extra_headers=nuage_extra_headers)
        if zones:
            return zones[0]
        zone_name = TEMPLATE_SHARED_ZONE if shared else TEMPLATE_ISOLATED_ZONE
        nuage_extra_headers = nuage_l3_domain.extra_headers_get_name(
            zone_name)
        zones = self.restproxy.get(nuage_l3_domain.get_all_zones(),
                                   extra_headers=nuage_extra_headers)
        return zones[0] if zones else None
Example #2
0
 def _get_nuage_static_routes_by_router_id(self, neutron_router_id):
     domain_id = helper.get_l3domid_by_router_id(self.restproxy,
                                                 neutron_router_id)
     req_params = {
         'domain_id': domain_id
     }
     nuage_route = nuagelib.NuageStaticRoute(create_params=req_params)
     return self.restproxy.get(nuage_route.post_resource(),
                               required=True)
    def _get_nuage_static_routes_by_router_id(self, neutron_router_id):
        domain_id = helper.get_l3domid_by_router_id(self.restproxy,
                                                    neutron_router_id)
        req_params = {'domain_id': domain_id}
        nuage_route = nuagelib.NuageStaticRoute(create_params=req_params)
        response = self.restproxy.rest_call('GET', nuage_route.post_resource(),
                                            '', '')

        if not nuage_route.validate(response):
            raise restproxy.RESTProxyError(nuage_route.error_msg)

        return response[3]
    def get_zone_by_routerid(self, neutron_router_id, shared=False):
        nuage_rtr_id = helper.get_l3domid_by_router_id(self.restproxy,
                                                       neutron_router_id)
        l3dom_tmplt_id = helper.get_l3dom_template_id_by_dom_id(
            self.restproxy, nuage_rtr_id)

        req_params = {'domain_id': nuage_rtr_id}
        nuage_l3_domain = nuagelib.NuageL3Domain(create_params=req_params)

        if shared:
            zone_name = constants.DEF_NUAGE_ZONE_PREFIX + '-pub-' + \
                l3dom_tmplt_id
        else:
            zone_name = constants.DEF_NUAGE_ZONE_PREFIX + '-' + l3dom_tmplt_id

        nuage_extra_headers = nuage_l3_domain.extra_headers_get_name(zone_name)
        response = self.restproxy.rest_call('GET',
                                            nuage_l3_domain.get_all_zones(),
                                            '',
                                            extra_headers=nuage_extra_headers)
        if not nuage_l3_domain.validate(response):
            raise restproxy.RESTProxyError(nuage_l3_domain.error_msg)
        if shared:
            if response[constants.VSD_RESP_OBJ]:
                return response[3][0]
            else:
                # TODO(Divya): try seems to be not required here
                try:
                    nuage_extra_headers = (
                        nuage_l3_domain.extra_headers_get_name(
                            TEMPLATE_SHARED_ZONE))
                    shared_zone = self.restproxy.rest_call(
                        'GET',
                        nuage_l3_domain.get_all_zones(),
                        '',
                        extra_headers=nuage_extra_headers)
                    if not nuage_l3_domain.validate(shared_zone):
                        raise restproxy.RESTProxyError(
                            nuage_l3_domain.error_msg)
                    if shared_zone[VSD_RESP_OBJ]:
                        return shared_zone[VSD_RESP_OBJ][0]
                except Exception:
                    return None
        else:
            if response[constants.VSD_RESP_OBJ]:
                return response[3][0]
            else:
                # This is needed for add_router_interface to a router created
                # with nuage-router-template parameter
                # return None when called from router_delete
                # TODO(Divya): try seems to be not required here
                try:
                    nuage_extra_headers = (
                        nuage_l3_domain.extra_headers_get_name(
                            TEMPLATE_ISOLATED_ZONE))
                    isolated_zone = self.restproxy.rest_call(
                        'GET',
                        nuage_l3_domain.get_all_zones(),
                        '',
                        extra_headers=nuage_extra_headers)
                    if not nuage_l3_domain.validate(isolated_zone):
                        raise restproxy.RESTProxyError(
                            nuage_l3_domain.error_msg)
                    if isolated_zone[VSD_RESP_OBJ]:
                        return isolated_zone[VSD_RESP_OBJ][0]
                except Exception:
                    return None

        return None