Package ganeti :: Module backend
[hide private]
[frames] | no frames]

Module backend

source code

Functions used by the node daemon

Classes [hide private]
  RPCFail
Class denoting RPC failure.
  HooksRunner
Hook runner.
  IAllocatorRunner
IAllocator runner.
  DevCacheManager
Simple class for managing a cache of block device information.
Functions [hide private]
string
_GetInstReasonFilename(instance_name)
Path of the file containing the reason of the instance status change.
source code
None
_StoreInstReasonTrail(instance_name, trail)
Serialize a reason trail related to an instance change of state to file.
source code
 
_Fail(msg, *args, **kwargs)
Log an error and the raise an RPCFail exception.
source code
ssconf.SimpleStore
_GetConfig()
Simple wrapper to return a SimpleStore.
source code
ssh.SshRunner
_GetSshRunner(cluster_name)
Simple wrapper to return an SshRunner.
source code
str
_Decompress(data)
Unpacks data compressed by the RPC client.
source code
 
_CleanDirectory(path, exclude=None)
Removes all regular files in a directory.
source code
 
_BuildUploadFileList()
Build the list of allowed upload files.
source code
tuple
JobQueuePurge()
Removes job queue files and archived jobs.
source code
string
GetMasterNodeName()
Returns the master node name.
source code
 
RunLocalHooks(hook_opcode, hooks_path, env_builder_fn)
Decorator that runs hooks before and after the decorated function.
source code
 
_BuildMasterIpEnv(master_params, use_external_mip_script=None)
Builds environment variables for master IP hooks.
source code
 
_RunMasterSetupScript(master_params, action, use_external_mip_script)
Execute the master IP address setup script.
source code
 
ActivateMasterIp(master_params, use_external_mip_script)
Activate the IP address of the master daemon.
source code
None
StartMasterDaemons(no_voting)
Activate local node as master node.
source code
 
DeactivateMasterIp(master_params, use_external_mip_script)
Deactivate the master IP on this node.
source code
None
StopMasterDaemons()
Stop the master daemons on this node.
source code
 
ChangeMasterNetmask(old_netmask, netmask, master_ip, master_netdev)
Change the netmask of the master IP.
source code
 
EtcHostsModify(mode, host, ip)
Modify a host entry in /etc/hosts.
source code
 
LeaveCluster(modify_ssh_setup)
Cleans up and remove the current node.
source code
 
_CheckStorageParams(params, num_params)
Performs sanity checks for storage parameters.
source code
 
_CheckLvmStorageParams(params)
Performs sanity check for the 'exclusive storage' flag.
source code
 
_GetLvmVgSpaceInfo(name, params)
Wrapper around _GetVgInfo which checks the storage parameters.
source code
 
_GetVgInfo(name, excl_stor, info_fn=bdev.LogicalVolume.GetVGInfo)
Retrieves information about a LVM volume group.
source code
 
_GetLvmPvSpaceInfo(name, params)
Wrapper around _GetVgSpindlesInfo with sanity checks.
source code
dict
_GetVgSpindlesInfo(name, excl_stor, info_fn=bdev.LogicalVolume.GetVgSpindlesInfo)
Retrieves information about spindles in an LVM volume group.
source code
 
_GetHvInfo(name, hvparams, get_hv_fn=hypervisor.GetHypervisor)
Retrieves node information from a hypervisor.
source code
 
_GetHvInfoAll(hv_specs, get_hv_fn=hypervisor.GetHypervisor)
Retrieves node information for all hypervisors.
source code
None or dict
_GetNamedNodeInfo(names, fn)
Calls fn for all names in names and returns a dictionary.
source code
tuple; (string, None/dict, None/dict)
GetNodeInfo(storage_units, hv_specs)
Gives back a hash with different information about the node.
source code
 
_GetFileStorageSpaceInfo(path, params)
Wrapper around filestorage.GetSpaceInfo.
source code
 
_ApplyStorageInfoFunction(storage_type, storage_key, *args)
Looks up and applies the correct function to calculate free and total storage for the given storage type.
source code
list of tuples (string, list of strings)
_CheckExclusivePvs(pvi_list)
Check that PVs are not shared among LVs
source code
 
_VerifyHypervisors(what, vm_capable, result, all_hvparams, get_hv_fn=hypervisor.GetHypervisor)
Verifies the hypervisor.
source code
 
_VerifyHvparams(what, vm_capable, result, get_hv_fn=hypervisor.GetHypervisor)
Verifies the hvparams.
source code
 
_VerifyInstanceList(what, vm_capable, result, all_hvparams)
Verifies the instance list.
source code
 
_VerifyNodeInfo(what, vm_capable, result, all_hvparams)
Verifies the node info.
source code
 
_VerifyClientCertificate(cert_file=pathutils.NODED_CLIENT_CERT_FILE)
Verify the existance and validity of the client SSL certificate.
source code
 
_VerifySshSetup(node_status_list, my_name, ssh_key_type, ganeti_pub_keys_file=pathutils.SSH_PUB_KEYS)
Verifies the state of the SSH key files.
source code
 
_VerifySshClutter(node_status_list, my_name)
Verifies that the 'authorized_keys' files are not cluttered up.
source code
dict
VerifyNode(what, cluster_name, all_hvparams)
Verify the status of the local node.
source code
list of tuples (string, string)
GetCryptoTokens(token_requests)
Perform actions on the node's cryptographic tokens.
source code
bool
EnsureDaemon(daemon_name, run)
Ensures the given daemon is running or stopped.
source code
 
_InitSshUpdateData(data, noded_cert_file, ssconf_store) source code
 
AddNodeSshKey(node_uuid, node_name, potential_master_candidates, to_authorized_keys=False, to_public_keys=False, get_public_keys=False, pub_key_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, run_cmd_fn=ssh.RunSshCmdWithStdin)
Distributes a node's public SSH key across the cluster.
source code
 
AddNodeSshKeyBulk(node_list, potential_master_candidates, pub_key_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, run_cmd_fn=ssh.RunSshCmdWithStdin)
Distributes a node's public SSH key across the cluster.
source code
list of string
RemoveNodeSshKey(node_uuid, node_name, master_candidate_uuids, potential_master_candidates, master_uuid=None, keys_to_remove=None, from_authorized_keys=False, from_public_keys=False, clear_authorized_keys=False, clear_public_keys=False, pub_key_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, readd=False, run_cmd_fn=ssh.RunSshCmdWithStdin)
Removes the node's SSH keys from the key files and distributes those.
source code
list of string
RemoveNodeSshKeyBulk(node_list, master_candidate_uuids, potential_master_candidates, master_uuid=None, keys_to_remove=None, pub_key_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, readd=False, run_cmd_fn=ssh.RunSshCmdWithStdin)
Removes the node's SSH keys from the key files and distributes those.
source code
 
_GenerateNodeSshKey(node_uuid, node_name, ssh_port_map, ssh_key_type, ssh_key_bits, pub_key_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, run_cmd_fn=ssh.RunSshCmdWithStdin, suffix="")
Generates the root SSH key pair on the node.
source code
 
_GetMasterNodeUUID(node_uuid_name_map, master_node_name) source code
 
_GetOldMasterKeys(master_node_uuid, pub_key_file) source code
 
_GetNewMasterKey(root_keyfiles, master_node_uuid) source code
 
_ReplaceMasterKeyOnMaster(root_keyfiles) source code
 
RenewSshKeys(node_uuids, node_names, master_candidate_uuids, potential_master_candidates, old_key_type, new_key_type, new_key_bits, ganeti_pub_keys_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, run_cmd_fn=ssh.RunSshCmdWithStdin)
Renews all SSH keys and updates authorized_keys and ganeti_pub_keys.
source code
dict
GetBlockDevSizes(devices)
Return the size of the given block devices
source code
dict
GetVolumeList(vg_names)
Compute list of logical volumes and their size.
source code
dict
ListVolumeGroups()
List the volume groups and their size.
source code
list
NodeVolumes()
List all volumes on this node.
source code
boolean
BridgesExist(bridges_list)
Check if a list of bridges exist on the current node.
source code
list
GetInstanceListForHypervisor(hname, hvparams=None, get_hv_fn=hypervisor.GetHypervisor)
Provides a list of instances of the given hypervisor.
source code
list
GetInstanceList(hypervisor_list, all_hvparams=None, get_hv_fn=hypervisor.GetHypervisor)
Provides a list of instances.
source code
dict
GetInstanceInfo(instance, hname, hvparams=None)
Gives back the information about an instance as a dictionary.
source code
tuple
GetInstanceMigratable(instance)
Computes whether an instance can be migrated.
source code
dict
GetAllInstancesInfo(hypervisor_list, all_hvparams)
Gather data about all instances.
source code
dict
GetInstanceConsoleInfo(instance_param_dict, get_hv_fn=hypervisor.GetHypervisor)
Gather data about the console access of a set of instances of this node.
source code
 
_InstanceLogName(kind, os_name, instance, component)
Compute the OS log filename for a given instance and operation.
source code
None
InstanceOsAdd(instance, reinstall, debug)
Add an OS to an instance.
source code
boolean
RunRenameInstance(instance, old_name, debug)
Run the OS rename script for an instance.
source code
 
_GetBlockDevSymlinkPath(instance_name, idx, _dir=None)
Returns symlink path for block device.
source code
 
_SymlinkBlockDev(instance_name, device_path, idx)
Set up symlinks to a instance's block device.
source code
 
