module documentation

Cluster related commands

Function ActivateMasterIp Activates the master IP.
Function ClusterCopyFile Copy a file from master to some nodes.
Function DeactivateMasterIp Deactivates the master IP.
Function DestroyCluster Destroy the cluster.
Function Epo EPO operations.
Function InitCluster Initialize the cluster.
Function Main Undocumented
Function MasterFailover Failover the master node.
Function MasterPing Checks if the master is alive.
Function QueueOps Queue operations.
Function RedistributeConfig Forces push of the cluster configuration.
Function RenameCluster Rename the cluster.
Function RenewCrypto Renews cluster certificates, keys and secrets.
Function RepairDiskSizes Verify sizes of cluster disks.
Function RunClusterCommand Run a command on some nodes.
Function SearchTags Searches the tags on all the cluster.
Function SetClusterParams Modify the cluster.
Function ShowClusterConfig Shows cluster information.
Function ShowClusterMaster Write name of master node to the standard output.
Function ShowClusterVersion Write version of ganeti software to the standard output.
Function ShowCreateCommand Shows the command that can be used to re-create the cluster.
Function UpgradeGanetiCommand Upgrade a cluster to a new ganeti version.
Function VerifyCluster Verify integrity of cluster, performing various test on nodes.
Function VerifyDisks Verify integrity of cluster disks.
Function WatcherOps Watcher operations.
Constant DATA_COLLECTOR_INTERVAL_OPT Undocumented
Constant FORCE_DISTRIBUTION Undocumented
Constant FORCE_FAILOVER Undocumented
Constant GROUPS_OPT Undocumented
Constant IGNORE_OFFLINE_NODES_FAILOVER Undocumented
Constant ON_OPT Undocumented
Constant RESUME_OPT Undocumented
Constant STRICT_OPT Undocumented
Constant TO_OPT Undocumented
Variable aliases Undocumented
Variable commands Undocumented
Class _RunWhenNodesReachableHelper Helper class to make shared internal state sharing easier.
Function _BuildGanetiPubKeys Recreates the 'ganeti_pub_key' file by polling all nodes.
Function _EpoOff Does the actual power off.
Function _EpoOn Does the actual power on.
Function _ExecuteCommands Execute a list of functions, in reverse order.
Function _FormatDataCollectors Format Grouped parameters (be, nic, disk) by group.
Function _FormatGroupedParams Format Grouped parameters (be, nic, disk) by group.
Function _GetCompressionTools Determine the list of custom compression tools.
Function _GetConfigVersion Determine the version the configuration file currently has.
Function _GetCreateCommand Undocumented
Function _GetDrbdHelper Determine the DRBD usermode helper.
Function _GetEnabledDiskTemplates Determine the list of enabled disk templates.
Function _GetRunning Determine the list of running jobs.
Function _GetVgName Determine the volume group name.
Function _InitDrbdHelper Initialize the DRBD usermode helper.
Function _InitEnabledDiskTemplates Initialize the list of enabled disk templates.
Function _InitVgName Initialize the volume group name.
Function _InstanceStart Puts the instances in the list to desired state.
Function _MaybeInstanceStartup Start the instances conditional based on node_states.
Function _OobPower Puts the node in the list to desired power state.
Function _ReadAndVerifyCert Reads and verifies an X509 certificate.
Function _ReadIntentToUpgrade Read the file documenting the intent to upgrade the cluster.
Function _RenewCrypto Renews cluster certificates, keys and secrets.
Function _RunCommandAndReport Run a command and report its output, iff it failed.
Function _RunWhenNodesReachable Run action_cb when nodes become reachable.
Function _SetGanetiVersionAndEnsure Symlink the active version of ganeti to the given versionstring, and run the ensure-dirs script.
Function _ShowWatcherPause Undocumented
Function _SwitchVersionAndConfig Switch to the new Ganeti version and change the configuration, in correct order.
Function _UpgradeAfterConfigurationChange Carry out the upgrade actions necessary after switching to the new Ganeti version and updating the configuration.
Function _UpgradeBeforeConfigurationChange Carry out all the tasks necessary for an upgrade that happen before the configuration file, or Ganeti version, changes.
Function _VerifyCommand Verify that a given command succeeds on all online nodes.
Function _VerifyCommandRaw Verify that a given command succeeds on all online nodes.
Function _VerifyVersionInstalled Verify that the given version of ganeti is installed on all online nodes.
Function _VersionSpecificDowngrade Perform any additional downrade tasks that are version specific and need to be done just after the configuration downgrade. This function needs to be idempotent, so that it can be redone if the downgrade procedure gets interrupted after changing the configuration.
Function _WriteIntentToUpgrade Write file documenting the intent to upgrade the cluster.
Constant _EPO_PING_INTERVAL Undocumented
Constant _EPO_PING_TIMEOUT Undocumented
Constant _EPO_REACHABLE_TIMEOUT Undocumented
def ActivateMasterIp(opts, args):

