class documentation

class LUInstanceSetParams(LogicalUnit):

View In Hierarchy

Modifies an instances's parameters.

Method BuildHooksEnv Build hooks env.
Method BuildHooksNodes Build hooks nodes.
Method CheckArguments Check syntactic validity for the opcode arguments.
Method CheckPrereq Check prerequisites.
Method DeclareLocks Declare LU locking needs for a level
Method Exec Modifies an instance.
Method ExpandNames Expand names for this LU.
Method GenericGetDiskInfo Find a disk object using the provided params.
Constant HPATH Undocumented
Constant REQ_BGL Undocumented
Instance Variable be_inst Undocumented
Instance Variable be_new Undocumented
Instance Variable be_proposed Undocumented
Instance Variable cluster Undocumented
Instance Variable diskmod Undocumented
Instance Variable diskparams Undocumented
Instance Variable disks_info Undocumented
Instance Variable feedback_fn Undocumented
Instance Variable hv_inst Undocumented
Instance Variable hv_new Undocumented
Instance Variable hv_proposed Undocumented
Instance Variable instance Undocumented
Instance Variable nicmod Undocumented
Instance Variable os_inst Undocumented
Instance Variable os_inst_private Undocumented
Instance Variable warn Undocumented
Static Method _CheckMods Ensures requested disk/NIC modifications are valid.
Static Method _InstanceCommunicationDDM Create a NIC mod that adds or removes the instance communication NIC to a running instance.
Static Method _UpgradeDiskNicMods Undocumented
Static Method _VerifyNicModification Verifies a network interface modification.
Method _ApplyNicMods Modifies a network interface.
Method _AttachDisk Attaches an existing disk to an instance.
Method _CheckAttachDisk Check if disk can be attached to an instance.
Method _CheckHotplug Undocumented
Method _ConvertDrbdToPlain Converts an instance from drbd to plain.
Method _ConvertInstanceDisks Converts the disks of an instance to another type.
Method _ConvertPlainToDrbd Converts an instance from plain to drbd.
Method _CreateNewDisk Creates a new disk.
Method _CreateNewNic Creates data structure for a new network interface.
Method _DetachDisk Detaches a disk from an instance.
Method _FillFileDriver Undocumented
Method _GenerateDiskTemplateWrapper Undocumented
Method _GetInstanceInfo Undocumented
Method _HotplugDevice Undocumented
Method _LookupDiskIndex Looks up uuid or name of disk if necessary.
Method _LookupDiskMods Looks up uuid or name of disk if necessary.
Method _ModifyDisk Modifies a disk.
Method _PostAddDisk Undocumented
Method _PreCheckDisks CheckPrereq checks related to disk changes.
Method _PreCheckDiskTemplate CheckPrereq checks related to a new disk template.
Method _PrepareNicCommunication Undocumented
Method _PrepareNicModification Undocumented
Method _ProcessBeParams Undocumented
Method _ProcessHVParams Undocumented
Method _ProcessMem Undocumented
Method _ProcessOsParams Undocumented
Method _RemoveDisk Removes a disk.
Method _RemoveNic Undocumented
Method _ValidateCpuParams Undocumented
Method _VerifyDiskModification Verifies a disk modification.
Constant _DISK_CONVERSIONS Undocumented
Instance Variable _new_nics Undocumented
Instance Variable _nic_chgdesc Undocumented

Inherited from LogicalUnit:

Method __init__ Constructor for LogicalUnit.
Method AssertReleasedLocks Raise AssertionError if the LU holds some locks of the given level.
Method HooksCallBack Notify the LU about the results of its hooks.
Method owned_locks Return the list of locks owned by the LU at a given level.
Method PreparePostHookNodes Extend list of nodes to run the post LU hook.
Method PrepareRetry Prepare the LU to run again.
Method release_request Return a request to release the specified locks of the given level.
Method WConfdClient Undocumented
Constant HTYPE Undocumented
Instance Variable add_locks Undocumented
Instance Variable cfg Undocumented
Instance Variable dont_collate_locks Undocumented
Instance Variable dry_run_result the value (if any) that will be returned to the caller in dry-run mode (signalled by opcode dry_run parameter)
Instance Variable Log Undocumented
Instance Variable LogInfo Undocumented
Instance Variable LogStep Undocumented
Instance Variable LogWarning Undocumented
Instance Variable needed_locks Undocumented
Instance Variable op Undocumented
Instance Variable opportunistic_locks Undocumented
Instance Variable opportunistic_locks_count Undocumented
Instance Variable proc Undocumented
Instance Variable recalculate_locks Undocumented
Instance Variable rpc Undocumented
Instance Variable share_locks Undocumented
Instance Variable tasklets Undocumented
Instance Variable wconfd Undocumented
Instance Variable wconfdcontext Undocumented
Instance Variable wconfdlocks Undocumented
Method _ExpandAndLockInstance Helper function to expand and lock an instance.
Method _LockInstancesNodes Helper function to declare instances' nodes for locking.
def BuildHooksEnv(self):

