def delete_nuage_staticroute(self, params): static_route = self.get_nuage_static_route(params) if static_route: nuage_staticroute = nuagelib.NuageStaticRoute() self.restproxy.delete( nuage_staticroute.delete_resource( static_route['nuage_static_route_id']))
def get_nuage_static_route(self, params): req_params = { 'address': params['address'], 'nexthop': params['nexthop'], 'domain_id': params['nuage_domain_id'] } static_route = nuagelib.NuageStaticRoute(create_params=req_params) nuage_extra_headers = static_route.extra_headers_get() response = self.restproxy.rest_call( 'GET', static_route.get_resources_of_domain(), '', extra_headers=nuage_extra_headers) if not static_route.validate(response): raise restproxy.RESTProxyError(static_route.error_msg) if len(response[3]) > 0: ret = { 'nuage_zone_id': response[3][0]['ID'], 'nuage_static_route_id': response[3][0]['ID'], 'rd': response[3][0]['routeDistinguisher'] } return ret
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 create_nuage_staticroute(self, params): req_params = { 'domain_id': params['nuage_domain_id'], 'router_id': params['neutron_rtr_id'], 'net': params['net'], 'nexthop': params['nexthop'] } nuage_staticroute = nuagelib.NuageStaticRoute(create_params=req_params) response = self.restproxy.rest_call('POST', nuage_staticroute.post_resource(), nuage_staticroute.post_data()) if not nuage_staticroute.validate(response): code = nuage_staticroute.get_error_code(response) raise restproxy.RESTProxyError(nuage_staticroute.error_msg, code) return nuage_staticroute.get_staticrouteid(response)
def get_nuage_static_route(self, params): cidr = netaddr.IPNetwork(params['address']) req_params = { 'cidr': cidr, 'nexthop': params['nexthop'], 'domain_id': params['nuage_domain_id'], 'ip_type': cidr.ip.version } static_route = nuagelib.NuageStaticRoute(create_params=req_params) static_route = self.restproxy.get( static_route.get_resources_of_domain(), extra_headers=static_route.extra_headers_get(), required=True) return { 'nuage_zone_id': static_route[0]['ID'], 'nuage_static_route_id': static_route[0]['ID'], 'rd': static_route[0]['routeDistinguisher'] } if static_route else None
def create_nuage_staticroute(self, params): ipv6_net = ipv4_net = None if netaddr.IPNetwork(params['net']).version == constants.IPV6_VERSION: ipv6_net = params['net'] ip_type = constants.IPV6 else: ipv4_net = params['net'] ip_type = constants.IPV4 req_params = { 'domain_id': params['nuage_domain_id'], 'router_id': params['neutron_rtr_id'], 'net': ipv4_net, 'ipv6_net': ipv6_net, 'nexthop': params['nexthop'], 'IPType': ip_type } nuage_staticroute = nuagelib.NuageStaticRoute(create_params=req_params) static_routes = self.restproxy.post(nuage_staticroute.post_resource(), nuage_staticroute.post_data()) return static_routes[0]['ID'] if static_routes else None