From: Salvatore Orlando Date: Fri, 24 Jun 2011 13:52:17 +0000 (+0100) Subject: Merge trunk X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a94c424f895b8f168f55311a147a300d11ddeb5a;p=openstack-build%2Fneutron-build.git Merge trunk Resolving conflicts --- a94c424f895b8f168f55311a147a300d11ddeb5a diff --cc quantum/api/networks.py index b959b527b,a24cf09ab..bcaef0f9f --- a/quantum/api/networks.py +++ b/quantum/api/networks.py @@@ -45,46 -44,28 +45,46 @@@ class Controller(common.QuantumControll self._resource_name = 'network' super(Controller, self).__init__() - def index(self, req, tenant_id): + def index(self, request, tenant_id): """ Returns a list of network ids """ #TODO: this should be for a given tenant!!! - return self._items(req, tenant_id, net_detail=False) - return self._items(request, tenant_id, is_detail=False) ++ return self._items(request, tenant_id, net_detail=False) - def _items(self, request, tenant_id, is_detail): + def _item(self, req, tenant_id, network_id, + net_details, port_details): + network = self.network_manager.get_network_details( + tenant_id, network_id) + builder = networks_view.get_view_builder(req) + result = builder.build(network, net_details, port_details) + return dict(networks=result) + + def _items(self, req, tenant_id, net_details, port_details): """ Returns a list of networks. """ networks = self.network_manager.get_all_networks(tenant_id) - builder = networks_view.get_view_builder(request) - result = [builder.build(network, is_detail)['network'] + builder = networks_view.get_view_builder(req) + result = [builder.build(network, net_details, port_details)['network'] for network in networks] return dict(networks=result) - def show(self, req, tenant_id, id): + def show(self, request, tenant_id, id): """ Returns network details for the given network id """ try: - return self._item(req, tenant_id, id, - network = self.network_manager.get_network_details( - tenant_id, id) - builder = networks_view.get_view_builder(request) - #build response with details - result = builder.build(network, True) - return dict(networks=result) ++ return self._item(request, tenant_id, id, + net_details=True, port_details=False) + except exception.NetworkNotFound as e: + return faults.Fault(faults.NetworkNotFound(e)) + - def detail(self, req, **kwargs): ++ def detail(self, request, **kwargs): + tenant_id = kwargs.get('tenant_id') + network_id = kwargs.get('id') + try: + if network_id: - return self._item(req, tenant_id, network_id, ++ return self._item(request, tenant_id, network_id, + net_details=True, port_details=True) + else: + #do like show but with detaik - return self._items(req, tenant_id, ++ return self._items(request, tenant_id, + net_details=True, port_details=False) except exception.NetworkNotFound as e: return faults.Fault(faults.NetworkNotFound(e)) diff --cc quantum/api/ports.py index bbe6d3f52,c2de0d75f..2a066255d --- a/quantum/api/ports.py +++ b/quantum/api/ports.py @@@ -42,11 -40,8 +40,9 @@@ class Controller(common.QuantumControll _serialization_metadata = { "application/xml": { "attributes": { - "port": ["id", "state"], - }, - }, - } + "port": ["id", "state"], }, }, } + + def __init__(self, plugin_conf_file=None): self._resource_name = 'port' super(Controller, self).__init__() @@@ -109,9 -104,9 +105,10 @@@ except exc.HTTPError as e: return faults.Fault(e) try: -- port = self.network_manager.update_port(tenant_id, network_id, id, - req_params['port-state']) - builder = ports_view.get_view_builder(req) - request_params['port-state']) ++ port = self.network_manager.\ ++ update_port(tenant_id, network_id, id, ++ request_params['port-state']) + builder = ports_view.get_view_builder(request) result = builder.build(port, True) return dict(ports=result) except exception.NetworkNotFound as e: @@@ -145,10 -140,13 +142,13 @@@ except exception.PortNotFound as e: return faults.Fault(faults.PortNotFound(e)) - def attach_resource(self, req, tenant_id, network_id, id): - #TODO - Complete implementation of these APIs ++ + def attach_resource(self, request, tenant_id, network_id, id): + content_type = request.best_match_content_type() + print "Content type:%s" % content_type try: - req_params = \ - self._parse_request_params(req, + request_params = \ + self._parse_request_params(request, self._attachment_ops_param_list) except exc.HTTPError as e: return faults.Fault(e) @@@ -166,7 -164,8 +166,7 @@@ except exception.AlreadyAttached as e: return faults.Fault(faults.AlreadyAttached(e)) - def detach_resource(self, req, tenant_id, network_id, id): - #TODO - Complete implementation of these APIs + def detach_resource(self, request, tenant_id, network_id, id): try: self.network_manager.unplug_interface(tenant_id, network_id, id) diff --cc quantum/common/wsgi.py index f3873e351,23e7c1c3d..b1d72c469 --- a/quantum/common/wsgi.py +++ b/quantum/common/wsgi.py @@@ -528,7 -538,8 +528,7 @@@ class Serializer(object) node = self._to_xml_node(doc, metadata, k, v) result.appendChild(node) else: -- # Type is atom - LOG.debug("TYPE IS ATOM:%s", data) ++ # Type is atom. node = doc.createTextNode(str(data)) result.appendChild(node) return result diff --cc quantum/manager.py index f4b829303,a9662d8eb..05762f3a5 --- a/quantum/manager.py +++ b/quantum/manager.py @@@ -18,10 -18,10 +18,9 @@@ """ - Quantum's Manager class is responsible for parsing a config file - and instantiating the correct plugin that concretely implement - quantum_plugin_base class - + Quantum's Manager class is responsible for parsing a config file and + instantiating the correct plugin that concretely implement quantum_plugin_base + class. - The caller should make sure that QuantumManager is a singleton. """ import gettext @@@ -34,11 -44,14 +43,14 @@@ def find_config(basepath) class QuantumManager(object): + - def __init__(self, config=CONFIG_FILE): - self.configuration_file = CONFIG_FILE - plugin_location = utils.getPluginFromConfig(CONFIG_FILE) - print "PLUGIN LOCATION:%s" % plugin_location + def __init__(self, config=None): + if config == None: + self.configuration_file = find_config( + os.path.abspath(os.path.dirname(__file__))) + else: + self.configuration_file = config + plugin_location = utils.getPluginFromConfig(self.configuration_file) - print "PLUGIN LOCATION:%s" % plugin_location plugin_klass = utils.import_class(plugin_location) if not issubclass(plugin_klass, QuantumPluginBase): raise Exception("Configured Quantum plug-in " \ diff --cc quantum/plugins/SamplePlugin.py index 15b6ab089,376456a6c..32dc823f9 --- a/quantum/plugins/SamplePlugin.py +++ b/quantum/plugins/SamplePlugin.py @@@ -161,9 -153,8 +167,7 @@@ class DummyDataPlugin(object) retrieved a list of all the remote vifs that are attached to the network """ -- print("get_network_details() called\n") - vifs_on_net = ["/tenant1/networks/net_id/portid/vif2.0", - "/tenant1/networks/10/121/vif1.1"] + vifs_on_net = ["/tenant1/networks/net_id/portid/vif2.0"] return vifs_on_net def rename_network(self, tenant_id, net_id, new_name): @@@ -222,27 -219,7 +226,6 @@@ """ print("unplug_interface() called\n") - def get_interface_details(self, tenant_id, net_id, port_id): - """ - Retrieves the remote interface that is attached at this - particular port. - """ - print("get_interface_details() called\n") - #returns the remote interface UUID - return "/tenant1/networks/net_id/portid/vif2.0" - - def get_all_attached_interfaces(self, tenant_id, net_id): - """ - Retrieves all remote interfaces that are attached to - a particular Virtual Network. - """ - print("get_all_attached_interfaces() called\n") - # returns a list of all attached remote interfaces - vifs_on_net = ["/tenant1/networks/net_id/portid/vif2.0", - "/tenant1/networks/10/121/vif1.1"] - return vifs_on_net - -- class FakePlugin(object): """ FakePlugin is a demo plugin that provides @@@ -253,20 -230,18 +236,18 @@@ #static data for networks and ports _port_dict_1 = { 1: {'port-id': 1, - 'port-state': 'DOWN', - 'attachment': None}, + 'port-state': 'DOWN', + 'attachment': None}, 2: {'port-id': 2, - 'port-state': 'UP', - 'attachment': None}} + 'port-state': 'UP', - 'attachment': None} - } ++ 'attachment': None}} _port_dict_2 = { 1: {'port-id': 1, - 'port-state': 'UP', - 'attachment': 'SomeFormOfVIFID'}, + 'port-state': 'UP', + 'attachment': 'SomeFormOfVIFID'}, 2: {'port-id': 2, - 'port-state': 'DOWN', - 'attachment': None}} + 'port-state': 'DOWN', - 'attachment': None} - } ++ 'attachment': None}} _networks = {'001': { 'net-id': '001', @@@ -339,8 -312,8 +319,9 @@@ str(FakePlugin._net_counter) print new_net_id new_net_dict = {'net-id': new_net_id, - 'net-name': net_name, - 'net-ports': {}} + 'net-name': net_name, + 'net-ports': {}} ++ FakePlugin._networks[new_net_id] = new_net_dict # return network_id of the created network return new_net_dict @@@ -470,15 -434,3 +451,14 @@@ # TODO(salvatore-orlando): # Should unplug on port without attachment raise an Error? port['attachment'] = None + - # TODO - neeed to update methods from this point onwards + def get_all_attached_interfaces(self, tenant_id, net_id): + """ + Retrieves all remote interfaces that are attached to + a particular Virtual Network. + """ + print("get_all_attached_interfaces() called\n") + # returns a list of all attached remote interfaces + vifs_on_net = ["/tenant1/networks/net_id/portid/vif2.0", + "/tenant1/networks/10/121/vif1.1"] + return vifs_on_net