COT.commands.deploy_esxi module

Module for deploying VMs to ESXi, vCenter, and vSphere.

Classes

COTDeployESXi Sub-command for deploying VMs on ESXi and VMware vCenter/vSphere.
SmarterConnection A smarter version of pyVmomi's SmartConnection context manager.
PyVmomiVMReconfigSpec Context manager for reconfiguring an ESXi VM using PyVmomi.
class COTDeployESXi(ui)[source]

Bases: COT.commands.deploy.COTDeploy

Sub-command for deploying VMs on ESXi and VMware vCenter/vSphere.

Inherited attributes: ui, package, generic_parser, parser, subparsers, hypervisor, configuration, username, password, power_on, vm_name, network_map serial_connection

Attributes: locator, datastore, ovftool_args

__init__(ui)[source]

Instantiate this command with the given UI.

Parameters:ui (UI) -- User interface instance.
create_subparser()[source]

Add subparser for the CLI of this command.

This will create the shared parser, then create our own sub-subparser under subparsers.

fixup_ovftool_args(ovftool_args, target)[source]

Make any needed modifications to the ovftool arguments.

Parameters:
  • ovftool_args (list) -- Any existing ovftool arguments to begin with.
  • target (str) -- deployment target URI
Returns:

list -- Updated ovftool arguments

fixup_serial_ports()[source]

Use PyVmomi to create and configure serial ports for the new VM.

Raises:NotImplementedError -- If any SerialConnection in serial_connection has a kind other than 'tcp', 'telnet', or 'device'
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 - deploying to ESXi.

Raises:InvalidInputError -- if ready_to_run() reports False
datastore = None

ESXi datastore to deploy to.

host = None

vSphere host to deploy to - set implicitly by self.locator.

locator

Target vSphere locator.

ovftool_args

List of CLI arguments to pass through to ovftool.

serial_connection

Mapping of serial ports to various connection types.

server = None

vCenter server or vSphere host - set implicitly by self.locator.

class PyVmomiVMReconfigSpec(service_instance, vm_name)[source]

Bases: object

Context manager for reconfiguring an ESXi VM using PyVmomi.

__init__(service_instance, vm_name)[source]

Use the given name to look up a VM using the given service_instance.

Parameters:
  • service_instance (pyVmomi.VmomiSupport.vim.ServiceInstance) -- Connection to ESXi.
  • vm_name (str) -- Virtual machine name.
lookup_object(vimtype, name)[source]

Look up an object by name.

Parameters:
  • vimtype (object) -- currently only vim.VirtualMachine
  • name (str) -- Name of the object to look up.
Returns:

object -- Located object

class SmarterConnection(ui, host, user, pwd, port=443)[source]

Bases: pyVim.connect.SmartConnection

A smarter version of pyVmomi's SmartConnection context manager.

__init__(ui, host, user, pwd, port=443)[source]

Create a connection to the given server.

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

For the other parameters, see pyVim.connect.SmartConnection

static unwrap_connection_error(outer_e)[source]

Extract inner attributes from a ConnectionError.

ConnectionError often wraps another exception with more context; this function dives inside the ConnectionError to find that context.

Parameters:outer_e (ConnectionError) -- ConnectionError to unwrap
Returns:tuple -- extracted (errno, inner_message)