module documentation

Instance related commands

Function ActivateDisks Activate an instance's disks.
Function AddInstance Add an instance to the cluster.
Function BatchCreate Create instances using a definition file.
Function ChangeGroup Moves an instance to another group.
Function ConnectToInstanceConsole Connect to the console of an instance.
Function DeactivateDisks Deactivate an instance's disks.
Function FailoverInstance Failover an instance.
Function GenericManyOps Generic multi-instance operations.
Function GrowDisk Grow an instance's disks.
Function ListInstanceFields List instance fields.
Function ListInstances List instances and their properties.
Function Main Undocumented
Function MigrateInstance Migrate an instance.
Function MoveInstance Move an instance.
Function RecreateDisks Recreate an instance's disks.
Function ReinstallInstance Reinstall an instance.
Function RemoveInstance Remove an instance.
Function RenameInstance Rename an instance.
Function ReplaceDisks Replace the disks of an instance
Function SetInstanceParams Modifies an instance.
Function ShowInstanceConfig Compute instance run-time status.
Variable add_opts Undocumented
Variable aliases Undocumented
Variable commands Undocumented
Variable m_clust_opt Undocumented
Variable m_force_multi Undocumented
Variable m_inst_opt Undocumented
Variable m_inst_tags_opt Undocumented
Variable m_node_opt Undocumented
Variable m_node_tags_opt Undocumented
Variable m_pri_node_opt Undocumented
Variable m_pri_node_tags_opt Undocumented
Variable m_sec_node_opt Undocumented
Variable m_sec_node_tags_opt Undocumented
Function _ConvertNicDiskModifications Converts NIC/disk modifications from CLI to opcode.
Function _DoConsole Acts based on the result of opcodes.OpInstanceConsole.
Function _EnsureInstancesExist Check for and ensure the given instance names exist.
Function _ExpandMultiNames Expand the given names using the passed mode.
Function _FormatBlockDevInfo Show block device information.
Function _FormatDiskDetails Formats the logical_id of a disk.
Function _FormatInstanceInfo Format instance information for cli.PrintGenericInfo()
Function _FormatInstanceNicInfo Helper function for _FormatInstanceInfo()
Function _FormatInstanceNodesInfo Helper function for _FormatInstanceInfo()
Function _GetVncConsoleInfo Helper function for _FormatInstanceInfo()
Function _ParseDiskSizes Parses disk sizes in parameters.
Function _ParseExtStorageParams Parses the disk params for ExtStorage conversions.
Function _RebootInstance Reboot instance(s).
Function _ShutdownInstance Shutdown an instance.
Function _StartupInstance Startup instances.
Constant _ENV_OVERRIDE Undocumented
Constant _EXPAND_CLUSTER Undocumented
Constant _EXPAND_INSTANCES Undocumented
Constant _EXPAND_INSTANCES_BY_TAGS Undocumented
Constant _EXPAND_NODES_BOTH Undocumented
Constant _EXPAND_NODES_BOTH_BY_TAGS Undocumented
Constant _EXPAND_NODES_PRI Undocumented
Constant _EXPAND_NODES_PRI_BY_TAGS Undocumented
Constant _EXPAND_NODES_SEC Undocumented
Constant _EXPAND_NODES_SEC_BY_TAGS Undocumented
Constant _EXPAND_NODES_TAGS_MODES Undocumented
Constant _INST_DATA_VAL Undocumented
Constant _LIST_DEF_FIELDS Undocumented
Constant _MISSING Undocumented
def ActivateDisks(opts, args):

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
optsthe command line options selected by the user
args:listshould contain only one element, the instance name
Returns
intthe desired exit code
def AddInstance(opts, args):

Add an instance to the cluster.

This is just a wrapper over GenericInstanceCreate.

def BatchCreate(opts, args):

Create instances using a definition file.

This function reads a json file with opcodes.OpInstanceCreate serialisations.

Parameters
optsthe command line options selected by the user
args:listshould contain one element, the json filename
Returns
intthe desired exit code
def ChangeGroup(opts, args):

Moves an instance to another group.

def ConnectToInstanceConsole(opts, args):

Connect to the console of an instance.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the instance name
Returns
intthe desired exit code
def DeactivateDisks(opts, args):

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
optsthe command line options selected by the user
args:listshould contain only one element, the instance name
Returns
intthe desired exit code
def FailoverInstance(opts, args):

Failover an instance.

The failover is done by shutting it down on its present node and starting it on the secondary.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the instance name
Returns
intthe desired exit code
def GenericManyOps(operation, fn):

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.

def GrowDisk(opts, args):

Grow an instance's disks.

Parameters
optsthe command line options selected by the user
args:listshould contain three elements, the target instance name, the target disk id, and the target growth
Returns
intthe desired exit code
def ListInstanceFields(opts, args):

List instance fields.

Parameters
optsthe command line options selected by the user
args:listfields to list, or empty for all
Returns
intthe desired exit code
def ListInstances(opts, args):

List instances and their properties.

Parameters
optsthe command line options selected by the user
args:listshould be an empty list
Returns
intthe desired exit code
def Main():

Undocumented

def MigrateInstance(opts, args):

Migrate an instance.

The migrate is done without shutdown.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the instance name
Returns
intthe desired exit code
def MoveInstance(opts, args):

Move an instance.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the instance name
Returns
intthe desired exit code
def RecreateDisks(opts, args):

Recreate an instance's disks.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the instance name
Returns
intthe desired exit code
def ReinstallInstance(opts, args):

Reinstall an instance.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the name of the instance to be reinstalled
Returns
intthe desired exit code
def RemoveInstance(opts, args):

Remove an instance.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the name of the instance to be removed
Returns
intthe desired exit code
def RenameInstance(opts, args):

Rename an instance.

Parameters
optsthe command line options selected by the user
args:listshould contain two elements, the old and the new instance names
Returns
intthe desired exit code
def ReplaceDisks(opts, args):

Replace the disks of an instance

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the instance name
Returns
intthe desired exit code
def SetInstanceParams(opts, args):

Modifies an instance.

All parameters take effect only at the next restart of the instance.

Parameters
optsthe command line options selected by the user
args:listshould contain only one element, the instance name
Returns
intthe desired exit code
def ShowInstanceConfig(opts, args):

Compute instance run-time status.

Parameters
optsthe command line options selected by the user
args:listeither an empty list, and then we query all instances, or should contain a list of instance names
Returns
intthe desired exit code
add_opts =

Undocumented

aliases: dict[str, str] =

Undocumented

commands =

Undocumented

m_clust_opt =

Undocumented

m_force_multi =

Undocumented

m_inst_opt =

Undocumented

m_inst_tags_opt =

Undocumented

m_node_opt =

Undocumented

m_node_tags_opt =

Undocumented

m_pri_node_opt =

Undocumented

m_pri_node_tags_opt =

Undocumented

m_sec_node_opt =

Undocumented

m_sec_node_tags_opt =

Undocumented

def _ConvertNicDiskModifications(mods):

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 tuplesModifications as given by command line parser
Returns
list of tuplesModifications as understood by opcodes.OpInstanceSetParams
def _DoConsole(console, show_command, cluster_name, feedback_fn=ToStdout, _runcmd_fn=utils.RunCmd):

Acts based on the result of opcodes.OpInstanceConsole.

Parameters
console:objects.InstanceConsoleConsole object
show_command:boolWhether to just display commands
cluster_name:stringCluster name as retrieved from master daemon
feedback_fnUndocumented
_runcmd_fnUndocumented
def _EnsureInstancesExist(client, names):

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.Clientthe client to use for the query
names:listthe list of instance names to query
Raises
errors.OpPrereqErrorin case any instance is missing
def _ExpandMultiNames(mode, names, client=None):

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
modeone of _EXPAND_CLUSTER, _EXPAND_NODES_BOTH, _EXPAND_NODES_PRI, _EXPAND_NODES_SEC or _EXPAND_INSTANCES
namesa list of names; for cluster, it must be empty, and for node and instance it must be a list of valid item names (short names are valid as usual, e.g. node1 instead of node1.example.com)
clientUndocumented
Returns
listthe list of names after the expansion
Raises
errors.ProgrammerErrorfor unknown selection type
errors.OpPrereqErrorfor invalid input parameters
def _FormatBlockDevInfo(idx, top_level, dev, roman):

Show block device information.

This is only used by ShowInstanceConfig, but it's too big to be left for an inline definition.

Parameters
idx:intthe index of the current disk
top_level:booleanif this a top-level disk?
dev:dictdictionary with disk information
roman:booleanwhether to try to use roman integers
Returns
a list of either strings, tuples or lists (which should be formatted at a higher indent level)
def _FormatDiskDetails(dev_type, dev, roman):

Formats the logical_id of a disk.

def _FormatInstanceInfo(instance, roman_integers):

Format instance information for cli.PrintGenericInfo()

def _FormatInstanceNicInfo(idx, nic, roman=False):

Helper function for _FormatInstanceInfo()

def _FormatInstanceNodesInfo(instance):

Helper function for _FormatInstanceInfo()

def _GetVncConsoleInfo(instance):

Helper function for _FormatInstanceInfo()

def _ParseDiskSizes(mods):

Parses disk sizes in parameters.

def _ParseExtStorageParams(params):

Parses the disk params for ExtStorage conversions.

def _RebootInstance(name, opts):

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
namethe name of the instance to act on
optsthe command line options selected by the user
Returns
the opcode needed for the operation
def _ShutdownInstance(name, opts):

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
namethe name of the instance to act on
optsthe command line options selected by the user
Returns
the opcode needed for the operation
def _StartupInstance(name, opts):

Startup instances.

This returns the opcode to start an instance, and its decorator will wrap this into a loop starting all desired instances.

Parameters
namethe name of the instance to act on
optsthe command line options selected by the user
Returns
the opcode needed for the operation
_ENV_OVERRIDE =

Undocumented

Value
compat.UniqueFrozenset(['list'])
_EXPAND_CLUSTER: str =

Undocumented

Value
'cluster'
_EXPAND_INSTANCES: str =

Undocumented

Value
'instances'
_EXPAND_INSTANCES_BY_TAGS: str =

Undocumented

Value
'instances-by-tags'
_EXPAND_NODES_BOTH: str =

Undocumented

Value
'nodes'
_EXPAND_NODES_BOTH_BY_TAGS: str =

Undocumented

Value
'nodes-by-tags'
_EXPAND_NODES_PRI: str =

Undocumented

Value
'nodes-pri'
_EXPAND_NODES_PRI_BY_TAGS: str =

Undocumented

Value
'nodes-pri-by-tags'
_EXPAND_NODES_SEC: str =

Undocumented

Value
'nodes-sec'
_EXPAND_NODES_SEC_BY_TAGS: str =

Undocumented

Value
'nodes-sec-by-tags'
_INST_DATA_VAL =

Undocumented

Value
ht.TListOf(ht.TDict)
_LIST_DEF_FIELDS: list[str] =

Undocumented

Value
['name', 'hypervisor', 'os', 'pnode', 'status', 'oper_ram']
_MISSING =

Undocumented

Value
object()