Пример #1
0
    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='******',
                                             rmPassword='******')

        InventoryCacheManager.get_all_compute_inventory()['1'] = \
            ComputeInventory(compute_rmcontext)

        conn.init_rmcontext(compute_rmcontext)
        conn._wrapped_conn = self.fakeConn

        conn.update_inventory('1')
Пример #2
0
    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='******',
                                             rmPassword='******')

        InventoryCacheManager.get_all_compute_inventory()['1'] = \
            ComputeInventory(compute_rmcontext)

        conn.init_rmcontext(compute_rmcontext)
        conn._wrapped_conn = self.fakeConn

        conn.update_inventory('1')
    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))
    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()))
Пример #5
0
    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))
Пример #6
0
    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()))
    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='******',
            rmPassword='******')
        conn.init_rmcontext(compute_rmcontext)
        conn._wrapped_conn = 'Invalid'
        self.assertRaises(Exception, conn._get_connection)

        self.mox.UnsetStubs()
    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)
Пример #9
0
 def get_new_connection(self, uri, read_only):
     import healthnmon.tests.FakeLibvirt as FakeLibvirt
     return FakeLibvirt.openReadOnly(uri)
Пример #10
0
 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()
Пример #11
0
 def get_new_connection(self, uri, read_only):
     import healthnmon.tests.FakeLibvirt as FakeLibvirt
     return FakeLibvirt.openReadOnly(uri)