Package ganeti :: Package client :: Module gnt_cluster
[hide private]
[frames] | no frames]

Module gnt_cluster

source code

Cluster related commands

Classes [hide private]
  _RunWhenNodesReachableHelper
Helper class to make shared internal state sharing easier.
Functions [hide private]
 
_InitEnabledDiskTemplates(opts)
Initialize the list of enabled disk templates.
source code
 
_InitVgName(opts, enabled_disk_templates)
Initialize the volume group name.
source code
 
_InitDrbdHelper(opts, enabled_disk_templates, feedback_fn=ToStdout)
Initialize the DRBD usermode helper.
source code
int
InitCluster(opts, args)
Initialize the cluster.
source code
int
DestroyCluster(opts, args)
Destroy the cluster.
source code
int
RenameCluster(opts, args)
Rename the cluster.
source code
 
ActivateMasterIp(opts, args)
Activates the master IP.
source code
 
DeactivateMasterIp(opts, args)
Deactivates the master IP.
source code
int
RedistributeConfig(opts, args)
Forces push of the cluster configuration.
source code
int
ShowClusterVersion(opts, args)
Write version of ganeti software to the standard output.
source code
int
ShowClusterMaster(opts, args)
Write name of master node to the standard output.
source code
dict of dicts
_FormatGroupedParams(paramsdict, roman=False)
Format Grouped parameters (be, nic, disk) by group.
source code
dict of dicts
_FormatDataCollectors(paramsdict)
Format Grouped parameters (be, nic, disk) by group.
source code
int
ShowClusterConfig(opts, args)
Shows cluster information.
source code
int
ClusterCopyFile(opts, args)
Copy a file from master to some nodes.
source code
int
RunClusterCommand(opts, args)
Run a command on some nodes.
source code
int
VerifyCluster(opts, args)
Verify integrity of cluster, performing various test on nodes.
source code
int
VerifyDisks(opts, args)
Verify integrity of cluster disks.
source code
int
RepairDiskSizes(opts, args)
Verify sizes of cluster disks.
source code
int
MasterFailover(opts, args)
Failover the master node.
source code
int
MasterPing(opts, args)
Checks if the master is alive.
source code
int
SearchTags(opts, args)
Searches the tags on all the cluster.
source code
string
_ReadAndVerifyCert(cert_filename, verify_private_key=False)
Reads and verifies an X509 certificate.
source code
 
_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, verbose, debug)
Renews cluster certificates, keys and secrets.
source code
 
_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.
source code
 
RenewCrypto(opts, args)
Renews cluster certificates, keys and secrets.
source code
 
_GetEnabledDiskTemplates(opts)
Determine the list of enabled disk templates.
source code
 
_GetVgName(opts, enabled_disk_templates)
Determine the volume group name.
source code
 
_GetDrbdHelper(opts, enabled_disk_templates)
Determine the DRBD usermode helper.
source code
 
_GetCompressionTools(opts)
Determine the list of custom compression tools.
source code
int
SetClusterParams(opts, args)
Modify the cluster.
source code
int
QueueOps(opts, args)
Queue operations.
source code
 
_ShowWatcherPause(until) source code
int
WatcherOps(opts, args)
Watcher operations.
source code
 
_OobPower(opts, node_list, power)
Puts the node in the list to desired power state.
source code
 
_InstanceStart(opts, inst_list, start, no_remember=False)
Puts the instances in the list to desired state.
source code
 
_RunWhenNodesReachable(node_list, action_cb, interval)
Run action_cb when nodes become reachable.
source code
 
_MaybeInstanceStartup(opts, inst_map, nodes_online, _instance_start_fn=_InstanceStart)
Start the instances conditional based on node_states.
source code
 
_EpoOn(opts, full_node_list, node_list, inst_map)
Does the actual power on.
source code
 
_EpoOff(opts, node_list, inst_map)
Does the actual power off.
source code
int
Epo(opts, args, qcl=None, _on_fn=_EpoOn, _off_fn=_EpoOff, _confirm_fn=ConfirmOperation, _stdout_fn=ToStdout, _stderr_fn=ToStderr)
EPO operations.
source code
 
