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

Module gnt_node

source code

Node related commands

Classes [hide private]
  ReplyStatus
Class holding a reply status for synchronous confd clients.
Functions [hide private]
 
ConvertStorageType(user_storage_type)
Converts a user storage type to its internal name.
source code
None or string
_TryReadFile(path)
Tries to read a file.
source code
list
_ReadSshKeys(keyfiles, _tostderr_fn=ToStderr)
Reads SSH keys according to keyfiles.
source code
 
_SetupSSH(options, cluster_name, node)
Configures a destination node's SSH daemon.
source code
int
AddNode(opts, args)
Add a node to the cluster.
source code
int
ListNodes(opts, args)
List nodes and their properties.
source code
int
ListNodeFields(opts, args)
List node fields.
source code
int
EvacuateNode(opts, args)
Relocate all secondary instance from a node.
source code
int
FailoverNode(opts, args)
Failover all primary instance on a node.
source code
 
MigrateNode(opts, args)
Migrate all primary instance on a node.
source code
 
_FormatNodeInfo(node_info)
Format node information for cli.PrintGenericInfo().
source code
int
ShowNodeConfig(opts, args)
Show node information.
source code
int
RemoveNode(opts, args)
Remove a node from the cluster.
source code
int
PowercycleNode(opts, args)
Remove a node from the cluster.
source code
int
PowerNode(opts, args)
Change/ask power state of a node.
source code
int
Health(opts, args)
Show health of a node using OOB.
source code
int
ListVolumes(opts, args)
List logical volumes on node(s).
source code
int
ListStorage(opts, args)
List physical volumes on node(s).
source code
int
ModifyStorage(opts, args)
Modify storage volume on a node.
source code
int
RepairStorage(opts, args)
Repairs a storage volume on a node.
source code
int
SetNodeParams(opts, args)
Modifies a node.
source code
int
RestrictedCommand(opts, args)
Runs a remote command on node(s).
source code
int
ListDrbd(opts, args)
Modifies a node.
source code
 
