various updates
This commit is contained in:
@ -4,7 +4,7 @@ from ..main import LibvirtSession
|
||||
from ..exceptions import VMNotFound
|
||||
|
||||
|
||||
class VMBase:
|
||||
class VirtualMachineBase:
|
||||
def __init__(self, session: LibvirtSession, name: str):
|
||||
self.domname = name
|
||||
self.session = session.session # virConnect object
|
||||
|
@ -1,14 +1,14 @@
|
||||
import json
|
||||
import logging
|
||||
from time import time, sleep
|
||||
from base64 import standard_b64encode, b64decode, b64encode
|
||||
from base64 import standard_b64encode, b64decode
|
||||
|
||||
import libvirt
|
||||
import libvirt_qemu
|
||||
|
||||
from ..main import LibvirtSession
|
||||
from ..exceptions import QemuAgentError
|
||||
from .base import VMBase
|
||||
from .base import VirtualMachineBase
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -18,7 +18,7 @@ QEMU_TIMEOUT = 60 # seconds
|
||||
POLL_INTERVAL = 0.3 # also seconds
|
||||
|
||||
|
||||
class QemuAgent(VMBase):
|
||||
class QemuAgent(VirtualMachineBase):
|
||||
"""
|
||||
Interacting with QEMU guest agent. Methods:
|
||||
|
||||
|
@ -3,13 +3,13 @@ import logging
|
||||
import libvirt
|
||||
|
||||
from ..exceptions import VMError
|
||||
from .base import VMBase
|
||||
from .base import VirtualMachineBase
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class VirtualMachine(VMBase):
|
||||
class VirtualMachine(VirtualMachineBase):
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@ -72,7 +72,7 @@ class VirtualMachine(VMBase):
|
||||
try:
|
||||
ret = self.domain.create()
|
||||
except libvirt.libvirtError as err:
|
||||
raise VMError(f'Cannot start vm={self.domname} return_code={ret}: {err}') from err
|
||||
raise VMError(f'Cannot start vm={self.domname}: {err}') from err
|
||||
|
||||
def shutdown(self, force=False, sigkill=False) -> None:
|
||||
"""
|
||||
@ -108,7 +108,7 @@ class VirtualMachine(VMBase):
|
||||
guest OS shutdown.
|
||||
"""
|
||||
try:
|
||||
self.domian.reset()
|
||||
self.domain.reset()
|
||||
except libvirt.libvirtError as err:
|
||||
raise VMError(f'Cannot reset vm={self.domname}: {err}') from err
|
||||
|
||||
|
Reference in New Issue
Block a user