Module gnt_instance
source code
Instance related commands
list
|
|
|
|
|
|
int
|
|
int
|
|
|
|
int
|
|
int
|
|
int
|
|
int
|
|
int
|
|
int
|
|
int
|
|
int
|
|
|
|
|
|
|
|
int
|
|
int
|
|
int
|
|
int
|
|
int
|
|
|
|
|
_FormatDiskDetails(dev_type,
dev,
roman)
Formats the logical_id of a disk. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
list of tuples
|
|
|
_ParseExtStorageParams(params)
Parses the disk params for ExtStorage conversions. |
source code
|
|
|
_ParseDiskSizes(mods)
Parses disk sizes in parameters. |
source code
|
|
int
|
|
|
ChangeGroup(opts,
args)
Moves an instance to another group. |
source code
|
|
|
|
|
_EXPAND_CLUSTER = "cluster"
|
|
_EXPAND_NODES_BOTH = "nodes"
|
|
_EXPAND_NODES_PRI = "nodes-pri"
|
|
_EXPAND_NODES_SEC = "nodes-sec"
|
|
_EXPAND_NODES_BOTH_BY_TAGS = "nodes-by-tags"
|
|
_EXPAND_NODES_PRI_BY_TAGS = "nodes-pri-by-tags"
|
|
_EXPAND_NODES_SEC_BY_TAGS = "nodes-sec-by-tags"
|
|
_EXPAND_INSTANCES = "instances"
|
|
_EXPAND_INSTANCES_BY_TAGS = "instances-by-tags"
|
|
_EXPAND_NODES_TAGS_MODES = compat.UniqueFrozenset([_EXPAND_NOD...
|
|
_LIST_DEF_FIELDS = ["name", "hypervisor", "os", "pnode", "stat...
default list of options for ListInstances
|
|
_MISSING = object()
|
|
_ENV_OVERRIDE = compat.UniqueFrozenset(["list"])
|
|
_INST_DATA_VAL = ht.TListOf(ht.TDict)
|
|
m_force_multi = cli_option("--force-multiple", dest= "force_mu...
|
|
m_pri_node_opt = cli_option("--primary", dest= "multi_mode", h...
|
|
m_sec_node_opt = cli_option("--secondary", dest= "multi_mode",...
|
|
m_node_opt = cli_option("--node", dest= "multi_mode", help= "F...
|
|
m_clust_opt = cli_option("--all", dest= "multi_mode", help= "S...
|
|
m_inst_opt = cli_option("--instance", dest= "multi_mode", help...
|
|
m_node_tags_opt = cli_option("--node-tags", dest= "multi_mode"...
|
|
m_pri_node_tags_opt = cli_option("--pri-node-tags", dest= "mul...
|
|
m_sec_node_tags_opt = cli_option("--sec-node-tags", dest= "mul...
|
|
m_inst_tags_opt = cli_option("--tags", dest= "multi_mode", hel...
|
|
add_opts = [FORTHCOMING_OPT, COMMIT_OPT, NOSTART_OPT, OS_OPT, ...
|
|
commands = {"add":(AddInstance, [ArgHost(min= 1, max= 1)], COM...
|
|
aliases = {"start": "startup", "stop": "shutdown", "show": "in...
dictionary with aliases for commands
|
Imports:
copy,
simplejson,
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,
pathutils,
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,
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,
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,
opcodes,
constants,
compat,
utils,
errors,
netutils,
ssh,
objects,
ht
_ExpandMultiNames(mode,
names,
client=None)
| source code
|
Expand the given names using the passed mode.
For _EXPAND_CLUSTER, all instances will be returned. For
_EXPAND_NODES_PRI/SEC, all instances having those nodes as
primary/secondary will be returned. For _EXPAND_NODES_BOTH, all instances
having those nodes as either primary or secondary will be returned. For
_EXPAND_INSTANCES, the given instances will be returned.
- Parameters:
- Returns: list
- the list of names after the expansion
- Raises:
|
Check for and ensure the given instance names exist.
This function will raise an OpPrereqError in case they don't exist.
Otherwise it will exit cleanly.
- Parameters:
client (ganeti.luxi.Client) - the client to use for the query
names (list) - the list of instance names to query
- Raises:
|
Generic multi-instance operations.
The will return a wrapper that processes the options and arguments
given, and uses the passed function to build the opcode needed for the
specific operation. Thus all the generic loop/confirmation code is
abstracted into this function.
|
List instances and their properties.
- Parameters:
opts - the command line options selected by the user
args (list) - should be an empty list
- Returns: int
- the desired exit code
|
List instance 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
|
Create instances using a definition file.
This function reads a json file with opcodes.OpInstanceCreate serialisations.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain one element, the json filename
- Returns: int
- the desired exit code
|
Reinstall an instance.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the name of the instance to be
reinstalled
- Returns: int
- the desired exit code
|
Remove an instance.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the name of the instance to be
removed
- Returns: int
- the desired exit code
|
Rename an instance.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain two elements, the old and the new instance names
- Returns: int
- the desired exit code
|
Activate an instance's disks.
This serves two purposes:
-
it allows (as long as the instance is not running) mounting the disks
and modifying them from the node
-
it repairs inactive secondary drbds
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the instance name
- Returns: int
- the desired exit code
|
Deactivate an instance's disks.
This function takes the instance name, looks for its primary node and
the tries to shutdown its block devices on that node.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the instance name
- Returns: int
- the desired exit code
|
Recreate an instance's disks.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the instance name
- Returns: int
- the desired exit code
|
Grow an instance's disks.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain three elements, the target instance name, the
target disk id, and the target growth
- Returns: int
- the desired exit code
|
Startup instances.
This returns the opcode to start an instance, and its decorator will
wrap this into a loop starting all desired instances.
- Parameters:
name - the name of the instance to act on
opts - the command line options selected by the user
- Returns:
- the opcode needed for the operation
|
Reboot instance(s).
This returns the opcode to reboot an instance, and its decorator will
wrap this into a loop rebooting all desired instances.
- Parameters:
name - the name of the instance to act on
opts - the command line options selected by the user
- Returns:
- the opcode needed for the operation
|
Shutdown an instance.
This returns the opcode to shutdown an instance, and its decorator
will wrap this into a loop shutting down all desired instances.
- Parameters:
name - the name of the instance to act on
opts - the command line options selected by the user
- Returns:
- the opcode needed for the operation
|
Replace the disks of an instance
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the instance name
- Returns: int
- the desired exit code
|
Failover an instance.
The failover is done by shutting it down on its present node and
starting it on the secondary.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the instance name
- Returns: int
- the desired exit code
|
Migrate an instance.
The migrate is done without shutdown.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the instance name
- Returns: int
- the desired exit code
|
Move an instance.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the instance name
- Returns: int
- the desired exit code
|
Connect to the console of an instance.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the instance name
- Returns: int
- the desired exit code
|
_DoConsole(console,
show_command,
cluster_name,
feedback_fn=ToStdout,
_runcmd_fn=utils.RunCmd)
| source code
|
Acts based on the result of opcodes.OpInstanceConsole.
- Parameters:
console (objects.InstanceConsole) - Console object
show_command (bool) - Whether to just display commands
cluster_name (string) - Cluster name as retrieved from master daemon
|
_FormatBlockDevInfo(idx,
top_level,
dev,
roman)
| source code
|
Show block device information.
This is only used by ShowInstanceConfig, but it's too big to be left for an
inline definition.
- Parameters:
idx (int) - the index of the current disk
top_level (boolean) - if this a top-level disk?
dev (dict) - dictionary with disk information
roman (boolean) - whether to try to use roman integers
- Returns:
- a list of either strings, tuples or lists (which should be
formatted at a higher indent level)
|
Compute instance run-time status.
- Parameters:
opts - the command line options selected by the user
args (list) - either an empty list, and then we query all instances, or should
contain a list of instance names
- Returns: int
- the desired exit code
|
Converts NIC/disk modifications from CLI to opcode.
When opcodes.OpInstanceSetParams was changed to support
adding/removing disks at arbitrary indices, its parameter format changed.
This function converts legacy requests (e.g. "--net add" or
"--disk add:size=4G") to the newer format and adds support for
new-style requests (e.g. "--new 4:add").
- Parameters:
mods (list of tuples) - Modifications as given by command line parser
- Returns: list of tuples
- Modifications as understood by opcodes.OpInstanceSetParams
|
Modifies an instance.
All parameters take effect only at the next restart of the
instance.
- Parameters:
opts - the command line options selected by the user
args (list) - should contain only one element, the instance name
- Returns: int
- the desired exit code
|
_EXPAND_NODES_TAGS_MODES
- Value:
compat.UniqueFrozenset([_EXPAND_NODES_BOTH_BY_TAGS, _EXPAND_NODES_PRI_
BY_TAGS, _EXPAND_NODES_SEC_BY_TAGS,])
|
|
_LIST_DEF_FIELDS
default list of options for ListInstances
- Value:
["name", "hypervisor", "os", "pnode", "status", "oper_ram",]
|
|
m_force_multi
- Value:
cli_option("--force-multiple", dest= "force_multi", help= "Do not ask
for confirmation when more than" " one instance is affected", action=
"store_true", default= False)
|
|
m_pri_node_opt
- Value:
cli_option("--primary", dest= "multi_mode", help= "Filter by nodes (pr
imary only)", const= _EXPAND_NODES_PRI, action= "store_const")
|
|
m_sec_node_opt
- Value:
cli_option("--secondary", dest= "multi_mode", help= "Filter by nodes (
secondary only)", const= _EXPAND_NODES_SEC, action= "store_const")
|
|
m_node_opt
- Value:
cli_option("--node", dest= "multi_mode", help= "Filter by nodes (prima
ry and secondary)", const= _EXPAND_NODES_BOTH, action= "store_const")
|
|
m_clust_opt
- Value:
cli_option("--all", dest= "multi_mode", help= "Select all instances in
the cluster", const= _EXPAND_CLUSTER, action= "store_const")
|
|
m_inst_opt
- Value:
cli_option("--instance", dest= "multi_mode", help= "Filter by instance
name [default]", const= _EXPAND_INSTANCES, action= "store_const")
|
|
m_node_tags_opt
- Value:
cli_option("--node-tags", dest= "multi_mode", help= "Filter by node ta
g", const= _EXPAND_NODES_BOTH_BY_TAGS, action= "store_const")
|
|
m_pri_node_tags_opt
- Value:
cli_option("--pri-node-tags", dest= "multi_mode", help= "Filter by pri
mary node tag", const= _EXPAND_NODES_PRI_BY_TAGS, action= "store_const
")
|
|
m_sec_node_tags_opt
- Value:
cli_option("--sec-node-tags", dest= "multi_mode", help= "Filter by sec
ondary node tag", const= _EXPAND_NODES_SEC_BY_TAGS, action= "store_con
st")
|
|
m_inst_tags_opt
- Value:
cli_option("--tags", dest= "multi_mode", help= "Filter by instance tag
", const= _EXPAND_INSTANCES_BY_TAGS, action= "store_const")
|
|
add_opts
- Value:
[FORTHCOMING_OPT, COMMIT_OPT, NOSTART_OPT, OS_OPT, FORCE_VARIANT_OPT,
NO_INSTALL_OPT, IGNORE_IPOLICY_OPT, INSTANCE_COMMUNICATION_OPT, HELPER
_STARTUP_TIMEOUT_OPT, HELPER_SHUTDOWN_TIMEOUT_OPT,]
|
|
commands
- Value:
{"add":(AddInstance, [ArgHost(min= 1, max= 1)], COMMON_CREATE_OPTS+ ad
d_opts, "[...] -t disk-type -n node[:secondary-node] -o os-type <name>
", "Creates and adds a new instance to the cluster"), "batch-create":(
BatchCreate, [ArgFile(min= 1, max= 1)], [DRY_RUN_OPT, PRIORITY_OPT, IA
LLOCATOR_OPT]+ SUBMIT_OPTS, "<instances.json>", "Create a bunch of ins
tances based on specs in the file."), "console":(ConnectToInstanceCons
ole, ARGS_ONE_INSTANCE, [SHOWCMD_OPT, PRIORITY_OPT], "[--show-cmd] <in
stance>", "Opens a console on the specified instance"), "failover":(Fa
...
|
|
aliases
dictionary with aliases for commands
- Value:
{"start": "startup", "stop": "shutdown", "show": "info",}
|
|