_GetCreateCommand(info) source code
 
ShowCreateCommand(opts, args)
Shows the command that can be used to re-create the cluster.
source code
bool
_RunCommandAndReport(cmd)
Run a command and report its output, iff it failed.
source code
list
_VerifyCommand(cmd)
Verify that a given command succeeds on all online nodes.
source code
bool
_VerifyVersionInstalled(versionstring)
Verify that the given version of ganeti is installed on all online nodes.
source code
list
_GetRunning()
Determine the list of running jobs.
source code
list
_SetGanetiVersion(versionstring)
Set the active version of ganeti to the given versionstring
source code
 
_ExecuteCommands(fns)
Execute a list of functions, in reverse order.
source code
tuple or None
_GetConfigVersion()
Determine the version the configuration file currently has.
source code
(string, string) or (None, None)
_ReadIntentToUpgrade()
Read the file documenting the intent to upgrade the cluster.
source code
 
_WriteIntentToUpgrade(version)
Write file documenting the intent to upgrade the cluster.
source code
(bool, list)
_UpgradeBeforeConfigurationChange(versionstring)
Carry out all the tasks necessary for an upgrade that happen before the configuration file, or Ganeti version, changes.
source code
 
_VersionSpecificDowngrade()
Perform any additional downrade tasks that are version specific and need to be done just after the configuration downgrade.
source code
(bool, list)
_SwitchVersionAndConfig(versionstring, downgrade)
Switch to the new Ganeti version and change the configuration, in correct order.
source code
int
_UpgradeAfterConfigurationChange(oldversion)
Carry out the upgrade actions necessary after switching to the new Ganeti version and updating the configuration.
source code
int
UpgradeGanetiCommand(opts, args)
Upgrade a cluster to a new ganeti version.
source code
 
