COT.platforms.generic module

API and generic implementation of platform-specific logic.

class GenericPlatform[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.

classmethod 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 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.
classmethod 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
classmethod 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

classmethod 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
classmethod 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
classmethod 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
classmethod 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'
CONFIG_TEXT_FILE = 'config.txt'
LITERAL_CLI_STRING = 'config'
PLATFORM_NAME = '(unrecognized platform, generic)'
SECONDARY_CONFIG_TEXT_FILE = None
SUPPORTED_NIC_TYPES = ['E1000e', 'E1000', 'PCNet32', 'virtio', 'VMXNET3']