Package ganeti :: Package cmdlib :: Module instance_create :: Class LUInstanceCreate
[hide private]
[frames] | no frames]

Class LUInstanceCreate

source code


Create an instance.

Instance Methods [hide private]
 
_CheckDiskTemplateValid(self)
Checks validity of disk template.
source code
 
_CheckDiskArguments(self)
Checks validity of disk-related arguments.
source code
 
_CheckVLANArguments(self)
Check validity of VLANs if given
source code
 
CheckArguments(self)
Check arguments.
source code
 
ExpandNames(self)
ExpandNames for CreateInstance.
source code
 
DeclareLocks(self, level)
Declare LU locking needs for a level
source code
 
_RunAllocator(self)
Run the allocator based on input opcode.
source code
dict
BuildHooksEnv(self)
Build hooks env.
source code
tuple; (list, list)
BuildHooksNodes(self)
Build hooks nodes.
source code
 
_ReadExportInfo(self)
Reads the export information from disk.
source code
 
_ReadExportParams(self, einfo)
Use export parameters as defaults.
source code
 
_RevertToDefaults(self, cluster)
Revert the instance parameters to the default values.
source code
 
_GetNodesFromForthcomingInstance(self)
Set nodes as in the forthcoming instance
source code
 
CheckPrereq(self)
Check prerequisites.
source code
NoneType
_RemoveDegradedDisks(self, feedback_fn, disk_abort, instance)
Removes degraded disks and instance.
source code
 
RunOsScripts(self, feedback_fn, iobj)
Run OS scripts
source code
dict of string to string
GetOsInstallPackageEnvironment(self, instance, script)
Returns the OS scripts environment for the helper VM
source code
 
UpdateInstanceOsInstallPackage(self, feedback_fn, instance, override_env)
Updates the OS parameter 'os-install-package' for an instance.
source code
 
RunOsScriptsVirtualized(self, feedback_fn, instance)
Runs the OS scripts inside a safe virtualized environment.
source code
 
Exec(self, feedback_fn)
Create and add the instance to the cluster.
source code
 
PrepareRetry(self, feedback_fn)
Prepare the LU to run again.
source code

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

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

Class Variables [hide private]
  HPATH = "instance-add"
hash(x)
  HTYPE = constants.HTYPE_INSTANCE
hash(x)
  REQ_BGL = False
Instance Variables [hide private]

Inherited from base.LogicalUnit: dry_run_result

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

CheckArguments(self)

source code 

Check arguments.

Overrides: base.LogicalUnit.CheckArguments

ExpandNames(self)

source code 

ExpandNames for CreateInstance.

Figure out the right locks for instance creation.

Overrides: base.LogicalUnit.ExpandNames

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 master, primary and secondary nodes of the instance.

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

_ReadExportInfo(self)

source code 

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

_ReadExportParams(self, einfo)

source code 

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.

CheckPrereq(self)

source code 

Check prerequisites.

Overrides: base.LogicalUnit.CheckPrereq

_RemoveDegradedDisks(self, feedback_fn, disk_abort, instance)

source code 

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 (callable) - function used send feedback back to the caller
  • disk_abort (boolean) - True if disks are degraded, False to first check if disks are degraded
  • instance (objects.Instance) - instance containing the disks to check
Returns: NoneType
None
Raises:

RunOsScripts(self, feedback_fn, iobj)

source code 

Run OS scripts

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

Parameters:
  • feedback_fn (callable) - function used send feedback back to the caller
  • iobj (objects.Instance) - instance object

GetOsInstallPackageEnvironment(self, instance, script)

source code 

Returns the OS scripts environment for the helper VM

Parameters:
  • instance (objects.Instance) - instance for which the OS scripts are run
  • script (string) - script to run (e.g., constants.OS_SCRIPT_CREATE_UNTRUSTED)
Returns: dict of string to string
OS scripts environment for the helper VM

UpdateInstanceOsInstallPackage(self, feedback_fn, instance, override_env)

source code 

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 (callable) - function used send feedback back to the caller
  • instance (objects.Instance) - instance for which the OS parameter 'os-install-package' is updated
  • override_env (dict of string to string) - if supplied, it overrides the environment of the export OS scripts archive

RunOsScriptsVirtualized(self, feedback_fn, instance)

source code 

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 (callable) - function used send feedback back to the caller
  • instance (objects.Instance) - instance for which the OS scripts must be run inside the virtualized environment

Exec(self, feedback_fn)

source code 

Create and add the instance to the cluster.

Overrides: base.LogicalUnit.Exec

PrepareRetry(self, feedback_fn)

source code 

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.

Overrides: base.LogicalUnit.PrepareRetry
(inherited documentation)