COT.commands.edit_hardware module

Module for editing hardware details of a VM.

Functions

expand_list_wildcard Expand a list containing a wildcard to the desired length.
guess_list_wildcard Inverse of expand_list_wildcard().

Classes

COTEditHardware Edit hardware information (CPUs, RAM, NICs, etc.).
class COTEditHardware(ui)[source]

Bases: COT.commands.command.ReadWriteCommand

Edit hardware information (CPUs, RAM, NICs, etc.).

Inherited attributes: ui, package, output

Attributes: profiles, delete_all_other_profiles, cpus, memory, nics, nic_types, mac_addresses_list, nic_networks, nic_names, network_descriptions, serial_ports, serial_connectivity, scsi_subtypes, ide_subtypes, virtual_system_type

__init__(ui)[source]

Instantiate this command with the given UI.

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

Create 'edit-hardware' CLI subparser.

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 -- if ready_to_run() reports False
MEMORY_REGEXP = '^\\s*(\\d+)\\s*([mMgG])?i?[bB]?\\s*$'
cpus

Number of CPUs to set.

delete_all_other_profiles = None

Delete all profiles other than those set in profiles.

ide_subtype

IDE controller subtype string to set.

Deprecated since version 1.5: Use ide_subtypes instead.

ide_subtypes

IDE controller subtype string(s) to set.

mac_addresses_list = None

List of MAC addresses to set.

memory

Amount of RAM (in megabytes) to set.

network_descriptions = None

List of network description strings.

Can use wildcards as described in expand_list_wildcard().

nic_names = None

List of NIC name strings.

Can use wildcards as described in expand_list_wildcard().

nic_networks = None

List of NIC-to-network mappings.

Can use wildcards as described in expand_list_wildcard().

nic_type

NIC type string to set.

Deprecated since version 1.5: Use nic_types instead.

nic_types

List of NIC type strings to set.

nics

Number of NICs to set.

profiles = None

Configuration profile(s) to edit.

scsi_subtype

SCSI controller subtype string to set.

Deprecated since version 1.5: Use scsi_subtypes instead.

scsi_subtypes

SCSI controller subtype string(s) to set.

serial_connectivity = None

List of serial connection strings.

serial_ports

Serial port count to set.

virtual_system_type = None

Virtual system type

expand_list_wildcard(name_list, length, quiet=False)[source]

Expand a list containing a wildcard to the desired length.

Parameters:
  • name_list (list) -- List of names to assign, or None
  • length (list) -- Length to expand to
  • quiet (bool) -- Silence usual log messages generated by this function.
Returns:

list -- Expanded list, or empty list if name_list is None or empty.

Since various items (NIC names, network names, etc.) are often named or numbered sequentially, we provide this API to allow the user to specify a wildcard value to permit automatically expanding a list of input strings to the desired length. The syntax for the wildcard option is { followed by a number (indicating the starting index for the name) followed by }.

Examples

>>> expand_list_wildcard(None, 3)
[]
>>> expand_list_wildcard(["eth{0}"], 3)
['eth0', 'eth1', 'eth2']
>>> expand_list_wildcard(["mgmt0", "eth{10}"], 4)
['mgmt0', 'eth10', 'eth11', 'eth12']
guess_list_wildcard(known_values)[source]

Inverse of expand_list_wildcard(). Guess the wildcard for a list.

Parameters:known_values (list) -- Values to guess from
Returns:list -- Guessed wildcard list, or None if unable to guess

Examples

>>> guess_list_wildcard(['foo', 'bar', 'baz'])
>>> guess_list_wildcard(['foo1', 'foo2', 'foo3'])
['foo{1}']
>>> guess_list_wildcard(['foo', 'bar', 'baz3', 'baz4', 'baz5'])
['foo', 'bar', 'baz{3}']
>>> guess_list_wildcard(['Eth0/1', 'Eth0/2', 'Eth0/3'])
['Eth0/{1}']
>>> guess_list_wildcard(['Eth0/0', 'Eth1/0', 'Eth2/0'])
['Eth{0}/0']
>>> guess_list_wildcard(['fake1', 'fake2', 'real4', 'real5'])
['fake1', 'fake2', 'real{4}']