Activates the master IP.

def ClusterCopyFile(opts, args):

Copy a file from master to some nodes.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the path of the file to be copied
Returns
intthe desired exit code
def DeactivateMasterIp(opts, args):

Deactivates the master IP.

@RunWithRPC
def DestroyCluster(opts, args):

Destroy the cluster.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def Epo(opts, args, qcl=None, _on_fn=_EpoOn, _off_fn=_EpoOff, _confirm_fn=ConfirmOperation, _stdout_fn=ToStdout, _stderr_fn=ToStderr):

EPO operations.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the subcommand
qclUndocumented
_on_fnUndocumented
_off_fnUndocumented
_confirm_fnUndocumented
_stdout_fnUndocumented
_stderr_fnUndocumented
Returns
intthe desired exit code
@RunWithRPC
def InitCluster(opts, args):

Initialize the cluster.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the desired cluster name
Returns
intthe desired exit code
def Main():

Undocumented

@RunWithRPC
def MasterFailover(opts, args):

Failover the master node.

This command, when run on a non-master node, will cause the current master to cease being master, and the non-master to become new master.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def MasterPing(opts, args):

Checks if the master is alive.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def QueueOps(opts, args):

Queue operations.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the subcommand
Returns
intthe desired exit code
def RedistributeConfig(opts, args):

Forces push of the cluster configuration.

Parameters
optsthe command line options selected by the user
args:listempty list
Returns
intthe desired exit code
def RenameCluster(opts, args):

Rename the cluster.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the new cluster name
Returns
intthe desired exit code
def RenewCrypto(opts, args):

Renews cluster certificates, keys and secrets.

def RepairDiskSizes(opts, args):

Verify sizes of cluster disks.

Parameters
optsthe command line options selected by the user
args:listoptional list of instances to restrict check to
Returns
intthe desired exit code
def RunClusterCommand(opts, args):

Run a command on some nodes.

Parameters
optsthe command line options selected by the user
args:listshould contain the command to be run and its arguments
Returns
intthe desired exit code
def SearchTags(opts, args):

Searches the tags on all the cluster.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the tag pattern
Returns
intthe desired exit code
def SetClusterParams(opts, args):

Modify the cluster.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def ShowClusterConfig(opts, args):

Shows cluster information.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def ShowClusterMaster(opts, args):

Write name of master node to the standard output.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def ShowClusterVersion(opts, args):

Write version of ganeti software to the standard output.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def ShowCreateCommand(opts, args):

Shows the command that can be used to re-create the cluster.

Currently it works only for ipolicy specs.

def UpgradeGanetiCommand(opts, args):

Upgrade a cluster to a new ganeti version.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def VerifyCluster(opts, args):

Verify integrity of cluster, performing various test on nodes.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def VerifyDisks(opts, args):

Verify integrity of cluster disks.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def WatcherOps(opts, args):

Watcher operations.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the subcommand
Returns
intthe desired exit code
DATA_COLLECTOR_INTERVAL_OPT =

Undocumented

Value
cli_option('--data-collector-interval',
           default={},
           type='keyval',
           help='Set collection intervals in seconds of data collectors.')
FORCE_DISTRIBUTION =

Undocumented

Value
cli_option('--yes-do-it',
           dest='yes_do_it',
           help='Unconditionally distribute the configuration, even if the queue
 is drained',
           default=False,
           action='store_true')
FORCE_FAILOVER =

Undocumented

Value
cli_option('--yes-do-it',
           dest='yes_do_it',
           help='Override interactive check for --no-voting',
           default=False,
           action='store_true')
GROUPS_OPT =

Undocumented

Value
cli_option('--groups',
           default=False,
           action='store_true',
           dest='groups',
           help='Arguments are node groups instead of nodes')
IGNORE_OFFLINE_NODES_FAILOVER =

Undocumented

Value
cli_option('--ignore-offline-nodes',
           dest='ignore_offline_nodes',
           help='Ignores offline nodes for master failover voting',
           default=True)
ON_OPT =

Undocumented

Value
cli_option('--on',
           default=False,
           action='store_true',
           dest='on',
           help='Recover from an EPO')
RESUME_OPT =

Undocumented

Value
cli_option('--resume',
           default=False,
           action='store_true',
           help='Resume any pending Ganeti upgrades')
STRICT_OPT =

Undocumented

