ganeti :: hypervisor :: hv_fake :: FakeHypervisor :: Class FakeHypervisor
[hide private]
[frames] | no frames]

Class FakeHypervisor

source code


Fake hypervisor interface.

This can be used for testing the ganeti code without having to have a real virtualisation software installed.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
ListInstances(self)
Get the list of running instances.
source code
 
GetInstanceInfo(self, instance_name)
Get instance properties.
source code
 
GetAllInstancesInfo(self)
Get properties of all instances.
source code
 
_IsAlive(self, instance_name)
Checks if an instance is alive.
source code
 
_MarkUp(self, instance, memory)
Mark the instance as running.
source code
 
_MarkDown(self, instance_name)
Mark the instance as running.
source code
 
StartInstance(self, instance, block_devices, startup_paused)
Start an instance.
source code
 
StopInstance(self, instance, force=False, retry=False, name=None)
Stop an instance.
source code
 
RebootInstance(self, instance)
Reboot an instance.
source code
 
BalloonInstanceMemory(self, instance, mem)
Balloon an instance memory to a certain value.
source code
 
GetNodeInfo(self)
Return information about the node.
source code
 
Verify(self)
Verify the hypervisor.
source code
 
AcceptInstance(self, instance, info, target)
Prepare to accept an instance.
source code
 
MigrateInstance(self, instance, target, live)
Migrate an instance.
source code
 
FinalizeMigrationDst(self, instance, info, success)
Finalize the instance migration on the target node.
source code
 
PostMigrationCleanup(self, instance)
Clean-up after a migration.
source code
 
FinalizeMigrationSource(self, instance, success, live)
Finalize the instance migration on the source node.
source code
objects.MigrationStatus
GetMigrationStatus(self, instance)
Get the migration status
source code

Inherited from hv_base.BaseHypervisor: CleanupInstance, MigrationInfo

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

Class Methods [hide private]
 
_InstanceFile(cls, instance_name)
Compute the instance file for an instance name.
source code
 
GetInstanceConsole(cls, instance, hvparams, beparams)
Return information for connecting to the console of an instance.
source code
 
PowercycleNode(cls)
Fake hypervisor powercycle, just a wrapper over Linux powercycle.
source code

Inherited from hv_base.BaseHypervisor: CheckParameterSyntax, GetAncillaryFiles, LinuxPowercycle, ValidateParameters

Static Methods [hide private]

Inherited from hv_base.BaseHypervisor: GetLinuxNodeInfo

Inherited from hv_base.BaseHypervisor (private): _FormatVerifyResults

Class Variables [hide private]
boolean CAN_MIGRATE = True
whether this hypervisor can do migration (either live or non-live)
  _ROOT_DIR = pathutils.RUN_DIR+ "/fake-hypervisor"

Inherited from hv_base.BaseHypervisor: ANCILLARY_FILES, ANCILLARY_FILES_OPT, PARAMETERS

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

ListInstances(self)

source code 

Get the list of running instances.

Overrides: hv_base.BaseHypervisor.ListInstances

GetInstanceInfo(self, instance_name)

source code 

Get instance properties.

Parameters:
  • instance_name - the instance name
Returns:
tuple of (name, id, memory, vcpus, stat, times)
Overrides: hv_base.BaseHypervisor.GetInstanceInfo

GetAllInstancesInfo(self)

source code 

Get properties of all instances.

Returns:
list of tuples (name, id, memory, vcpus, stat, times)
Overrides: hv_base.BaseHypervisor.GetAllInstancesInfo

_MarkUp(self, instance, memory)

source code 

Mark the instance as running.

This does no checks, which should be done by its callers.

_MarkDown(self, instance_name)

source code 

Mark the instance as running.

This does no checks, which should be done by its callers.

StartInstance(self, instance, block_devices, startup_paused)

source code 

Start an instance.

For the fake hypervisor, it just creates a file in the base dir, creating an exception if it already exists. We don't actually handle race conditions properly, since these are *FAKE* instances.

