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]
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
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
 
_PrintGroupedParams(paramsdict, level=1, roman=False)
Print 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
 
_RenewCrypto(new_cluster_cert, new_rapi_cert, rapi_cert_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)
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)
EPO operations.
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...
  _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",}
dictionary with aliases for commands

Imports: os, time, OpenSSL, itertools, opcodes, constants, errors, utils, bootstrap, ssh, objects, uidpool, compat, netutils


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

_PrintGroupedParams(paramsdict, level=1, roman=False)

source code 

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

Parameters:
  • paramsdict (dict of dicts) - {group: {param: value, ...}, ...}
  • level (int) - Level of indention

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

_RenewCrypto(new_cluster_cert, new_rapi_cert, rapi_cert_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_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)

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

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

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

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, NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, NOMODIFY_ETCHOST\
S_OPT, NOMODIFY_SSH_SETUP_OPT, SECONDARY_IP_OPT, VG_NAME_OPT, MAINTAIN\
_NODE_HEALTH_OPT, UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT, DE\
FAULT_IALLOCATOR_OPT, PRIMARY_IP_VERSION_OPT, PREALLOC_WIPE_DISKS_OPT,\
 NODE_PARAMS_OPT, GLOBAL_SHARED_FILEDIR_OPT], "[opts...] <cluster_name\
>", "Initialises a new cluster configuration"), "destroy":(DestroyClus\
...