コード例 #1
0
 def test_reconnect(self):
     # test with an inexisting connection (not cached)
     with ConnectionManager(self.uri) as cm:
         cm._drv = None
         self.assertIsNotNone(cm.connection)
         self.assertIsInstance(cm.connection, libvirt.virConnect)
     # test with an existing connection (already cached)
     with ConnectionManager(self.uri) as cmo:
         # call version to force call to connect()
         version = cmo.version
         cmo._drv = None
         with ConnectionManager(self.uri) as cmi:
             version = cmi.version
             self.assertIsNotNone(cmi.connection)
             self.assertIsInstance(cmi.connection, libvirt.virConnect)
コード例 #2
0
    def __init__(self, connection):

        self._wait_timeout = 30
        self._connection = ConnectionManager(connection)
        self._domain = DomainManager(connection)

        super(LibVirtMachineManager, self).__init__()
コード例 #3
0
    def depends_on(cls, *args, **kwargs):
        # singleton is based on the uri, extracted from the libvirt handler
        (handler, ) = args[0]
        if isinstance(handler, basestring):
            handler = ConnectionManager(handler)
        if isinstance(handler, ConnectionManager):
            handler = handler.connection
        if not isinstance(handler, libvirt.virConnect):
            what = type(handler)
            reason = "Invalid type for 'connection' field: {0}".format(what)
            raise DomainManagerError(reason)

        try:
            uri = handler.getURI()
        except libvirt.libvirtError as e:
            reason = "unable to get domain uri from connection handle"
            raise DomainManagerError(reason)
        return uri
コード例 #4
0
    def depends_on(cls, *args, **kwargs):
        # singleton is based on the uri, extracted from the libvirt handler
        (handler,) = args[0]
        if isinstance(handler, basestring):
            handler = ConnectionManager(handler)
        if isinstance(handler, ConnectionManager):
            handler = handler.connection
        if not isinstance(handler, libvirt.virConnect):
            what = type(handler)
            reason = "Invalid type for 'connection' field: {0}".format(what)
            raise DomainManagerError(reason)

        try:
            uri = handler.getURI()
        except libvirt.libvirtError as e:
            reason = "unable to get domain uri from connection handle"
            raise DomainManagerError(reason)
        return uri
コード例 #5
0
 def test_connection(self):
     with ConnectionManager(self.uri) as cm:
         self.assertIsNotNone(cm.connection)
         self.assertIsInstance(cm.connection, libvirt.virConnect)
コード例 #6
0
 def test_uri(self):
     with ConnectionManager(self.uri) as cm:
         self.assertEqual(cm.uri, self.uri)
コード例 #7
0
 def test_create_uri(self):
     with self.assertRaises(NotImplementedError):
         with ConnectionManager(self.uri) as cm:
             cm.create_uri("dummy")
コード例 #8
0
 def test_version(self):
     with ConnectionManager(self.uri) as cm:
         self.assertIsNotNone(cm.version)
         self.assertEqual(len(cm.version), 3)
         self.assertIsInstance(cm.version, tuple)
コード例 #9
0
 def test_with(self):
     with ConnectionManager(self.uri) as cm:
         pass
コード例 #10
0
 def test_constructor(self):
     cm = ConnectionManager(self.uri)
     self.assertIsNotNone(cm)
コード例 #11
0
ファイル: test_virt_domain.py プロジェクト: vaginessa/irma
 def test_constructor_with_connection_manager(self):
     with ConnectionManager(self.uri) as cm:
         dm = DomainManager(cm)
         self.assertIsNotNone(dm)
         self.assertIsInstance(dm, DomainManager)