pyvcloud.system_test_framework.environment module

class pyvcloud.system_test_framework.environment.CommonRoles

Bases: flufl.enum._enum.Enum

CATALOG_AUTHOR = <EnumValue: CommonRoles.CATALOG_AUTHOR [value=Catalog Author]>
CONSOLE_ACCESS_ONLY = <EnumValue: CommonRoles.CONSOLE_ACCESS_ONLY [value=Console Access Only]>
ORGANIZATION_ADMINISTRATOR = <EnumValue: CommonRoles.ORGANIZATION_ADMINISTRATOR [value=Organization Administrator]>
VAPP_AUTHOR = <EnumValue: CommonRoles.VAPP_AUTHOR [value=vApp Author]>
VAPP_USER = <EnumValue: CommonRoles.VAPP_USER [value=vApp User]>
class pyvcloud.system_test_framework.environment.Environment

Bases: object

classmethod attach_vc()

Attaches VC and NSX to vCD as per configuration file.

If VC is already attached no further action is taken.

classmethod cleanup()

Cleans up the various class variables.

classmethod create_catalog()

Creates a catalog by the name specified in the configuration file.

Skips creating one, if such a catalog already exists.

Raises:Exception: if the class variable _org_href is not populated.
classmethod create_org()

Creates an org by the name specified in the config file.

Skips creating one, if such an org already exists. Also stores the href of the org as class variable for future use.

classmethod create_ovdc()

Creates an org vdc with the name specified in the config file.

Skips creating one, if such an org vdc already exists. Also stores the href of the org vdc as class variable for future use.

Raises:Exception: if the class variable _org_href or _pvdc_name is not populated.
classmethod create_ovdc_network()

Creates an isolated org vdc network.

The name of the created org vdc network is specified in the configuration file, skips creating one, if such a network already exists.

Raises:Exception: if the class variable _ovdc_href is not populated.
classmethod create_pvdc()

Creates a pvdc by the name specified in the config file.

Skips creating one, if such a pvdc already exists. Also stores the href and name of the provider vdc as class variables for future use.

classmethod create_users()

Creates users for each of the roles in CommonRoles.

Skips creating users which are already present in the organization.

Raises:Exception: if the class variable _org_href is not populated.
classmethod get_client(org, username, password)

Returns a client for a particular user.

The user is identified by the specified username-password combo in a given organization.

Parameters:
  • org (str) – name of the organization, which the user belongs to.
  • username (str) – username of the user.
  • password (str) – password of the user.
Returns:

a client.

Return type:

pyvcloud.vcd.client.Client

Raises:

Exception: if the basic configuration is missing.

classmethod get_client_in_default_org(role)

Returns a client.

The client is for a user in the default test organization who has the specified role.

Parameters:role (CommonRoles) – role of the user.
Returns:a client configured with a user of the specified role logged in.
Return type:pyvcloud.vcd.client.Client
Raises:Exception: if the basic configuration is missing.
classmethod get_config()

Get test configuration parameter dictionary.

Returns:a dict containing configuration information.
Return type:dict
classmethod get_default_catalog_name()

Get the name of the default catalog that will be used for testing.

Returns:name of the test catalog.
Return type:str
classmethod get_default_logger()

Get a handle to the logger for system_tests.

Returns:default logger instance.
Return type:logging.Logger
classmethod get_default_orgvdc_network_name()

Get the name of the default org vdc network for testing.

Returns:name of the org vdc network.
Return type:str
classmethod get_default_template_name()

Get the name of the default template that will be used for testing.

Returns:name of the test template.
Return type:str
classmethod get_sys_admin_client()

Creates a sys admin client.

Returns:a sys admin client.
Return type:pyvcloud.vcd.client.Client
Raises:Exception: if the basic configuration is missing.
classmethod get_test_org(client)

Gets the organization used for testing.

Parameters:client (pyvcloud.vcd.client.Client) – client which will be used to create the Org object.
Returns:the organization in which all tests will run.
Return type:pyvcloud.vcd.org.Org
classmethod get_test_pvdc_name()

Gets the name of the pvdc to be used for testing.

Can return None if the method create_pvdc hasn’t be called before invoking this method.

Returns:name of the pvdc to be used for testing.
Return type:str
classmethod get_test_vdc(client)

Gets the vdc for testing.

Parameters:client (pyvcloud.vcd.client.Client) – client which will be used to create the VDC object.
Returns:the vdc that is backing the organization in which all tests will run.
Return type:pyvcloud.vcd.vdc.VDC
classmethod get_user_href_in_test_org(user_name)

Gets href of an user in the test organization.

Parameters:user_name (str) – name of the user whose href needs to be retrieved.
Returns:href of the user.
Return type:str
classmethod get_username_for_role_in_test_org(role_name)

Gets the username of the user in the test org with particular role.

Parameters:role_name (str) – name of the role which the concerned user has.
Returns:username of the concerned user.
Return type:str
classmethod get_vapp_in_test_vdc(client, vapp_name)

Gets the vApp identified by it’s name in the current org vdc.

Parameters:
  • client (pyvcloud.vcd.client.Client) – client which will be used to create the VApp object.
  • vapp_name (str) – name of the vApp which needs to be retrieved.
Returns:

the requested vApp.

Return type:

pyvcloud.vcd.vapp.VApp

classmethod init(config_data)

Initializer for Environment class.

Parameters:config_data (object) – a PyYAML object that contains the yaml representation of configuration data read from the configuration file.
classmethod share_catalog()

Shares the test catalog with all members in the test organization.

Raises:Exception: if the class variable _org_href is not populated.
Raises:EntityNotFoundException: if the catalog in question is missing.
classmethod upload_template()

Uploads the test template to the test catalog.

If template already exists in the catalog then skips uploading it.

Raises:Exception: if the class variable _org_href is not populated.
pyvcloud.system_test_framework.environment.developerModeAware(function)

Decorator function to skip execution of decorated function.

To be used on test teardown methods.

Parameters:function (function) – decorated function.
Returns:a function that either executes the decorated function or skips it, based on the value of a particular param in the environment configuration.
Return type:function