Module gnt_instance
source code
Instance related commands
list
|
|
|
|
|
|
int
|
|
int
|
|
|
|
int
|
|
int
|
|
int
|
|
int
|
|
int
|
|
int
|
|
int
|
|
int
|
|
|
|
|
|
|
|
int
|
|
int
|
|
int
|
|
int
|
|
int
|
|
|
|
|
_FormatLogicalID(dev_type,
logical_id,
roman)
Formats the logical_id of a disk. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
list of tuples
|
|
|
_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 = [NOSTART_OPT, OS_OPT, FORCE_VARIANT_OPT, NO_INSTALL...
|
|
commands = {"add":(AddInstance, [ArgHost(min= 1, max= 1)], COM...
|
|
aliases = {"start": "startup", "stop": "shutdown", "show": "in...
dictionary with aliases for commands
|
Imports:
copy,
itertools,
simplejson,
logging,
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,
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,
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,
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
|
Add an instance to the cluster.
This is just a wrapper over GenericInstanceCreate.
|
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:
[NOSTART_OPT, OS_OPT, FORCE_VARIANT_OPT, NO_INSTALL_OPT, IGNORE_IPOLIC
Y_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_OPT], "<instances.json>", "Create a bunch of inst
ances based on specs in the file."), "console":(ConnectToInstanceConso
le, ARGS_ONE_INSTANCE, [SHOWCMD_OPT, PRIORITY_OPT], "[--show-cmd] <ins
tance>", "Opens a console on the specified instance"), "failover":(Fai
...
|
|
aliases
dictionary with aliases for commands
- Value:
{"start": "startup", "stop": "shutdown", "show": "info",}
|
|