Merge "fakelibvirt: Remove nova-network remnants"
This commit is contained in:
commit
662398a1a4
|
@ -782,22 +782,6 @@ class libvirtError(Exception):
|
|||
return self.err[8]
|
||||
|
||||
|
||||
class NWFilter(object):
|
||||
def __init__(self, connection, xml):
|
||||
self._connection = connection
|
||||
|
||||
self._xml = xml
|
||||
self._parse_xml(xml)
|
||||
|
||||
def _parse_xml(self, xml):
|
||||
tree = etree.fromstring(xml)
|
||||
root = tree.find('.')
|
||||
self._name = root.get('name')
|
||||
|
||||
def undefine(self):
|
||||
self._connection._remove_filter(self)
|
||||
|
||||
|
||||
class NodeDevice(object):
|
||||
|
||||
def __init__(self, connection, xml=None):
|
||||
|
@ -1421,7 +1405,6 @@ class Connection(object):
|
|||
self._vms = {}
|
||||
self._running_vms = {}
|
||||
self._id_counter = 1 # libvirt reserves 0 for the hypervisor.
|
||||
self._nwfilters = {}
|
||||
self._nodedevs = {}
|
||||
self._secrets = {}
|
||||
self._event_callbacks = {}
|
||||
|
@ -1434,12 +1417,6 @@ class Connection(object):
|
|||
self.mdev_info = mdev_info or HostMdevDevicesInfo(devices={})
|
||||
self.hostname = hostname or 'compute1'
|
||||
|
||||
def _add_filter(self, nwfilter):
|
||||
self._nwfilters[nwfilter._name] = nwfilter
|
||||
|
||||
def _remove_filter(self, nwfilter):
|
||||
del self._nwfilters[nwfilter._name]
|
||||
|
||||
def _add_nodedev(self, nodedev):
|
||||
self._nodedevs[nodedev._name] = nodedev
|
||||
|
||||
|
@ -1703,20 +1680,6 @@ class Connection(object):
|
|||
error_code=VIR_ERR_INTERNAL_ERROR,
|
||||
error_domain=VIR_FROM_QEMU)
|
||||
|
||||
def nwfilterLookupByName(self, name):
|
||||
try:
|
||||
return self._nwfilters[name]
|
||||
except KeyError:
|
||||
raise make_libvirtError(
|
||||
libvirtError,
|
||||
"no nwfilter with matching name %s" % name,
|
||||
error_code=VIR_ERR_NO_NWFILTER,
|
||||
error_domain=VIR_FROM_NWFILTER)
|
||||
|
||||
def nwfilterDefineXML(self, xml):
|
||||
nwfilter = NWFilter(self, xml)
|
||||
self._add_filter(nwfilter)
|
||||
|
||||
def device_lookup_by_name(self, dev_name):
|
||||
return self.pci_info.get_device_by_name(dev_name)
|
||||
|
||||
|
@ -1834,7 +1797,6 @@ virNodeDevice = NodeDevice
|
|||
|
||||
virConnect = Connection
|
||||
virSecret = Secret
|
||||
virNWFilter = NWFilter
|
||||
|
||||
|
||||
class FakeLibvirtFixture(fixtures.Fixture):
|
||||
|
|
|
@ -282,25 +282,6 @@ class FakeLibvirtTests(test.NoDBTestCase):
|
|||
etree.fromstring(conn.getDomainCapabilities(
|
||||
'/usr/bin/qemu-kvm', 'x86_64', 'q35', 'kvm', 0))
|
||||
|
||||
def test_nwfilter_define_undefine(self):
|
||||
conn = self.get_openAuth_curry_func()('qemu:///system')
|
||||
# Will raise an exception if it's not valid XML
|
||||
xml = '''<filter name='nova-instance-instance-789' chain='root'>
|
||||
<uuid>946878c6-3ad3-82b2-87f3-c709f3807f58</uuid>
|
||||
</filter>'''
|
||||
|
||||
conn.nwfilterDefineXML(xml)
|
||||
nwfilter = conn.nwfilterLookupByName('nova-instance-instance-789')
|
||||
nwfilter.undefine()
|
||||
try:
|
||||
conn.nwfilterLookupByName('nova-instance-instance-789320334')
|
||||
except libvirt.libvirtError as e:
|
||||
self.assertEqual(e.get_error_code(), libvirt.VIR_ERR_NO_NWFILTER)
|
||||
self.assertEqual(e.get_error_domain(), libvirt.VIR_FROM_NWFILTER)
|
||||
return
|
||||
raise self.failureException("Invalid NWFilter name didn't"
|
||||
" raise libvirtError")
|
||||
|
||||
def test_compareCPU_compatible(self):
|
||||
conn = self.get_openAuth_curry_func()('qemu:///system')
|
||||
|
||||
|
|
|
@ -1386,7 +1386,6 @@ class LibvirtTpoolProxyTestCase(test.NoDBTestCase):
|
|||
self.assertIn(fakelibvirt.virConnect, proxy_classes)
|
||||
self.assertIn(fakelibvirt.virNodeDevice, proxy_classes)
|
||||
self.assertIn(fakelibvirt.virSecret, proxy_classes)
|
||||
self.assertIn(fakelibvirt.virNWFilter, proxy_classes)
|
||||
|
||||
# Assert that we filtered out libvirtError
|
||||
self.assertNotIn(fakelibvirt.libvirtError, proxy_classes)
|
||||
|
|
Loading…
Reference in New Issue