class documentation

class LUInstanceCreate(LogicalUnit):

View In Hierarchy

Create an instance.

Method BuildHooksEnv Build hooks env.
Method BuildHooksNodes Build hooks nodes.
Method CheckArguments Check arguments.
Method CheckPrereq Check prerequisites.
Method DeclareLocks Declare LU locking needs for a level
Method Exec Create and add the instance to the cluster.
Method ExpandNames ExpandNames for CreateInstance.
Method GetOsInstallPackageEnvironment Returns the OS scripts environment for the helper VM
Method PrepareRetry Prepare the LU to run again.
Method RunOsScripts Run OS scripts
Method RunOsScriptsVirtualized Runs the OS scripts inside a safe virtualized environment.
Method UpdateInstanceOsInstallPackage Updates the OS parameter 'os-install-package' for an instance.
Constant HPATH Undocumented
Constant REQ_BGL Undocumented
Instance Variable adopt_disks Undocumented
Instance Variable be_full Undocumented
Instance Variable check_ip Undocumented
Instance Variable disks Undocumented
Instance Variable dry_run_result Undocumented
Instance Variable hostname Undocumented
Instance Variable hv_full Undocumented
Instance Variable instance_file_storage_dir Undocumented
Instance Variable needed_locks Undocumented
Instance Variable nics Undocumented
Instance Variable os_full Undocumented
Instance Variable pnode Undocumented
Instance Variable secondaries Undocumented
Instance Variable src_images Undocumented
Method _CheckDiskArguments Checks validity of disk-related arguments.
Method _CheckDiskTemplateValid Checks validity of disk template.
Method _CheckVLANArguments Check validity of VLANs if given
Method _GetNodesFromForthcomingInstance Set nodes as in the forthcoming instance
Method _ReadExportInfo Reads the export information from disk.
Method _ReadExportParams Use export parameters as defaults.
Method _RemoveDegradedDisks Removes degraded disks and instance.
Method _RevertToDefaults Revert the instance parameters to the default values.
Method _RunAllocator Run the allocator based on input opcode.
Instance Variable _old_instance_name 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 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 Log Undocumented
Instance Variable LogInfo Undocumented
Instance Variable LogStep Undocumented
Instance Variable LogWarning 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 master, primary and secondary nodes of the instance.

def BuildHooksNodes(self):

Build hooks nodes.

def CheckArguments(self):
def CheckPrereq(self):

Check prerequisites.

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):

Create and add the instance to the cluster.

def ExpandNames(self):

ExpandNames for CreateInstance.

Figure out the right locks for instance creation.

def GetOsInstallPackageEnvironment(self, instance, script):

Returns the OS scripts environment for the helper VM

Parameters
instance:objects.Instanceinstance for which the OS scripts are run
script:stringscript to run (e.g., constants.OS_SCRIPT_CREATE_UNTRUSTED)
Returns
dict of string to stringOS scripts environment for the helper VM
def PrepareRetry(self, feedback_fn):

Prepare the LU to run again.

This method is called if the Exec failed for temporarily lacking resources. It is expected to change the state of the LU so that it can be tried again, and also change its locking policy to acquire more resources to have a better chance of suceeding in the retry.

def RunOsScripts(self, feedback_fn, iobj):

Run OS scripts

If necessary, disks are paused. It handles instance create, import, and remote import.

Parameters
feedback_fn:callablefunction used send feedback back to the caller
iobj:objects.Instanceinstance object
def RunOsScriptsVirtualized(self, feedback_fn, instance):

Runs the OS scripts inside a safe virtualized environment.

The virtualized environment reuses the instance and temporarily creates a disk onto which the image of the helper VM is dumped. The temporary disk is used to boot the helper VM. The OS scripts are passed to the helper VM through the metadata daemon and the OS install package.

Parameters
feedback_fn:callablefunction used send feedback back to the caller
instance:objects.Instanceinstance for which the OS scripts must be run inside the virtualized environment
def UpdateInstanceOsInstallPackage(self, feedback_fn, instance, override_env):

Updates the OS parameter 'os-install-package' for an instance.

The OS install package is an archive containing an OS definition and a file containing the environment variables needed to run the OS scripts.

The OS install package is served by the metadata daemon to the instances, so the OS scripts can run inside the virtualized environment.

Parameters
feedback_fn:callablefunction used send feedback back to the caller
instance:objects.Instanceinstance for which the OS parameter 'os-install-package' is updated
override_env:dict of string to stringif supplied, it overrides the environment of the export OS scripts archive
HPATH: str =

Undocumented

Value
'instance-add'
REQ_BGL: bool =

Undocumented

Value
False
adopt_disks =

Undocumented

be_full =

Undocumented

check_ip =

Undocumented

disks =

Undocumented

dry_run_result =
hostname =

Undocumented

hv_full =

Undocumented

instance_file_storage_dir =

Undocumented

needed_locks: dict =
nics =

Undocumented

os_full =

Undocumented

pnode =

Undocumented

secondaries: list =

Undocumented

src_images =

Undocumented

def _CheckDiskArguments(self):

Checks validity of disk-related arguments.

def _CheckDiskTemplateValid(self):

Checks validity of disk template.

def _CheckVLANArguments(self):

Check validity of VLANs if given

def _GetNodesFromForthcomingInstance(self):

Set nodes as in the forthcoming instance

def _ReadExportInfo(self):

Reads the export information from disk.

It will override the opcode source node and path with the actual information, if these two were not specified before.

Returns
the export information
def _ReadExportParams(self, einfo):

Use export parameters as defaults.

In case the opcode doesn't specify (as in override) some instance parameters, then try to use them from the export information, if that declares them.

def _RemoveDegradedDisks(self, feedback_fn, disk_abort, instance):

Removes degraded disks and instance.

It optionally checks whether disks are degraded. If the disks are degraded, they are removed and the instance is also removed from the configuration.

If disk_abort is True, then the disks are considered degraded and removed, and the instance is removed from the configuration.

If disk_abort is False, then it first checks whether disks are degraded and, if so, it removes the disks and the instance is removed from the configuration.

Parameters
feedback_fn:callablefunction used send feedback back to the caller
disk_abort:booleanTrue if disks are degraded, False to first check if disks are degraded
instance:objects.Instanceinstance containing the disks to check
Returns
NoneTypeNone
Raises
errors.OpPrereqErrorif disks are degraded
def _RevertToDefaults(self, cluster):

Revert the instance parameters to the default values.

def _RunAllocator(self):

Run the allocator based on input opcode.

_old_instance_name =

Undocumented