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 the DSA SSH keys according to keyfiles.
source code
 
_SetupSSH(options, cluster_name, node, ssh_port, cl)
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
 
RepairCommand(opts, args) 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: OOB_TIMEOUT_OPT, MAC_PREFIX_OPT, IPOLICY_STD_SPECS_OPT, SHUTDOWN_TIMEOUT_OPT, HV_STATE_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, objects, 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, ERROR_CODES_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, DIAGNOSE_DATA_COLLECTOR_FILENAME_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, SSH_KEY_TYPE_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, SSH_KEY_BITS_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, MAINT_BALANCE_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, MAINT_INTERVAL_OPT, HELPER_STARTUP_TIMEOUT_OPT, OFFLINE_OPT, YES_DOIT_OPT, NEW_CONFD_HMAC_KEY_OPT, UsesRPC, MAINT_BALANCE_THRESHOLD_OPT, INPUT_OPT, ZEROING_TIMEOUT_FIXED_OPT, UIDPOOL_OPT, ALLOC_POLICY_OPT, ArgUnknown, 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, qlang, 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, IPOLICY_MEMORY_RATIO, 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, serializer, 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 the DSA 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, ssh_port, cl)

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
  • ssh_port (int) - Destination node ssh port
  • cl - luxi client

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", constants.ST_SHARED_FILE: "sharedfile", constants.\
ST_GLUSTER: "gluster",}

_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] [--netw\
ork] [--debug] <node_name>", "Add a node to the cluster"), "evacuate":\
(EvacuateNode, ARGS_ONE_NODE, [FORCE_OPT, IALLOCATOR_OPT, IGNORE_SOFT_\
ERRORS_OPT, NEW_SECONDARY_OPT, EARLY_RELEASE_OPT, PRIORITY_OPT, PRIMAR\
...