本文整理汇总了Python中healthnmon.tests.FakeLibvirt.openReadOnly方法的典型用法代码示例。如果您正苦于以下问题:Python FakeLibvirt.openReadOnly方法的具体用法?Python FakeLibvirt.openReadOnly怎么用?Python FakeLibvirt.openReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类healthnmon.tests.FakeLibvirt
的用法示例。
在下文中一共展示了FakeLibvirt.openReadOnly方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_inventory
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import openReadOnly [as 别名]
def test_update_inventory(self):
self.mox.StubOutWithMock(libvirt, 'openReadOnly')
libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
self.mox.StubOutWithMock(api, 'vm_save')
self.mox.StubOutWithMock(api, 'vm_host_save')
self.mox.StubOutWithMock(api, 'storage_volume_save')
api.storage_volume_save(mox.IgnoreArg(),
mox.IgnoreArg()).MultipleTimes().AndReturn(None)
api.vm_host_save(mox.IgnoreArg(),
mox.IgnoreArg()).MultipleTimes().AndReturn(None)
api.vm_save(mox.IgnoreArg(),
mox.IgnoreArg()).MultipleTimes().AndReturn(None)
self.mox.ReplayAll()
conn = connection.get_connection(True)
compute_rmcontext = ComputeRMContext(rmType='QEMU',
rmIpAddress='10.10.155.165', rmUserName='openstack',
rmPassword='password')
InventoryCacheManager.get_all_compute_inventory()['1'] = \
ComputeInventory(compute_rmcontext)
conn.init_rmcontext(compute_rmcontext)
conn._wrapped_conn = self.fakeConn
conn.update_inventory('1')
示例2: test_get_connection_with_conn_static_exception
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import openReadOnly [as 别名]
def test_get_connection_with_conn_static_exception(self):
self.mox.StubOutWithMock(libvirt, 'openReadOnly')
libvirt.openReadOnly(mox.IgnoreArg()).AndRaise(libvirt.libvirtError)
self.mox.ReplayAll()
try:
self.libvirt_connection_cls._connect('uri', True)
except Exception as e:
self.assertTrue(isinstance(e, libvirt.libvirtError))
示例3: test_get_connection_with_conn_static
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import openReadOnly [as 别名]
def test_get_connection_with_conn_static(self):
self.mox.StubOutWithMock(libvirt, 'openReadOnly')
libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
self.mox.ReplayAll()
con = self.libvirt_connection_cls._connect('uri', True)
self.assertEquals("ubuntu164.vmm.hp.com", con.getHostname())
self.assertTrue("ReleaseBDevEnv" in con.listDefinedDomains())
self.assertTrue("1" in str(con.listDomainsID()))
示例4: test__get_connection_with_invalid_conn
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import openReadOnly [as 别名]
def test__get_connection_with_invalid_conn(self):
self.mox.StubOutWithMock(libvirt, 'openReadOnly')
libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
self.mox.ReplayAll()
conn = connection.get_connection(True)
compute_rmcontext = ComputeRMContext(
rmType='QEMU',
rmIpAddress='10.10.155.165', rmUserName='openstack',
rmPassword='password')
conn.init_rmcontext(compute_rmcontext)
conn._wrapped_conn = 'Invalid'
self.assertRaises(Exception, conn._get_connection)
self.mox.UnsetStubs()
示例5: test_update_perfdata
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import openReadOnly [as 别名]
def test_update_perfdata(self):
conn = connection.get_connection(True)
self.mox.StubOutWithMock(connection.LibvirtConnection, 'uri')
conn.uri().AndReturn(None)
self.mox.StubOutWithMock(libvirt, 'openReadOnly')
libvirt.openReadOnly(mox.IgnoreArg()).AndReturn(self.fakeConn)
self.mox.ReplayAll()
conn.update_perfdata('uuid', 'perfmon_type')
self.assertTrue(conn.libvirt_perfmon.perfDataCache is not None)
conn.update_perfdata('uuid', 'perfmon_type1')
self.assertTrue(conn.libvirt_perfmon.perfDataCache is not None)
示例6: get_new_connection
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import openReadOnly [as 别名]
def get_new_connection(self, uri, read_only):
import healthnmon.tests.FakeLibvirt as FakeLibvirt
return FakeLibvirt.openReadOnly(uri)
示例7: test__register_libvirt_domain_events
# 需要导入模块: from healthnmon.tests import FakeLibvirt [as 别名]
# 或者: from healthnmon.tests.FakeLibvirt import openReadOnly [as 别名]
def test__register_libvirt_domain_events(self):
libvirt_event_monitor.libvirt = libvirt
libvirtEvents = libvirt_event_monitor.LibvirtEvents()
libvirtEvents.libvirt_con = libvirt.openReadOnly('fake:///system')
libvirtEvents._register_libvirt_domain_events()