COT.submodule module

Parent classes for implementing COT subcommands.

Classes

COTGenericSubmodule Abstract interface for COT command submodules.
COTReadOnlySubmodule Class for submodules that do not modify the OVF, such as ‘deploy’.
COTSubmodule Class for submodules that read and write the OVF.
class COTGenericSubmodule(UI)[source]

Bases: object

Abstract interface for COT command submodules.

Attributes: vm, UI

Note

Generally a command should not inherit directly from this class, but should instead subclass COTReadOnlySubmodule or COTSubmodule as appropriate.

create_subparser(parent)[source]

Add subparser for the CLI of this submodule.

Parameters:parent (object) – Subparser grouping object returned by ArgumentParser.add_subparsers()
Returns:(label, subparser) or ("", None) if this module has no CLI
destroy()[source]

Destroy any VM associated with this submodule.

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:(True, ready_message) or (False, reason_why_not)
run()[source]

Do the actual work of this submodule.

Raises:InvalidInputError if ready_to_run() reports False
UI = None

User interface instance (UI or subclass) to use.

vm = None

Virtual machine description (VMDescription).

class COTReadOnlySubmodule(UI)[source]

Bases: COT.submodule.COTGenericSubmodule

Class for submodules that do not modify the OVF, such as ‘deploy’.

Inherited attributes: vm, UI

Attributes: package

ready_to_run()[source]

Check whether the module is ready to run().

Returns:(True, ready_message) or (False, reason_why_not)
package[source]

VM description file to read from.

Calls COT.vm_factory.VMFactory.create() to instantiate self.vm from the provided file.

Raises:InvalidInputError if the file does not exist.
class COTSubmodule(UI)[source]

Bases: COT.submodule.COTGenericSubmodule

Class for submodules that read and write the OVF.

Inherited attributes: vm, UI

Attributes: package, output

finished()[source]

Write the current VM state out to disk if requested.

ready_to_run()[source]

Check whether the module is ready to run().

Returns:(True, ready_message) or (False, reason_why_not)
run()[source]

Do the actual work of this submodule.

If output was not previously set, automatically sets it to the value of PACKAGE.

Raises:InvalidInputError if ready_to_run() reports False
output[source]

Output file for this submodule.

If the specified file already exists, will prompt the user (confirm_or_die()) to confirm overwriting the existing file.

package[source]

VM description file to read (and possibly write).

Calls COT.vm_factory.VMFactory.create() to instantiate self.vm from the provided file.

Raises:InvalidInputError if the file does not exist.