]> xenbits.xensource.com Git - osstest/openstack-nova.git/commitdiff
move os_vif.initialize() to nova-compute start
authorSean Dague <sean@dague.net>
Wed, 21 Sep 2016 15:11:21 +0000 (11:11 -0400)
committerSean Dague <sean@dague.net>
Wed, 21 Sep 2016 20:49:50 +0000 (16:49 -0400)
os_vif.initialize() was previously executed during module load. This
means it was entirely possible that it was run before things like
logging were actually set up in the expected way. Move this back into
execution time instead of load time to ensure that logging is actually
setup.

Changes need to be made to tests which make assumptions about os_vif
objects to manually initialize os_vif when it will be used. os_vif
objects can't be created until it is initialized, so some delayed
object creation is also done in test_vif.py.

Closes-Bug: #1615676

Change-Id: I89fe5c5b3d762f3a3238b587685df85d15ee56c4

nova/cmd/compute.py
nova/network/os_vif_util.py
nova/tests/unit/virt/libvirt/test_driver.py
nova/tests/unit/virt/libvirt/test_vif.py

index 3f7ca9e7fba16d678f4906d1e7c5c3f1d841b8a0..af321e008ac70a3884301054104a0cd51ab9b1e5 100644 (file)
@@ -19,6 +19,7 @@
 import shlex
 import sys
 
+import os_vif
 from oslo_log import log as logging
 from oslo_privsep import priv_context
 from oslo_reports import guru_meditation_report as gmr
@@ -44,6 +45,8 @@ def main():
     priv_context.init(root_helper=shlex.split(utils.get_root_helper()))
     utils.monkey_patch()
     objects.register_all()
+    # Ensure os-vif objects are registered and plugins loaded
+    os_vif.initialize()
 
     gmr.TextGuruMeditation.setup_autorun(version)
 
index 54107a066095b1fe9012eee81f372bfd8ff055bc..1244a4e0ca827f207d528e49ceaed2cdcc01b7ba 100644 (file)
@@ -20,7 +20,6 @@ versioned object model os_vif.objects.*
 
 import sys
 
-import os_vif
 from os_vif import objects
 from oslo_config import cfg
 from oslo_log import log as logging
@@ -33,9 +32,6 @@ from nova.network import model
 LOG = logging.getLogger(__name__)
 CONF = cfg.CONF
 
