]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
ryu/nova: catch up d1888a3359345acffd8d0845c137eefd88072112
authorIsaku Yamahata <yamahata@valinux.co.jp>
Thu, 8 Mar 2012 07:20:09 +0000 (16:20 +0900)
committerIsaku Yamahata <yamahata@valinux.co.jp>
Thu, 15 Mar 2012 00:16:18 +0000 (09:16 +0900)
FLAGS.add_option -> FLAGS.register_opt

> commit d1888a3359345acffd8d0845c137eefd88072112
> Author: Mark McLoughlin <markmc@redhat.com>
> Date:   Fri Feb 3 00:50:58 2012 +0000
>
>     Remove the last of the gflags shim layer
>
>     Make FLAGS a ConfigOpts instance and fix up all the places where we
>     expected FlagValues behaviour.
>
>     Change-Id: I8f96f42e0d8d30ba6b362d29861e717cf0fa9e89

and removed work around for circular import as the nova change set of
1265104b873d4cd791cecc62134ef874b4656003 fixes the circular import issue.

Change-Id: I4897dc848efa7fff6c73399a72d876fb503121e7

quantum/plugins/ryu/nova/linux_net.py
quantum/plugins/ryu/nova/vif.py

index 500d6f03ce96bfe28fdb1688695d68e9185b5282..b14f678576fb3837f201ce9ce31ee7d208f9727a 100644 (file)
@@ -18,6 +18,7 @@
 from nova import flags
 from nova import log as logging
 from nova import utils
+from nova.network import linux_net
 from nova.openstack.common import cfg
 from ryu.app.client import OFPClient
 
@@ -28,7 +29,7 @@ ryu_linux_net_opt = cfg.StrOpt('linuxnet_ovs_ryu_api_host',
                                help='Openflow Ryu REST API host:port')
 
 FLAGS = flags.FLAGS
-FLAGS.add_option(ryu_linux_net_opt)
+FLAGS.register_opt(ryu_linux_net_opt)
 
 
 def _get_datapath_id(bridge_name):
@@ -43,48 +44,28 @@ def _get_port_no(dev):
     return int(out.strip())
 
 
-# In order to avoid circular import, dynamically import the base class,
-# nova.network.linux_net.LinuxOVSInterfaceDriver
-# and use composition instead of inheritance.
-# The following inheritance code doesn't work due to circular import.
-#    from nova.network import linux_net as nova_linux_net
-#    class LinuxOVSRyuInterfaceDriver(nova_linux_net.LinuxOVSInterfaceDriver):
-#
-# nova.network.linux_net imports FLAGS.linuxnet_interface_driver
-# We are being imported from linux_net so that linux_net can't be imported
-# here due to circular import.
-# Another approach would be to factor out nova.network.linux_net so that
-# linux_net doesn't import FLAGS.linuxnet_interface_driver or it loads
-# lazily FLAGS.linuxnet_interface_driver.
-
-
-class LinuxOVSRyuInterfaceDriver(object):
+class LinuxOVSRyuInterfaceDriver(linux_net.LinuxOVSInterfaceDriver):
     def __init__(self):
-        from nova.network import linux_net as nova_linux_net
-        self.parent = nova_linux_net.LinuxOVSInterfaceDriver()
+        super(LinuxOVSRyuInterfaceDriver, self).__init__()
 
         LOG.debug('ryu rest host %s', FLAGS.linuxnet_ovs_ryu_api_host)
         self.ryu_client = OFPClient(FLAGS.linuxnet_ovs_ryu_api_host)
         self.datapath_id = _get_datapath_id(
             FLAGS.linuxnet_ovs_integration_bridge)
 
-        if nova_linux_net.binary_name == 'nova-network':
-            for tables in [nova_linux_net.iptables_manager.ipv4,
-                           nova_linux_net.iptables_manager.ipv6]:
+        if linux_net.binary_name == 'nova-network':
+            for tables in [linux_net.iptables_manager.ipv4,
+                           linux_net.iptables_manager.ipv6]:
                 tables['filter'].add_rule('FORWARD',
                         '--in-interface gw-+ --out-interface gw-+ -j DROP')
-            nova_linux_net.iptables_manager.apply()
+            linux_net.iptables_manager.apply()
 
     def plug(self, network, mac_address, gateway=True):
         LOG.debug("network %s mac_adress %s gateway %s",
                   network, mac_address, gateway)
-        ret = self.parent.plug(network, mac_address, gateway)
+        ret = super(LinuxOVSRyuInterfaceDriver, self).plug(
+            network, mac_address, gateway)
+
         port_no = _get_port_no(self.get_dev(network))
         self.ryu_client.create_port(network['uuid'], self.datapath_id, port_no)
         return ret
-
-    def unplug(self, network):
-        return self.parent.unplug(network)
-
-    def get_dev(self, network):
-        return self.parent.get_dev(network)
index 91c416ce0e25c5f5efcd36adc090adec95ecc0d3..2bd2f00963ccf05d0df49219658fd35a6c1bfdd8 100644 (file)
@@ -32,7 +32,7 @@ ryu_libvirt_ovs_driver_opt = cfg.StrOpt('libvirt_ovs_ryu_api_host',
                                         help='Openflow Ryu REST API host:port')
 
 FLAGS = flags.FLAGS
-FLAGS.add_option(ryu_libvirt_ovs_driver_opt)
+FLAGS.register_opt(ryu_libvirt_ovs_driver_opt)
 
 
 def _get_datapath_id(bridge_name):