Main() source code
Variables [hide private]
  ON_OPT = cli_option("--on", default= False, action= "store_tru...
  GROUPS_OPT = cli_option("--groups", default= False, action= "s...
  FORCE_FAILOVER = cli_option("--yes-do-it", dest= "yes_do_it", ...
  FORCE_DISTRIBUTION = cli_option("--yes-do-it", dest= "yes_do_i...
  TO_OPT = cli_option("--to", default= None, type= "string", hel...
  RESUME_OPT = cli_option("--resume", default= False, action= "s...
  DATA_COLLECTOR_INTERVAL_OPT = cli_option("--data-collector-int...
  _EPO_PING_INTERVAL = 30
  _EPO_PING_TIMEOUT = 1
  _EPO_REACHABLE_TIMEOUT = 15* 60
  commands = {"init":(InitCluster, [ArgHost(min= 1, max= 1)], [B...
  aliases = {"masterfailover": "master-failover", "show": "info",}
dictionary with aliases for commands

Imports: OpenSSL, tempfile, OOB_TIMEOUT_OPT, MAC_PREFIX_OPT, IPOLICY_STD_SPECS_OPT, SHUTDOWN_TIMEOUT_OPT, ARGS_ONE_GROUP, ARGS_MANY_NODES, IGNORE_REMOVE_FAILURES_OPT, NWSYNC_OPT, IDENTIFY_DEFAULTS_OPT, FormatParamsDictInfo, FormatTimestamp, DEFAULT_IALLOCATOR_PARAMS_OPT, RAPI_CERT_OPT, AUTO_PROMOTE_OPT, RESERVED_LVS_OPT, FormatPolicyInfo, GLOBAL_SHARED_FILEDIR_OPT, MAINTAIN_NODE_HEALTH_OPT, shlex, DRY_RUN_OPT, ARGS_MANY_FILTERS, NIC_PARAMS_OPT, PrintIPolicyCommand, AUTO_REPLACE_OPT, USEUNITS_OPT, NOMODIFY_ETCHOSTS_OPT, VERBOSE_OPT, NEW_NODE_CERT_OPT, HOTPLUG_OPT, GenerateTable, ARGS_ONE_NODE, ALLOW_FAILOVER_OPT, NOSTART_OPT, INSTANCE_COMMUNICATION_NETWORK_OPT, SPECS_NIC_COUNT_OPT, MASTER_NETMASK_OPT, SPICE_CERT_OPT, INTERVAL_OPT, ToStdout, OSPARAMS_OPT, StringIO, RQL_OPT, StdioJobPollReportCb, CAPAB_MASTER_OPT, MODIFY_ETCHOSTS_OPT, SPECS_MEM_SIZE_OPT, TAG_SRC_OPT, NODEGROUP_OPT, SYNC_OPT, ONLINE_INST_OPT, TableColumn, NONPLUS1_OPT, NEW_SSH_KEY_OPT, JobSubmittedException, ARGS_ONE_OS, PollJob, NETWORK_OPT, TIMEOUT_OPT, ON_SECONDARY_OPT, MIGRATION_MODE_OPT, REMOVE_INSTANCE_OPT, SEQUENTIAL_OPT, ZEROING_TIMEOUT_PER_MIB_OPT, DISK_TEMPLATE_OPT, REASON_OPT, NO_INSTALL_OPT, DEFAULT_IALLOCATOR_OPT, NOCONFLICTSCHECK_OPT, SubmitOpCode, LONG_SLEEP_OPT, JobPollReportCbBase, ArgNode, CP_SIZE_OPT, ALLOCATABLE_OPT, PREALLOC_WIPE_DISKS_OPT, IPOLICY_VCPU_RATIO, GetClient, EXT_PARAMS_OPT, ENABLED_HV_OPT, PrintGenericInfo, FIELDS_OPT, GLOBAL_GLUSTER_FILEDIR_OPT, INCLUDEDEFAULTS_OPT, ARGS_ONE_INSTANCE, IPOLICY_SPINDLE_RATIO, IPOLICY_DISK_TEMPLATES, JobPollCbBase, NO_REMEMBER_OPT, NOVOTING_OPT, SPECS_CPU_COUNT_OPT, SECONDARY_IP_OPT, NETWORK6_OPT, GenericPollJob, ABSOLUTE_OPT, READD_OPT, BACKEND_OPT, FormatTable, FILESTORE_DIR_OPT, OSPARAMS_PRIVATE_OPT, NONAMECHECK_OPT, NODE_POWERED_OPT, TAG_ADD_OPT, ArgOs, HVLIST_OPT, CONFIRM_OPT, ALL_OPT, CalculateOSNames, ENABLED_USER_SHUTDOWN_OPT, FAILURE_ONLY_OPT, ENABLED_DISK_TEMPLATES_OPT, SUBMIT_OPT, GATEWAY_OPT, ADD_UIDS_OPT, logging, IPOLICY_STD_SPECS_STR, NODE_PARAMS_OPT, SPLIT_ISPECS_OPTS, GLOBAL_FILEDIR_OPT, NOSHUTDOWN_OPT, TISPECS_CLUSTER_TYPES, NET_OPT, IGNORE_FAILURES_OPT, SRC_DIR_OPT, REMOVE_UIDS_OPT, HYPERVISOR_OPT, MC_OPT, NODE_FORCE_JOIN_OPT, IGNORE_CONSIST_OPT, RunWhileDaemonsStopped, STATIC_OPT, NONLIVE_OPT, DISK_OPT, REMOVE_RESERVED_IPS_OPT, COMPRESS_OPT, FILESTORE_DRIVER_OPT, CreateIPolicyFromOpts, ArgJobId, ConfirmOperation, HELPER_SHUTDOWN_TIMEOUT_OPT, SHOWCMD_OPT, ArgGroup, OFFLINE_INST_OPT, ListTags, NEW_CLUSTER_DOMAIN_SECRET_OPT, COMMON_OPTS, ParseTimespec, ZERO_FREE_SPACE_OPT, ArgFilter, RUNTIME_MEM_OPT, HID_OS_OPT, NOHDR_OPT, ZEROING_IMAGE_OPT, TISPECS_GROUP_TYPES, VG_NAME_OPT, SubmitOpCodeToDrainedQueue, IALLOCATOR_OPT, STARTUP_PAUSED_OPT, DISKIDX_OPT, TO_GROUP_OPT, POWER_DELAY_OPT, OPT_COMPL_ALL, IGNORE_SECONDARIES_OPT, GenericList, CLEANUP_OPT, GetNodeUUIDs, HOTPLUG_IF_POSSIBLE_OPT, COMMON_CREATE_OPTS, GenericInstanceCreate, ArgChoice, CAPAB_VM_OPT, NODE_PLACEMENT_OPT, FixHvParams, ToStderr, ganeti, ArgExtStorage, FORCE_VARIANT_OPT, AskUser, CLUSTER_DOMAIN_SECRET_OPT, DISK_STATE_OPT, TitledHelpFormatter, ARGS_NONE, IGNORE_SIZE_OPT, SetGenericOpcodeOpts, OS_SIZE_OPT, ARGS_ONE_FILTER, ParseFields, HV_STATE_OPT, ArgNetwork, itertools, SRC_NODE_OPT, NOSSH_KEYCHECK_OPT, INSTANCE_POLICY_OPTS, MASTER_NETDEV_OPT, NOMODIFY_SSH_SETUP_OPT, INSTANCE_COMMUNICATION_OPT, IGNORE_OFFLINE_OPT, IGNORE_ERRORS_OPT, EARLY_RELEASE_OPT, FormatResultError, SplitNodeOption, NEW_SPICE_CERT_OPT, SPECS_DISK_COUNT_OPT, FORCE_FAILOVER_OPT, PRIMARY_ONLY_OPT, RemoveTags, NEW_PRIMARY_OPT, ArgInstance, COMMIT_OPT, MAX_TRACK_OPT, NONICS_OPT, SELECT_OS_OPT, FORCE_OPT, PRINT_JOBID_OPT, PRIORITY_OPT, DRAINED_OPT, IGNORE_SOFT_ERRORS_OPT, VERIFY_CLUTTER_OPT, PRIMARY_IP_VERSION_OPT, NODEGROUP_OPT_NAME, GetNodesSshPorts, SHOW_MACHINE_OPT, sys, FormatQueryResult, HELPER_STARTUP_TIMEOUT_OPT, OFFLINE_OPT, YES_DOIT_OPT, NEW_CONFD_HMAC_KEY_OPT, UsesRPC, ZEROING_TIMEOUT_FIXED_OPT, UIDPOOL_OPT, ALLOC_POLICY_OPT, ArgUnknown, ERROR_CODES_OPT, SPECS_DISK_SIZE_OPT, ARGS_ONE_NETWORK, DEBUG_SIMERR_OPT, textwrap, SUBMIT_OPTS, ROMAN_OPT, ARGS_MANY_NETWORKS, rpcerr, SEP_OPT, USE_EXTERNAL_MIP_SCRIPT, rpc, TRANSPORT_COMPRESSION_OPT, JobExecutor, SINGLE_NODE_OPT, INSTALL_IMAGE_OPT, SPICE_CACERT_OPT, OSPARAMS_SECRET_OPT, cli_option, HVOPTS_OPT, NEW_RAPI_CERT_OPT, ArgHost, GenericListFields, ParseNicOption, ArgCommand, DEBUG_OPT, ON_PRIMARY_OPT, NEW_CLUSTER_CERT_OPT, AddTags, RunWhileClusterStopped, BLK_OS_OPT, ENABLED_DATA_COLLECTORS_OPT, os, OS_OPT, IGNORE_HVVERSIONS_OPT, USE_REPL_NET_OPT, SendJob, errno, REBOOT_TYPE_OPT, ToStdoutAndLoginfo, IGNORE_IPOLICY_OPT, GATEWAY6_OPT, FORTHCOMING_OPT, SECONDARY_ONLY_OPT, GetOnlineNodes, NODE_LIST_OPT, NOIPCHECK_OPT, IPOLICY_BOUNDS_SPECS_STR, DRBD_HELPER_OPT, COMPRESSION_TOOLS_OPT, OptionParser, ARGS_MANY_GROUPS, FormatLogMessage, GenericMain, ArgFile, WFSYNC_OPT, NORUNTIME_CHGS_OPT, ADD_RESERVED_IPS_OPT, ARGS_MANY_INSTANCES, FORCE_FILTER_OPT, FormatError, ArgSuggest, SubmitOrSend, NEW_SECONDARY_OPT, DISK_PARAMS_OPT, DST_NODE_OPT, time, FeedbackFnJobPollReportCb, bootstrap, compat, constants, config, errors, netutils, objects, opcodes, pathutils, qlang, serializer, ssconf, ssh, uidpool, utils, base


Function Details [hide private]

_InitVgName(opts, enabled_disk_templates)

source code 

Initialize the volume group name.

Parameters:
  • enabled_disk_templates (list of strings) - cluster-wide enabled disk templates

InitCluster(opts, args)

source code 

Initialize the cluster.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain only one element, the desired cluster name
Returns: int
the desired exit code
Decorators:
  • @UsesRPC

DestroyCluster(opts, args)

source code 

Destroy the cluster.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code
Decorators:
  • @UsesRPC

RenameCluster(opts, args)

source code 

Rename the cluster.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain only one element, the new cluster name
Returns: int
the desired exit code

RedistributeConfig(opts, args)

source code 

Forces push of the cluster configuration.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - empty list
Returns: int
the desired exit code

ShowClusterVersion(opts, args)

source code 

Write version of ganeti software to the standard output.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code

ShowClusterMaster(opts, args)

source code 

Write name of master node to the standard output.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code

_FormatGroupedParams(paramsdict, roman=False)

source code 

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

Parameters:
  • paramsdict (dict of dicts) - {group: {param: value, ...}, ...}
Returns: dict of dicts
copy of the input dictionaries with strings as values

_FormatDataCollectors(paramsdict)

source code 

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

Parameters:
  • paramsdict (dict of dicts) - response of QueryClusterInfo
Returns: dict of dicts
parameter grouped by data collector

ShowClusterConfig(opts, args)

source code 

Shows cluster information.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code

ClusterCopyFile(opts, args)

source code 

Copy a file from master to some nodes.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain only one element, the path of the file to be copied
Returns: int
the desired exit code

RunClusterCommand(opts, args)

source code 

Run a command on some nodes.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain the command to be run and its arguments
Returns: int
the desired exit code

VerifyCluster(opts, args)

source code 

Verify integrity of cluster, performing various test on nodes.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code

VerifyDisks(opts, args)

source code 

Verify integrity of cluster disks.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code

RepairDiskSizes(opts, args)

source code 

Verify sizes of cluster disks.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - optional list of instances to restrict check to
Returns: int
the desired exit code

MasterFailover(opts, args)

source code 

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:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code
Decorators:
  • @UsesRPC

MasterPing(opts, args)

source code 

Checks if the master is alive.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code

SearchTags(opts, args)

source code 

Searches the tags on all the cluster.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain only one element, the tag pattern
Returns: int
the desired exit code

_ReadAndVerifyCert(cert_filename, verify_private_key=False)

source code 

Reads and verifies an X509 certificate.

Parameters:
  • cert_filename (string) - the path of the file containing the certificate to verify encoded in PEM format
  • verify_private_key (bool) - whether to verify the private key in addition to the public certificate
Returns: string
a string containing the PEM-encoded certificate.

_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, verbose, debug)

source code 

Renews cluster certificates, keys and secrets.

Parameters:
  • new_cluster_cert (bool) - Whether to generate a new cluster certificate
  • new_rapi_cert (bool) - Whether to generate a new RAPI certificate
  • rapi_cert_filename (string) - Path to file containing new RAPI certificate
  • new_spice_cert (bool) - Whether to generate a new SPICE certificate
  • spice_cert_filename (string) - Path to file containing new SPICE certificate
  • spice_cacert_filename (string) - Path to file containing the certificate of the CA that signed the SPICE certificate
  • new_confd_hmac_key (bool) - Whether to generate a new HMAC key
  • new_cds (bool) - Whether to generate a new cluster domain secret
  • cds_filename (string) - Path to file containing new cluster domain secret
  • force (bool) - Whether to ask user for confirmation
  • new_node_cert (bool) - Whether to generate new node certificates
  • new_ssh_keys (bool) - Whether to generate new node SSH keys
  • verbose (boolean) - show verbose output
  • debug (boolean) - show debug output

_GetVgName(opts, enabled_disk_templates)

source code 

Determine the volume group name.

Parameters:
  • enabled_disk_templates (list of strings) - cluster-wide enabled disk-templates

SetClusterParams(opts, args)

source code 

Modify the cluster.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code

QueueOps(opts, args)

source code 

Queue operations.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain only one element, the subcommand
Returns: int
the desired exit code

WatcherOps(opts, args)

source code 

Watcher operations.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain only one element, the subcommand
Returns: int
the desired exit code

_OobPower(opts, node_list, power)

source code 

Puts the node in the list to desired power state.

Parameters:
  • opts - The command line options selected by the user
  • node_list - The list of nodes to operate on
  • power - True if they should be powered on, False otherwise
Returns:
The success of the operation (none failed)

_InstanceStart(opts, inst_list, start, no_remember=False)

source code 

Puts the instances in the list to desired state.

Parameters:
  • opts - The command line options selected by the user
  • inst_list - The list of instances to operate on
  • start - True if they should be started, False for shutdown
  • no_remember - If the instance state should be remembered
Returns:
The success of the operation (none failed)

_RunWhenNodesReachable(node_list, action_cb, interval)

source code 

Run action_cb when nodes become reachable.

Parameters:
  • node_list - The list of nodes to be reachable
  • action_cb - Callback called when a new host is reachable
  • interval - The earliest time to retry

_MaybeInstanceStartup(opts, inst_map, nodes_online, _instance_start_fn=_InstanceStart)

source code 

Start the instances conditional based on node_states.

Parameters:
  • opts - The command line options selected by the user
  • inst_map - A dict of inst -> nodes mapping
  • nodes_online - A list of nodes online
  • _instance_start_fn - Callback to start instances (unittest use only)
Returns:
Success of the operation on all instances

_EpoOn(opts, full_node_list, node_list, inst_map)

source code 

Does the actual power on.

Parameters:
  • opts - The command line options selected by the user
  • full_node_list - All nodes to operate on (includes nodes not supporting OOB)
  • node_list - The list of nodes to operate on (all need to support OOB)
  • inst_map - A dict of inst -> nodes mapping
Returns:
The desired exit status

_EpoOff(opts, node_list, inst_map)

source code 

Does the actual power off.

Parameters:
  • opts - The command line options selected by the user
  • node_list - The list of nodes to operate on (all need to support OOB)
  • inst_map - A dict of inst -> nodes mapping
Returns:
The desired exit status

Epo(opts, args, qcl=None, _on_fn=_EpoOn, _off_fn=_EpoOff, _confirm_fn=ConfirmOperation, _stdout_fn=ToStdout, _stderr_fn=ToStderr)

source code 

EPO operations.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain only one element, the subcommand
Returns: int
the desired exit code

ShowCreateCommand(opts, args)

source code 

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

Currently it works only for ipolicy specs.

_RunCommandAndReport(cmd)

source code 

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

Parameters:
  • cmd (list) - the command to execute
Returns: bool
False, if the execution failed.

_VerifyCommand(cmd)

source code 

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 (list) - the command to execute
Returns: list
the list of node names that are online where the command failed.

_VerifyVersionInstalled(versionstring)

source code 

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 (string) - the version to check for
Returns: bool
True, if the version is installed on all online nodes

_GetRunning()

source code 

Determine the list of running jobs.

Returns: list
the number of jobs still running

_SetGanetiVersion(versionstring)

source code 

Set the active version of ganeti to the given versionstring

Parameters:
  • versionstring (string)
Returns: list
the list of nodes where the version change failed

_ExecuteCommands(fns)

source code 

Execute a list of functions, in reverse order.

Parameters:
  • fns (list of functions.) - the functions to be executed.

_GetConfigVersion()

source code 

Determine the version the configuration file currently has.

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

_ReadIntentToUpgrade()

source code 

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.

_WriteIntentToUpgrade(version)

source code 

Write file documenting the intent to upgrade the cluster.

Parameters:
  • version (string) - the version we intent to upgrade to

_UpgradeBeforeConfigurationChange(versionstring)

source code 

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

Parameters:
  • versionstring (string) - the version to upgrade to
Returns: (bool, list)
tuple of a bool indicating success and a list of rollback tasks

_VersionSpecificDowngrade()

source code 

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

_SwitchVersionAndConfig(versionstring, downgrade)

source code 

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

Parameters:
  • versionstring (string) - the version to change to
  • downgrade (bool) - True, if the configuration should be downgraded
Returns: (bool, list)
tupe of a bool indicating success, and a list of additional rollback tasks

_UpgradeAfterConfigurationChange(oldversion)

source code 

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 trough, even if some of them fail.

Parameters:
  • oldversion (string) - the version the upgrade started from
Returns: int
the intended return value

UpgradeGanetiCommand(opts, args)

source code 

Upgrade a cluster to a new ganeti version.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code

Variables Details [hide private]

ON_OPT

Value:
cli_option("--on", default= False, action= "store_true", dest= "on", h\
elp= "Recover from an EPO")

GROUPS_OPT

Value:
cli_option("--groups", default= False, action= "store_true", dest= "gr\
oups", help= "Arguments are node groups instead of nodes")

FORCE_FAILOVER

Value:
cli_option("--yes-do-it", dest= "yes_do_it", help= "Override interacti\
ve check for --no-voting", default= False, action= "store_true")

FORCE_DISTRIBUTION

Value:
cli_option("--yes-do-it", dest= "yes_do_it", help= "Unconditionally di\
stribute the" " configuration, even if the queue" " is drained", defau\
lt= False, action= "store_true")

TO_OPT

Value:
cli_option("--to", default= None, type= "string", help= "The Ganeti ve\
rsion to upgrade to")

RESUME_OPT

Value:
cli_option("--resume", default= False, action= "store_true", help= "Re\
sume any pending Ganeti upgrades")

DATA_COLLECTOR_INTERVAL_OPT

Value:
cli_option("--data-collector-interval", default= {}, type= "keyval", h\
elp= "Set collection intervals in seconds of data collectors.")

commands

Value:
{"init":(InitCluster, [ArgHost(min= 1, max= 1)], [BACKEND_OPT, CP_SIZE\
_OPT, ENABLED_HV_OPT, GLOBAL_FILEDIR_OPT, HVLIST_OPT, MAC_PREFIX_OPT, \
MASTER_NETDEV_OPT, MASTER_NETMASK_OPT, NIC_PARAMS_OPT, NOMODIFY_ETCHOS\
TS_OPT, NOMODIFY_SSH_SETUP_OPT, SECONDARY_IP_OPT, VG_NAME_OPT, MAINTAI\
N_NODE_HEALTH_OPT, UIDPOOL_OPT, DRBD_HELPER_OPT, DEFAULT_IALLOCATOR_OP\
T, DEFAULT_IALLOCATOR_PARAMS_OPT, PRIMARY_IP_VERSION_OPT, PREALLOC_WIP\
E_DISKS_OPT, NODE_PARAMS_OPT, GLOBAL_SHARED_FILEDIR_OPT, USE_EXTERNAL_\
MIP_SCRIPT, DISK_PARAMS_OPT, HV_STATE_OPT, DISK_STATE_OPT, ENABLED_DIS\
...