Build hooks env.

This runs on the master, primary and secondaries.

def BuildHooksNodes(self):

Build hooks nodes.

def CheckArguments(self):

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.

def CheckPrereq(self):

Check prerequisites.

This only checks the instance list against the existing names.

def DeclareLocks(self, level):

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:member of ganeti.locking.LEVELSLocking level which is going to be locked
def Exec(self, feedback_fn):

Modifies an instance.

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

def ExpandNames(self):

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
def GenericGetDiskInfo(self, uuid=None, name=None):

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.

HPATH: str =

Undocumented

Value
'instance-modify'
REQ_BGL: bool =

Undocumented

Value
False
be_inst =

Undocumented

be_new =

Undocumented

be_proposed =

Undocumented

cluster =

Undocumented

diskmod =

Undocumented

diskparams =

Undocumented

disks_info =

Undocumented

feedback_fn =

Undocumented

hv_inst =

Undocumented

hv_new =

Undocumented

hv_proposed =

Undocumented

instance =

Undocumented

nicmod =

Undocumented

os_inst =

Undocumented

os_inst_private =

Undocumented

warn: list =

Undocumented

@staticmethod
def _CheckMods(kind, mods, key_types, item_fn):

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.

@staticmethod
def _InstanceCommunicationDDM(cfg, instance_communication, instance):

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.ConfigWritercluster configuration
instance_communication:booleanwhether instance communication is enabled or disabled
instance:objects.Instanceinstance to which the NIC mod will be applied to
Returns
(constants.DDM_ADD, -1, parameters) or (constants.DDM_REMOVE, -1, parameters) or NoneDDM mod containing an action to add or remove the NIC, or None if nothing needs to be done
@staticmethod
def _UpgradeDiskNicMods(kind, mods, verify_fn):

Undocumented

@staticmethod
def _VerifyNicModification(op, params):

Verifies a network interface modification.

def _ApplyNicMods(self, idx, nic, params, private):

Modifies a network interface.

def _AttachDisk(self, idx, params, _):

Attaches an existing disk to an instance.

def _CheckAttachDisk(self, params):

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.

def _CheckHotplug(self):

Undocumented

def _ConvertDrbdToPlain(self, feedback_fn):

Converts an instance from drbd to plain.

def _ConvertInstanceDisks(self, feedback_fn):

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:callablefunction used to send feedback back to the caller
Returns
NoneTypeNone
Raises
errors.OpPrereqErrorin case of failure
def _ConvertPlainToDrbd(self, feedback_fn):

Converts an instance from plain to drbd.

def _CreateNewDisk(self, idx, params, _):

Creates a new disk.

def _CreateNewNic(self, idx, params, private):

Creates data structure for a new network interface.

def _DetachDisk(self, idx, root, _):

Detaches a disk from an instance.

def _FillFileDriver(self):

Undocumented

def _GenerateDiskTemplateWrapper(self, idx, disk_type, params):

Undocumented

def _GetInstanceInfo(self, cluster_hvparams):

Undocumented

def _HotplugDevice(self, action, dev_type, device, extra, seq):

Undocumented

def _LookupDiskIndex(self, idx):

Looks up uuid or name of disk if necessary.

def _LookupDiskMods(self):

Looks up uuid or name of disk if necessary.

def _ModifyDisk(self, idx, disk, params, _):

Modifies a disk.

def _PostAddDisk(self, _, disk):

Undocumented

def _PreCheckDisks(self, ispec):

CheckPrereq checks related to disk changes.

Parameters
ispec:dictinstance specs to be updated with the new disks
def _PreCheckDiskTemplate(self, pnode_info):

CheckPrereq checks related to a new disk template.

def _PrepareNicCommunication(self):

Undocumented

def _PrepareNicModification(self, params, private, old_ip, old_net_uuid, old_params, cluster, pnode_uuid):

Undocumented

def _ProcessBeParams(self):

Undocumented

def _ProcessHVParams(self, node_uuids):

Undocumented

def _ProcessMem(self, cluster_hvparams, be_old, pnode_uuid):

Undocumented

def _ProcessOsParams(self, node_uuids):

Undocumented

def _RemoveDisk(self, idx, root, _):

Removes a disk.

def _RemoveNic(self, idx, nic, _):

Undocumented

def _ValidateCpuParams(self):

Undocumented

def _VerifyDiskModification(self, op, params, excl_stor, group_access_types):

Verifies a disk modification.

_new_nics =

Undocumented

_nic_chgdesc: list =

Undocumented