Value
cli_option('--no-strict',
           default=False,
           dest='no_strict',
           action='store_true',
           help='Do not run group verify in strict mode')
TO_OPT =

Undocumented

Value
cli_option('--to',
           default=None, type='string', help='The Ganeti version to upgrade to')
aliases: dict[str, str] =

Undocumented

commands =

Undocumented

def _BuildGanetiPubKeys(options, pub_key_file=pathutils.SSH_PUB_KEYS, cl=None, get_online_nodes_fn=GetOnlineNodes, get_nodes_ssh_ports_fn=GetNodesSshPorts, get_node_uuids_fn=GetNodeUUIDs, homedir_fn=None):

Recreates the 'ganeti_pub_key' file by polling all nodes.

def _EpoOff(opts, node_list, inst_map):

Does the actual power off.

Parameters
optsThe command line options selected by the user
node_listThe list of nodes to operate on (all need to support OOB)
inst_mapA dict of inst -> nodes mapping
Returns
The desired exit status
def _EpoOn(opts, full_node_list, node_list, inst_map):

Does the actual power on.

Parameters
optsThe command line options selected by the user
full_node_listAll nodes to operate on (includes nodes not supporting OOB)
node_listThe list of nodes to operate on (all need to support OOB)
inst_mapA dict of inst -> nodes mapping
Returns
The desired exit status
def _ExecuteCommands(fns):

Execute a list of functions, in reverse order.

Parameters
fns:list of functions.the functions to be executed.
def _FormatDataCollectors(paramsdict):

Format Grouped parameters (be, nic, disk) by group.

Parameters
paramsdict:dict of dictsresponse of QueryClusterInfo
Returns
dict of dictsparameter grouped by data collector
def _FormatGroupedParams(paramsdict, roman=False):

Format Grouped parameters (be, nic, disk) by group.

Parameters
paramsdict:dict of dicts{group: {param: value, ...}, ...}
romanUndocumented
Returns
dict of dictscopy of the input dictionaries with strings as values
def _GetCompressionTools(opts):

Determine the list of custom compression tools.

def _GetConfigVersion():

Determine the version the configuration file currently has.

Returns
tuple or None(major, minor, revision) if the version can be determined, None otherwise
def _GetCreateCommand(info):

Undocumented

def _GetDrbdHelper(opts, enabled_disk_templates):

Determine the DRBD usermode helper.

def _GetEnabledDiskTemplates(opts):

Determine the list of enabled disk templates.

def _GetRunning():

Determine the list of running jobs.

Returns
listthe number of jobs still running
def _GetVgName(opts, enabled_disk_templates):

Determine the volume group name.

Parameters
optsUndocumented
enabled_disk_templates:list of stringscluster-wide enabled disk-templates
def _InitDrbdHelper(opts, enabled_disk_templates, feedback_fn=ToStdout):

Initialize the DRBD usermode helper.

def _InitEnabledDiskTemplates(opts):

Initialize the list of enabled disk templates.

def _InitVgName(opts, enabled_disk_templates):

Initialize the volume group name.

Parameters
optsUndocumented
enabled_disk_templates:list of stringscluster-wide enabled disk templates
def _InstanceStart(opts, inst_list, start, no_remember=False):

Puts the instances in the list to desired state.

Parameters
optsThe command line options selected by the user
inst_listThe list of instances to operate on
startTrue if they should be started, False for shutdown
no_rememberIf the instance state should be remembered
Returns
The success of the operation (none failed)
def _MaybeInstanceStartup(opts, inst_map, nodes_online, _instance_start_fn=_InstanceStart):

Start the instances conditional based on node_states.

Parameters
optsThe command line options selected by the user
inst_mapA dict of inst -> nodes mapping
nodes_onlineA list of nodes online
_instance_start_fnCallback to start instances (unittest use only)
Returns
Success of the operation on all instances
def _OobPower(opts, node_list, power):

Puts the node in the list to desired power state.

Parameters
optsThe command line options selected by the user
node_listThe list of nodes to operate on
powerTrue if they should be powered on, False otherwise
Returns
The success of the operation (none failed)
def _ReadAndVerifyCert(cert_filename, verify_private_key=False):

Reads and verifies an X509 certificate.

Parameters
cert_filename:stringthe path of the file containing the certificate to verify encoded in PEM format
verify_private_key:boolwhether to verify the private key in addition to the public certificate
Returns
stringa string containing the PEM-encoded certificate.
def _ReadIntentToUpgrade():

Read the file documenting the intent to upgrade the cluster.

