COT.deploy
module¶
Module for deploying VM descriptions to a hypervisor to instantiate VMs.
Classes
COTDeploy |
Semi-abstract class for submodules used to deploy a VM to a hypervisor. |
SerialConnection |
Generic class defining a serial port connection. |
-
class
COTDeploy
(ui)[source]¶ Bases:
COT.submodule.COTReadOnlySubmodule
Semi-abstract class for submodules 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
-
__init__
(ui)[source]¶ Instantiate this submodule with the given UI.
Parameters: ui (UI) – User interface instance.
-
create_subparser
()[source]¶ Create ‘deploy’ CLI subparser if it doesn’t already exist.
Note
Unlike most submodules, this one has subparsers of its own -
'cot deploy PACKAGE <hypervisor>'
so subclasses of this module should callsuper().create_subparser()
(to create the main ‘deploy’ subparser if it doesn’t already exist) then callself.ui.add_parser(..., parent=self.subparsers, ...)
to add their own sub-subparser.
-
ready_to_run
()[source]¶ Check whether the module is ready to
run()
.Returns: tuple – (True, ready_message)
or(False, reason_why_not)
-
configuration
¶ 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
¶ Hypervisor to deploy to.
Raises: InvalidInputError
– if not a recognized value.
-
network_map
¶ Mapping of network names to networks.
-
password
= None¶ Server login password.
-
power_on
¶ Whether to automatically power on the VM after deployment.
-
serial_connection
¶ 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 withparent=
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.
Parameters:
-
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
– ifcli_string
cannot be parsedExamples
>>> 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://1.1.1.1:1111')) '<SerialConnection kind: telnet value: 1.1.1.1:1111 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
– ifkind
is not recognized as valid
-
classmethod
validate_options
(kind, value, options)[source]¶ Check that the given set of options are valid for this connection.
Parameters: Returns: dict – Validated options
Raises: InvalidInputError
– if options are not valid.
-
classmethod
validate_value
(kind, value)[source]¶ Check that the given value is valid for the given connection kind.
Parameters: - kind (str) – Connection type, valid per
validate_kind()
. - value (str) – Connection value such as ‘/dev/ttyS0’ or ‘1.1.1.1:80’
Returns: str – Munged value string.
Raises: InvalidInputError
– if value string is not recognized as validNotImplementedError
– ifkind
is not valid
- kind (str) – Connection type, valid per
-
kind
= None¶ Connection type string
-
options
= None¶ Dictionary of connection options.
-
value
= None¶ Connection value such as ‘/dev/ttyS0’ or ‘1.1.1.1:80’
-