Package ganeti :: Package hypervisor :: Module hv_base
[hide private]
[frames] | no frames]

Module hv_base

source code

Base class for all hypervisors

The syntax for the _CHECK variables and the contents of the PARAMETERS dict is the same, see the docstring for BaseHypervisor.PARAMETERS.

Classes [hide private]
  HvInstanceState
  BaseHypervisor
Abstract virtualisation technology interface
Functions [hide private]
 
_IsCpuMaskWellFormed(cpu_mask)
Verifies if the given single CPU mask is valid
source code
 
_IsMultiCpuMaskWellFormed(cpu_mask)
Verifies if the given multiple CPU mask is valid
source code
 
ParamInSet(required, my_set)
Builds parameter checker for set membership.
source code
string
GenerateTapName()
Generate a TAP network interface name for a NIC.
source code
 
ConfigureNIC(cmd, instance, seq, nic, tap)
Run the network configuration script for a specified NIC
source code
Variables [hide private]
  _FILE_CHECK = utils.IsNormAbsPath, "must be an absolute normal...
stub for file checks, without the required flag
  _FILE_OR_URL_CHECK = lambda x: utils.IsNormAbsPath(x) or utils...
  _DIR_CHECK = utils.IsNormAbsPath, "must be an absolute normali...
stub for directory checks, without the required flag
  _CPU_MASK_CHECK = _IsCpuMaskWellFormed, "CPU mask definition i...
  _MULTI_CPU_MASK_CHECK = _IsMultiCpuMaskWellFormed, "Multiple C...
  _NET_PORT_CHECK = lambda x: 0 < x < 65535, "invalid port numbe...
  _VIRTIO_NET_QUEUES_CHECK = lambda x: 0 < x < 9, "invalid numbe...
  _NONNEGATIVE_INT_CHECK = lambda x: x >= 0, "cannot be negative...
  REQ_FILE_CHECK = True,+ _FILE_CHECK
mandatory file parameter
  OPT_FILE_CHECK = False,+ _FILE_CHECK
optional file parameter
  REQ_FILE_OR_URL_CHECK = True,+ _FILE_OR_URL_CHECK
  OPT_FILE_OR_URL_CHECK = False,+ _FILE_OR_URL_CHECK
  REQ_DIR_CHECK = True,+ _DIR_CHECK
mandatory directory parametr
  OPT_DIR_CHECK = False,+ _DIR_CHECK
optional directory parameter
  REQ_NET_PORT_CHECK = True,+ _NET_PORT_CHECK
  OPT_NET_PORT_CHECK = False,+ _NET_PORT_CHECK
  REQ_VIRTIO_NET_QUEUES_CHECK = True,+ _VIRTIO_NET_QUEUES_CHECK
  OPT_VIRTIO_NET_QUEUES_CHECK = False,+ _VIRTIO_NET_QUEUES_CHECK
  REQ_CPU_MASK_CHECK = True,+ _CPU_MASK_CHECK
  OPT_CPU_MASK_CHECK = False,+ _CPU_MASK_CHECK
  REQ_MULTI_CPU_MASK_CHECK = True,+ _MULTI_CPU_MASK_CHECK
  OPT_MULTI_CPU_MASK_CHECK = False,+ _MULTI_CPU_MASK_CHECK
  REQ_NONNEGATIVE_INT_CHECK = True,+ _NONNEGATIVE_INT_CHECK
  OPT_NONNEGATIVE_INT_CHECK = False,+ _NONNEGATIVE_INT_CHECK
  NO_CHECK = False, None, None, None, None
parameter without any checks at all
  REQUIRED_CHECK = True, None, None, None, None
parameter required to exist (and non-false), but without other checks; beware that this can't be used for boolean parameters, where you should use NO_CHECK or a custom checker
  MIGRATION_MODE_CHECK = True, lambda x: x in constants.HT_MIGRA...

Imports: os, re, logging, constants, errors, objects, utils


Function Details [hide private]

_IsCpuMaskWellFormed(cpu_mask)

source code 

Verifies if the given single CPU mask is valid

The single CPU mask should be in the form "a,b,c,d", where each letter is a positive number or range.

_IsMultiCpuMaskWellFormed(cpu_mask)

source code 

Verifies if the given multiple CPU mask is valid

A valid multiple CPU mask is in the form "a:b:c:d", where each letter is a single CPU mask.

ParamInSet(required, my_set)

source code 

Builds parameter checker for set membership.

Parameters:
  • required (boolean) - whether this is a required parameter
  • my_set (tuple, list or set) - allowed values set

GenerateTapName()

source code 

Generate a TAP network interface name for a NIC.

This helper function generates a special TAP network interface name for NICs that are meant to be used in instance communication. This function checks the existing TAP interfaces in order to find a unique name for the new TAP network interface. The TAP network interface names are of the form 'gnt.com.%d', where '%d' is a unique number within the node.

Returns: string
TAP network interface name, or the empty string if the NIC is not used in instance communication

ConfigureNIC(cmd, instance, seq, nic, tap)

source code 

Run the network configuration script for a specified NIC

Parameters:
  • cmd (string) - command to run
  • instance (instance object) - instance we're acting on
  • seq (int) - nic sequence number
  • nic (nic object) - nic we're acting on
  • tap (str) - the host's tap interface this NIC corresponds to

Variables Details [hide private]

_FILE_CHECK

stub for file checks, without the required flag
Value:
utils.IsNormAbsPath, "must be an absolute normalized path", os.path.is\
file, "not found or not a file"

_FILE_OR_URL_CHECK

Value:
lambda x: utils.IsNormAbsPath(x) or utils.IsUrl(x), "must be an absolu\
te normalized path or a URL", lambda x: os.path.isfile(x) or utils.IsU\
rl(x), "not found or not a file or URL"

_DIR_CHECK

stub for directory checks, without the required flag
Value:
utils.IsNormAbsPath, "must be an absolute normalized path", os.path.is\
dir, "not found or not a directory"

_CPU_MASK_CHECK

Value:
_IsCpuMaskWellFormed, "CPU mask definition is not well-formed", None, \
None

_MULTI_CPU_MASK_CHECK

Value:
_IsMultiCpuMaskWellFormed, "Multiple CPU mask definition is not well-f\
ormed", None, None

_NET_PORT_CHECK

Value:
lambda x: 0 < x < 65535, "invalid port number", None, None

_VIRTIO_NET_QUEUES_CHECK

Value:
lambda x: 0 < x < 9, "invalid number of queues", None, None

_NONNEGATIVE_INT_CHECK

Value:
lambda x: x >= 0, "cannot be negative", None, None

MIGRATION_MODE_CHECK

Value:
True, lambda x: x in constants.HT_MIGRATION_MODES, "invalid migration \
mode", None, None