pycloudlib.qemu.instance module

Instance class for QEMU.

class pycloudlib.qemu.instance.QemuInstance(key_pair, *, instance_id: str, handle: Popen | None = None, username: str | None = None)[source]

Bases: BaseInstance

QEMU instance object.

__init__(key_pair, *, instance_id: str, handle: Popen | None = None, username: str | None = None)[source]

Set up instance.

Parameters:
  • key_pair – key pair to use for instance

  • instance_id – ID identifying the instance, in the form <instance_path>::<port>::<telnet_port>

  • handle – handle to qemu process

  • username – username to use for ssh

add_network_interface(**kwargs) str[source]

Add nic to running instance.

console_log()[source]

Return the instance console log.

delete(wait=True) List[Exception][source]

Delete the instance.

Parameters:

wait – Ignored. Our ‘quit’ command is synchronous.

get_status()[source]

Get instance status.

property id: str

Return instance ID.

property ip

Return IP address of instance.

property name

Return instance name.

remove_network_interface(ip_address: str)[source]

Remove nic from running instance.

shutdown(wait=True, **kwargs)[source]

Shutdown the instance.

Parameters:

wait – wait for the instance to shutdown

start(wait=True)[source]

Start the instance.

Parameters:

wait – wait for the instance to start.

wait_for_delete(**kwargs)[source]

Not implemented as “quit” is executed synchronously.

wait_for_stop(**kwargs)[source]

Wait for instance stop.

wait_till_status(expected_status: str, timeout: int = 500)[source]

Wait for instance to reach a certain status.

Parameters:
  • status – status to wait for

  • timeout – timeout in seconds

class pycloudlib.qemu.instance.QmpConnection(qmp_socket: Path, log: Logger)[source]

Bases: object

Stupid wrapper to handle asyncio.

__init__(qmp_socket: Path, log: Logger)[source]

Set up QMP connection.

Parameters:
  • qmp_socket – path to QMP socket

  • log – logger to use

disconnect()[source]

Disconnect from QMP socket.

execute(command: str, arguments: Dict[str, Any] | None = None) Any[source]

Write data to QMP socket.

Parameters:
  • command – command to run

  • arguments – arguments to pass to command

Returns the response from QMP.