def setUp(self): super(DomainJobInfoTestCase, self).setUp() self.useFixture(fakelibvirt.FakeLibvirtFixture()) self.conn = fakelibvirt.openAuth("qemu:///system", [[], lambda: True]) xml = ("<domain type='kvm'>" " <name>instance-0000000a</name>" "</domain>") self.dom = self.conn.createXML(xml, 0) host.DomainJobInfo._have_job_stats = True
def get_openAuth_curry_func(self, readOnly=False): def fake_cb(credlist): return 0 creds = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_NOECHOPROMPT], fake_cb, None] flags = 0 if readOnly: flags = libvirt.VIR_CONNECT_RO return lambda uri: libvirt.openAuth(uri, creds, flags)
def connect_with_block(*a, **k): # enough to allow another connect to run eventlet.sleep(0) self.connect_calls += 1 return fakelibvirt.openAuth("qemu:///system", [[], lambda: 1, None], 0)