COT.commands.deploy module

Module for deploying VM descriptions to a hypervisor to instantiate VMs.


COTDeploy Semi-abstract class for commands used to deploy a VM to a hypervisor.
SerialConnection Generic class defining a serial port connection.
class COTDeploy(ui)[source]

Bases: COT.commands.command.ReadCommand

Semi-abstract class for commands used to deploy a VM to a hypervisor.

Provides some baseline parameters and input validation that are expected to be common across all concrete subclasses.

Inherited attributes: ui, package,

Attributes: generic_parser, parser, subparsers, hypervisor, configuration, username, password, power_on, vm_name, network_map


Instantiate this command with the given UI.

Parameters:ui (UI) -- User interface instance.

Create 'deploy' CLI subparser if it doesn't already exist.


Unlike most commands, this one has subparsers of its own - 'cot deploy PACKAGE <hypervisor>' so subclasses of this module should call super().create_subparser() (to create the main 'deploy' subparser if it doesn't already exist) then call self.ui.add_parser(..., parent=self.subparsers, ...) to add their own sub-subparser.


Check whether the module is ready to run().

Returns:tuple -- (True, ready_message) or (False, reason_why_not)

Do the actual work of this command.


VM configuration profile to use for deployment.

Raises:InvalidInputError -- if not a profile defined in the VM.
generic_parser = None

Generic parser object providing args that most subclasses will use.

Subclasses can call self.subparsers.add_parser(parents=[self.generic_parser]) to automatically inherit this set of args


Hypervisor to deploy to.

Raises:InvalidInputError -- if not a recognized value.

Mapping of network names to networks.

password = None

Server login password.


Whether to automatically power on the VM after deployment.


Mapping of serial ports to various connection types.

subparsers = None

Subparser grouping for hypervisor-specific sub-subparsers.

Subclasses should generally have their create_subparser() implementations create their sub-subparsers with parent=subparsers.

username = None

Server login username.

vm_name = None

Name of the created virtual machine

class SerialConnection(kind, value, options)[source]

Bases: object

Generic class defining a serial port connection.

__init__(kind, value, options)[source]

Construct a SerialConnection object of the given kind and value.

  • kind (str) -- Connection type string, possibly in need of munging.
  • value (str) -- Connection value such as '/dev/ttyS0' or ''
  • options (dict) -- Input options dictionary.
classmethod from_cli_string(cli_string)[source]

Parse a string 'kind:value[,opts]' to build a SerialConnection.

Based on the QEMU CLI for serial ports.

Parameters:cli_string (str) -- String of the form 'kind:value[,opts]'
Returns:SerialConnection -- Created instance or None.
Raises:InvalidInputError -- if cli_string cannot be parsed


>>> str(SerialConnection.from_cli_string('/dev/ttyS0'))
'<SerialConnection kind: device value: /dev/ttyS0 options: {}>'
>>> str(SerialConnection.from_cli_string('tcp::22,server'))
"<SerialConnection kind: tcp value: :22 options: {'server': True}>"
>>> str(SerialConnection.from_cli_string('telnet://'))
'<SerialConnection kind: telnet value: options: {}>'
classmethod validate_kind(kind)[source]

Validate the connection type string and munge it as needed.

Parameters:kind (str) -- Connection type string, possibly in need of munging.
Returns:str -- A valid type string
Raises:ValueUnsupportedError -- if kind is not recognized as valid
classmethod validate_options(kind, value, options)[source]

Check that the given set of options are valid for this connection.

  • kind (str) -- Validated 'kind' string.
  • value (str) -- Validated 'value' string. Currently unused.
  • options (dict) -- Input options dictionary.

dict -- Validated options


InvalidInputError -- if options are not valid.

classmethod validate_value(kind, value)[source]

Check that the given value is valid for the given connection kind.

  • kind (str) -- Connection type, valid per validate_kind().
  • value (str) -- Connection value such as '/dev/ttyS0' or ''

str -- Munged value string.

  • InvalidInputError -- if value string is not recognized as valid
  • NotImplementedError -- if kind is not valid
kind = None

Connection type string

options = None

Dictionary of connection options.

value = None

Connection value such as '/dev/ttyS0' or ' -- 80'