]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Merge trunk
authorSalvatore Orlando <salvatore.orlando@eu.citrix.com>
Fri, 24 Jun 2011 13:52:17 +0000 (14:52 +0100)
committerSalvatore Orlando <salvatore.orlando@eu.citrix.com>
Fri, 24 Jun 2011 13:52:17 +0000 (14:52 +0100)
Resolving conflicts

1  2 
quantum/api/__init__.py
quantum/api/networks.py
quantum/api/ports.py
quantum/common/wsgi.py
quantum/manager.py
quantum/plugins/SamplePlugin.py

Simple merge
index b959b527bd7bfeeff34e6e236a895eaba069d123,a24cf09ab50ba6c7805f8d4de3070508ae58b3d1..bcaef0f9ff7cadcd974a9b5c7d26a0b6f6b35946
@@@ -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))
  
index bbe6d3f5206fa9582aca20db18bdd95e2e02eb3d,c2de0d75fbf9fda6105b700400493eb99aecbf91..2a066255dea20396b614c44772c614441fdd9a6a
@@@ -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__()
          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:
          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)
          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)
index f3873e351c6d632089de37d066b2ee4e9669371a,23e7c1c3d0eb3e8fb0db3c4bd1c8bd694cdc4103..b1d72c469925056a121fd8ada0921191c09fb4e0
@@@ -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
index f4b829303ddd4ac4c39361282bd2c71f4c6a4f32,a9662d8eb6a15ad057860675a04a7a679a5f3b1a..05762f3a59024e49f24acb5bc20a4348f1812900
  
  
  """
- 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
 +
 -        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)
          plugin_klass = utils.import_class(plugin_location)
          if not issubclass(plugin_klass, QuantumPluginBase):
              raise Exception("Configured Quantum plug-in " \
index 15b6ab08990d63419538d45bb72f35bf8046613f,376456a6c81dae207c152684f9128cd265a68dbb..32dc823f9989e6e2df744f4bb0addcadbb45a3dc
@@@ -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):
          """
          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
      #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',
                      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
          # 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