Merge "fakelibvirt: Make 'Connection.getHostname' unique"
This commit is contained in:
commit
28b80d975d
|
@ -98,7 +98,7 @@ class ServersTestBase(base.ServersTestBase):
|
|||
|
||||
def _get_connection(self, host_info, pci_info=None,
|
||||
libvirt_version=fakelibvirt.FAKE_LIBVIRT_VERSION,
|
||||
mdev_info=None):
|
||||
mdev_info=None, hostname=None):
|
||||
# sanity check
|
||||
self.assertGreater(16, host_info.cpus,
|
||||
"Host.get_online_cpus is only accounting for 16 CPUs but you're "
|
||||
|
@ -110,7 +110,8 @@ class ServersTestBase(base.ServersTestBase):
|
|||
hv_version=fakelibvirt.FAKE_QEMU_VERSION,
|
||||
host_info=host_info,
|
||||
pci_info=pci_info,
|
||||
mdev_info=mdev_info)
|
||||
mdev_info=mdev_info,
|
||||
hostname=hostname)
|
||||
return fake_connection
|
||||
|
||||
|
||||
|
|
|
@ -379,8 +379,8 @@ class NUMAServersTest(NUMAServersTestBase):
|
|||
self.computes = {}
|
||||
self.compute_rp_uuids = {}
|
||||
for host in ['test_compute0', 'test_compute1']:
|
||||
fake_connection = self._get_connection(host_info=host_info)
|
||||
fake_connection.getHostname = lambda: host
|
||||
fake_connection = self._get_connection(
|
||||
host_info=host_info, hostname=host)
|
||||
|
||||
# This is fun. Firstly we need to do a global'ish mock so we can
|
||||
# actually start the service.
|
||||
|
@ -669,8 +669,8 @@ class NUMAServersWithNetworksTest(NUMAServersTestBase):
|
|||
# Start services
|
||||
self.computes = {}
|
||||
for host in ['test_compute0', 'test_compute1']:
|
||||
fake_connection = self._get_connection(host_info=host_info)
|
||||
fake_connection.getHostname = lambda: host
|
||||
fake_connection = self._get_connection(
|
||||
host_info=host_info, hostname=host)
|
||||
|
||||
# This is fun. Firstly we need to do a global'ish mock so we can
|
||||
# actually start the service.
|
||||
|
@ -742,8 +742,8 @@ class NUMAServersWithNetworksTest(NUMAServersTestBase):
|
|||
self.computes = {}
|
||||
for host in ['test_compute0', 'test_compute1']:
|
||||
host_info = host_infos.pop(0)
|
||||
fake_connection = self._get_connection(host_info=host_info)
|
||||
fake_connection.getHostname = lambda: host
|
||||
fake_connection = self._get_connection(
|
||||
host_info=host_info, hostname=host)
|
||||
|
||||
# This is fun. Firstly we need to do a global'ish mock so we can
|
||||
# actually start the service.
|
||||
|
|
|
@ -1223,7 +1223,7 @@ class Secret(object):
|
|||
class Connection(object):
|
||||
def __init__(self, uri=None, readonly=False, version=FAKE_LIBVIRT_VERSION,
|
||||
hv_version=FAKE_QEMU_VERSION, host_info=None, pci_info=None,
|
||||
mdev_info=None):
|
||||
mdev_info=None, hostname=None):
|
||||
if not uri or uri == '':
|
||||
if allow_default_uri_connection:
|
||||
uri = 'qemu:///session'
|
||||
|
@ -1261,6 +1261,7 @@ class Connection(object):
|
|||
num_pfs=0,
|
||||
num_vfs=0)
|
||||
self.mdev_info = mdev_info or []
|
||||
self.hostname = hostname or 'compute1'
|
||||
|
||||
def _add_filter(self, nwfilter):
|
||||
self._nwfilters[nwfilter._name] = nwfilter
|
||||
|
@ -1359,7 +1360,7 @@ class Connection(object):
|
|||
return self.fakeVersion
|
||||
|
||||
def getHostname(self):
|
||||
return 'compute1'
|
||||
return self.hostname
|
||||
|
||||
def domainEventRegisterAny(self, dom, eventid, callback, opaque):
|
||||
self._event_callbacks[eventid] = [callback, opaque]
|
||||
|
|
Loading…
Reference in New Issue