def create_nuage_sharedresource(self, params):
        subnet = params['neutron_subnet']
        req_params = {
            'name': subnet['id'],
            'gateway_ip': subnet['gateway_ip'],
            'net': params['net'],
            'type': params['type'],
            'net_id': params['net_id'],
            'externalID': get_vsd_external_id(subnet['id'])
        }
        desc_str = params['net_id'] + '_' + subnet['name']
        extra_params = {'description': desc_str}
        if params.get('underlay_config'):
            extra_params['underlay'] = True
        if params.get('underlay') is not None:
            extra_params['underlay'] = params['underlay']
        if params.get('nuage_uplink'):
            extra_params['sharedResourceParentID'] = params['nuage_uplink']

        nuage_sharedresource = nuagelib.NuageSharedResources(
            create_params=req_params, extra_params=extra_params)
        response = self.restproxy.rest_call(
            'POST', nuage_sharedresource.post_resource(),
            nuage_sharedresource.post_data())
        if not nuage_sharedresource.validate(response):
            code = nuage_sharedresource.get_error_code(response)
            raise restproxy.RESTProxyError(nuage_sharedresource.error_msg,
                                           code)
        return nuage_sharedresource.get_sharedresource_id(response)
 def _delete_nuage_sharedresource(self, id):
     nuage_sharedresource = nuagelib.NuageSharedResources()
     resp = self.restproxy.rest_call(
         'DELETE', nuage_sharedresource.delete_resource(id), '')
     if not nuage_sharedresource.validate(resp):
         code = nuage_sharedresource.get_error_code(resp)
         raise restproxy.RESTProxyError(nuage_sharedresource.error_msg,
                                        error_code=code)
 def get_nuage_sharedresource(self, id):
     nuage_sharedresource = nuagelib.NuageSharedResources()
     response = self.restproxy.rest_call(
         'GET', nuage_sharedresource.get_resource_by_id(id), '')
     if not nuage_sharedresource.get_validate(response):
         raise restproxy.RESTProxyError(nuage_sharedresource.error_msg,
                                        nuage_sharedresource.vsd_error_code)
     return nuage_sharedresource.get_response_obj(response)
 def delete_nuage_sharedresource(self, id):
     req_params = {'name': id}
     nuage_sharedresource = nuagelib.NuageSharedResources(
         create_params=req_params)
     sharedresource = self.restproxy.get(
         nuage_sharedresource.get_resource(),
         extra_headers=nuage_sharedresource.extra_headers_get_by_name())
     if sharedresource:
         self._delete_nuage_sharedresource(sharedresource[0]['ID'])
示例#5
0
 def is_shared_l2_domain_managed(self, shared_nuage_id):
     nuage_sharedresource = nuagelib.NuageSharedResources()
     response = self.restproxy.rest_call(
         'GET',
         nuage_sharedresource.get_resource_by_id(shared_nuage_id),
         '')
     if not nuage_sharedresource.get_validate(response):
         raise restproxy.RESTProxyError(nuage_sharedresource.error_msg)
     l2_shared = nuage_sharedresource.get_response_obj(response)
     return l2_shared.get('DHCPManaged')
 def _get_sharedresource_by_external(self, neutron_id):
     create_params = {'externalID': get_vsd_external_id(neutron_id)}
     nuage_sharedresource = nuagelib.NuageSharedResources(create_params)
     url = nuage_sharedresource.get_resource()
     extra_headers = nuage_sharedresource.extra_headers_get_by_externalID()
     shared_resouces = self.restproxy.get(url, extra_headers=extra_headers)
     if not shared_resouces:
         raise restproxy.ResourceNotFoundException(
             "Cannot find sharednetworkresource with externalID '%s'" %
             create_params['externalID'])
     return shared_resouces[0]
    def update_nuage_sharedresource(self, neutron_id, params):
        nuage_id = self._get_sharedresource_by_external(neutron_id)['ID']

        req_params = {}
        if params.get('net_id') and params.get('subnet_name'):
            description = params['net_id'] + '_' + params['subnet_name']
            req_params['description'] = description
        if params.get('gateway_ip'):
            req_params['gateway'] = params.get('gateway_ip')
        if not req_params:
            return

        create_params = {'id': nuage_id}
        nuage_sharedresource = nuagelib.NuageSharedResources(create_params, )
        url = nuage_sharedresource.put_resource()
        self.restproxy.rest_call('PUT', url, req_params)
示例#8
0
    def get_nuage_fip_pool_by_id(self, net_id):
        req_params = {'externalID': get_vsd_external_id(net_id)}
        nuage_fip_pool = nuagelib.NuageSharedResources(
            create_params=req_params)
        nuage_extra_headers = nuage_fip_pool.extra_headers_get_by_externalID()

        response = self.restproxy.rest_call('GET',
                                            nuage_fip_pool.get_resource(),
                                            '',
                                            extra_headers=nuage_extra_headers)

        if not nuage_fip_pool.get_validate(response):
            raise restproxy.RESTProxyError(nuage_fip_pool.error_msg)

        ret = {'nuage_fip_pool_id': response[3][0]['ID']}
        return ret