COT.platforms.platform module

API and generic implementation of platform-specific logic.

class Hardware[source]

Bases: enum.Enum

Enumeration of hardware types that have integer quantities.

cpus = 1
memory = 2
nic_count = 3
serial_count = 4
class Platform[source]

Bases: object

Generic class for operations that depend on guest platform.

To be used whenever the guest is unrecognized or does not need special handling.

__init__()[source]

Create an instance of this class.

controller_type_for_device(device_type)[source]

Get the default controller type for the given device type.

Parameters:device_type (str) -- 'harddisk', 'cdrom', etc.
Returns:str -- 'ide' unless overridden by subclass.
classmethod for_product_string(product_string)[source]

Get the class of Platform corresponding to a product string.

Parameters:product_string (str) -- String such as 'com.cisco.iosxrv'
Returns:Platform -- Instance of Platform or the appropriate subclass.

Examples

>>> Platform.for_product_string("com.cisco.n9k")
<class 'COT.platforms.cisco_nexus_9000v.Nexus9000v'>
>>> Platform.for_product_string(None)
<class 'COT.platforms.platform.Platform'>
>>> Platform.for_product_string("frobozz")
<class 'COT.platforms.platform.Platform'>
guess_nic_name(nic_number)[source]

Guess the name of the Nth NIC for this platform.

Note

This method counts from 1, not from 0!

Parameters:nic_number (int) -- Nth NIC to name.
Returns:str -- "Ethernet1", "Ethernet2", etc. unless overridden by subclass.
validate_cpu_count(cpus)[source]

Throw an error if the number of CPUs is not a supported value.

Parameters:

cpus (int) -- Number of CPUs

Raises:
  • ValueTooLowError -- if cpus is less than the minimum required by this platform
  • ValueTooHighError -- if cpus exceeds the maximum supported by this platform
validate_memory_amount(mebibytes)[source]

Throw an error if the amount of RAM is not supported.

Parameters:

mebibytes (int) -- RAM, in MiB.

Raises:
ValueTooLowError -- if mebibytes is less than the minimum

required by this platform

ValueTooHighError: if mebibytes is more than the maximum

supported by this platform

validate_nic_count(count)[source]

Throw an error if the number of NICs is not supported.

Parameters:

count (int) -- Number of NICs.

Raises:
  • ValueTooLowError -- if count is less than the minimum required by this platform
  • ValueTooHighError -- if count is more than the maximum supported by this platform
validate_nic_type(type_string)[source]

Throw an error if the NIC type string is not supported.

Parameters:type_string (str) -- See COT.data_validation.NIC_TYPES
Raises:ValueUnsupportedError -- if type_string is not in SUPPORTED_NIC_TYPES
validate_nic_types(type_list)[source]

Throw an error if any NIC type string in the list is unsupported.

Parameters:type_list (list) -- See COT.data_validation.NIC_TYPES
Raises:ValueUnsupportedError -- if any value in type_list is not in SUPPORTED_NIC_TYPES
validate_serial_count(count)[source]

Throw an error if the number of serial ports is not supported.

Parameters:

count (int) -- Number of serial ports.

Raises:
  • ValueTooLowError -- if count is less than the minimum required by this platform
  • ValueTooHighError -- if count is more than the maximum supported by this platform
BOOTSTRAP_DISK_TYPE = 'cdrom'

Type of disk (cdrom/harddisk) to use for bootstrap configuration.

Most platforms use a CD-ROM for this purpose.

CONFIG_TEXT_FILE = 'config.txt'

When embedding a primary configuration text file, use this filename.

See also

COT.inject_config.COTInjectConfig.config_file

HARDWARE_LIMITS = {<Hardware.nic_count: 3>: ValidRange(minimum=0, maximum=None), <Hardware.serial_count: 4>: ValidRange(minimum=0, maximum=None), <Hardware.cpus: 1>: ValidRange(minimum=1, maximum=None), <Hardware.memory: 2>: ValidRange(minimum=1, maximum=None)}

Range of valid values for various hardware properties.

LITERAL_CLI_STRING = 'config'

Key prefix for converting text config to OVF environment properties.

Most platforms do not support configuration properties in the environment, and so should define this attribute to None.

PLATFORM_NAME = '(unrecognized platform, generic)'

String used as a descriptive label for this class of Platform.

PRODUCT_PLATFORM_MAP = {None: <class 'COT.platforms.platform.Platform'>, 'com.cisco.csr1000v': <class 'COT.platforms.cisco_csr1000v.CSR1000V'>, 'com.cisco.ios-xrv': <class 'COT.platforms.cisco_iosxrv.IOSXRv'>, 'com.cisco.ios-xrv.lc': <class 'COT.platforms.cisco_iosxrv.IOSXRvLC'>, 'com.cisco.ios-xrv.rp': <class 'COT.platforms.cisco_iosxrv.IOSXRvRP'>, 'com.cisco.ios-xrv64': <class 'COT.platforms.cisco_iosxrv_9000.IOSXRv9000'>, 'com.cisco.ios-xrv9000': <class 'COT.platforms.cisco_iosxrv_9000.IOSXRv9000'>, 'com.cisco.iosv': <class 'COT.platforms.cisco_iosv.IOSv'>, 'com.cisco.n9k': <class 'COT.platforms.cisco_nexus_9000v.Nexus9000v'>, 'com.cisco.nx-osv': <class 'COT.platforms.cisco_nxosv.NXOSv'>}

Mapping of product strings to product classes.

SECONDARY_CONFIG_TEXT_FILE = None

When embedding a secondary configuration text file, use this filename.

Most platforms do not support a secondary configuration file.

See also

COT.inject_config.COTInjectConfig.secondary_config_file

SUPPORTED_NIC_TYPES = ['E1000e', 'E1000', 'PCNet32', 'virtio', 'VMXNET3']

List of NIC device types supported by this platform.