-# Ensure os-vif objects are registered and plugins loaded
-os_vif.initialize()
-
 
 def _get_vif_name(vif):
     """Get a VIF device name
index 17dd0b1bc3d32458457955a71a618ff89a0770f6..3875ccf1a52cb2d0d4a77ff1fbedb7febf7f1525 100644 (file)
@@ -36,6 +36,7 @@ from lxml import etree
 import mock
 from mox3 import mox
 from os_brick.initiator import connector
+import os_vif
 from oslo_concurrency import lockutils
 from oslo_concurrency import processutils
 from oslo_config import cfg
@@ -694,6 +695,9 @@ class LibvirtConnTestCase(test.NoDBTestCase):
 
         self.flags(sysinfo_serial="hardware", group="libvirt")
 
+        # normally loaded during nova-compute startup
+        os_vif.initialize()
+
         self.useFixture(fixtures.MonkeyPatch(
             'nova.virt.libvirt.imagebackend.libvirt_utils',
             fake_libvirt_utils))
@@ -15007,6 +15011,8 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
     """Test for nova.virt.libvirt.libvirt_driver.LibvirtDriver."""
     def setUp(self):
         super(LibvirtDriverTestCase, self).setUp()
+        os_vif.initialize()
+
         self.drvr = libvirt_driver.LibvirtDriver(
             fake.FakeVirtAPI(), read_only=True)
         self.context = context.get_admin_context()
index 19be56c65db380d64cd184e26a58870aeed718fe..e1481d14e866169cab91533eeafa090541d5ab46 100644 (file)
@@ -389,52 +389,56 @@ class LibvirtVifTestCase(test.NoDBTestCase):
         'quota:vif_outbound_burst': '30'
     }
 
-    os_vif_network = osv_objects.network.Network(
-        id="b82c1929-051e-481d-8110-4669916c7915",
-        label="Demo Net",
-        subnets=osv_objects.subnet.SubnetList(
-            objects=[]))
-
-    os_vif_bridge = osv_objects.vif.VIFBridge(
-        id="dc065497-3c8d-4f44-8fb4-e1d33c16a536",
-        address="22:52:25:62:e2:aa",
-        plugin="linux_bridge",
-        vif_name="nicdc065497-3c",
-        bridge_name="br100",
-        has_traffic_filtering=False,
-        network=os_vif_network)
-
-    os_vif_ovs_prof = osv_objects.vif.VIFPortProfileOpenVSwitch(
-        interface_id="07bd6cea-fb37-4594-b769-90fc51854ee9",
-        profile_id="fishfood")
-
-    os_vif_ovs = osv_objects.vif.VIFOpenVSwitch(
-        id="dc065497-3c8d-4f44-8fb4-e1d33c16a536",
-        address="22:52:25:62:e2:aa",
-        unplugin="linux_bridge",
-        vif_name="nicdc065497-3c",
-        bridge_name="br0",
-        port_profile=os_vif_ovs_prof,
-        network=os_vif_network)
-
-    os_vif_ovs_hybrid = osv_objects.vif.VIFBridge(
-        id="dc065497-3c8d-4f44-8fb4-e1d33c16a536",
-        address="22:52:25:62:e2:aa",
-        unplugin="linux_bridge",
-        vif_name="nicdc065497-3c",
-        bridge_name="br0",
-        port_profile=os_vif_ovs_prof,
-        has_traffic_filtering=False,
-        network=os_vif_network)
-
-    os_vif_inst_info = osv_objects.instance_info.InstanceInfo(
-        uuid="d5b1090c-9e00-4fa4-9504-4b1494857970",
-        name="instance-000004da",
-        project_id="2f37d7f6-e51a-4a1f-8b6e-b0917ffc8390")
+    def setup_os_vif_objects(self):
+        self.os_vif_network = osv_objects.network.Network(
+            id="b82c1929-051e-481d-8110-4669916c7915",
+            label="Demo Net",
+            subnets=osv_objects.subnet.SubnetList(
+                objects=[]))
+
+        self.os_vif_bridge = osv_objects.vif.VIFBridge(
+            id="dc065497-3c8d-4f44-8fb4-e1d33c16a536",
+            address="22:52:25:62:e2:aa",
+            plugin="linux_bridge",
+            vif_name="nicdc065497-3c",
+            bridge_name="br100",
+            has_traffic_filtering=False,
+            network=self.os_vif_network)
+
+        self.os_vif_ovs_prof = osv_objects.vif.VIFPortProfileOpenVSwitch(
+            interface_id="07bd6cea-fb37-4594-b769-90fc51854ee9",
+            profile_id="fishfood")
+
+        self.os_vif_ovs = osv_objects.vif.VIFOpenVSwitch(
+            id="dc065497-3c8d-4f44-8fb4-e1d33c16a536",
+            address="22:52:25:62:e2:aa",
+            unplugin="linux_bridge",
+            vif_name="nicdc065497-3c",
+            bridge_name="br0",
+            port_profile=self.os_vif_ovs_prof,
+            network=self.os_vif_network)
+
+        self.os_vif_ovs_hybrid = osv_objects.vif.VIFBridge(
+            id="dc065497-3c8d-4f44-8fb4-e1d33c16a536",
+            address="22:52:25:62:e2:aa",
+            unplugin="linux_bridge",
+            vif_name="nicdc065497-3c",
+            bridge_name="br0",
+            port_profile=self.os_vif_ovs_prof,
+            has_traffic_filtering=False,
+            network=self.os_vif_network)
+
+        self.os_vif_inst_info = osv_objects.instance_info.InstanceInfo(
+            uuid="d5b1090c-9e00-4fa4-9504-4b1494857970",
+            name="instance-000004da",
+            project_id="2f37d7f6-e51a-4a1f-8b6e-b0917ffc8390")
 
     def setUp(self):
         super(LibvirtVifTestCase, self).setUp()
         self.flags(allow_same_net_traffic=True)
+        # os_vif.initialize is typically done in nova-compute startup
+        os_vif.initialize()
+        self.setup_os_vif_objects()
         self.executes = []
 
         def fake_execute(*cmd, **kwargs):