Main() source code
Variables [hide private]
  _LIST_DEF_FIELDS = ["name", "dtotal", "dfree", "mtotal", "mnod...
default list of field for ListNodes
  _LIST_VOL_DEF_FIELDS = ["node", "phys", "vg", "name", "size", ...
Default field list for ListVolumes
  _LIST_STOR_DEF_FIELDS = [constants.SF_NODE, constants.SF_TYPE,...
default list of field for ListStorage
  _LIST_POWER_COMMANDS = ["on", "off", "cycle", "status"]
default list of power commands
  _LIST_STOR_HEADERS = {constants.SF_NODE: "Node", constants.SF_...
headers (and full field list) for ListStorage
  _USER_STORAGE_TYPE = {constants.ST_FILE: "file", constants.ST_...
User-facing storage unit types
  _STORAGE_TYPE_OPT = cli_option("-t", "--storage-type", dest= "...
  _REPAIRABLE_STORAGE_TYPES = [st for st, so in constants.VALID_...
  _MODIFIABLE_STORAGE_TYPES = constants.MODIFIABLE_STORAGE_FIELD...
  _OOB_COMMAND_ASK = compat.UniqueFrozenset([constants.OOB_POWER...
  _ENV_OVERRIDE = compat.UniqueFrozenset(["list"])
  NONODE_SETUP_OPT = cli_option("--no-node-setup", default= True...
  IGNORE_STATUS_OPT = cli_option("--ignore-status", default= Fal...
  commands = {"add":(AddNode, [ArgHost(min= 1, max= 1)], [SECOND...
  aliases = {"show": "info",}
dictionary with aliases for commands

Imports: itertools, errno, 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, cli, bootstrap, opcodes, utils, constants, errors, netutils, pathutils, ssh, compat, confd, confd_client


Function Details [hide private]

_TryReadFile(path)

source code 

Tries to read a file.

If the file is not found, None is returned.

Parameters:
  • path (string) - Filename
Returns: None or string

To Do: Consider adding a generic ENOENT wrapper

_ReadSshKeys(keyfiles, _tostderr_fn=ToStderr)

source code 

Reads SSH keys according to keyfiles.

Parameters:
  • keyfiles (dict) - Dictionary with keys of constants.SSHK_ALL and two-values tuples (private and public key file)
Returns: list
List of three-values tuples (constants.SSHK_ALL, private and public key as strings)

_SetupSSH(options, cluster_name, node)

source code 

Configures a destination node's SSH daemon.

Parameters:
  • options - Command line options @type cluster_name
  • cluster_name - Cluster name
  • node (string) - Destination node name

AddNode(opts, args)

source code 

Add a node to the cluster.

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

ListNodes(opts, args)

source code 

List nodes and their properties.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - nodes to list, or empty for all
Returns: int
the desired exit code

ListNodeFields(opts, args)

source code 

List node fields.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - fields to list, or empty for all
Returns: int
the desired exit code

EvacuateNode(opts, args)

source code 

Relocate all secondary instance from a node.

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

FailoverNode(opts, args)

source code 

Failover all primary instance on a node.

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

ShowNodeConfig(opts, args)

source code 

Show node information.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should either be an empty list, in which case we show information about all nodes, or should contain a list of nodes to be queried for information
Returns: int
the desired exit code

RemoveNode(opts, args)

source code 

Remove a node from the cluster.

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

PowercycleNode(opts, args)

source code 

Remove a node from the cluster.

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

PowerNode(opts, args)

source code 

Change/ask power state of a node.

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

Health(opts, args)

source code 

Show health of a node using OOB.

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

ListVolumes(opts, args)

source code 

List logical volumes on node(s).

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should either be an empty list, in which case we list data for all nodes, or contain a list of nodes to display data only for those
Returns: int
the desired exit code

ListStorage(opts, args)

source code 

List physical volumes on node(s).

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should either be an empty list, in which case we list data for all nodes, or contain a list of nodes to display data only for those
Returns: int
the desired exit code

ModifyStorage(opts, args)

source code 

Modify storage volume on a node.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain 3 items: node name, storage type and volume name
Returns: int
the desired exit code

RepairStorage(opts, args)

source code 

Repairs a storage volume on a node.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain 3 items: node name, storage type and volume name
Returns: int
the desired exit code

SetNodeParams(opts, args)

source code 

Modifies a node.

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

RestrictedCommand(opts, args)

source code 

Runs a remote command on node(s).

Parameters:
  • opts - Command line options selected by user
  • args (list) - Command line arguments
Returns: int
Exit code

ListDrbd(opts, args)

source code 

Modifies a node.

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

Variables Details [hide private]

_LIST_DEF_FIELDS

default list of field for ListNodes

Value:
["name", "dtotal", "dfree", "mtotal", "mnode", "mfree", "pinst_cnt", "\
sinst_cnt",]

_LIST_VOL_DEF_FIELDS

Default field list for ListVolumes

Value:
["node", "phys", "vg", "name", "size", "instance"]

_LIST_STOR_DEF_FIELDS

default list of field for ListStorage

Value:
[constants.SF_NODE, constants.SF_TYPE, constants.SF_NAME, constants.SF\
_SIZE, constants.SF_USED, constants.SF_FREE, constants.SF_ALLOCATABLE,\
]

_LIST_STOR_HEADERS

headers (and full field list) for ListStorage

Value:
{constants.SF_NODE: "Node", constants.SF_TYPE: "Type", constants.SF_NA\
ME: "Name", constants.SF_SIZE: "Size", constants.SF_USED: "Used", cons\
tants.SF_FREE: "Free", constants.SF_ALLOCATABLE: "Allocatable",}

_USER_STORAGE_TYPE

User-facing storage unit types

Value:
{constants.ST_FILE: "file", constants.ST_LVM_PV: "lvm-pv", constants.S\
T_LVM_VG: "lvm-vg",}

_STORAGE_TYPE_OPT

Value:
cli_option("-t", "--storage-type", dest= "user_storage_type", choices=\
 _USER_STORAGE_TYPE.keys(), default= None, metavar= "STORAGE_TYPE", he\
lp= ("Storage type (%s)" % utils.CommaJoin(_USER_STORAGE_TYPE.keys()))\
)

_REPAIRABLE_STORAGE_TYPES

Value:
[st for st, so in constants.VALID_STORAGE_OPERATIONS.iteritems() if co\
nstants.SO_FIX_CONSISTENCY in so]

_MODIFIABLE_STORAGE_TYPES

Value:
constants.MODIFIABLE_STORAGE_FIELDS.keys()

_OOB_COMMAND_ASK

Value:
compat.UniqueFrozenset([constants.OOB_POWER_OFF, constants.OOB_POWER_C\
YCLE,])

NONODE_SETUP_OPT

Value:
cli_option("--no-node-setup", default= True, action= "store_false", de\
st= "node_setup", help= ("Do not make initial SSH setup on remote" " n\
ode (needs to be done manually)"))

IGNORE_STATUS_OPT

Value:
cli_option("--ignore-status", default= False, action= "store_true", de\
st= "ignore_status", help= ("Ignore the Node(s) offline status" " (pot\
entially DANGEROUS)"))

commands

Value:
{"add":(AddNode, [ArgHost(min= 1, max= 1)], [SECONDARY_IP_OPT, READD_O\
PT, NOSSH_KEYCHECK_OPT, NODE_FORCE_JOIN_OPT, NONODE_SETUP_OPT, VERBOSE\
_OPT, NODEGROUP_OPT, PRIORITY_OPT, CAPAB_MASTER_OPT, CAPAB_VM_OPT, NOD\
E_PARAMS_OPT, HV_STATE_OPT, DISK_STATE_OPT], "[-s ip] [--readd] [--no-\
ssh-key-check] [--force-join]" " [--no-node-setup] [--verbose]" " <nod\
e_name>", "Add a node to the cluster"), "evacuate":(EvacuateNode, ARGS\
_ONE_NODE, [FORCE_OPT, IALLOCATOR_OPT, NEW_SECONDARY_OPT, EARLY_RELEAS\
E_OPT, PRIORITY_OPT, PRIMARY_ONLY_OPT, SECONDARY_ONLY_OPT]+ SUBMIT_OPT\
...