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]
 
_CheckNoLvmStorageOptDeprecated(opts)
Checks if the legacy option '--no-lvm-storage' is used.
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
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)
Renews cluster certificates, keys and secrets.
source code
 
RenewCrypto(opts, args)
Renews cluster certificates, keys and secrets.
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, cl=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
 
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", ...
  _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: StringIO, os, time, OpenSSL, itertools, ARGS_ONE_INSTANCE, POWER_DELAY_OPT, NEW_RAPI_CERT_OPT, OOB_TIMEOUT_OPT, TO_GROUP_OPT, MAC_PREFIX_OPT, IPOLICY_STD_SPECS_OPT, CONFIRM_OPT, NOSHUTDOWN_OPT, SHUTDOWN_TIMEOUT_OPT, ParseFields, PRIMARY_IP_VERSION_OPT, ARGS_NONE, ARGS_ONE_GROUP, ARGS_MANY_NODES, UsesRPC, ALLOC_POLICY_OPT, GenericListFields, NOVOTING_OPT, INSTANCE_POLICY_OPTS, ArgUnknown, ERROR_CODES_OPT, SPECS_CPU_COUNT_OPT, SPECS_DISK_SIZE_OPT, SECONDARY_IP_OPT, ARGS_ONE_NETWORK, GATEWAY_OPT, REMOVE_INSTANCE_OPT, PrintGenericInfo, IPOLICY_DISK_TEMPLATES, FormatTimestamp, GenerateTable, ABSOLUTE_OPT, IGNORE_SIZE_OPT, COMMON_CREATE_OPTS, READD_OPT, NO_REMEMBER_OPT, SUBMIT_OPTS, ConfirmOperation, SubmitOrSend, RAPI_CERT_OPT, GATEWAY6_OPT, HV_STATE_OPT, ARGS_MANY_NETWORKS, FILESTORE_DIR_OPT, RUNTIME_MEM_OPT, ROMAN_OPT, SEP_OPT, RESERVED_LVS_OPT, USE_EXTERNAL_MIP_SCRIPT, GLOBAL_SHARED_FILEDIR_OPT, FormatPolicyInfo, NOMODIFY_SSH_SETUP_OPT, GenericInstanceCreate, ArgChoice, NODE_FORCE_JOIN_OPT, DRY_RUN_OPT, CAPAB_VM_OPT, NODE_POWERED_OPT, NODE_PLACEMENT_OPT, JobExecutor, FixHvParams, ToStderr, SELECT_OS_OPT, SINGLE_NODE_OPT, ArgExtStorage, ArgOs, SPICE_CACERT_OPT, PrintIPolicyCommand, IGNORE_ERRORS_OPT, AUTO_REPLACE_OPT, HVLIST_OPT, cli_option, AskUser, ENABLED_DISK_TEMPLATES_OPT, DISK_STATE_OPT, USEUNITS_OPT, EARLY_RELEASE_OPT, VERBOSE_OPT, ArgHost, UIDPOOL_OPT, ALL_OPT, CalculateOSNames, OS_OPT, ARGS_ONE_NODE, ArgCommand, FAILURE_ONLY_OPT, ALLOW_FAILOVER_OPT, NOSTART_OPT, SPECS_NIC_COUNT_OPT, OS_SIZE_OPT, DEBUG_OPT, ON_PRIMARY_OPT, JobSubmittedException, SUBMIT_OPT, MASTER_NETMASK_OPT, SPICE_CERT_OPT, NEW_CLUSTER_CERT_OPT, INTERVAL_OPT, ToStdout, FORCE_FILTER_OPT, OSPARAMS_OPT, AddTags, NONICS_OPT, NODE_PARAMS_OPT, ArgNetwork, RunWhileClusterStopped, BLK_OS_OPT, GLOBAL_FILEDIR_OPT, SRC_NODE_OPT, CAPAB_MASTER_OPT, MODIFY_ETCHOSTS_OPT, SPECS_MEM_SIZE_OPT, TAG_SRC_OPT, NOSSH_KEYCHECK_OPT, NET_OPT, IGNORE_FAILURES_OPT, ADD_UIDS_OPT, MASTER_NETDEV_OPT, USE_REPL_NET_OPT, NODEGROUP_OPT, SRC_DIR_OPT, NODRBD_STORAGE_OPT, SYNC_OPT, IDENTIFY_DEFAULTS_OPT, REMOVE_UIDS_OPT, HYPERVISOR_OPT, IGNORE_IPOLICY_OPT, MC_OPT, ONLINE_INST_OPT, IGNORE_SECONDARIES_OPT, SplitNodeOption, NOLVM_STORAGE_OPT, REBOOT_TYPE_OPT, NONPLUS1_OPT, IGNORE_CONSIST_OPT, NOHDR_OPT, NEW_SPICE_CERT_OPT, TAG_ADD_OPT, SPECS_DISK_COUNT_OPT, NONLIVE_OPT, ARGS_ONE_OS, DISK_OPT, PRIMARY_ONLY_OPT, RemoveTags, AUTO_PROMOTE_OPT, ListTags, DEFAULT_IALLOCATOR_OPT, NEW_PRIMARY_OPT, FORCE_VARIANT_OPT, GetOnlineNodes, NETWORK_OPT, TIMEOUT_OPT, NODE_LIST_OPT, GenericList, ON_SECONDARY_OPT, FormatLogMessage, ArgInstance, CLEANUP_OPT, CreateIPolicyFromOpts, MIGRATION_MODE_OPT, NIC_PARAMS_OPT, NOIPCHECK_OPT, ArgJobId, DRBD_HELPER_OPT, DEBUG_SIMERR_OPT, STATIC_OPT, DISK_TEMPLATE_OPT, ARGS_MANY_GROUPS, REASON_OPT, NO_INSTALL_OPT, YES_DOIT_OPT, FORCE_OPT, PRINT_JOBID_OPT, SHOWCMD_OPT, SPLIT_ISPECS_OPTS, ArgGroup, OFFLINE_INST_OPT, NWSYNC_OPT, NOCONFLICTSCHECK_OPT, PRIORITY_OPT, SECONDARY_ONLY_OPT, NEW_CLUSTER_DOMAIN_SECRET_OPT, FormatParamsDictInfo, SubmitOpCode, DRAINED_OPT, ParseTimespec, REMOVE_RESERVED_IPS_OPT, GenericMain, ArgFile, WFSYNC_OPT, NORUNTIME_CHGS_OPT, ArgNode, IGNORE_REMOVE_FAILURES_OPT, CP_SIZE_OPT, ADD_RESERVED_IPS_OPT, CLUSTER_DOMAIN_SECRET_OPT, HID_OS_OPT, SHOW_MACHINE_OPT, ALLOCATABLE_OPT, ARGS_MANY_INSTANCES, PREALLOC_WIPE_DISKS_OPT, NONAMECHECK_OPT, FormatQueryResult, FormatError, GetClient, MAINTAIN_NODE_HEALTH_OPT, ArgSuggest, HVOPTS_OPT, IPOLICY_VCPU_RATIO, OFFLINE_OPT, NETWORK6_OPT, NOMODIFY_ETCHOSTS_OPT, ENABLED_HV_OPT, NEW_SECONDARY_OPT, IGNORE_OFFLINE_OPT, VG_NAME_OPT, DISK_PARAMS_OPT, FIELDS_OPT, DST_NODE_OPT, IALLOCATOR_OPT, NEW_CONFD_HMAC_KEY_OPT, FILESTORE_DRIVER_OPT, INCLUDEDEFAULTS_OPT, STARTUP_PAUSED_OPT, DISKIDX_OPT, BACKEND_OPT, opcodes, constants, errors, utils, bootstrap, ssh, objects, uidpool, compat, netutils, pathutils


Function Details [hide private]

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

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)

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

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, cl=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.


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")

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, NOLVM_STORAGE_O\
PT, NOMODIFY_ETCHOSTS_OPT, NOMODIFY_SSH_SETUP_OPT, SECONDARY_IP_OPT, V\
G_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT, UIDPOOL_OPT, DRBD_HELPER_OPT, NO\
DRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT, PRIMARY_IP_VERSION_OPT, PREA\
LLOC_WIPE_DISKS_OPT, NODE_PARAMS_OPT, GLOBAL_SHARED_FILEDIR_OPT, USE_E\
XTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT, HV_STATE_OPT, DISK_STATE_OPT, ENA\
...