COT.commands
module¶
Package describing various operations COT can perform on a VM description.
API¶
Command |
Abstract interface for COT commands. |
ReadCommand |
Command, such as ‘deploy’, that reads from a VM file to create its vm. |
ReadWriteCommand |
Command that reads from and writes to a VM description. |
Command modules¶
COT.commands.add_disk |
Module for adding disks to VMs. |
COT.commands.add_file |
Module for adding files to VM definitions. |
COT.commands.deploy |
Module for deploying VM descriptions to a hypervisor to instantiate VMs. |
COT.commands.deploy_esxi |
Module for deploying VMs to ESXi, vCenter, and vSphere. |
COT.commands.edit_hardware |
Module for editing hardware details of a VM. |
COT.commands.edit_product |
Module for editing product information in a VM description. |
COT.commands.edit_properties |
Module for managing VM environment configuration properties. |
COT.commands.help |
Provide ‘help’ keyword for COT CLI. |
COT.commands.info |
Implements “info” subcommand. |
COT.commands.inject_config |
Implements “inject-config” command. |
COT.commands.install_helpers |
Implements “install-helpers” command. |
COT.commands.remove_file |
Module for removing files from VM definitions. |
-
class
Command
(ui)[source]¶ Bases:
object
Abstract interface for COT commands.
Attributes:
vm
,ui
Note
Generally a command should not inherit directly from this class, but should instead subclass
ReadCommand
orReadWriteCommand
as appropriate.-
__init__
(ui)[source]¶ Instantiate this command with the given UI.
Parameters: ui (UI) – User interface instance.
-
check_disk_space
(required_size, location, label='File', context=None, force_check=False, die=False)[source]¶ Check if there is sufficient disk space available at a location.
If there is insufficient space, warn the user before continuing.
Caches space requirements per location, so it’s safe to call repeatedly, as it will only re-check (and possibly re-prompt the user) if:
- a different location is requested
- or the required size changes
- or
force_check
is True.
Parameters: - required_size (int) – Bytes required
- location (str) – Path to check availability of.
- label (str) – Descriptive label to display in user messages.
- context (str) – Optional string for additional context to provide when prompting the user.
- force_check (bool) – If True, re-check and re-prompt the user even
if this location has previously been checked and its
required_size
has not changed. - die (bool) – If True, use
confirm_or_die()
instead ofconfirm()
Returns: bool –
- Whether sufficient space is available (or if not,
whether the user has opted to continue anyway).
Raises: SystemExit
– if disk space is insufficient anddie
is True and the user declines to continue.
-
finished
()[source]¶ Do any final actions before being destroyed.
This class does nothing; subclasses may choose to do things like write their VM state out to a file.
-
ready_to_run
()[source]¶ Check whether the module is ready to
run()
.Returns: tuple – (True, ready_message)
or(False, reason_why_not)
-
run
()[source]¶ Do the actual work of this command.
Raises: InvalidInputError
– ifready_to_run()
reportsFalse
-
-
class
ReadCommand
(ui)[source]¶ Bases:
COT.commands.command.Command
Command, such as ‘deploy’, that reads from a VM file to create its vm.
Inherited attributes:
vm
,ui
Attributes:
package
-
__init__
(ui)[source]¶ Instantiate this command with the given UI.
Parameters: ui (UI) – User interface instance.
-
ready_to_run
()[source]¶ Check whether the module is ready to
run()
.Returns: tuple – (True, ready_message)
or(False, reason_why_not)
-
package
¶ VM description file to read from.
Calls
COT.vm_description.VMDescription.factory()
to instantiateself.vm
from the provided file.Raises: InvalidInputError
– if the file does not exist.
-
-
class
ReadWriteCommand
(ui)[source]¶ Bases:
COT.commands.command.ReadCommand
Command that reads from and writes to a VM description.
Inherited attributes:
vm
,ui
-
__init__
(ui)[source]¶ Instantiate this command with the given UI.
Parameters: ui (UI) – User interface instance.
-
ready_to_run
()[source]¶ Check whether the module is ready to
run()
.Returns: tuple – (True, ready_message)
or(False, reason_why_not)
-
run
()[source]¶ Do the actual work of this command.
If
output
was not previously set, automatically sets it to the value ofPACKAGE
.Raises: InvalidInputError
– ifready_to_run()
reportsFalse
-
output
¶ Output file for this command.
If the specified file already exists, will prompt the user (
confirm_or_die()
) to confirm overwriting the existing file.
-
package
¶ VM description file to read from.
Calls
COT.vm_description.VMDescription.factory()
to instantiateself.vm
from the provided file.Raises: InvalidInputError
– if the file does not exist.
-