Created
August 15, 2014 19:10
-
-
Save mriedem/61651bbc6c054f5a97dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -33,6 +34,7 @@ from lxml import etree | |
import mock | |
import mox | |
from oslo.config import cfg | |
+import six | |
from nova.api.ec2 import cloud | |
from nova.api.metadata import base as instance_metadata | |
@@ -399,6 +401,37 @@ class FakeNodeDevice(object): | |
class LibvirtConnTestCase(test.TestCase, | |
test_driver.DriverAPITestHelper): | |
+ @classmethod | |
+ def setUpClass(cls): | |
+ # NOTE(mriedem): If the libvirt module being used doesn't have the | |
+ # VIR_DOMAIN_BLOCK_REBASE_COPY attribute then we aren't using a new | |
+ # enough version of native libvirt and need to stub out some values | |
+ # for certain tests. | |
+ cls.extra_volume_attributes = { | |
+ 'VIR_DOMAIN_BLOCK_REBASE_COPY': False, | |
+ 'VIR_DOMAIN_BLOCK_REBASE_COPY': False, | |
+ 'VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT': False, | |
+ 'VIR_DOMAIN_BLOCK_REBASE_SHALLOW': False, | |
+ 'VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT': False, | |
+ } | |
+ for attr, remove in six.iteritems(cls.extra_volume_attributes): | |
+ if not hasattr(libvirt_driver.libvirt, attr): | |
+ setattr(libvirt_driver.libvirt, attr, | |
+ getattr(fakelibvirt, attr)) | |
+ cls.extra_volume_attributes[attr] = True | |
+ super(LibvirtConnTestCase, cls).setUpClass() | |
+ | |
+ @classmethod | |
+ def tearDownClass(cls): | |
+ # Unset any extra fields we set on libvirt during this test run | |
+ for attr, remove in six.iteritems(cls.extra_volume_attributes): | |
+ if remove: | |
+ delattr(libvirt_driver.libvirt, attr) | |
+ super(LibvirtConnTestCase, cls).tearDownClass() | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment