Package ganeti :: Package cmdlib :: Module instance_set_params :: Class LUInstanceSetParams
[hide private]
[frames] | no frames]

Class LUInstanceSetParams

source code


Modifies an instances's parameters.

Instance Methods [hide private]
 
GenericGetDiskInfo(self, uuid=None, name=None)
Find a disk object using the provided params.
source code
 
_VerifyDiskModification(self, op, params, excl_stor, group_access_types)
Verifies a disk modification.
source code
 
_LookupDiskIndex(self, idx)
Looks up uuid or name of disk if necessary.
source code
 
_LookupDiskMods(self)
Looks up uuid or name of disk if necessary.
source code
 
CheckArguments(self)
Check syntactic validity for the opcode arguments.
source code
 
_CheckAttachDisk(self, params)
Check if disk can be attached to an instance.
source code
 
ExpandNames(self)
Expand names for this LU.
source code
 
DeclareLocks(self, level)
Declare LU locking needs for a level
source code
dict
BuildHooksEnv(self)
Build hooks env.
source code
tuple; (list, list)
BuildHooksNodes(self)
Build hooks nodes.
source code
 
_PrepareNicModification(self, params, private, old_ip, old_net_uuid, old_params, cluster, pnode_uuid) source code
 
_PreCheckDiskTemplate(self, pnode_info)
CheckPrereq checks related to a new disk template.
source code
 
_PreCheckDisks(self, ispec)
CheckPrereq checks related to disk changes.
source code
 
_GetInstanceInfo(self, cluster_hvparams) source code
 
_CheckHotplug(self) source code
 
_PrepareNicCommunication(self) source code
 
_ProcessHVParams(self, node_uuids) source code
 
_ProcessBeParams(self) source code
 
_ValidateCpuParams(self) source code
 
_ProcessOsParams(self, node_uuids) source code
 
_ProcessMem(self, cluster_hvparams, be_old, pnode_uuid) source code
 
CheckPrereq(self)
Check prerequisites.
source code
NoneType
_ConvertInstanceDisks(self, feedback_fn)
Converts the disks of an instance to another type.
source code
 
_ConvertPlainToDrbd(self, feedback_fn)
Converts an instance from plain to drbd.
source code
 
_ConvertDrbdToPlain(self, feedback_fn)
Converts an instance from drbd to plain.
source code
 
_HotplugDevice(self, action, dev_type, device, extra, seq) source code
 
_FillFileDriver(self) source code
 
_GenerateDiskTemplateWrapper(self, idx, disk_type, params) source code
 
_CreateNewDisk(self, idx, params, _)
Creates a new disk.
source code
 
_PostAddDisk(self, _, disk) source code
 
_AttachDisk(self, idx, params, _)
Attaches an existing disk to an instance.
source code
 
_ModifyDisk(self, idx, disk, params, _)
Modifies a disk.
source code
 
_RemoveDisk(self, idx, root, _)
Removes a disk.
source code
 
_DetachDisk(self, idx, root, _)
Detaches a disk from an instance.
source code
 
_CreateNewNic(self, idx, params, private)
Creates data structure for a new network interface.
source code
 
_ApplyNicMods(self, idx, nic, params, private)
Modifies a network interface.
source code
 
_RemoveNic(self, idx, nic, _) source code
 
Exec(self, feedback_fn)
Modifies an instance.
source code

Inherited from base.LogicalUnit: AssertReleasedLocks, HooksCallBack, PreparePostHookNodes, PrepareRetry, WConfdClient, __init__, owned_locks, release_request

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
 
_UpgradeDiskNicMods(kind, mods, verify_fn) source code
 
_CheckMods(kind, mods, key_types, item_fn)
Ensures requested disk/NIC modifications are valid.
source code
 
_VerifyNicModification(op, params)
Verifies a network interface modification.
source code
(constants.DDM_ADD, -1, parameters) or (constants.DDM_REMOVE, -1, parameters) or None
_InstanceCommunicationDDM(cfg, instance_communication, instance)
Create a NIC mod that adds or removes the instance communication NIC to a running instance.
source code
Class Variables [hide private]
  HPATH = "instance-modify"
hash(x)
  HTYPE = constants.HTYPE_INSTANCE
hash(x)
  REQ_BGL = False
  _DISK_CONVERSIONS = {(constants.DT_PLAIN, constants.DT_DRBD8):...
Instance Variables [hide private]

Inherited from base.LogicalUnit: dry_run_result

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

GenericGetDiskInfo(self, uuid=None, name=None)

source code 

Find a disk object using the provided params.

Accept arguments as keywords and use the GetDiskInfo/GetDiskInfoByName config functions to retrieve the disk info based on these arguments.

In case of an error, raise the appropriate exceptions.

_CheckMods(kind, mods, key_types, item_fn)
Static Method

source code 

Ensures requested disk/NIC modifications are valid.

Note that the 'attach' action needs a way to refer to the UUID of the disk, since the disk name is not unique cluster-wide. However, the UUID of the disk is not settable but rather generated by Ganeti automatically, therefore it cannot be passed as an IDISK parameter. For this reason, this function will override the checks to accept uuid parameters solely for the attach action.

CheckArguments(self)

source code 

Check syntactic validity for the opcode arguments.

This method is for doing a simple syntactic check and ensure validity of opcode parameters, without any cluster-related checks. While the same can be accomplished in ExpandNames and/or CheckPrereq, doing these separate is better because:

  • ExpandNames is left as as purely a lock-related function
  • CheckPrereq is run after we have acquired locks (and possible waited for them)

The function is allowed to change the self.op attribute so that later methods can no longer worry about missing parameters.

Overrides: base.LogicalUnit.CheckArguments
(inherited documentation)

_CheckAttachDisk(self, params)

source code 

Check if disk can be attached to an instance.

Check if the disk and instance have the same template. Also, check if the disk nodes are visible from the instance.

ExpandNames(self)

source code 

Expand names for this LU.

This method is called before starting to execute the opcode, and it should update all the parameters of the opcode to their canonical form (e.g. a short node name must be fully expanded after this method has successfully completed). This way locking, hooks, logging, etc. can work correctly.

LUs which implement this method must also populate the self.needed_locks member, as a dict with lock levels as keys, and a list of needed lock names as values. Rules:

  • use an empty dict if you don't need any lock
  • if you don't need any lock at a particular level omit that level (note that in this case DeclareLocks won't be called at all for that level)
  • if you need locks at a level, but you can't calculate it in this function, initialise that level with an empty list and do further processing in LogicalUnit.DeclareLocks (see that function's docstring)
  • don't put anything for the BGL level
  • if you want all locks at a level use locking.ALL_SET as a value

If you need to share locks (rather than acquire them exclusively) at one level you can modify self.share_locks, setting a true value (usually 1) for that level. By default locks are not shared.

This function can also define a list of tasklets, which then will be executed in order instead of the usual LU-level CheckPrereq and Exec functions, if those are not defined by the LU.

Examples:

 # Acquire all nodes and one instance
 self.needed_locks = {
   locking.LEVEL_NODE: locking.ALL_SET,
   locking.LEVEL_INSTANCE: ['instance1.example.com'],
 }
 # Acquire just two nodes
 self.needed_locks = {
   locking.LEVEL_NODE: ['node1-uuid', 'node2-uuid'],
 }
 # Acquire no locks
 self.needed_locks = {} # No, you can't leave it to the default value None
Overrides: base.LogicalUnit.ExpandNames
(inherited documentation)

DeclareLocks(self, level)

source code 

Declare LU locking needs for a level

While most LUs can just declare their locking needs at ExpandNames time, sometimes there's the need to calculate some locks after having acquired the ones before. This function is called just before acquiring locks at a particular level, but after acquiring the ones at lower levels, and permits such calculations. It can be used to modify self.needed_locks, and by default it does nothing.

This function is only called if you have something already set in self.needed_locks for the level.

Parameters:
  • level - Locking level which is going to be locked
Overrides: base.LogicalUnit.DeclareLocks
(inherited documentation)

BuildHooksEnv(self)

source code 

Build hooks env.

This runs on the master, primary and secondaries.

Returns: dict
Dictionary containing the environment that will be used for running the hooks for this LU. The keys of the dict must not be prefixed with "GANETI_"--that'll be added by the hooks runner. The hooks runner will extend the environment with additional variables. If no environment should be defined, an empty dictionary should be returned (not None).
Overrides: base.LogicalUnit.BuildHooksEnv

BuildHooksNodes(self)

source code 

Build hooks nodes.

Returns: tuple; (list, list)
Tuple containing a list of node UUIDs on which the hook should run before the execution and a list of node UUIDs on which the hook should run after the execution. No nodes should be returned as an empty list (and not None).
Overrides: base.LogicalUnit.BuildHooksNodes

_PreCheckDisks(self, ispec)

source code 

CheckPrereq checks related to disk changes.

Parameters:
  • ispec (dict) - instance specs to be updated with the new disks

_InstanceCommunicationDDM(cfg, instance_communication, instance)
Static Method

source code 

Create a NIC mod that adds or removes the instance communication NIC to a running instance.

The NICS are dynamically created using the Dynamic Device Modification (DDM). This function produces a NIC modification (mod) that inserts an additional NIC meant for instance communication in or removes an existing instance communication NIC from a running instance, using DDM.

Parameters:
  • cfg (config.ConfigWriter) - cluster configuration
  • instance_communication (boolean) - whether instance communication is enabled or disabled
  • instance (objects.Instance) - instance to which the NIC mod will be applied to
Returns: (constants.DDM_ADD, -1, parameters) or (constants.DDM_REMOVE, -1, parameters) or None
DDM mod containing an action to add or remove the NIC, or None if nothing needs to be done

CheckPrereq(self)

source code 

Check prerequisites.

This only checks the instance list against the existing names.

Overrides: base.LogicalUnit.CheckPrereq

_ConvertInstanceDisks(self, feedback_fn)

source code 

Converts the disks of an instance to another type.

This function converts the disks of an instance. It supports conversions among all the available disk types except conversions between the LVM-based disk types, that use their separate code path. Also, this method does not support conversions that include the 'diskless' template and those targeting the 'blockdev' template.

Parameters:
  • feedback_fn (callable) - function used to send feedback back to the caller
Returns: NoneType
None
Raises:

Exec(self, feedback_fn)

source code 

Modifies an instance.

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

Overrides: base.LogicalUnit.Exec

Class Variable Details [hide private]

_DISK_CONVERSIONS

Value:
{(constants.DT_PLAIN, constants.DT_DRBD8): _ConvertPlainToDrbd, (const\
ants.DT_DRBD8, constants.DT_PLAIN): _ConvertDrbdToPlain,}