Esempio n. 1
0
def qemuAttach(conn, pid_value, flags):
    """This API is QEMU specific, so it will only work with hypervisor
    connections to the QEMU driver.
    
    This API will attach to an externally launched QEMU process
    identified by @pid. There are several requirements to successfully
    attach to an external QEMU process:
    
      - It must have been started with a monitor socket using the UNIX
        domain socket protocol.
      - No device hotplug/unplug, or other configuration changes can
        have been made via the monitor since it started.
      - The '-name' and '-uuid' arguments should have been set (not
        mandatory, but strongly recommended)
    
    To date, the only platforms we know of where pid_t is larger than
    unsigned int (64-bit Windows) also lack UNIX sockets, so the choice
    of @pid_value as an unsigned int should not present any difficulties.
    
    If successful, then the guest will appear in the list of running
    domains for this connection, and other APIs should operate
    normally (provided the above requirements were honored). """
    ret = libvirtmod_qemu.virDomainQemuAttach(conn._o, pid_value, flags)
    if ret is None:
        raise libvirt.libvirtError('virDomainQemuAttach() failed')
    __tmp = libvirt.virDomain(conn, _obj=ret)
    return __tmp
 def test_delete_ok(self, mock_lookup, mock_isact, mock_destr, mock_undef):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     mock_isact.return_value = 1
     try:
         self.lvirt.delete_vm("vm")
     except libvirt.libvirtError as le:
         self.fail(le.get_error_message())
Esempio n. 3
0
 def test_delete_ok(self, mock_lookup, mock_isact, mock_destr, mock_undef):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     mock_isact.return_value = 1
     try:
         self.lvirt.delete_vm("vm")
     except libvirt.libvirtError as le:
         self.fail(le.get_error_message())
Esempio n. 4
0
def _dispatchQemuMonitorEventCallback(conn: libvirt.virConnect,
                                      dom: libvirt.virDomain, event: str,
                                      seconds: int, micros: int, details: str,
                                      cbData: Dict[str, Any]) -> int:
    """Dispatches events to python user qemu monitor event callbacks
    """
    cb = cbData["cb"]
    opaque = cbData["opaque"]

    cb(conn, libvirt.virDomain(conn, _obj=dom), event, seconds, micros,
       details, opaque)
    return 0
    def test_domain_name_increment(self):
        vc = libvirt.virConnect()
        d = libvirt.virDomain(vc)

        c = Cluster('unittest', 'template_domain', vc)

        vc.listAllDomains = MagicMock(return_value=[])
        self.assertEqual('unittest-00', c.next_domain_name())

        d.name = MagicMock(return_value='unittest-00')
        vc.listAllDomains = MagicMock(return_value=[d])
        self.assertEqual('unittest-01', c.next_domain_name())
Esempio n. 6
0
 def test_poweroff_fail(self, mock_lookup, mock_shut):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     mock_shut.side_effect = libvirt.libvirtError('Mock Lvirt Error')
     self.assertRaises(libvirt.libvirtError, self.lvirt.power_off, "vm")
Esempio n. 7
0
 def test_poweroff_ok(self, mock_lookup, mock_shut):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     try:
         self.lvirt.power_off("vm")
     except libvirt.libvirtError as le:
         self.fail(le.get_error_message())
Esempio n. 8
0
 def test_delete_fail_undef(self, mock_lookup, mock_isact, mock_destr,
                            mock_undef):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     mock_isact.return_value = 0
     mock_undef.side_effect = libvirt.libvirtError('Mock Lvirt Error')
     self.assertRaises(libvirt.libvirtError, self.lvirt.delete_vm, "vm")
Esempio n. 9
0
 def test_reboot_fail(self, mock_lookup, mock_reboot):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     mock_reboot.side_effect = libvirt.libvirtError('Mock Lvirt Error')
     self.assertRaises(libvirt.libvirtError, self.lvirt.reboot, "vm")
Esempio n. 10
0
 def test_reboot_ok(self, mock_lookup, mock_reboot):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     try:
         self.lvirt.reboot("vm")
     except libvirt.libvirtError as le:
         self.fail(le.get_error_message())
Esempio n. 11
0
 def test_poweroff_fail(self, mock_lookup, mock_shut):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     mock_shut.side_effect = libvirt.libvirtError('Mock Lvirt Error')
     self.assertRaises(libvirt.libvirtError, self.lvirt.power_off, "vm")
Esempio n. 12
0
 def test_poweroff_ok(self, mock_lookup, mock_shut):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     try:
         self.lvirt.power_off("vm")
     except libvirt.libvirtError as le:
         self.fail(le.get_error_message())
Esempio n. 13
0
 def test_delete_fail_undef(self, mock_lookup, mock_isact,
                            mock_destr, mock_undef):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     mock_isact.return_value = 0
     mock_undef.side_effect = libvirt.libvirtError('Mock Lvirt Error')
     self.assertRaises(libvirt.libvirtError, self.lvirt.delete_vm, "vm")
Esempio n. 14
0
 def test_reboot_fail(self, mock_lookup, mock_reboot):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     mock_reboot.side_effect = libvirt.libvirtError('Mock Lvirt Error')
     self.assertRaises(libvirt.libvirtError, self.lvirt.reboot, "vm")
Esempio n. 15
0
 def test_reboot_ok(self, mock_lookup, mock_reboot):
     mock_lookup.return_value = libvirt.virDomain(self.lvirt.conn)
     try:
         self.lvirt.reboot("vm")
     except libvirt.libvirtError as le:
         self.fail(le.get_error_message())