Overrides: hv_base.BaseHypervisor.StartInstance

StopInstance(self, instance, force=False, retry=False, name=None)

source code 

Stop an instance.

For the fake hypervisor, this just removes the file in the base dir, if it exist, otherwise we raise an exception.

Parameters:
  • instance - instance to stop
  • force - whether to do a "hard" stop (destroy)
  • retry - whether this is just a retry call
  • name - if this parameter is passed, the the instance object should not be used (will be passed as None), and the shutdown must be done by name only
Overrides: hv_base.BaseHypervisor.StopInstance

RebootInstance(self, instance)

source code 

Reboot an instance.

For the fake hypervisor, this does nothing.

Overrides: hv_base.BaseHypervisor.RebootInstance

BalloonInstanceMemory(self, instance, mem)

source code 

Balloon an instance memory to a certain value.

Parameters:
  • instance (objects.Instance) - instance to be accepted
  • mem (int) - actual memory size to use for instance runtime
Overrides: hv_base.BaseHypervisor.BalloonInstanceMemory

GetNodeInfo(self)

source code 

Return information about the node.

This is just a wrapper over the base GetLinuxNodeInfo method.

Returns:
a dict with the following keys (values in MiB):
  • memory_total: the total memory size on the node
  • memory_free: the available memory on the node for instances
  • memory_dom0: the memory used by the node itself, if available
Overrides: hv_base.BaseHypervisor.GetNodeInfo

GetInstanceConsole(cls, instance, hvparams, beparams)
Class Method

source code 

Return information for connecting to the console of an instance.

Overrides: hv_base.BaseHypervisor.GetInstanceConsole

Verify(self)

source code 

Verify the hypervisor.

For the fake hypervisor, it just checks the existence of the base dir.

Returns:
Problem description if something is wrong, None otherwise
Overrides: hv_base.BaseHypervisor.Verify

PowercycleNode(cls)
Class Method

source code 

Fake hypervisor powercycle, just a wrapper over Linux powercycle.

Overrides: hv_base.BaseHypervisor.PowercycleNode

AcceptInstance(self, instance, info, target)

source code 

Prepare to accept an instance.

Parameters:
  • instance (objects.Instance) - instance to be accepted
  • info (string) - instance info, not used
  • target (string) - target host (usually ip), on this node
Overrides: hv_base.BaseHypervisor.AcceptInstance

MigrateInstance(self, instance, target, live)

source code 

Migrate an instance.

Parameters:
  • instance (objects.Instance) - the instance to be migrated
  • target (string) - hostname (usually ip) of the target node
  • live (boolean) - whether to do a live or non-live migration
Overrides: hv_base.BaseHypervisor.MigrateInstance

FinalizeMigrationDst(self, instance, info, success)

source code 

Finalize the instance migration on the target node.

For the fake hv, this just marks the instance up.

Parameters:
  • instance (objects.Instance) - instance whose migration is being finalized
  • info (string/data (opaque)) - migration information, from the source node
  • success (boolean) - whether the migration was a success or a failure
Overrides: hv_base.BaseHypervisor.FinalizeMigrationDst

PostMigrationCleanup(self, instance)

source code 

Clean-up after a migration.

To be executed on the source node.

Parameters:

FinalizeMigrationSource(self, instance, success, live)

source code 

Finalize the instance migration on the source node.

Parameters:
  • instance (objects.Instance) - the instance that was migrated
  • success (bool) - whether the migration succeeded or not
  • live (bool) - whether the user requested a live migration or not
Overrides: hv_base.BaseHypervisor.FinalizeMigrationSource

GetMigrationStatus(self, instance)

source code 

Get the migration status

The fake hypervisor migration always succeeds.

Parameters:
Returns: objects.MigrationStatus
the status of the current migration (one of constants.HV_MIGRATION_VALID_STATUSES), plus any additional progress info that can be retrieved from the hypervisor
Overrides: hv_base.BaseHypervisor.GetMigrationStatus