Returns
(string, string) or (None, None)(old version, version to upgrade to), if the file exists, and (None, None) otherwise.
def _RenewCrypto(new_cluster_cert, new_rapi_cert, rapi_cert_filename, new_spice_cert, spice_cert_filename, spice_cacert_filename, new_confd_hmac_key, new_cds, cds_filename, force, new_node_cert, new_ssh_keys, ssh_key_type, ssh_key_bits, verbose, debug):

Renews cluster certificates, keys and secrets.

Parameters
new_cluster_cert:boolWhether to generate a new cluster certificate
new_rapi_cert:boolWhether to generate a new RAPI certificate
rapi_cert_filename:stringPath to file containing new RAPI certificate
new_spice_cert:boolWhether to generate a new SPICE certificate
spice_cert_filename:stringPath to file containing new SPICE certificate
spice_cacert_filename:stringPath to file containing the certificate of the CA that signed the SPICE certificate
new_confd_hmac_key:boolWhether to generate a new HMAC key
new_cds:boolWhether to generate a new cluster domain secret
cds_filename:stringPath to file containing new cluster domain secret
force:boolWhether to ask user for confirmation
new_node_cert:boolWhether to generate new node certificates
new_ssh_keys:boolWhether to generate new node SSH keys
ssh_key_type:One of constants.SSHK_ALLThe type of SSH key to be generated
ssh_key_bits:intThe length of the key to be generated
verbose:booleanShow verbose output
debug:booleanShow debug output
def _RunCommandAndReport(cmd):

Run a command and report its output, iff it failed.

Parameters
cmd:listthe command to execute
Returns
boolFalse, if the execution failed.
def _RunWhenNodesReachable(node_list, action_cb, interval):

Run action_cb when nodes become reachable.

Parameters
node_listThe list of nodes to be reachable
action_cbCallback called when a new host is reachable
intervalThe earliest time to retry
def _SetGanetiVersionAndEnsure(versionstring):

Symlink the active version of ganeti to the given versionstring, and run the ensure-dirs script.

Parameters
versionstring:stringUndocumented
Returns
listthe list of nodes where the version change failed
def _ShowWatcherPause(until):

Undocumented

def _SwitchVersionAndConfig(versionstring, downgrade):

Switch to the new Ganeti version and change the configuration, in correct order.

Parameters
versionstring:stringthe version to change to
downgrade:boolTrue, if the configuration should be downgraded
Returns
(bool, list)tupe of a bool indicating success, and a list of additional rollback tasks
def _UpgradeAfterConfigurationChange(oldversion):

Carry out the upgrade actions necessary after switching to the new Ganeti version and updating the configuration.

As this part is run at a time where the new version of Ganeti is already running, no communication should happen via luxi, as this is not a stable interface. Also, as the configuration change is the point of no return, all actions are pushed through, even if some of them fail.

Parameters
oldversion:stringthe version the upgrade started from
Returns
intthe intended return value
def _UpgradeBeforeConfigurationChange(versionstring):

Carry out all the tasks necessary for an upgrade that happen before the configuration file, or Ganeti version, changes.

Parameters
versionstring:stringthe version to upgrade to
Returns
(bool, list)tuple of a bool indicating success and a list of rollback tasks
def _VerifyCommand(cmd):

Verify that a given command succeeds on all online nodes.

As this function is intended to run during upgrades, it is implemented in such a way that it still works, if all Ganeti daemons are down.

Parameters
cmd:lista list of unquoted shell arguments
Returns
listthe list of node names that are online where the command failed.
def _VerifyCommandRaw(command):

Verify that a given command succeeds on all online nodes.

As this function is intended to run during upgrades, it is implemented in such a way that it still works, if all Ganeti daemons are down.

Parameters
commandUndocumented
cmd:stringa bare string to pass to SSH. The caller must do their own shell/ssh escaping.
Returns
listthe list of node names that are online where the command failed.
def _VerifyVersionInstalled(versionstring):

Verify that the given version of ganeti is installed on all online nodes.

Do nothing, if this is the case, otherwise print an appropriate message to stderr.

Parameters
versionstring:stringthe version to check for
Returns
boolTrue, if the version is installed on all online nodes
def _VersionSpecificDowngrade():

Perform any additional downrade tasks that are version specific and need to be done just after the configuration downgrade. This function needs to be idempotent, so that it can be redone if the downgrade procedure gets interrupted after changing the configuration.

Note that this function has to be reset with every version bump.

Returns
True upon success
def _WriteIntentToUpgrade(version):

Write file documenting the intent to upgrade the cluster.

Parameters
version:stringthe version we intent to upgrade to
_EPO_PING_INTERVAL: int =

Undocumented

Value
30
_EPO_PING_TIMEOUT: int =

Undocumented

Value
1
_EPO_REACHABLE_TIMEOUT =

Undocumented

Value
15*60