Selena API Documentation

Selena module

The main module for the selena emulation control.

Selena.S_EXIT(message=None)

Exits the program return 1 as error status and printing a message.

Parameters:message – The message to print to standard output before exiting Selena
class Selena.Selena(selena_config, **kwargs)

Bases: object

This is the main Selena Class

doPoolFirstPass(pScenario)

Make a first pass of the pool to extract VMs with exact name matches (reuse VMs from previous scenario runs) :param pScenario: The name of the scenario

generateVmConfig(pNode, pScenarioName)

Create a VM configuration based on the details of a scenario Node. This configuration is ready to be consumed by XAPI :param pNode: The node object of the scenario :param pScenarioName: The scenario object :return: The new VM configuration in the form of a dictionary

getVmFromPool_byName(pVmName, pType)

Try to Retrieve a VM from the VMs pool with the specified label-name (left from previous emulation runs) All VMs in pool have the scenario’s name in their description-name meta-info (distinct from the name-label) :param pVmName: The name of the Vm that we wish to retrieve :param pType: The type of the VM which determines the sub-pool in which Selena will search for a matching VM :return: The index in the pools and the VM object if a matching VM is found, (None, None) otherwise

get_class(pathToClass)

A recursive class tracker.

Parameters:kls – A string that contains a path to a class in dotted format
Returns:The Class object
haltVM(pRef, pForce=False)

Stops the specified VM :param pRef: the OpaqueRef for the VM to be shut down :param pForce: Force shutdown, do not wait for the VM to exit gracefully (boolean type) :return: True if the VM is shut-down successfully, False otherwise

initXenNetPool(pScenarioName)

Initialize the pool with the Xen server networks. It obtains a list of the networks that are currently installed on the Xen server and based on their name-description meta-info it checks if they belong to the specified scenario and allocates them to the networks pool. Networks added in the pool are reused across emulations. :param pScenario: The name of the scenario for which we are initializing the pool :return:

initXenVmPool(pScenarioName, pDoShutdown=True)

Initializes the pool with the VMs. It obtains a list of the VMs that are currently installed on the Xen server and based on their name-description meta-info it checks if they belong to the specified scenario and also infers their template type and allocates them to the correct sub-pool. VMs added in the pool are reused across emulations. :param pScenarioName: The name of the scenario for which we are initializing the pool :param pDoShutdown: If True it will shut down each VM before adding it to the pool.

loadScenario(pScenarioClassName)

Creates an instance of the specified scenario and initializes it by calling instance’s method initScenario()

Parameters:pScenarioClassName – The name (or path) of the scenario module and/or class.
Returns:The new instance of the scenario
reuseVM(pNode, pVmRef, pScenarioName)

Reuse a VM from the scenario’s VM pool. Update the node meta-info with the VM’s details. :param pNode: The scenario’s node object that we wish to update with the matching VM’s details :param pVmRef: The OpaqueRef of the VM to be reused :param pScenarioName: The name of the scenario

selenaDo_installScenario(pScenarioName)
This method instructs Selena to create the VMs and virtual networks
necessary to execute the specified scenario.
Parameters:pScenarioName – The module and/or class name of the scenario description
Returns:True if all VMs and network are created successfully, False otherwise
selenaDo_killScenario(pScenarioName)

This method instructs Selena to halt all the VMs which are related to the specified scenario. It is assumed that the scenario has been previously installed.

Parameters:pScenarioName – The module and/or class name of the scenario description
Returns:True if all VMs and network are stopped successfully, False otherwise
selenaDo_startScenario(pScenarioName)

This method instructs Selena to start the VMs of the specified scenario. It is assumed that the scenario has been previously installed.

Parameters:pScenarioName – The module and/or class name of the scenario description
Returns:True if all VMs and network are created successfully, False otherwise
selenaDo_uninstallScenario(pScenarioName)
This method instructs Selena to halt and destroy the VMs and virtual networks
which are related to the specified scenario.
Parameters:pScenarioName – The module and/or class name of the scenario description
Returns:True if all VMs and network are destroyed successfully, False otherwise
stopAllRunningVMs(pForce=False)

Stops all the VMs that are currently in running state on the Xen server :param pForce: Force shutdown, do not wait for VMs to exit gracefully (boolean type)

class SelenaLogger.SelenaLogger

Bases: logging.Logger, object

This is the main Selena logger Class

setAllLevels(pLevel)

Sets the logging level for the logger itself and for all its handlers.

Parameters:pLevel – The request logging level
class Scenario.Scenario

Bases: object

classdocs

class XcpManager.XcpManager(pUrl='localhost', pUserName='root', pPasswd='root')

Bases: object

classdocs

Singleton module

This is a helper module, used to implement the Singleton pattern (the python way).

class Singleton.Singleton(name, bases, dict_)

Singleton class

Class necessary to implement the Singleton pattern. Taken from StackOverflow

Intended to be used as a __metaclass_ param, as shown for the class below.