_RemoveBlockDevLinks(instance_name, disks)
Remove the block device symlinks belonging to the given instance.
source code
string
_CalculateDeviceURI(instance, disk, device)
Get the URI for the device.
source code
list
_GatherAndLinkBlockDevs(instance)
Set up an instance's block device(s).
source code
 
_IsInstanceUserDown(instance_info) source code
 
_GetInstanceInfo(instance)
Helper function GetInstanceInfo
source code
None
StartInstance(instance, startup_paused, reason, store_reason=True)
Start an instance.
source code
None
InstanceShutdown(instance, timeout, reason, store_reason=True)
Shut an instance down.
source code
None
InstanceReboot(instance, reboot_type, shutdown_timeout, reason)
Reboot an instance.
source code
None
InstanceBalloonMemory(instance, memory)
Resize an instance's memory.
source code
 
MigrationInfo(instance)
Gather information about an instance to be migrated.
source code
 
AcceptInstance(instance, info, target)
Prepare the node to accept an instance.
source code
 
FinalizeMigrationDst(instance, info, success)
Finalize any preparation to accept an instance.
source code
 
MigrateInstance(cluster_name, instance, target, live)
Migrates an instance to another node.
source code
 
FinalizeMigrationSource(instance, success, live)
Finalize the instance migration on the source node.
source code
objects.MigrationStatus
GetMigrationStatus(instance)
Get the migration status
source code
 
HotplugDevice(instance, action, dev_type, device, extra, seq)
Hotplug a device
source code
 
HotplugSupported(instance)
Checks if hotplug is generally supported.
source code
 
ModifyInstanceMetadata(metadata)
Sends instance data to the metadata daemon.
source code
 
BlockdevCreate(disk, size, owner, on_primary, info, excl_stor)
Creates a block device for an instance.
source code
 
_DumpDevice(source_path, target_path, offset, size, truncate)
This function images/wipes the device using a local file.
source code
NoneType
_DownloadAndDumpDevice(source_url, target_path, size)
This function images a device using a downloaded image file.
source code
NoneType
BlockdevConvert(src_disk, target_disk)
Copies data from source block device to target.
source code
 
BlockdevWipe(disk, offset, size)
Wipes a block device.
source code
NoneType
BlockdevImage(disk, image, size)
Images a block device either by dumping a local file or downloading a URL.
source code
 
BlockdevPauseResumeSync(disks, pause)
Pause or resume the sync of the block device.
source code
boolean
BlockdevRemove(disk)
Remove a block device.
source code
 
_RecursiveAssembleBD(disk, owner, as_primary)
Activate a block device for an instance.
source code
str or boolean
BlockdevAssemble(disk, instance, as_primary, idx)
Activate a block device for an instance.
source code
None
BlockdevShutdown(disk)
Shut down a block device.
source code
None
BlockdevAddchildren(parent_cdev, new_cdevs)
Extend a mirrored block device.
source code
None
BlockdevRemovechildren(parent_cdev, new_cdevs)
Shrink a mirrored block device.
source code
disk
BlockdevGetmirrorstatus(disks)
Get the mirroring status of a list of devices.
source code
disk
BlockdevGetmirrorstatusMulti(disks)
Get the mirroring status of a list of devices.
source code
 
_RecursiveFindBD(disk)
Check if a device is activated.
source code
 
_OpenRealBD(disk)
Opens the underlying block device of a disk.
source code
None or objects.BlockDevStatus
BlockdevFind(disk)
Check if a device is activated.
source code
list
BlockdevGetdimensions(disks)
Computes the size of the given disks.
source code
None
UploadFile(file_name, data, mode, uid, gid, atime, mtime)
Write a file to the filesystem.
source code
 
RunOob(oob_program, command, node, timeout)
Executes oob_program with given command on given node.
source code
tuple
_OSOndiskAPIVersion(os_dir)
Compute and return the API version of a given OS.
source code
list of objects.OS
DiagnoseOS(top_dirs=None)
Compute the validity for all OSes.
source code
tuple
_TryOSFromDisk(name, base_dir=None)
Create an OS instance from disk.
source code
objects.OS
OSFromDisk(name, base_dir=None)
Create an OS instance from disk.
source code
dict
OSCoreEnv(os_name, inst_os, os_params, debug=0)
Calculate the basic environment for an os script.
source code
dict
OSEnvironment(instance, inst_os, debug=0)
Calculate the environment for an os script.
source code
list of objects.ExtStorage
DiagnoseExtStorage(top_dirs=None)
Compute the validity for all ExtStorage Providers.
source code
(status, result)
BlockdevGrow(disk, amount, dryrun, backingstore, excl_stor)
Grow a stack of block devices.
source code
string
BlockdevSnapshot(disk, snap_name, snap_size)
Create a snapshot copy of a block device.
source code
(status, result)
BlockdevSetInfo(disk, info)
Sets 'metadata' information on block devices.
source code
None
FinalizeExport(instance, snap_disks)
Write out the export configuration information.
source code
objects.SerializableConfigParser
ExportInfo(dest)
Get export configuration information.
source code
list
ListExports()
Return a list of exports currently available on this machine.
source code
None
RemoveExport(export)
Remove an existing export from the node.
source code
boolean
BlockdevRename(devlist)
Rename a list of block devices.
source code
 
_TransformFileStorageDir(fs_dir)
Checks whether given file_storage_dir is valid.
source code
tuple
CreateFileStorageDir(file_storage_dir)
Create file storage directory.
source code
tuple (success,)
RemoveFileStorageDir(file_storage_dir)
Remove file storage directory.
source code
tuple (success,)
RenameFileStorageDir(old_file_storage_dir, new_file_storage_dir)
Rename the file storage directory.
source code
None
_EnsureJobQueueFile(file_name)
Checks whether the given filename is in the queue directory.
source code
boolean
JobQueueUpdate(file_name, content)
Updates a file in the queue directory.
source code
tuple
JobQueueRename(old, new)
Renames a job queue file.
source code
tuple (success, message)
BlockdevClose(instance_name, disks)
Closes the given block devices.
source code
 
BlockdevOpen(instance_name, disks, exclusive)
Opens the given block devices.
source code
None
ValidateHVParams(hvname, hvparams)
Validates the given hypervisor parameters.
source code
 
_CheckOSPList(os_obj, parameters)
Check whether a list of parameters is supported by the OS.
source code
NoneType
_CheckOSVariant(os_obj, name)
Check whether an OS name conforms to the os variants specification.
source code
boolean
ValidateOS(required, osname, checks, osparams, force_variant)
Validate the given OS parameters.
source code
string
ExportOS(instance, override_env)
Creates a GZIPed tarball with an OS definition and environment.
source code
 
DemoteFromMC()
Demotes the current node from master candidate role.
source code
 
_GetX509Filenames(cryptodir, name)
Returns the full paths for the private key and certificate.
source code
tuple; (string, string)
CreateX509Certificate(validity, cryptodir=pathutils.CRYPTO_KEYS_DIR)
Creates a new X509 certificate for SSL/TLS.
source code
 
RemoveX509Certificate(name, cryptodir=pathutils.CRYPTO_KEYS_DIR)
Removes a X509 certificate.
source code
 
_GetImportExportIoCommand(instance, mode, ieio, ieargs)
Returns the command for the requested input/output.
source code
 
_CreateImportExportStatusDir(prefix)
Creates status directory for import/export.
source code
 
StartImportExportDaemon(mode, opts, host, port, instance, component, ieio, ieioargs)
Starts an import or export daemon.
source code
List of dicts
GetImportExportStatus(names)
Returns import/export daemon status.
source code
 
AbortImportExport(name)
Sends SIGTERM to a running import/export daemon.
source code
 
CleanupImportExport(name)
Cleanup after an import or export.
source code
 
_FindDisks(disks)
Finds attached BlockDevs for the given disks.
source code
 
DrbdDisconnectNet(disks)
Disconnects the network on a list of drbd devices.
source code
 
DrbdAttachNet(disks, multimaster)
Attaches the network on a list of drbd devices.
source code
 
DrbdWaitSync(disks)
Wait until DRBDs have synchronized.
source code
 
DrbdNeedsActivation(disks)
Checks which of the passed disks needs activation and returns their UUIDs.
source code
 
GetDrbdUsermodeHelper()
Returns DRBD usermode helper currently configured.
source code
 
PowercycleNode(hypervisor_type, hvparams=None)
Hard-powercycle the node.
source code
tuple; (boolean, string or None)
_VerifyRestrictedCmdName(cmd)
Verifies a restricted command name.
source code
tuple; (boolean, string or os.stat result)
_CommonRestrictedCmdCheck(path, owner)
Common checks for restricted command file system directories and files.
source code
tuple; (boolean, string or None)
_VerifyRestrictedCmdDirectory(path, _owner=None)
Verifies restricted command directory.
source code
tuple; (boolean, string)
_VerifyRestrictedCmd(path, cmd, _owner=None)
Verifies a whole restricted command and returns its executable filename.
source code
 
_PrepareRestrictedCmd(path, cmd, _verify_dir=_VerifyRestrictedCmdDirectory, _verify_name=_VerifyRestrictedCmdName, _verify_cmd=_VerifyRestrictedCmd)
Performs a number of tests on a restricted command.
source code
string
RunRestrictedCmd(cmd, _lock_timeout=_RCMD_LOCK_TIMEOUT, _lock_file=pathutils.RESTRICTED_COMMANDS_LOCK_FILE, _path=pathutils.RESTRICTED_COMMANDS_DIR, _sleep_fn=time.sleep, _prepare_fn=_PrepareRestrictedCmd, _runcmd_fn=utils.RunCmd, _enabled=constants.ENABLE_RESTRICTED_COMMANDS)
Executes a restricted command after performing strict tests.
source code
 
