def create(self, request, tenant_id): """ Creates a new network for a given tenant """ try: request_params = \ self._parse_request_params(request, self._network_ops_param_list) except exc.HTTPError as e: return faults.Fault(e) # NOTE(bgh): We're currently passing both request_params['name'] and # the entire request_params dict because their may be pieces of # information (data extensions) inside the request params that the # actual plugin will want to parse. We could just pass only # request_params but that would mean all the plugins would need to # change. network = self._plugin.\ create_network(tenant_id, request_params['name'], **request_params) builder = networks_view.get_view_builder(request) result = builder.build(network)['network'] # Wsgi middleware allows us to build the response # before returning the call. # This will allow us to return a 200 status code. NOTE: in v1.1 we # will be returning a 202 status code. return self._build_response(request, dict(network=result), 200)
def _items(self, request, tenant_id, net_details=False): """ Returns a list of networks. Ideally, the plugin would perform filtering, returning only the items matching filters specified on the request query string. However, plugins are not required to support filtering. In this case, this function will filter the complete list of networks returned by the plugin """ filter_opts = {} filter_opts.update(request.GET) networks = self._plugin.get_all_networks(tenant_id, filter_opts=filter_opts) # Inefficient, API-layer filtering # will be performed only for the filters not implemented by the plugin # NOTE(salvatore-orlando): the plugin is supposed to leave only filters # it does not implement in filter_opts networks = filters.filter_networks(networks, self._plugin, tenant_id, filter_opts) builder = networks_view.get_view_builder(request, self.version) result = [builder.build(network, net_details)['network'] for network in networks] return dict(networks=result)
def _items(self, req, tenant_id, net_details=False): """ Returns a list of networks. """ networks = self._plugin.get_all_networks(tenant_id) builder = networks_view.get_view_builder(req) result = [builder.build(network, net_details)['network'] for network in networks] return dict(networks=result)
def _items(self, request, tenant_id, net_details=False): """ Returns a list of networks. Ideally, the plugin would perform filtering, returning only the items matching filters specified on the request query string. However, plugins are not required to support filtering. In this case, this function will filter the complete list of networks returned by the plugin """ filter_opts = {} filter_opts.update(request.str_GET) networks = self._plugin.get_all_networks(tenant_id, filter_opts=filter_opts) # Inefficient, API-layer filtering # will be performed only for the filters not implemented by the plugin # NOTE(salvatore-orlando): the plugin is supposed to leave only filters # it does not implement in filter_opts networks = filters.filter_networks(networks, self._plugin, tenant_id, filter_opts) builder = networks_view.get_view_builder(request, self.version) result = [builder.build(network, net_details)['network'] for network in networks] return dict(networks=result)
def _item(self, req, tenant_id, network_id, net_details=True, port_details=False): # We expect get_network_details to return information # concerning logical ports as well. network = self._plugin.get_network_details(tenant_id, network_id) port_list = self._plugin.get_all_ports(tenant_id, network_id) ports_data = [self._plugin.get_port_details(tenant_id, network_id, port["port-id"]) for port in port_list] builder = networks_view.get_view_builder(req) result = builder.build(network, net_details, ports_data, port_details)["network"] return dict(network=result)
def create(self, request, tenant_id, body): """ Creates a new network for a given tenant """ # NOTE(bgh): We're currently passing both request_params['name'] and # the entire request_params dict because their may be pieces of # information (data extensions) inside the request params that the # actual plugin will want to parse. We could just pass only # request_params but that would mean all the plugins would need to # change. body = self._prepare_request_body(body, self._network_ops_param_list) network = self._plugin.create_network(tenant_id, body['network']['name'], **body) builder = networks_view.get_view_builder(request, self.version) result = builder.build(network)['network'] return dict(network=result)
def _item(self, request, tenant_id, network_id, net_details=True, port_details=False): # We expect get_network_details to return information # concerning logical ports as well. network = self._plugin.get_network_details( tenant_id, network_id) # Doing this in the API is inefficient # TODO(salvatore-orlando): This should be fixed with Bug #834012 # Don't pass filter options port_list = self._plugin.get_all_ports(tenant_id, network_id) ports_data = [self._plugin.get_port_details( tenant_id, network_id, port['port-id']) for port in port_list] builder = networks_view.get_view_builder(request, self.version) result = builder.build(network, net_details, ports_data, port_details)['network'] return dict(network=result)
def create(self, request, tenant_id): """ Creates a new network for a given tenant """ #look for network name in request try: request_params = \ self._parse_request_params(request, self._network_ops_param_list) except exc.HTTPError as e: return faults.Fault(e) network = self._plugin.\ create_network(tenant_id, request_params['name']) builder = networks_view.get_view_builder(request) result = builder.build(network)['network'] # Wsgi middleware allows us to build the response # before returning the call. # This will allow us to return a 202 status code. return self._build_response(request, dict(network=result), 202)
def _item(self, request, tenant_id, network_id, net_details=True, port_details=False): # We expect get_network_details to return information # concerning logical ports as well. network = self._plugin.get_network_details( tenant_id, network_id) # Doing this in the API is inefficient # TODO(salvatore-orlando): This should be fixed with Bug #834012 # Don't pass filter options ports_data = None if port_details: port_list = self._plugin.get_all_ports(tenant_id, network_id) ports_data = [self._plugin.get_port_details( tenant_id, network_id, port['port-id']) for port in port_list] builder = networks_view.get_view_builder(request, self.version) result = builder.build(network, net_details, ports_data, port_details)['network'] return dict(network=result)