SetWatcherPause(until, _filename=pathutils.WATCHER_PAUSEFILE)
Creates or removes the watcher pause file.
source code
 
ConfigureOVS(ovs_name, ovs_link)
Creates a OpenvSwitch on the node.
source code
tuple of bool, dict
GetFileInfo(file_path)
Checks if a file exists and returns information related to it.
source code
Variables [hide private]
  _BOOT_ID_PATH = "/proc/sys/kernel/random/boot_id"
  _ALLOWED_CLEAN_DIRS = compat.UniqueFrozenset([pathutils.DATA_D...
denotes which directories are accepted in the _CleanDirectory function
  _MAX_SSL_CERT_VALIDITY = 7* 24* 60* 60
  _X509_KEY_FILE = "key"
  _X509_CERT_FILE = "cert"
  _IES_STATUS_FILE = "status"
  _IES_PID_FILE = "pid"
  _IES_CA_FILE = "ca"
  _LVSLINE_REGEX = re.compile(r"^ *([^|]+)\|([^|]+)\|([0-9.]+)\|...
Valid LVS output line regex
  _MASTER_START = "start"
  _MASTER_STOP = "stop"
  _RCMD_MAX_MODE = stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | ...
Maximum file permissions for restricted command directory and executables
  _RCMD_INVALID_DELAY = 10
Delay before returning an error for restricted commands
  _RCMD_LOCK_TIMEOUT = _RCMD_INVALID_DELAY* 0.8
How long to wait to acquire lock for restricted commands (shorter than _RCMD_INVALID_DELAY) to reduce blockage of noded forks when many command requests arrive
  _ALLOWED_UPLOAD_FILES = _BuildUploadFileList()
denotes which files are accepted in the UploadFile function
  _STORAGE_TYPE_INFO_FN = {constants.ST_BLOCK: None, constants.S...
  SshAddNodeInfo = collections.namedtuple("SshAddNodeInfo", ["uu...
  SshRemoveNodeInfo = collections.namedtuple("SshRemoveNodeInfo"...

Imports: base64, errno, logging, os, pycurl, random, re, shutil, signal, stat, tempfile, time, zlib, contextlib, collections, errors, http, utils, ssh, hypervisor, hv_base, constants, bdev, drbd, extstorage, filestorage, objects, ssconf, serializer, netutils, runtime, compat, pathutils, vcluster, ht, BlockDev, DRBD8, hooksmaster, metad


Function Details [hide private]

_GetInstReasonFilename(instance_name)

source code 

Path of the file containing the reason of the instance status change.

Parameters:
  • instance_name (string) - The name of the instance
Returns: string
The path of the file

_StoreInstReasonTrail(instance_name, trail)

source code 

Serialize a reason trail related to an instance change of state to file.

The exact location of the file depends on the name of the instance and on the configuration of the Ganeti cluster defined at deploy time.

Parameters:
  • instance_name (string) - The name of the instance
  • trail (list of reasons) - reason trail
Returns: None

_Fail(msg, *args, **kwargs)

source code 

Log an error and the raise an RPCFail exception.

This exception is then handled specially in the ganeti daemon and turned into a 'failed' return type. As such, this function is a useful shortcut for logging the error and returning it to the master daemon.

Parameters:
  • msg (string) - the text of the exception @raise RPCFail

_GetConfig()

source code 

Simple wrapper to return a SimpleStore.

Returns: ssconf.SimpleStore
a SimpleStore instance

_GetSshRunner(cluster_name)

source code 

Simple wrapper to return an SshRunner.

Parameters:
  • cluster_name (str) - the cluster name, which is needed by the SshRunner constructor
Returns: ssh.SshRunner
an SshRunner instance

_Decompress(data)

source code 

Unpacks data compressed by the RPC client.

Parameters:
  • data (list or tuple) - Data sent by RPC client
Returns: str
Decompressed data

_CleanDirectory(path, exclude=None)

source code 

Removes all regular files in a directory.

Parameters:
  • path (str) - the directory to clean
  • exclude (list) - list of files to be excluded, defaults to the empty list

_BuildUploadFileList()

source code 

Build the list of allowed upload files.

This is abstracted so that it's built only once at module import time.

JobQueuePurge()

source code 

Removes job queue files and archived jobs.

Returns: tuple
True, None

GetMasterNodeName()

source code 

Returns the master node name.

Returns: string
name of the master node
Raises:

RunLocalHooks(hook_opcode, hooks_path, env_builder_fn)

source code 

Decorator that runs hooks before and after the decorated function.

Parameters:
  • hook_opcode (string) - opcode of the hook
  • hooks_path (string) - path of the hooks
  • env_builder_fn (function) - function that returns a dictionary containing the environment variables for the hooks. Will get all the parameters of the decorated function.
Raises:
  • RPCFail - in case of pre-hook failure

_BuildMasterIpEnv(master_params, use_external_mip_script=None)

source code 

Builds environment variables for master IP hooks.

Parameters:
  • master_params (objects.MasterNetworkParameters) - network parameters of the master
  • use_external_mip_script (boolean) - whether to use an external master IP address setup script (unused, but necessary per the implementation of the _RunLocalHooks decorator)

_RunMasterSetupScript(master_params, action, use_external_mip_script)

source code 

Execute the master IP address setup script.

Parameters:
Raises:

ActivateMasterIp(master_params, use_external_mip_script)

source code 

Activate the IP address of the master daemon.

Parameters:
  • master_params (objects.MasterNetworkParameters) - network parameters of the master
  • use_external_mip_script (boolean) - whether to use an external master IP address setup script
Decorators:
  • @RunLocalHooks(constants.FAKE_OP_MASTER_TURNUP, "master-ip-turnup", _BuildMasterIpEnv)
Raises:
  • RPCFail - in case of errors during the IP startup

StartMasterDaemons(no_voting)

source code 

Activate local node as master node.

The function will start the master daemons (ganeti-masterd and ganeti-rapi).

Parameters:
  • no_voting (boolean) - whether to start ganeti-masterd without a node vote but still non-interactively
Returns: None

DeactivateMasterIp(master_params, use_external_mip_script)

source code 

Deactivate the master IP on this node.

Parameters:
  • master_params (objects.MasterNetworkParameters) - network parameters of the master
  • use_external_mip_script (boolean) - whether to use an external master IP address setup script
Decorators:
  • @RunLocalHooks(constants.FAKE_OP_MASTER_TURNDOWN, "master-ip-turndown", _BuildMasterIpEnv)
Raises:
  • RPCFail - in case of errors during the IP turndown

StopMasterDaemons()

source code 

Stop the master daemons on this node.

Stop the master daemons (ganeti-masterd and ganeti-rapi) on this node.

Returns: None

ChangeMasterNetmask(old_netmask, netmask, master_ip, master_netdev)

source code 

Change the netmask of the master IP.

Parameters:
  • old_netmask - the old value of the netmask
  • netmask - the new value of the netmask
  • master_ip - the master IP
  • master_netdev - the master network device

EtcHostsModify(mode, host, ip)

source code 

Modify a host entry in /etc/hosts.

Parameters:
  • mode - The mode to operate. Either add or remove entry
  • host - The host to operate on
  • ip - The ip associated with the entry

LeaveCluster(modify_ssh_setup)

source code 

Cleans up and remove the current node.

This function cleans up and prepares the current node to be removed from the cluster.

If processing is successful, then it raises an errors.QuitGanetiException which is used as a special case to shutdown the node daemon.

Parameters:
  • modify_ssh_setup - boolean

_CheckStorageParams(params, num_params)

source code 

Performs sanity checks for storage parameters.

Parameters:
  • params (list) - list of storage parameters
  • num_params (int) - expected number of parameters

_CheckLvmStorageParams(params)

source code 

Performs sanity check for the 'exclusive storage' flag.

See Also: _CheckStorageParams

_GetLvmVgSpaceInfo(name, params)

source code 

Wrapper around _GetVgInfo which checks the storage parameters.

Parameters:
  • name (string) - name of the volume group
  • params (list) - list of storage parameters, which in this case should be containing only one for exclusive storage

_GetLvmPvSpaceInfo(name, params)

source code 

Wrapper around _GetVgSpindlesInfo with sanity checks.

See Also: _GetLvmVgSpaceInfo

_GetVgSpindlesInfo(name, excl_stor, info_fn=bdev.LogicalVolume.GetVgSpindlesInfo)

source code 

Retrieves information about spindles in an LVM volume group.

Parameters:
  • name (string) - VG name
  • excl_stor (bool) - exclusive storage
Returns: dict
dictionary whose keys are "name", "vg_free", "vg_size" for VG name, free spindles, total spindles respectively

_GetHvInfo(name, hvparams, get_hv_fn=hypervisor.GetHypervisor)

source code 

Retrieves node information from a hypervisor.

The information returned depends on the hypervisor. Common items:

  • vg_size is the size of the configured volume group in MiB
  • vg_free is the free size of the volume group in MiB
  • memory_dom0 is the memory allocated for domain0 in MiB
  • memory_free is the currently available (free) ram in MiB
  • memory_total is the total number of ram in MiB
  • hv_version: the hypervisor version, if available
Parameters:
  • hvparams (dict of string) - the hypervisor's hvparams

_GetHvInfoAll(hv_specs, get_hv_fn=hypervisor.GetHypervisor)

source code 

Retrieves node information for all hypervisors.

See _GetHvInfo for information on the output.

Parameters:
  • hv_specs (list of pairs (string, dict of strings)) - list of pairs of a hypervisor's name and its hvparams

GetNodeInfo(storage_units, hv_specs)

source code 

Gives back a hash with different information about the node.

Parameters:
  • storage_units (list of tuples (string, string, list)) - List of tuples (storage unit, identifier, parameters) to ask for disk space information. In case of lvm-vg, the identifier is the VG name. The parameters can contain additional, storage-type-specific parameters, for example exclusive storage for lvm storage.
  • hv_specs (list of pairs (string, dict of strings)) - list of pairs of a hypervisor's name and its hvparams
Returns: tuple; (string, None/dict, None/dict)
Tuple containing boot ID, volume group information and hypervisor information

_GetFileStorageSpaceInfo(path, params)

source code 

Wrapper around filestorage.GetSpaceInfo.

The purpose of this wrapper is to call filestorage.GetFileStorageSpaceInfo and ignore the *args parameter to not leak it into the filestorage module's code.

See Also: filestorage.GetFileStorageSpaceInfo for description of the parameters.

_ApplyStorageInfoFunction(storage_type, storage_key, *args)

source code 

Looks up and applies the correct function to calculate free and total storage for the given storage type.

Parameters:
  • storage_type (string) - the storage type for which the storage shall be reported.
  • storage_key (string) - identifier of a storage unit, e.g. the volume group name of an LVM storage unit
  • args (any) - various parameters that can be used for storage reporting. These parameters and their semantics vary from storage type to storage type and are just propagated in this function.
Returns:
the results of the application of the storage space function (see _STORAGE_TYPE_INFO_FN) if storage space reporting is implemented for that storage type
Raises:
  • NotImplementedError - for storage types who don't support space reporting yet

_CheckExclusivePvs(pvi_list)

source code 

Check that PVs are not shared among LVs

Parameters:
Returns: list of tuples (string, list of strings)
offending volumes, as tuples: (pv_name, [lv1_name, lv2_name...])

_VerifyHypervisors(what, vm_capable, result, all_hvparams, get_hv_fn=hypervisor.GetHypervisor)

source code 

Verifies the hypervisor. Appends the results to the 'results' list.

Parameters:
  • what (dict) - a dictionary of things to check
  • vm_capable (boolean) - whether or not this node is vm capable
  • result (dict) - dictionary of verification results; results of the verifications in this function will be added here
  • all_hvparams (dict of dict of string) - dictionary mapping hypervisor names to hvparams
  • get_hv_fn (function) - function to retrieve the hypervisor, to improve testability

_VerifyHvparams(what, vm_capable, result, get_hv_fn=hypervisor.GetHypervisor)

source code 

Verifies the hvparams. Appends the results to the 'results' list.

Parameters:
  • what (dict) - a dictionary of things to check
  • vm_capable (boolean) - whether or not this node is vm capable
  • result (dict) - dictionary of verification results; results of the verifications in this function will be added here
  • get_hv_fn (function) - function to retrieve the hypervisor, to improve testability

_VerifyInstanceList(what, vm_capable, result, all_hvparams)

source code 

Verifies the instance list.

Parameters:
  • what (dict) - a dictionary of things to check
  • vm_capable (boolean) - whether or not this node is vm capable
  • result (dict) - dictionary of verification results; results of the verifications in this function will be added here
  • all_hvparams (dict of dict of string) - dictionary mapping hypervisor names to hvparams

_VerifyNodeInfo(what, vm_capable, result, all_hvparams)

source code 

Verifies the node info.

Parameters:
  • what (dict) - a dictionary of things to check
  • vm_capable (boolean) - whether or not this node is vm capable
  • result (dict) - dictionary of verification results; results of the verifications in this function will be added here
  • all_hvparams (dict of dict of string) - dictionary mapping hypervisor names to hvparams

_VerifyClientCertificate(cert_file=pathutils.NODED_CLIENT_CERT_FILE)

source code 

Verify the existance and validity of the client SSL certificate.

Also, verify that the client certificate is not self-signed. Self- signed client certificates stem from Ganeti versions 2.12.0 - 2.12.4 and should be replaced by client certificates signed by the server certificate. Hence we output a warning when we encounter a self-signed one.

_VerifySshSetup(node_status_list, my_name, ssh_key_type, ganeti_pub_keys_file=pathutils.SSH_PUB_KEYS)

source code 

Verifies the state of the SSH key files.

Parameters:
  • node_status_list (list of tuples) - list of nodes of the cluster associated with a couple of flags: (uuid, name, is_master_candidate, is_potential_master_candidate, online)
  • my_name (str) - name of this node
  • ssh_key_type (one of constants.SSHK_ALL) - type of key used on nodes
  • ganeti_pub_keys_file (str) - filename of the public keys file

_VerifySshClutter(node_status_list, my_name)

source code 

Verifies that the 'authorized_keys' files are not cluttered up.

Parameters:
  • node_status_list (list of tuples) - list of nodes of the cluster associated with a couple of flags: (uuid, name, is_master_candidate, is_potential_master_candidate, online)
  • my_name (str) - name of this node

VerifyNode(what, cluster_name, all_hvparams)

source code 

Verify the status of the local node.

Based on the input what parameter, various checks are done on the local node.

If the filelist key is present, this list of files is checksummed and the file/checksum pairs are returned.

If the nodelist key is present, we check that we have connectivity via ssh with the target nodes (and check the hostname report).

If the node-net-test key is present, we check that we have connectivity to the given nodes via both primary IP and, if applicable, secondary IPs.

Parameters:
  • what (dict) - a dictionary of things to check:
    • filelist: list of files for which to compute checksums
    • nodelist: list of nodes we should check ssh communication with
    • node-net-test: list of nodes we should check node daemon port connectivity with
    • hypervisor: list with hypervisors to run the verify for
  • cluster_name (string) - the cluster's name
  • all_hvparams (dict of dict of strings) - a dictionary mapping hypervisor names to hvparams
Returns: dict
a dictionary with the same keys as the input dict, and values representing the result of the checks

GetCryptoTokens(token_requests)

source code 

Perform actions on the node's cryptographic tokens.

Token types can be 'ssl' or 'ssh'. So far only some actions are implemented for 'ssl'. Action 'get' returns the digest of the public client ssl certificate. Action 'create' creates a new client certificate and private key and also returns the digest of the certificate. The third parameter of a token request are optional parameters for the actions, so far only the filename is supported.

Parameters:
  • token_requests (list of tuples of (string, string, dict), where the first string is in constants.CRYPTO_TYPES, the second in constants.CRYPTO_ACTIONS. The third parameter is a dictionary of string to string.) - list of requests of cryptographic tokens and actions to perform on them. The actions come with a dictionary of options.
Returns: list of tuples (string, string)
list of tuples of the token type and the public crypto token

EnsureDaemon(daemon_name, run)

source code 

Ensures the given daemon is running or stopped.

Parameters:
  • daemon_name (string) - name of the daemon (e.g., constants.KVMD)
  • run (bool) - whether to start or stop the daemon
Returns: bool
'True' if daemon successfully started/stopped, 'False' otherwise

AddNodeSshKey(node_uuid, node_name, potential_master_candidates, to_authorized_keys=False, to_public_keys=False, get_public_keys=False, pub_key_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, run_cmd_fn=ssh.RunSshCmdWithStdin)

source code 

Distributes a node's public SSH key across the cluster.

Note that this function should only be executed on the master node, which then will copy the new node's key to all nodes in the cluster via SSH.

Also note: at least one of the flags to_authorized_keys, to_public_keys, and get_public_keys has to be set to True for the function to actually perform any actions.

Parameters:
  • node_uuid (str) - the UUID of the node whose key is added
  • node_name (str) - the name of the node whose key is added
  • potential_master_candidates (list of str) - list of node names of potential master candidates; this should match the list of uuids in the public key file
  • to_authorized_keys (boolean) - whether the key should be added to the authorized_keys file of all nodes
  • to_public_keys (boolean) - whether the keys should be added to the public key file
  • get_public_keys (boolean) - whether the node should add the clusters' public keys to its {ganeti_pub_keys} file

AddNodeSshKeyBulk(node_list, potential_master_candidates, pub_key_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, run_cmd_fn=ssh.RunSshCmdWithStdin)

source code 

Distributes a node's public SSH key across the cluster.

Note that this function should only be executed on the master node, which then will copy the new node's key to all nodes in the cluster via SSH.

Also note: at least one of the flags to_authorized_keys, to_public_keys, and get_public_keys has to be set to True for the function to actually perform any actions.

Parameters:
  • node_list (list of SshAddNodeInfo tuples) - list of tuples containing the necessary node information for adding their keys
  • potential_master_candidates (list of str) - list of node names of potential master candidates; this should match the list of uuids in the public key file

RemoveNodeSshKey(node_uuid, node_name, master_candidate_uuids, potential_master_candidates, master_uuid=None, keys_to_remove=None, from_authorized_keys=False, from_public_keys=False, clear_authorized_keys=False, clear_public_keys=False, pub_key_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, readd=False, run_cmd_fn=ssh.RunSshCmdWithStdin)

source code 

Removes the node's SSH keys from the key files and distributes those.

Note that at least one of the flags from_authorized_keys, from_public_keys, clear_authorized_keys, and clear_public_keys has to be set to True for the function to perform any action at all. Not doing so will trigger an assertion in the function.

Parameters:
  • node_uuid (str) - UUID of the node whose key is removed
  • node_name (str) - name of the node whose key is remove
  • master_candidate_uuids (list of str) - list of UUIDs of the current master candidates
  • potential_master_candidates (list of str) - list of names of potential master candidates
  • keys_to_remove (dict of str to list of str) - a dictionary mapping node UUIDS to lists of SSH keys to be removed. This list is supposed to be used only if the keys are not in the public keys file. This is for example the case when removing a master node's key.
  • from_authorized_keys (boolean) - whether or not the key should be removed from the authorized_keys file
  • from_public_keys (boolean) - whether or not the key should be remove from the ganeti_pub_keys file
  • clear_authorized_keys (boolean) - whether or not the authorized_keys file should be cleared on the node whose keys are removed
  • clear_public_keys (boolean) - whether to clear the node's ganeti_pub_key file
  • readd (boolean) - whether this is called during a readd operation.
Returns: list of string
list of feedback messages

RemoveNodeSshKeyBulk(node_list, master_candidate_uuids, potential_master_candidates, master_uuid=None, keys_to_remove=None, pub_key_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, readd=False, run_cmd_fn=ssh.RunSshCmdWithStdin)

source code 

Removes the node's SSH keys from the key files and distributes those.

Note that at least one of the flags from_authorized_keys, from_public_keys, clear_authorized_keys, and clear_public_keys of at least one node has to be set to True for the function to perform any action at all. Not doing so will trigger an assertion in the function.

Parameters:
  • node_list (list of SshRemoveNodeInfo.) - list of information about nodes whose keys are being removed
  • master_candidate_uuids (list of str) - list of UUIDs of the current master candidates
  • potential_master_candidates (list of str) - list of names of potential master candidates
  • keys_to_remove (dict of str to list of str) - a dictionary mapping node UUIDS to lists of SSH keys to be removed. This list is supposed to be used only if the keys are not in the public keys file. This is for example the case when removing a master node's key.
  • readd (boolean) - whether this is called during a readd operation.
Returns: list of string
list of feedback messages

_GenerateNodeSshKey(node_uuid, node_name, ssh_port_map, ssh_key_type, ssh_key_bits, pub_key_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, run_cmd_fn=ssh.RunSshCmdWithStdin, suffix="")

source code 

Generates the root SSH key pair on the node.

Parameters:
  • node_uuid (str) - UUID of the node whose key is removed
  • node_name (str) - name of the node whose key is remove
  • ssh_port_map (dict of str to int) - mapping of node names to their SSH port
  • ssh_key_type (One of constants.SSHK_ALL) - the type of SSH key to be generated
  • ssh_key_bits (int) - the length of the key to be generated

RenewSshKeys(node_uuids, node_names, master_candidate_uuids, potential_master_candidates, old_key_type, new_key_type, new_key_bits, ganeti_pub_keys_file=pathutils.SSH_PUB_KEYS, ssconf_store=None, noded_cert_file=pathutils.NODED_CERT_FILE, run_cmd_fn=ssh.RunSshCmdWithStdin)

source code 

Renews all SSH keys and updates authorized_keys and ganeti_pub_keys.

Parameters:
  • node_uuids (list of str) - list of node UUIDs whose keys should be renewed
  • node_names (list of str) - list of node names whose keys should be removed. This list should match the node_uuids parameter
  • master_candidate_uuids (list of str) - list of UUIDs of master candidates or master node
  • old_key_type (One of constants.SSHK_ALL) - the type of SSH key already present on nodes
  • new_key_type (One of constants.SSHK_ALL) - the type of SSH key to be generated
  • new_key_bits (int) - the length of the key to be generated
  • ganeti_pub_keys_file (str) - file path of the the public key file
  • noded_cert_file (str) - path of the noded SSL certificate file
  • run_cmd_fn (function) - function to run commands on remote nodes via SSH
Raises:
  • ProgrammerError - if node_uuids and node_names don't match; SshUpdateError if a node's key is missing from the public key file, if a node's new SSH key could not be fetched from it, if there is none or more than one entry in the public key list for the master node.

GetBlockDevSizes(devices)

source code 

Return the size of the given block devices

Parameters:
  • devices (list) - list of block device nodes to query
Returns: dict
dictionary of all block devices under /dev (key). The value is their size in MiB.

{'/dev/disk/by-uuid/123456-12321231-312312-312': 124}

GetVolumeList(vg_names)

source code 

Compute list of logical volumes and their size.

Parameters:
  • vg_names (list) - the volume groups whose LVs we should list, or empty for all volume groups
Returns: dict
dictionary of all partions (key) with value being a tuple of their size (in MiB), inactive and online status:
 {'xenvg/test1': ('20.06', True, True)}

in case of errors, a string is returned with the error details.

ListVolumeGroups()

source code 

List the volume groups and their size.

Returns: dict
dictionary with keys volume name and values the size of the volume

NodeVolumes()

source code 

List all volumes on this node.

Returns: list
A list of dictionaries, each having four keys:
  • name: the logical volume name,
  • size: the size of the logical volume
  • dev: the physical device on which the LV lives
  • vg: the volume group to which it belongs

In case of errors, we return an empty list and log the error.

Note that since a logical volume can live on multiple physical volumes, the resulting list might include a logical volume multiple times.

BridgesExist(bridges_list)

source code 

Check if a list of bridges exist on the current node.

Returns: boolean
True if all of them exist, False otherwise

GetInstanceListForHypervisor(hname, hvparams=None, get_hv_fn=hypervisor.GetHypervisor)

source code 

Provides a list of instances of the given hypervisor.

Parameters:
  • hname (string) - name of the hypervisor
  • hvparams (dict of strings) - hypervisor parameters for the given hypervisor
  • get_hv_fn (function) - function that returns a hypervisor for the given hypervisor name; optional parameter to increase testability
Returns: list
a list of all running instances on the current node
  • instance1.example.com
  • instance2.example.com

GetInstanceList(hypervisor_list, all_hvparams=None, get_hv_fn=hypervisor.GetHypervisor)

source code 

Provides a list of instances.

Parameters:
  • hypervisor_list (list) - the list of hypervisors to query information
  • all_hvparams (dict of dict of strings) - a dictionary mapping hypervisor types to respective cluster-wide hypervisor parameters
  • get_hv_fn (function) - function that returns a hypervisor for the given hypervisor name; optional parameter to increase testability
Returns: list
a list of all running instances on the current node
  • instance1.example.com
  • instance2.example.com

GetInstanceInfo(instance, hname, hvparams=None)

source code 

Gives back the information about an instance as a dictionary.

Parameters:
  • instance (string) - the instance name
  • hname (string) - the hypervisor type of the instance
  • hvparams (dict of strings) - the instance's hvparams
Returns: dict
dictionary with the following keys:
  • memory: memory size of instance (int)
  • state: state of instance (HvInstanceState)
  • time: cpu time of instance (float)
  • vcpus: the number of vcpus (int)

GetInstanceMigratable(instance)

source code 

Computes whether an instance can be migrated.

Parameters:
Returns: tuple
tuple of (result, description) where:
  • result: whether the instance can be migrated or not
  • description: a description of the issue, if relevant

GetAllInstancesInfo(hypervisor_list, all_hvparams)

source code 

Gather data about all instances.

This is the equivalent of GetInstanceInfo, except that it computes data for all instances at once, thus being faster if one needs data about more than one instance.

Parameters:
  • hypervisor_list (list) - list of hypervisors to query for instance data
  • all_hvparams (dict of dict of strings) - mapping of hypervisor names to hvparams
Returns: dict
dictionary of instance: data, with data having the following keys:
  • memory: memory size of instance (int)
  • state: xen state of instance (string)
  • time: cpu time of instance (float)
  • vcpus: the number of vcpus

GetInstanceConsoleInfo(instance_param_dict, get_hv_fn=hypervisor.GetHypervisor)

source code 

Gather data about the console access of a set of instances of this node.

This function assumes that the caller already knows which instances are on this node, by calling a function such as GetAllInstancesInfo or GetInstanceList.

For every instance, a large amount of configuration data needs to be provided to the hypervisor interface in order to receive the console information. Whether this could or should be cut down can be discussed. The information is provided in a dictionary indexed by instance name, allowing any number of instance queries to be done.

Parameters:
  • instance_param_dict (dict of string to tuple of dictionaries, where the dictionaries represent: objects.Instance, objects.Node, objects.NodeGroup, HvParams, BeParams) - mapping of instance name to parameters necessary for console information retrieval
Returns: dict
dictionary of instance: data, with data having the following keys:
  • instance: instance name
  • kind: console kind
  • message: used with kind == CONS_MESSAGE, indicates console to be unavailable, supplies error message
  • host: host to connect to
  • port: port to use
  • user: user for login
  • command: the command, broken into parts as an array
  • display: unknown, potentially unused?

_InstanceLogName(kind, os_name, instance, component)

source code 

Compute the OS log filename for a given instance and operation.

The instance name and os name are passed in as strings since not all operations have these as part of an instance object.

Parameters:
  • kind (string) - the operation type (e.g. add, import, etc.)
  • os_name (string) - the os name
  • instance (string) - the name of the instance being imported/added/etc.
  • component (string or None) - the name of the component of the instance being transferred

InstanceOsAdd(instance, reinstall, debug)

source code 

Add an OS to an instance.

Parameters:
  • instance (objects.Instance) - Instance whose OS is to be installed
  • reinstall (boolean) - whether this is an instance reinstall
  • debug (integer) - debug level, passed to the OS scripts
Returns: None

RunRenameInstance(instance, old_name, debug)

source code 

Run the OS rename script for an instance.

Parameters:
  • instance (objects.Instance) - Instance whose OS is to be installed
  • old_name (string) - previous instance name
  • debug (integer) - debug level, passed to the OS scripts
Returns: boolean
the success of the operation

_SymlinkBlockDev(instance_name, device_path, idx)

source code 

Set up symlinks to a instance's block device.

This is an auxiliary function run when an instance is start (on the primary node) or when an instance is migrated (on the target node).

Parameters:
  • instance_name - the name of the target instance
  • device_path - path of the physical block device, on the node
  • idx - the disk index
Returns:
absolute path to the disk's symlink

_CalculateDeviceURI(instance, disk, device)

source code 

Get the URI for the device.

Parameters:
Returns: string
the device uri if any else None

_GatherAndLinkBlockDevs(instance)

source code 

Set up an instance's block device(s).

This is run on the primary node at instance startup. The block devices must be already assembled.

Parameters:
Returns: list
list of (disk_object, link_name, drive_uri)

StartInstance(instance, startup_paused, reason, store_reason=True)

source code 

Start an instance.

Parameters:
  • instance (objects.Instance) - the instance object
  • instance (objects.Instance) - pause instance at startup?
  • reason (list of reasons) - the reason trail for this startup
  • store_reason (boolean) - whether to store the shutdown reason trail on file
  • startup_paused (bool)
Returns: None

InstanceShutdown(instance, timeout, reason, store_reason=True)

source code 

Shut an instance down.

Parameters:
  • instance (objects.Instance) - the instance object
  • timeout (integer) - maximum timeout for soft shutdown
  • reason (list of reasons) - the reason trail for this shutdown
  • store_reason (boolean) - whether to store the shutdown reason trail on file
Returns: None

Note: this functions uses polling with a hardcoded timeout.

InstanceReboot(instance, reboot_type, shutdown_timeout, reason)

source code 

Reboot an instance.

Parameters:
  • instance (objects.Instance) - the instance object to reboot
  • reboot_type (str) - the type of reboot, one the following constants:
    • constants.INSTANCE_REBOOT_SOFT: only reboot the instance OS, do not recreate the VM
    • constants.INSTANCE_REBOOT_HARD: tear down and restart the VM (at the hypervisor level)
    • the other reboot type (constants.INSTANCE_REBOOT_FULL) is not accepted here, since that mode is handled differently, in cmdlib, and translates into full stop and start of the instance (instead of a call_instance_reboot RPC)
  • shutdown_timeout (integer) - maximum timeout for soft shutdown
  • reason (list of reasons) - the reason trail for this reboot
Returns: None

InstanceBalloonMemory(instance, memory)

source code 

Resize an instance's memory.

Parameters:
  • instance (objects.Instance) - the instance object
  • memory (int) - new memory amount in MB
Returns: None

MigrationInfo(instance)

source code 

Gather information about an instance to be migrated.

Parameters:

AcceptInstance(instance, info, target)

source code 

Prepare the node to accept an instance.

Parameters:
  • instance (objects.Instance) - the instance definition
  • info (string/data (opaque)) - migration information, from the source node
  • target (string) - target host (usually ip), on this node

FinalizeMigrationDst(instance, info, success)

source code 

Finalize any preparation to accept an instance.

Parameters:
  • instance (objects.Instance) - the instance definition
  • info (string/data (opaque)) - migration information, from the source node
  • success (boolean) - whether the migration was a success or a failure

MigrateInstance(cluster_name, instance, target, live)

source code 

Migrates an instance to another node.

Parameters:
  • cluster_name (string) - name of the cluster
  • instance (objects.Instance) - the instance definition
  • target (string) - the target node name
  • live (boolean) - whether the migration should be done live or not (the interpretation of this parameter is left to the hypervisor)
Raises:
  • RPCFail - if migration fails for some reason

FinalizeMigrationSource(instance, success, live)

source code 

Finalize the instance migration on the source node.

Parameters:
  • instance (objects.Instance) - the instance definition of the migrated instance
  • success (bool) - whether the migration succeeded or not
  • live (bool) - whether the user requested a live migration or not
Raises:
  • RPCFail - If the execution fails for some reason

GetMigrationStatus(instance)

source code 

Get the migration status

Parameters:
Returns: objects.MigrationStatus
the status of the current migration (one of constants.HV_MIGRATION_VALID_STATUSES), plus any additional progress info that can be retrieved from the hypervisor
Raises:
  • RPCFail - If the migration status cannot be retrieved

HotplugDevice(instance, action, dev_type, device, extra, seq)

source code 

Hotplug a device

Hotplug is currently supported only for KVM Hypervisor.

Parameters:
  • instance (objects.Instance) - the instance to which we hotplug a device
  • action (string) - the hotplug action to perform
  • dev_type (string) - the device type to hotplug
  • device (either objects.NIC or objects.Disk) - the device object to hotplug
  • extra (tuple) - extra info used for disk hotplug (disk link, drive uri)
  • seq (int) - the index of the device from master perspective
Raises:
  • RPCFail - in case instance does not have KVM hypervisor

ModifyInstanceMetadata(metadata)

source code 

Sends instance data to the metadata daemon.

Uses the Luxi transport layer to communicate with the metadata daemon configuration server. It starts the metadata daemon if it is not running. The daemon must be enabled during at configuration time.

Parameters:

BlockdevCreate(disk, size, owner, on_primary, info, excl_stor)

source code 

Creates a block device for an instance.

Parameters:
  • disk (objects.Disk) - the object describing the disk we should create
  • size (int) - the size of the physical underlying device, in MiB
  • owner (str) - the name of the instance for which disk is created, used for device cache data
  • on_primary (boolean) - indicates if it is the primary node or not
  • info (string) - string that will be sent to the physical device creation, used for example to set (LVM) tags on LVs
  • excl_stor (boolean) - Whether exclusive_storage is active
Returns:
the new unique_id of the device (this can sometime be computed only after creation), or None. On secondary nodes, it's not required to return anything.

_DumpDevice(source_path, target_path, offset, size, truncate)

source code 

This function images/wipes the device using a local file.

Parameters:
  • source_path (string) - path of the image or data source (e.g., "/dev/zero")
  • target_path (string) - path of the device to image/wipe
  • offset (int) - offset in MiB in the output file
  • size (int) - maximum size in MiB to write (data source might be smaller)
  • truncate (bool) - whether the file should be truncated
Returns:
None
Raises:

_DownloadAndDumpDevice(source_url, target_path, size)

source code 

This function images a device using a downloaded image file.

Parameters:
  • source_url (string) - URL of image to dump to disk
  • target_path (string) - path of the device to image
  • size (int) - maximum size in MiB to write (data source might be smaller)
Returns: NoneType
None
Raises:
  • RPCFail - in case of download or write failures

BlockdevConvert(src_disk, target_disk)

source code 

Copies data from source block device to target.

This function gets the export and import commands from the source and target devices respectively, and then concatenates them to a single command using a pipe ("|"). Finally, executes the unified command that will transfer the data between the devices during the disk template conversion operation.

Parameters:
  • src_disk (objects.Disk) - the disk object we want to copy from
  • target_disk (objects.Disk) - the disk object we want to copy to
Returns: NoneType
None
Raises:

BlockdevWipe(disk, offset, size)

source code 

Wipes a block device.

Parameters:
  • disk (objects.Disk) - the disk object we want to wipe
  • offset (int) - The offset in MiB in the file
  • size (int) - The size in MiB to write

BlockdevImage(disk, image, size)

source code 

Images a block device either by dumping a local file or downloading a URL.

Parameters:
  • disk (objects.Disk) - the disk object we want to image
  • image (string) - file path to the disk image be dumped
  • size (int) - The size in MiB to write
Returns: NoneType
None
Raises:

BlockdevPauseResumeSync(disks, pause)

source code 

Pause or resume the sync of the block device.

Parameters:
  • disks (list of objects.Disk) - the disks object we want to pause/resume
  • pause (bool) - Wheater to pause or resume

BlockdevRemove(disk)

source code 

Remove a block device.

Parameters:
Returns: boolean
the success of the operation

Note: This is intended to be called recursively.

_RecursiveAssembleBD(disk, owner, as_primary)

source code 

Activate a block device for an instance.

This is run on the primary and secondary nodes for an instance.

Parameters:
  • disk (objects.Disk) - the disk we try to assemble
  • owner (str) - the name of the instance which owns the disk
  • as_primary (boolean) - if we should make the block device read/write
Returns:
the assembled device or None (in case no device was assembled)
Raises:

Note: this function is called recursively.

BlockdevAssemble(disk, instance, as_primary, idx)

source code 

Activate a block device for an instance.

This is a wrapper over _RecursiveAssembleBD.

Returns: str or boolean
a tuple with the /dev/... path and the created symlink for primary nodes, and (True, True) for secondary nodes

BlockdevShutdown(disk)

source code 

Shut down a block device.

First, if the device is assembled (Attach() is successful), then the device is shutdown. Then the children of the device are shutdown.

This function is called recursively. Note that we don't cache the children or such, as oppossed to assemble, shutdown of different devices doesn't require that the upper device was active.

Parameters:
  • disk (objects.Disk) - the description of the disk we should shutdown
Returns: None

BlockdevAddchildren(parent_cdev, new_cdevs)

source code 

Extend a mirrored block device.

Parameters:
  • parent_cdev (objects.Disk) - the disk to which we should add children
  • new_cdevs (list of objects.Disk) - the list of children which we should add
Returns: None

BlockdevRemovechildren(parent_cdev, new_cdevs)

source code 

Shrink a mirrored block device.

Parameters:
  • parent_cdev (objects.Disk) - the disk from which we should remove children
  • new_cdevs (list of objects.Disk) - the list of children which we should remove
Returns: None

BlockdevGetmirrorstatus(disks)

source code 

Get the mirroring status of a list of devices.

Parameters:
  • disks (list of objects.Disk) - the list of disks which we should query
Returns: disk
List of objects.BlockDevStatus, one for each disk
Raises:

BlockdevGetmirrorstatusMulti(disks)

source code 

Get the mirroring status of a list of devices.

Parameters:
  • disks (list of objects.Disk) - the list of disks which we should query
Returns: disk
List of tuples, (bool, status), one for each disk; bool denotes success/failure, status is objects.BlockDevStatus on success, string otherwise

_RecursiveFindBD(disk)

source code 

Check if a device is activated.

If so, return information about the real device.

Parameters:
Returns:
None if the device can't be found, otherwise the device instance

_OpenRealBD(disk)

source code 

Opens the underlying block device of a disk.

Parameters:

BlockdevFind(disk)

source code 

Check if a device is activated.

If it is, return information about the real device.

Parameters:
Returns: None or objects.BlockDevStatus
None if the disk cannot be found, otherwise a the current information

BlockdevGetdimensions(disks)

source code 

Computes the size of the given disks.

If a disk is not found, returns None instead.

Parameters:
  • disks (list of objects.Disk) - the list of disk to compute the size for
Returns: list
list with elements None if the disk cannot be found, otherwise the pair (size, spindles), where spindles is None if the device doesn't support that

UploadFile(file_name, data, mode, uid, gid, atime, mtime)

source code 

Write a file to the filesystem.

This allows the master to overwrite(!) a file. It will only perform the operation if the file belongs to a list of configuration files.

Parameters:
  • file_name (str) - the target file name
  • data (str) - the new contents of the file
  • mode (int) - the mode to give the file (can be None)
  • uid (string) - the owner of the file
  • gid (string) - the group of the file
  • atime (float) - the atime to set on the file (can be None)
  • mtime (float) - the mtime to set on the file (can be None)
Returns: None

RunOob(oob_program, command, node, timeout)

source code 

Executes oob_program with given command on given node.

Parameters:
  • oob_program - The path to the executable oob_program
  • command - The command to invoke on oob_program
  • node - The node given as an argument to the program
  • timeout - Timeout after which we kill the oob program
Returns:
stdout
Raises:
  • RPCFail - If execution fails for some reason

_OSOndiskAPIVersion(os_dir)

source code 

Compute and return the API version of a given OS.

This function will try to read the API version of the OS residing in the 'os_dir' directory.

Parameters:
  • os_dir (str) - the directory in which we should look for the OS
Returns: tuple
tuple (status, data) with status denoting the validity and data holding either the valid versions or an error message

DiagnoseOS(top_dirs=None)

source code 

Compute the validity for all OSes.

Parameters:
Returns: list of objects.OS
a list of tuples (name, path, status, diagnose, variants, parameters, api_version) for all (potential) OSes under all search paths, where:
  • name is the (potential) OS name
  • path is the full path to the OS
  • status True/False is the validity of the OS
  • diagnose is the error message for an invalid OS, otherwise empty
  • variants is a list of supported OS variants, if any
  • parameters is a list of (name, help) parameters, if any
  • api_version is a list of support OS API versions

_TryOSFromDisk(name, base_dir=None)

source code 

Create an OS instance from disk.

This function will return an OS instance if the given name is a valid OS name.

Parameters:
  • base_dir (string) - Base directory containing OS installations. Defaults to a search in all the OS_SEARCH_PATH dirs.
Returns: tuple
success and either the OS instance if we find a valid one, or error message

OSFromDisk(name, base_dir=None)

source code 

Create an OS instance from disk.

This function will return an OS instance if the given name is a valid OS name. Otherwise, it will raise an appropriate RPCFail exception, detailing why this is not a valid OS.

This is just a wrapper over _TryOSFromDisk, which doesn't raise an exception but returns true/false status data.

Parameters:
  • base_dir (string) - Base directory containing OS installations. Defaults to a search in all the OS_SEARCH_PATH dirs.
Returns: objects.OS
the OS instance if we find a valid one
Raises:
  • RPCFail - if we don't find a valid OS

OSCoreEnv(os_name, inst_os, os_params, debug=0)

source code 

Calculate the basic environment for an os script.

Parameters:
  • os_name (str) - full operating system name (including variant)
  • inst_os (objects.OS) - operating system for which the environment is being built
  • os_params (dict) - the OS parameters
  • debug (integer) - debug level (0 or 1, for OS Api 10)
Returns: dict
dict of environment variables
Raises:

OSEnvironment(instance, inst_os, debug=0)

source code 

Calculate the environment for an os script.

Parameters:
  • instance (objects.Instance) - target instance for the os script run
  • inst_os (objects.OS) - operating system for which the environment is being built
  • debug (integer) - debug level (0 or 1, for OS Api 10)
Returns: dict
dict of environment variables
Raises:

DiagnoseExtStorage(top_dirs=None)

source code 

Compute the validity for all ExtStorage Providers.

Parameters:
Returns: list of objects.ExtStorage
a list of tuples (name, path, status, diagnose, parameters) for all (potential) ExtStorage Providers under all search paths, where:
  • name is the (potential) ExtStorage Provider
  • path is the full path to the ExtStorage Provider
  • status True/False is the validity of the ExtStorage Provider
  • diagnose is the error message for an invalid ExtStorage Provider, otherwise empty
  • parameters is a list of (name, help) parameters, if any

BlockdevGrow(disk, amount, dryrun, backingstore, excl_stor)

source code 

Grow a stack of block devices.

This function is called recursively, with the childrens being the first ones to resize.

Parameters:
  • disk (objects.Disk) - the disk to be grown
  • amount (integer) - the amount (in mebibytes) to grow with
  • dryrun (boolean) - whether to execute the operation in simulation mode only, without actually increasing the size
  • backingstore - whether to execute the operation on backing storage only, or on "logical" storage only; e.g. DRBD is logical storage, whereas LVM, file, RBD are backing storage
  • excl_stor (boolean) - Whether exclusive_storage is active
Returns: (status, result)
a tuple with the status of the operation (True/False), and the errors message if status is False

BlockdevSnapshot(disk, snap_name, snap_size)

source code 

Create a snapshot copy of a block device.

This function is called recursively, and the snapshot is actually created just for the leaf lvm backend device.

Parameters:
  • disk (objects.Disk) - the disk to be snapshotted
  • snap_name (string) - the name of the snapshot
  • snap_size (int) - the size of the snapshot
Returns: string
snapshot disk ID as (vg, lv)

BlockdevSetInfo(disk, info)

source code 

Sets 'metadata' information on block devices.

This function sets 'info' metadata on block devices. Initial information is set at device creation; this function should be used for example after renames.

Parameters:
  • disk (objects.Disk) - the disk to be grown
  • info (string) - new 'info' metadata
Returns: (status, result)
a tuple with the status of the operation (True/False), and the errors message if status is False

FinalizeExport(instance, snap_disks)

source code 

Write out the export configuration information.

Parameters:
  • instance (objects.Instance) - the instance which we export, used for saving configuration
  • snap_disks (list of objects.Disk) - list of snapshot block devices, which will be used to get the actual name of the dump file
Returns: None

ExportInfo(dest)

source code 

Get export configuration information.

Parameters:
  • dest (str) - directory containing the export
Returns: objects.SerializableConfigParser
a serializable config file containing the export info

ListExports()

source code 

Return a list of exports currently available on this machine.

Returns: list
list of the exports

RemoveExport(export)

source code 

Remove an existing export from the node.

Parameters:
  • export (str) - the name of the export to remove
Returns: None

BlockdevRename(devlist)

source code 

Rename a list of block devices.

Parameters:
  • devlist (list of tuples) - list of tuples of the form (disk, new_unique_id); disk is an objects.Disk object describing the current disk, and new unique_id is the name we rename it to
Returns: boolean
True if all renames succeeded, False otherwise

_TransformFileStorageDir(fs_dir)

source code 

Checks whether given file_storage_dir is valid.

Checks wheter the given fs_dir is within the cluster-wide default file_storage_dir or the shared_file_storage_dir, which are stored in SimpleStore. Only paths under those directories are allowed.

Parameters:
  • fs_dir (str) - the path to check
Returns:
the normalized path if valid, None otherwise

CreateFileStorageDir(file_storage_dir)

source code 

Create file storage directory.

Parameters:
  • file_storage_dir (str) - directory to create
Returns: tuple
tuple with first element a boolean indicating wheter dir creation was successful or not

RemoveFileStorageDir(file_storage_dir)

source code 

Remove file storage directory.

Remove it only if it's empty. If not log an error and return.

Parameters:
  • file_storage_dir (str) - the directory we should cleanup
Returns: tuple (success,)
tuple of one element, success, denoting whether the operation was successful

RenameFileStorageDir(old_file_storage_dir, new_file_storage_dir)

source code 

Rename the file storage directory.

Parameters:
  • old_file_storage_dir (str) - the current path
  • new_file_storage_dir (str) - the name we should rename to
Returns: tuple (success,)
tuple of one element, success, denoting whether the operation was successful

_EnsureJobQueueFile(file_name)

source code 

Checks whether the given filename is in the queue directory.

Parameters:
  • file_name (str) - the file name we should check
Returns: None
Raises:
  • RPCFail - if the file is not valid

JobQueueUpdate(file_name, content)

source code 

Updates a file in the queue directory.

This is just a wrapper over utils.io.WriteFile, with proper checking.

Parameters:
  • file_name (str) - the job file name
  • content (str) - the new job contents
Returns: boolean
the success of the operation

JobQueueRename(old, new)

source code 

Renames a job queue file.

This is just a wrapper over os.rename with proper checking.

Parameters:
  • old (str) - the old (actual) file name
  • new (str) - the desired file name
Returns: tuple
the success of the operation and payload

BlockdevClose(instance_name, disks)

source code 

Closes the given block devices.

This means they will be switched to secondary mode (in case of DRBD).

Parameters:
  • instance_name - if the argument is not empty, the symlinks of this instance will be removed
  • disks (list of objects.Disk) - the list of disks to be closed
Returns: tuple (success, message)
a tuple of success and message, where success indicates the succes of the operation, and message which will contain the error details in case we failed

ValidateHVParams(hvname, hvparams)

source code 

Validates the given hypervisor parameters.

Parameters:
  • hvname (string) - the hypervisor name
  • hvparams (dict) - the hypervisor parameters to be validated
Returns: None

_CheckOSPList(os_obj, parameters)

source code 

Check whether a list of parameters is supported by the OS.

Parameters:
  • os_obj (objects.OS) - OS object to check
  • parameters (list) - the list of parameters to check

_CheckOSVariant(os_obj, name)

source code 

Check whether an OS name conforms to the os variants specification.

Parameters:
  • os_obj (objects.OS) - OS object to check
  • name (string) - OS name passed by the user, to check for validity
Returns: NoneType
None
Raises:
  • RPCFail - if OS variant is not valid

ValidateOS(required, osname, checks, osparams, force_variant)

source code 

Validate the given OS parameters.

Parameters:
  • required (boolean) - whether absence of the OS should translate into failure or not
  • osname (string) - the OS to be validated
  • checks (list) - list of the checks to run (currently only 'parameters')
  • osparams (dict) - dictionary with OS parameters, some of which may be private.
Returns: boolean
True if the validation passed, or False if the OS was not found and required was false

ExportOS(instance, override_env)

source code 

Creates a GZIPed tarball with an OS definition and environment.

The archive contains a file with the environment variables needed by the OS scripts.

Parameters:
  • instance (objects.Instance) - instance for which the OS definition is exported
  • override_env (dict of string to string) - if supplied, it overrides the environment on a key-by-key basis that is part of the archive
Returns: string
filepath of the archive

CreateX509Certificate(validity, cryptodir=pathutils.CRYPTO_KEYS_DIR)

source code 

Creates a new X509 certificate for SSL/TLS.

Parameters:
  • validity (int) - Validity in seconds
Returns: tuple; (string, string)
Certificate name and public part

RemoveX509Certificate(name, cryptodir=pathutils.CRYPTO_KEYS_DIR)

source code 

Removes a X509 certificate.

Parameters:
  • name (string) - Certificate name

_GetImportExportIoCommand(instance, mode, ieio, ieargs)

source code 

Returns the command for the requested input/output.

Parameters:
  • instance (objects.Instance) - The instance object
  • mode - Import/export mode
  • ieio - Input/output type
  • ieargs - Input/output arguments

StartImportExportDaemon(mode, opts, host, port, instance, component, ieio, ieioargs)

source code 

Starts an import or export daemon.

Parameters:
  • mode - Import/output mode
  • opts (objects.ImportExportOptions) - Daemon options
  • host (string) - Remote host for export (None for import)
  • port (int) - Remote port for export (None for import)
  • instance (objects.Instance) - Instance object
  • component (string) - which part of the instance is transferred now, e.g. 'disk/0'
  • ieio - Input/output type
  • ieioargs - Input/output arguments

GetImportExportStatus(names)

source code 

Returns import/export daemon status.

Parameters:
  • names (sequence) - List of names
Returns: List of dicts
Returns a list of the state of each named import/export or None if a status couldn't be read

CleanupImportExport(name)

source code 

Cleanup after an import or export.

If the import/export daemon is still running it's killed. Afterwards the whole status directory is removed.

_FindDisks(disks)

source code 

Finds attached BlockDevs for the given disks.

Parameters:
  • disks (list of objects.Disk) - the disk objects we need to find
Returns:
list of BlockDev objects or None if a given disk was not found or was no attached.

PowercycleNode(hypervisor_type, hvparams=None)

source code 

Hard-powercycle the node.

Because we need to return first, and schedule the powercycle in the background, we won't be able to report failures nicely.

_VerifyRestrictedCmdName(cmd)

source code 

Verifies a restricted command name.

Parameters:
  • cmd (string) - Command name
Returns: tuple; (boolean, string or None)
The tuple's first element is the status; if False, the second element is an error message string, otherwise it's None

_CommonRestrictedCmdCheck(path, owner)

source code 

Common checks for restricted command file system directories and files.

Parameters:
  • path (string) - Path to check
  • owner - None or tuple containing UID and GID
Returns: tuple; (boolean, string or os.stat result)
The tuple's first element is the status; if False, the second element is an error message string, otherwise it's the result of os.stat

_VerifyRestrictedCmdDirectory(path, _owner=None)

source code 

Verifies restricted command directory.

Parameters:
  • path (string) - Path to check
Returns: tuple; (boolean, string or None)
The tuple's first element is the status; if False, the second element is an error message string, otherwise it's None

_VerifyRestrictedCmd(path, cmd, _owner=None)

source code 

Verifies a whole restricted command and returns its executable filename.

Parameters:
  • path (string) - Directory containing restricted commands
  • cmd (string) - Command name
Returns: tuple; (boolean, string)
The tuple's first element is the status; if False, the second element is an error message string, otherwise the second element is the absolute path to the executable

_PrepareRestrictedCmd(path, cmd, _verify_dir=_VerifyRestrictedCmdDirectory, _verify_name=_VerifyRestrictedCmdName, _verify_cmd=_VerifyRestrictedCmd)

source code 

Performs a number of tests on a restricted command.

Parameters:
  • path (string) - Directory containing restricted commands
  • cmd (string) - Command name
Returns:
Same as _VerifyRestrictedCmd

RunRestrictedCmd(cmd, _lock_timeout=_RCMD_LOCK_TIMEOUT, _lock_file=pathutils.RESTRICTED_COMMANDS_LOCK_FILE, _path=pathutils.RESTRICTED_COMMANDS_DIR, _sleep_fn=time.sleep, _prepare_fn=_PrepareRestrictedCmd, _runcmd_fn=utils.RunCmd, _enabled=constants.ENABLE_RESTRICTED_COMMANDS)

source code 

Executes a restricted command after performing strict tests.

Parameters:
  • cmd (string) - Command name
Returns: string
Command output
Raises:

SetWatcherPause(until, _filename=pathutils.WATCHER_PAUSEFILE)

source code 

Creates or removes the watcher pause file.

Parameters:
  • until (None or number) - Unix timestamp saying until when the watcher shouldn't run

ConfigureOVS(ovs_name, ovs_link)

source code 

Creates a OpenvSwitch on the node.

This function sets up a OpenvSwitch on the node with given name nad connects it via a given eth device.

Parameters:
  • ovs_name (string) - Name of the OpenvSwitch to create.
  • ovs_link (None or string) - Ethernet device for outside connection (can be missing)

GetFileInfo(file_path)

source code 

Checks if a file exists and returns information related to it.

Currently returned information:

  • file size: int, size in bytes
Parameters:
  • file_path (string) - Name of file to examine.
Returns: tuple of bool, dict
Whether the file exists, and a dictionary of information about the file gathered by os.stat.

Variables Details [hide private]

_ALLOWED_CLEAN_DIRS

denotes which directories are accepted in the _CleanDirectory function
Value:
compat.UniqueFrozenset([pathutils.DATA_DIR, pathutils.JOB_QUEUE_ARCHIV\
E_DIR, pathutils.QUEUE_DIR, pathutils.CRYPTO_KEYS_DIR,])

_LVSLINE_REGEX

Valid LVS output line regex

Value:
re.compile(r"^ *([^|]+)\|([^|]+)\|([0-9.]+)\|([^|]{6,})\|?$")

_RCMD_MAX_MODE

Maximum file permissions for restricted command directory and executables

Value:
stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXO\
TH

_STORAGE_TYPE_INFO_FN

Value:
{constants.ST_BLOCK: None, constants.ST_DISKLESS: None, constants.ST_E\
XT: None, constants.ST_FILE: _GetFileStorageSpaceInfo, constants.ST_LV\
M_PV: _GetLvmPvSpaceInfo, constants.ST_LVM_VG: _GetLvmVgSpaceInfo, con\
stants.ST_SHARED_FILE: None, constants.ST_GLUSTER: None, constants.ST_\
RADOS: None,}

SshAddNodeInfo

Value:
collections.namedtuple("SshAddNodeInfo", ["uuid", "name", "to_authoriz\
ed_keys", "to_public_keys", "get_public_keys"])

SshRemoveNodeInfo

Value:
collections.namedtuple("SshRemoveNodeInfo", ["uuid", "name", "from_aut\
horized_keys", "from_public_keys", "clear_authorized_keys", "clear_pub\
lic_keys"])