curie package

Submodules

curie.acropolis_cluster module

class curie.acropolis_cluster.AcropolisCluster(cluster_metadata)

Bases: curie.nutanix_cluster_dp_mixin.NutanixClusterDPMixin, curie.cluster.Cluster

cleanup(test_ids=())

Shutdown and remove all curie VMs from this cluster.

Raises:CurieException if cluster is not ready for cleanup after 40 minutes.
cleanup_images()

Cleans up image service, removing any images associated with curie.

clone_vms(vm, vm_names, node_ids=(), datastore_name=None, max_parallel_tasks=None, linked_clone=False)

Clones ‘vm’ and creates the VMs with names ‘vm_names’.

Parameters:
  • CurieVM (vm) – Base VM that clones will be created from.
  • list of strings (vm_names) – One clone will be created for each name in list.
  • list of node ids (node_ids) – If provided, must be the same length as ‘vm_names’, then ‘vm_names[xx]’ will be cloned to ‘node_ids[xx]’. Otherwise VMs will be cloned to random nodes on cluster.
  • datastore_name – If provided, name of datastore VMs will be cloned to. Otherwise the VMs will be created on the datastore associated with the curie server’s settings for this cluster.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel. The default value is FLAGS.prism_max_parallel_tasks.
  • linked_clone (bool) – Whether or not the clones should be “normal” full clones or linked clones.
Returns:

List of cloned VMs.

collect_performance_stats(**kwargs)

Collect performance statistics for all nodes in the cluster.

Optional arguments ‘start_time_secs’ and ‘end_time_secs’ can be used to limit the results to a specific time range. Note that these times are relative to the vSphere clock. If the clock of the Curie server is not synchronized, the samples returned might appear to be outside of the given time boundaries.

Parameters:
  • start_time_secs (int) – Optionally specify the oldest sample to return, in seconds since epoch. Defaults to five minutes in the past.
  • end_time_secs (int) – Optionally specify the newest sample to return, in seconds since epoch.
Returns:

(dict) Dict of list of curie_metrics_pb2.CurieMetric. Top level dict

keyed by node ID. List contains one entry per metric.

create_vm(goldimages_directory, goldimage_name, vm_name, vcpus=1, ram_mb=1024, node_id=None, datastore_name=None, data_disks=())

See ‘Cluster.create_vm’ for documentation.

delete_vms(vms, ignore_errors=False, max_parallel_tasks=None, timeout_secs=None)

Delete VMs.

Acropolis DELETE requests for /vms/{vm_id} are async. This method collects all taskUuids and polls until completion.

Parameters:
  • vms (list<CurieVM>) – List of VMs to delete.
  • ignore_errors (bool) – Optional. Whether to allow individual tasks to fail. Default False.
  • max_parallel_tasks (int) – Max number of requests to have in-flight at any given time. (Currently ignored)
  • timeout_secs (int) – If provided, overall timeout for VM deletion tasks.
Raises:

CurieTestException – - If any VM is not already powered off. - All VMs are not destroyed with in the timeout. - Destroy task fails and ignore_errors is False.

deploy_goldimage_image_service(goldimages_directory, goldimage_name)

Deploy a gold image to the image service.

Parameters:goldimage_name (str) – Name of the gold image to deploy.
Returns:ID of the created disk image.
Return type:str
disable_drs_vms(*args, **kwargs)

Disable DRS on VMs.

Parameters:vms – list of CurieVms: List of VMs disable DRS on.
disable_ha_vms(*args, **kwargs)

Disable HA on VMs.

Parameters:vms – list of CurieVms: List of VMs disable HA on.
enable_ha_vms(vms)

Enable HA on VMs.

Parameters:vms – list of CurieVms: List of VMs enable HA on.
get_cluster_architecture()

Get the processor architecture used by the cluster.

Returns:Cluster processor architecture.
Return type:str
get_node_uuid_metadata_id_map()
get_power_state_for_nodes(nodes)

See ‘Cluster.get_power_state_for_nodes’ for documentation.

get_power_state_for_vms(vms)

See ‘Cluster.get_power_state_for_vms’ for documentation.

classmethod identifier_to_cluster_uuid(rest_client, cluster_id_or_name)
classmethod identifier_to_node_uuid(rest_client, node_id_name_or_ip)
import_vm(goldimages_directory, goldimage_name, vm_name, node_id=None)

Creates a VM from the specified gold image. If ‘node_id’ is specified, the VM is created on that node, else a random node is selected. The VM will be created on the datastore associated with the curie server’s settings for this cluster.

is_drs_enabled()

See ‘Cluster.is_drs_enabled’ for documentation.

is_ha_enabled()

See ‘Cluster.is_ha_enabled’ for documentation.

migrate_vms(vms, nodes, max_parallel_tasks=None)

Move ‘vms’ to ‘nodes’.

For each VM ‘vms[xx]’ move to the corresponding Node ‘nodes[xx]’.

Parameters:
  • vms (list<Vm>) – List of VMs to migrate.
  • nodes (list<Node>) –

    List of nodes to which ‘vms’ should be migrated. Must be the same length as ‘vms’.

    Each VM in ‘vms’ wll be moved to the corresponding node in ‘nodes’.

  • max_parallel_tasks (int) – The number of VMs to migrate in parallel.
node_metadata(node_id)
nodes()

Returns a list of Node objects for the nodes in the cluster.

power_off_nodes_soft(nodes, timeout_secs=None, async=False)

See ‘Cluster.power_off_nodes_soft’ for definition.

power_off_vms(vms, max_parallel_tasks=None)

See ‘Cluster.power_off_vms’ for documentation.

power_on_vms(vms, max_parallel_tasks=None)

See ‘Cluster.power_on_vms’ for documentation.

relocate_vms_datastore(vms, datastore_names, max_parallel_tasks=None)

Relocate ‘vms’ to ‘datastore_names’.

sync_power_state_for_nodes(nodes, timeout_secs=None)

See ‘Cluster.sync_power_state_for_nodes’ for documentation.

update_metadata(include_reporting_fields)

Update the cluster’s metadata with additional information (if available) about the corresponding cluster. If ‘include_reporting_fields’ is True, also include additional information intended for reporting.

Note: this should only be called before the test begins executing steps in the kSetup, kRun, and kTeardown phases.

vms()

Returns a list of VM objects for the VMs in the cluster.

curie.acropolis_node module

class curie.acropolis_node.AcropolisNode(cluster, node_id, node_index)

Bases: curie.node.Node

cpu_capacity_in_hz
classmethod get_management_software_property_name_map()

See ‘Node.get_node_property_map’ for documentation.

node_ip()
power_off_soft(timeout_secs=None, async=False)

See ‘Node.power_off_soft’ for documentation.

curie.acropolis_types module

class curie.acropolis_types.AcropolisTaskEntity(*args, **kwargs)

Bases: curie.json_util.JsonData

entity_name = None
entity_type = None
uuid = None
class curie.acropolis_types.AcropolisTaskInfo(*args, **kwargs)

Bases: curie.json_util.JsonData

create_time = None
entity_list = None
message = None
meta_response = None
operation_type = None
percentage_complete = None
progress_status = None
uuid = None
class curie.acropolis_types.AcropolisTaskMetaResponse(*args, **kwargs)

Bases: curie.json_util.JsonData

error = None
error_detail = None

curie.acropolis_unix_vm module

class curie.acropolis_unix_vm.AcropolisUnixVm(vm_params)

Bases: curie.unix_vm_mixin.CurieUnixVmMixin, curie.acropolis_vm.AcropolisVm

curie.acropolis_vm module

class curie.acropolis_vm.AcropolisVm(vm_params)

Bases: curie.vm.Vm

is_powered_on()

See ‘CurieVM.is_powered_on’ for documentation.

curie.agent_rpc_client module

class curie.agent_rpc_client.AgentRpcClient(ip, port=5001, path='/rpc')

Bases: curie.rpc_util.RpcClientUtil

Client to issue CurieAgentRpcSvc RPCs to server at a given ‘ip’, ‘port’, and endpoint ‘path’.

CmdExecute(arg, initial_timeout_secs=1.0, max_retries=20)
CmdList(arg, initial_timeout_secs=1.0, max_retries=20)
CmdRemove(arg, initial_timeout_secs=1.0, max_retries=20)
CmdStatus(arg, initial_timeout_secs=1.0, max_retries=20)
CmdStop(arg, initial_timeout_secs=1.0, max_retries=20)
FileGet(arg, initial_timeout_secs=1.0, max_retries=20)
cmd_execute_sync(arg, timeout_secs, include_output=False)

Given the CmdExecute request ‘arg’, simulate synchronous execution by sending a CmdExecute RPC to start the command, polling until the command reaches a terminal state, then returning an (exit_status, stdout, stderr) tuple for the command. ‘include_output’ specifies whether stdout and stderr should be returned or not (both are None if this is set to False).

fetch_cmd_status(cmd_id)

Fetch the status for cmd_id.

Returns:where ret: CmdStatusRet filled out by rpc call to agent. err: None if no error or CurieError if there was an error.
Return type:(ret, err)
Raises:CurieException may be raised by rpc_client.CmdStatus().

curie.charon_agent_interface_pb2 module

curie.cluster module

class curie.cluster.Cluster(cluster_metadata)

Bases: object

check_cluster_ready(sync_with_oob=True)

Performs minimal checks to see if cluster is in a functioning state. Specifically:

– All associated nodes report ready via their ‘is_ready’ method. – Subclasses may extend this method to provide additional cluster-level checks specific to a given cluster type. – If applicable, will ensure that the host power states in management

software are synced with those reported via OOB queries.
Parameters:sync_with_oob (bool) – Optional. If True, ensure host power states are consistent as reported by OOB and management software prior to performing subsequent checks.
Returns:(bool) True if cluster is ready, else False.
check_nodes_ready(nodes, sync_with_oob=True)

Performs minimal checks to see if nodes are in a functioning state. Specifically:

– All nodes in ‘nodes’ report ready via their ‘is_ready’ method. – Subclasses may extend this method to provide additional cluster-level checks specific to a given cluster type.
Parameters:
  • nodes (list<Node>) – List of nodes to check.
  • sync_with_oob (bool) – Optional. If True, ensure host power states are consistent as reported by OOB and management software prior to performing subsequent checks.
Returns:

(bool) True if all nodes are ready, else False.

cleanup(test_ids=())

Clean up any state (e.g., lingering goldimage and test VMs) on the cluster for specified tests. If no test IDs are specified (empty list), then state is cleaned up for all tests regardless of their state.

clone_vms(vm, vm_names, node_ids=(), datastore_name=None, max_parallel_tasks=None, linked_clone=False)

Clones the VM ‘vm’ to create VMs with names ‘vm_names’. If the underlying cluster supports cloning VMs and binding them to specific nodes in the cluster, ‘node_ids’ can be specified for this purpose.

Note

Subclasses should provide a meaningful default value for ‘max_parallel_tasks’ or None if it is not used by its implementation.

collect_performance_stats(start_time_secs=None, end_time_secs=None)

Collect performance statistics for all nodes in the cluster.

Parameters:
  • start_time_secs (int) – The oldest sample to return, in seconds since epoch.
  • end_time_secs (int) – The newest sample to return, in seconds since epoch.
Returns:

(dict) Dict of list of curie_metrics_pb2.CurieMetric. Top level dict

keyed by node ID. List contains one entry per metric.

create_vm(goldimages_directory, goldimage_name, vm_name, vcpus=1, ram_mb=1024, node_id=None, datastore_name=None, data_disks=())

Creates a VM with the specifications provided.

The new VM will have an OS disk copied from the goldimage provided. It is placed on the requested node and datastore. Additional data disks are allocated if requested.

Parameters:
  • goldimage_name (str) – Name of the goldimage.
  • vm_name (str) – Name of the VM
  • vcpus (int) – Number of vCPUs.
  • ram_mb (int) – RAM in MB
  • node_id (str) – Node identifier
  • datastore_name (str) – Name of the datastore to put VM on.
  • data_disks (list) – List of additional data disk sizes to attach to the VM in gigabytes. e.g. [10,10] will create 2 disks of 10 GB each.
Returns:

VM that was created.

Return type:

curie.vm

delete_vms(vms, ignore_errors=False, max_parallel_tasks=None)

Delete VMs.

Acropolis DELETE requests for /vms/{vm_id} are async. This method collects all taskUuids and polls until completion.

Parameters:
  • vms (list<Vm>) – List of VMs to delete.
  • ignore_errors (bool) – Optional. Whether to allow individual tasks to fail. Default False.
  • max_parallel_tasks (int) – Max number of requests to have in-flight at any given time. (Currently ignored)
Raises:

CurieTestException – - If any VM is not already powered off. - All VMs are not destroyed with in the timeout. - Destroy task fails and ignore_errors is False.

disable_drs_vms(vms)

Disable DRS on VMs.

Parameters:vms – list of CurieVms: List of VMs disable DRS on.
disable_ha_vms(vms)

Disable HA on VMs.

Parameters:vms – list of CurieVms: List of VMs disable HA on.
enable_ha_vms(vms)

Enable HA on VMs.

Parameters:vms – list of CurieVms: List of VMs enable HA on.
find_vm(vm_name)

Return a VM whose name is equal to vm_name.

Parameters:vm_name – VM name string.
Returns:VM whose name is equal to vm_name, or None if not found.
find_vms(vm_names, sort_key=None)

Return list of VMs whose names are equal to the list of VM names.

The length of the returned list will be equal to the length of the input iterable. The ordering of the returned list will be the same as the input. If a VM is not found by a given name, None will be returned in its place.

Parameters:
  • vm_names – Iterable containing VM name strings.
  • sort_key – key parameter passed to sorted(). If None, the ordering of the returned list is the same as the input iterable.
Returns:

List of VMs that match the provided list of vm_names.

find_vms_regex(pattern)

Return list of VMs whose names match a regex pattern.

The VMs in the returned list will be sorted alphabetically by name.

Parameters:pattern (str) – regex pattern.
Returns:List of VMs whose names match the provided pattern.
get_power_state_for_nodes(nodes)

Returns a map of Node IDs for ‘nodes’ to their respective power states.

A Node’s ID will map to None upon error querying its power state.

Parameters:
  • nodes (list<Node>) – Nodes whose power state to check.
  • sync_with_oob (bool) – Optional. If True, confirm power state via OOB checks and refresh management software if necessary.

NB: The representation of the Node’s power state is currently dependent on the management software running on the cluster.

get_power_state_for_vms(vms)

Returns a map of VM IDs for ‘vms’ to their respective power states.

A VM’s ID will map to None upon error querying its power state.

NB: The representation of the VM’s power state is currently dependent on the management software running on the cluster.

get_powered_off_nodes(nodes=None, sync_with_oob=True)

Gets list of those ‘nodes’ which are not powered on.

If ‘nodes’ is None, returns all nodes which are not powered on.

Parameters:
  • nodes (list<Node>|None) – List of nodes to check.
  • sync_with_oob (bool) – Optional. If True, sync management reported data with OOB reported data.
Returns:

(list<Node>) List (possibly empty) of Nodes which are not powered on.

get_unready_nodes(nodes=None, sync_with_oob=True)

Performs minimal checks to see if cluster nodes are in in a ready state. Specifically:

– All associated nodes report ready via their ‘is_ready’ method.
Parameters:
  • nodes (list<Node>) – Optional. List of nodes to check. Defaults to all nodes in the cluster.
  • sync_with_oob (bool) – Optional. If True, sync management reported data with OOB data.
Returns:

(list<Node>) List (possibly empty) of Nodes

which are not ready.

import_vm(goldimages_directory, goldimage_name, vm_name, node_id=None)

Creates a VM from the specified gold image. The gold image ‘goldimage_name’ must be a gold image that the curie server has access to. If ‘vm_name’ is specified and the underlying cluster supports assigning a name to a VM on an import, assign the imported VM this name. If the underlying cluster supports creating a VM and binding it to a specific node in the cluster, ‘node_id’ can be specified for this purpose.

is_drs_enabled()

Checks whether cluster has any dynamic resource scheduling service enabled.

Returns:(bool) True if DRS is enabled, else False.
is_ha_enabled()

Checks whether cluster has any high availbility service enabled.

Returns:(bool) True if HA is enabled, else False.
metadata()
classmethod metrics()
migrate_vms(vms, nodes, max_parallel_tasks=None)

Move ‘vms’ to ‘nodes’.

For each VM ‘vms[xx]’ move to the corresponding Node ‘nodes[xx]’.

Parameters:
  • list of Vms (vms) – List of VMs to migrate.
  • list of Nodes (nodes) – Must be the same length as ‘vms’. Each VM in ‘vms’ wll be moved to the corresponding node in ‘nodes’.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel.

Note

Subclasses should provide a meaningful default value for ‘max_parallel_tasks’ or None if it is not used by its implementation.

name()
node_count()

Returns the number of nodes in the cluster.

node_metadata(node_id)
nodes()

Returns a list of Node objects for the nodes in the cluster.

power_off_nodes_soft(nodes, timeout_secs, async=False)

Power off ‘nodes’ via cluster management software.

Parameters:
  • 'nodes' (list<? extends Node>) – List of nodes to power off.
  • 'timeout_secs' (int|float) – Timeout in seconds for all nodes to power off. If ‘async’ is True this is inclusive of the time until power status is confirmed.
  • 'async' (bool) – Optional. If False, block until all of ‘nodes’ are confirmed to be powered off, or until ‘timeout_secs’ elapses. (Default False)
Raises:

CurieException<kTimeout> on timeout.

power_off_vms(vms, max_parallel_tasks=None)

Powers off VMs.

Parameters:
  • vms – List of VMs to power off.
  • int (max_parallel_tasks) – The number of VMs to power off in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
Raises:

CurieTestException – VMs fail to power off within the timeout.

power_on_nodes(nodes=None, async=False, timeout_mins=40)

Power on nodes. Optionally, wait for those nodes to become available.

Parameters:
  • nodes (list<Node>) – List of nodes to power on.
  • async (bool) – If False, block until nodes are ready. Otherwise, return immediately.
  • timeout_mins (int) – If async is False, block for no more than timeout_mins minutes. If async is True, this value has no effect.
Raises:

CurieException if cluster is not ready after wait_timeout_mins minutes.

power_on_vms(vms, max_parallel_tasks=None)

Powers on VMs and verifies that an IP address is assigned.

Parameters:
  • vms – List of VMs to power on.
  • max_parallel_tasks (int) – The number of VMs to power on in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
Raises:
  • CurieTestException – VMs fail to acquire an IP address within the
  • timeout.
relocate_vms_datastore(vms, datastore_names, max_parallel_tasks=None)

Relocate ‘vms’ to a datastore/container with names ‘datastore_names’.

For each VM ‘vms[xx]’ move to the datastore_names[xx].

Parameters:
  • list of CurieVms (vms) – List of VMs to migrate.
  • datastore_names – Must be the same length as ‘vms’. Each VM in ‘vms’ wll be moved to the corresponding datastore in ‘datastore_names’.
  • max_parallel_tasks (int) – The number of VMs to power on in parallel.

Note

Subclasses should provide a meaningful default value for ‘max_parallel_tasks’ or None if it is not used by its implementation.

snapshot_vms(vms, tag=None, max_parallel_tasks=None)

For each VM in vms on the cluster, creates a snapshot with snapshot name ‘snapshot_names[xx]’ and optional description ‘snapshot_descriptions[xx]’.

Args

vms (list<CurieVMs>): List of VMs to create snapshots for. snapshot_names list of strings: Names for snapshot which must be the same

length as ‘vms’.
snapshot_descriptions (list<str>): List of escriptions for each
snapshot corresponding to ‘vms’ and ‘snapshot_names’. If provided it must be the same length as ‘vms’.
max_parallel_tasks (int|None): Optional. If provided, max number of
management server tasks to perform in parellel. Default None.
sync_power_state_for_nodes(nodes, timeout_secs=None)

Synchronize management software and OOB power state for ‘nodes’.

Confirm power state via OOB checks matches value reported by management software. If there is a mismatch, refresh management software, and verify that the state is synchronized.

Parameters:
  • nodes (list<Node>) – Nodes whose power state to sync.
  • timeout_secs (int) – Maximum amount of time to try to sync, in seconds.
Returns:

Map of Node IDs for ‘nodes’ to their respective power states.

Return type:

dict

Raises:

CurieTestException – If power states cannot be synchronized.

NB: The representation of the Node’s power state is currently dependent on the management software running on the cluster.

update_metadata(include_reporting_fields)

Update the cluster’s metadata with additional information (if available) about the corresponding cluster. If ‘include_reporting_fields’ is True, also include additional information intended for reporting.

Note: this should only be called before the test begins executing steps in the kSetup, kRun, and kTeardown phases.

vms()

Returns a list of VM objects for the VMs in the cluster.

curie.curie_error_pb2 module

curie.curie_extensions_pb2 module

curie.curie_interface_pb2 module

curie.curie_metrics_pb2 module

curie.curie_server_state_pb2 module

curie.curie_test_pb2 module

curie.curie_types_pb2 module

curie.decorator module

curie.decorator.curie_api_handler(func)
class curie.decorator.validate_parameter(param_name, valid_types=None, valid_values=None, valid_func=None)

Bases: object

class curie.decorator.validate_return(valid_types=None, valid_values=None, valid_func=None, err_code=3)

Bases: object

curie.discovery_util module

class curie.discovery_util.DiscoveryUtil

Bases: object

CE_HOST_ATTR_KEY = 'blockModelName'
CE_HOST_ATTR_VAL = 'CommunityEdition'
VENDOR_ALIAS_RE_MAP = {1: ['super ?micro'], 2: ['\\bdell(\\b| )']}
static compute_vcenter_cluster_inventory(vim_folder)

Discovers clusters present in the ‘vim.Folder’ object ‘vim_folder’.

Parameters:vim_folder (vim.Folder) – vCenter folder whose inventory to return.
Returns:
cluster inventory mapping from
(vim_datacenter_name (str), vim.Datacenter) ->
(vim_cluster_name (str), vim.ClusterComputeInstance) ->
(vim_datastore_name (str), vim.Datastore)
Return type:(dict)
static discover_clusters_prism(address, username, password, ret)
Parameters:
  • address (str) – Address of the management server.
  • username (str) – Name of user of the management server.
  • password (str) – Password of user of the management server
  • ret (DiscoverClustersV2Ret) – Return proto to be populated.
static discover_clusters_vcenter(address, username, password, ret)
Parameters:
  • address (str) – Address of the management server.
  • username (str) – Name of user of the management server.
  • password (str) – Password of user of the management server
  • ret (DiscoverClustersV2Ret) – Return proto to be populated.
static discover_clusters_vmm(address, username, password, ret)
Parameters:
  • address (str) – Address of the management server.
  • username (str) – Name of user of the management server.
  • password (str) – Password of user of the management server
  • ret (DiscoverClustersV2Ret) – Return proto to be populated.
static discover_nodes_prism(arg, ret)

See ‘DiscoveryUtil.handle_nodes_discovery_v2’ for info.

static discover_nodes_vcenter(arg, ret)

See ‘DiscoveryUtil.handle_nodes_discovery_v2’ for info.

static discover_nodes_vmm(arg, ret)

See ‘DiscoveryUtil.handle_nodes_discovery_v2’ for info.

static lookup_node_bmc_info(vim_node)

Looks up BMC data for ‘vim_node’.

Parameters:vim_node (vim.HostSystem) – Host whose IPMI data to fetch.
Returns:
(str, Node.NodeOutOfBandManagementInfo.Vendor) IPv4 Address and
vendor for the node’s BMC.
Raises:CurieException<kInternalError> (with original trace) on error
static update_cluster_version_info(cluster_pb)
Parameters:cluster_pb (curie_server_state_pb2.CurieSettings.Cluster) – Populated cluster proto whose data to update.
static update_cluster_virtual_ip(cluster_pb)

Updates ‘prism_host’ to correspond to the cluster virtual IP.

The ‘prism_host’ field is set for management and clustering software as appropriate for the target hypervisor.

Returns:True if ‘prism_host’ was updated, else False.
Raises:CurieException – ‘cluster_pb’ is a Nutanix cluster but does not have a Virtual IP.
static validate_host_connectivity(cluster_pb)
static validate_oob_config(cluster_pb)

Validates provided out-of-band management config in ‘cluster_pb’.

Parameters:cluster_pb (curie_server_state_pb2.CurieSettings.Cluster) – Populated cluster proto whose data to validate.

Raises: CurieException on any error encountered.

curie.error module

curie.error.curie_error_to_http_status(error_code)

Returns an HTTP status code corresponding to the curie error code ‘error_code’.

curie.exception module

exception curie.exception.CurieException(error_code, error_msg)

Bases: exceptions.Exception

exception curie.exception.CurieTestException

Bases: exceptions.RuntimeError

exception curie.exception.ScenarioStoppedError

Bases: curie.exception.CurieTestException

exception curie.exception.ScenarioTimeoutError

Bases: curie.exception.CurieTestException

curie.generic_vsphere_cluster module

class curie.generic_vsphere_cluster.GenericVsphereCluster(cluster_metadata)

Bases: curie.vsphere_cluster.VsphereCluster

snapshot_vms(vms, tag=None, max_parallel_tasks=None)

For each VM with name ‘vm_names[xx]’ on the cluster ‘vim_cluster’, creates a snapshot with snapshot name ‘snapshot_names[xx]’ and optional description ‘snapshot_descriptions[xx]’.

Args

vms list of CurieVMs: List of VMs to create snapshots for. snapshot_names list of strings: Names for snapshot which must be the same

length as ‘vms’.
snapshot_descriptions List of strings: List of escriptions for each
snapshot corresponding to ‘vms’ and ‘snapshot_names’. If provided it must be the same length as ‘vms’.
max_parallel_tasks int: The number of VMs to power on in parallel. The
default value is FLAGS.vsphere_vcenter_max_parallel_tasks.

curie.generic_vsphere_node_util module

class curie.generic_vsphere_node_util.GenericVsphereNodeUtil(node)

Bases: curie.node_util.NodeUtil

is_ready()

See ‘NodeUtil.is_ready’ documentation for further details.

For a generic vSphere node, check only that vCenter reports the node is powered on.

curie.goldimage_manager module

class curie.goldimage_manager.GoldImageManager(images_root)

Bases: object

Manage base OS disk images for use by Curie VMs.

The GoldImageManager relies on a directory that contains disk images of various image formats and may target more than one architecture. The manager expects that the filenames of the images follow this convention:

<image_name>_<architecture>.<format> e.g. debian9-x86_64.qcow2

The manager can also issue qemu-img convert commands to convert disk images to alternative formats.

ARCH_PPC64LE = 'ppc64le'
ARCH_X86_64 = 'x86_64'
FORMAT_QCOW2 = 'qcow2'
FORMAT_RAW = 'raw'
FORMAT_VHDX = 'vhdx'
FORMAT_VHDX_ZIP = 'vhdx.zip'
FORMAT_VMDK = 'vmdk'
VALID_ARCH = ['x86_64', 'ppc64le']
VALID_FORMAT = ['raw', 'qcow2', 'vmdk', 'vhdx', 'vhdx.zip']
static convert_image_format(source_image_path, dest_image_path, dest_format)

Converts a disk image from source_image_path to the desired format.

Parameters:
  • source_image_path (str) – Full path to source image.
  • dest_image_path (str) – Full path to destination image.
  • dest_format (str) – The desired destination format.
Returns:

Return code from ‘qemu-img convert’ call.

Return type:

int

static get_goldimage_filename(image_name, format_str='vmdk', arch='x86_64')

Provides the expected filename of a goldimage based on :param image_name: The name of the image to get. :type image_name: str :param format_str: A format to get the image in. Valid options include

raw, qcow2, vmdk or vhdx.
Parameters:arch (str) – The target architecture of the image. Valid options include x86_64 or ppc64le.
Returns:Filename of goldimage
Return type:str
get_goldimage_path(image_name, format_str='vmdk', arch='x86_64', auto_convert=True)

Find an image file based on the name, format, and architecture.

If the image doesn’t exist in the current format, if auto_convert is set and a QCOW2 formatted version of the image exists, attempt to convert to the desired format.

Parameters:
  • image_name (str) – The name of the image to get.
  • format_str (str) – A format to get the image in. Valid options include raw, qcow2, vmdk or vhdx.
  • arch (str) – The target architecture of the image. Valid options include x86_64 or ppc64le.
  • auto_convert (bool) – Whether or not an image should be automatically converted from an existing format to the desired format.
Returns:

Full path to image.

Return type:

str

Raises:

CurieException – If the image doesn’t exist or could not be created.

curie.hyperv_cluster module

class curie.hyperv_cluster.HyperVCluster(cluster_metadata)

Bases: curie.cluster.Cluster

TIMEOUT = 900
cleanup(test_ids=())

Shutdown and remove all curie VMs from this cluster.

Raises:CurieException if cluster is not ready for cleanup after 40 minutes.
clone_vms(vm, vm_names, node_ids=(), datastore_name=None, max_parallel_tasks=16, linked_clone=False)

Clones the VM ‘vm’ to create VMs with names ‘vm_names’. If the underlying cluster supports cloning VMs and binding them to specific nodes in the cluster, ‘node_ids’ can be specified for this purpose.

Note

Subclasses should provide a meaningful default value for ‘max_parallel_tasks’ or None if it is not used by its implementation.

collect_performance_stats(start_time_secs=None, end_time_secs=None)

Collect performance statistics for all nodes in the cluster.

Parameters:
  • start_time_secs (int) – The oldest sample to return, in seconds since epoch.
  • end_time_secs (int) – The newest sample to return, in seconds since epoch.
Returns:

(dict) Dict of list of curie_metrics_pb2.CurieMetric. Top level dict

keyed by node ID. List contains one entry per metric.

create_vm(goldimages_directory, goldimage_name, vm_name, vcpus=1, ram_mb=1024, node_id=None, datastore_name=None, data_disks=())

Creates a VM with the specifications provided.

The new VM will have an OS disk copied from the goldimage provided. It is placed on the requested node and datastore. Additional data disks are allocated if requested.

Parameters:
  • goldimage_name (str) – Name of the goldimage.
  • vm_name (str) – Name of the VM
  • vcpus (int) – Number of vCPUs.
  • ram_mb (int) – RAM in MB
  • node_id (str) – Node identifier
  • datastore_name (str) – Name of the datastore to put VM on.
  • data_disks (list) – List of additional data disk sizes to attach to the VM in gigabytes. e.g. [10,10] will create 2 disks of 10 GB each.
Returns:

VM that was created.

Return type:

curie.vm

delete_vms(vms, ignore_errors=False, max_parallel_tasks=100)

Delete VMs.

Acropolis DELETE requests for /vms/{vm_id} are async. This method collects all taskUuids and polls until completion.

Parameters:
  • vms (list<Vm>) – List of VMs to delete.
  • ignore_errors (bool) – Optional. Whether to allow individual tasks to fail. Default False.
  • max_parallel_tasks (int) – Max number of requests to have in-flight at any given time. (Currently ignored)
Raises:

CurieTestException – - If any VM is not already powered off. - All VMs are not destroyed with in the timeout. - Destroy task fails and ignore_errors is False.

disable_drs_vms(vms)

Disable DRS on VMs.

Parameters:vms – list of CurieVms: List of VMs disable DRS on.
disable_ha_vms(vms)

Disable HA on VMs.

Parameters:vms – list of CurieVms: List of VMs disable HA on.
enable_ha_vms(vms)

Enable HA on VMs.

Parameters:vms – list of CurieVms: List of VMs enable HA on.
get_power_state_for_nodes(nodes)

Returns a map of Node IDs for ‘nodes’ to their respective power states.

A Node’s ID will map to None upon error querying its power state.

Parameters:
  • nodes (list<Node>) – Nodes whose power state to check.
  • sync_with_oob (bool) – Optional. If True, confirm power state via OOB checks and refresh management software if necessary.

NB: The representation of the Node’s power state is currently dependent on the management software running on the cluster.

get_power_state_for_vms(vms)

See ‘Cluster.get_power_state_for_vms’ for documentation.

import_vm(goldimages_directory, goldimage_name, vm_name, node_id=None)

Creates a VM from the specified gold image. The gold image ‘goldimage_name’ must be a gold image that the curie server has access to. If ‘vm_name’ is specified and the underlying cluster supports assigning a name to a VM on an import, assign the imported VM this name. If the underlying cluster supports creating a VM and binding it to a specific node in the cluster, ‘node_id’ can be specified for this purpose.

is_drs_enabled()

See ‘Cluster.is_drs_enabled’ for documentation.

is_ha_enabled()

See ‘Cluster.is_ha_enabled’ for documentation.

migrate_vms(vms, nodes, max_parallel_tasks=8)

Move ‘vms’ to ‘nodes’.

For each VM ‘vms[xx]’ move to the corresponding Node ‘nodes[xx]’.

Parameters:
  • list of Vms (vms) – List of VMs to migrate.
  • list of Nodes (nodes) – Must be the same length as ‘vms’. Each VM in ‘vms’ wll be moved to the corresponding node in ‘nodes’.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel.

Note

Subclasses should provide a meaningful default value for ‘max_parallel_tasks’ or None if it is not used by its implementation.

nodes(node_ids=None)

Returns a list of Node objects for the nodes in the cluster.

power_off_nodes_soft(nodes, timeout_secs=None, async=False)

See ‘Cluster.power_off_nodes_soft’ for definition.

power_off_vms(vms, max_parallel_tasks=100)

Powers off VMs.

Parameters:
  • vms – List of VMs to power off.
  • int (max_parallel_tasks) – The number of VMs to power off in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
Raises:

CurieTestException – VMs fail to power off within the timeout.

power_on_vms(vms, max_parallel_tasks=100)

Powers on VMs and verifies that an IP address is assigned.

Parameters:
  • vms – List of VMs to power on.
  • max_parallel_tasks (int) – The number of VMs to power on in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
Raises:
  • CurieTestException – VMs fail to acquire an IP address within the
  • timeout.
relocate_vms_datastore(vms, datastore_names, max_parallel_tasks=16)

Relocate ‘vms’ to ‘datastore_names’.

snapshot_vms(vms, tag, snapshot_description=None)

For each VM in vms on the cluster, creates a snapshot with snapshot name ‘snapshot_names[xx]’ and optional description ‘snapshot_descriptions[xx]’.

Args

vms (list<CurieVMs>): List of VMs to create snapshots for. snapshot_names list of strings: Names for snapshot which must be the same

length as ‘vms’.
snapshot_descriptions (list<str>): List of escriptions for each
snapshot corresponding to ‘vms’ and ‘snapshot_names’. If provided it must be the same length as ‘vms’.
max_parallel_tasks (int|None): Optional. If provided, max number of
management server tasks to perform in parellel. Default None.
sync_power_state_for_nodes(nodes, timeout_secs=None)

Synchronize management software and OOB power state for ‘nodes’.

Confirm power state via OOB checks matches value reported by management software. If there is a mismatch, refresh management software, and verify that the state is synchronized.

Parameters:
  • nodes (list<Node>) – Nodes whose power state to sync.
  • timeout_secs (int) – Maximum amount of time to try to sync, in seconds.
Returns:

Map of Node IDs for ‘nodes’ to their respective power states.

Return type:

dict

Raises:

CurieTestException – If power states cannot be synchronized.

NB: The representation of the Node’s power state is currently dependent on the management software running on the cluster.

update_metadata(include_reporting_fields)

Update the cluster’s metadata with additional information (if available) about the corresponding cluster. If ‘include_reporting_fields’ is True, also include additional information intended for reporting.

Note: this should only be called before the test begins executing steps in the kSetup, kRun, and kTeardown phases.

vms()

Returns a list of VM objects for the VMs in the cluster.

curie.hyperv_node module

class curie.hyperv_node.HyperVNode(cluster, node_id, node_index, node_properties)

Bases: curie.node.Node

get_fqdn()
classmethod get_management_software_property_name_map()

See ‘Node.get_node_property_map’ for documentation.

power_off_soft(timeout_secs=None, async=False)

See ‘Node.power_off_soft’ for documentation.

curie.hyperv_node_util module

class curie.hyperv_node_util.HyperVNodeUtil(node)

Bases: curie.node_util.NodeUtil

is_ready()

See ‘NodeUtil.is_ready’ documentation for further details.

For a generic vSphere node, check only that vCenter reports the node is powered on.

curie.hyperv_unix_vm module

class curie.hyperv_unix_vm.HyperVUnixVM(vm_params, json_vm)

Bases: curie.unix_vm_mixin.CurieUnixVmMixin, curie.hyperv_vm.HyperVVm

curie.hyperv_vm module

class curie.hyperv_vm.HyperVVm(vm_params, json__vm)

Bases: curie.vm.Vm

is_powered_on()

Returns True if the VM is powered on, else False.

NB: This method only checks the VM’s power state. It does not guarantee that the VM is accessible (cf. ‘Vm.is_accessible’)

Returns:(bool) True if VM is powered on, else False.

curie.idrac_util module

Util for iDRAC XML requests.

The idracadm command-line util provided by Dell essentially wraps a command in an <EXEC> tag and issues a POST request to the iDRAC host. As an alternative to wrapping calls to the iracadm binary, this util accepts racadm commands, generates and sends the POST request, and parses the returned data.

This allows for both caching sessions (overhead for authentication averages roughly 2-4 seconds), as well as eliminating the need for additional dependencies on vendor binaries.

IdracUtil may be registered as an OoB Management handler for OobManagementUtil, as it implements the required API.

Example (note it attempts to cache and reuse session credentials):

iDRAC commandline:

idracadm -r neutrino07-i1 -u root -p nutanix/4u getsysinfo idracadm -r neutrino07-i1 -u root -p nutanix/4u serveraction poweron

Util usage:

idrac = IdracUtil(“neutrino07-i1”, “root”, “nutanix/4u”) idrac.send_racadm_command(“getsysinfo”) idrac.send_racadm_command(“serveraction poweron”)
class curie.idrac_util.IdracUtil(ip, username, password)

Bases: curie.oob_management_util.OobManagementUtil

Util class for managing XML-HTTP iDRAC calls.

HOST_SESSION_ID_MAP = {}
LOCK = <thread.lock object>
get_chassis_status()
Returns:(dict) map of system info.
Raises:CurieException<kInternalError> on failure.
is_powered_on()
Returns:(bool) True if powered on, else False.
power_cycle(async=False)

Power cycles node associated with iDRAC at ‘self.__host’.

Parameters:
  • async (bool) – Optional. If False, issue blocking calls to ‘power_off’
  • 'power_on'. (then) –
Returns:

(bool) True on success, else False.

power_off(async=False)

Powers off node associated with iDRAC at ‘self.__host’.

Parameters:async (bool) – Optional. If True, return immediately after command succeeds, don’t block until power state has changed to off.
Returns:(bool) True on success, else False.
power_on(async=False)

Powers on node associated with iDRAC at ‘self.__host’.

Parameters:async (bool) – Optional. If True, return immediately after command succeeds, don’t block until power state has changed to on.
Returns:(bool) True on success, else False.
send_racadm_command(cmd, max_retries=5)

Issues ‘cmd’ to iDRAC at ‘self.__host’, retrying up to ‘max_retries’ times.

Automatically reauthenticates if necessary.

Parameters:
  • cmd (str) – Command to execute.
  • max_retries (int) – Optional. Maximum number of retry attempts on failure.
Returns:

(dict) parsed XML response.

class curie.idrac_util.RacAdmRequest(host, method_name, cookie=None)

Bases: curie.xml_util.XmlData

Base class for any iDRAC request objects.

Manages DOM root for building and serializing a message.

For login requests (handled internally as necessary): <LOGIN>

<REQ>
<USERNAME>USERNAME</USERNAME> <PASSWORD>PASSWORD</PASSWORD>

</REQ>

</LOGIN>

For commands:

<EXEC>
<REQ>
<CMDINPUT>SOME COMMAND STRING</CMDINPUT> <MAXOUTPUTLEN>0x0fff</MAXOUTPUTLEN>

</REQ>

</EXEC>

HEADERS = {'User-Agent': 'racadm'}
URL = 'https://{idrac_ip}/cgi-bin/{cmd_type}'
add_param(name, value)

Appends a request parameter ‘name’ with value ‘value’.

Appends a parameter to the <REQ> node as: <$name>

$value

</$name>

headers()
send()

Issues command represented by this instance to iDRAC at ‘self._host’.

Returns:(dict) parsed XML response.
Raises:CurieException<kInvalidParameter> on error.
static xpath()
class curie.idrac_util.RacAdmResponse(resp_root)

Bases: dict

curie.ipmi_util module

Provides utils related to IPMI, and wrapper around ipmitool calls.

class curie.ipmi_util.Flag(switch, value)

Bases: object

to_unredacted()
class curie.ipmi_util.IpmiUtil(ip, username, password, interface='lanplus', verbosity=0, ipmitool_abspath='/usr/bin/ipmitool')

Bases: curie.oob_management_util.OobManagementUtil

Wraps calls to ipmitool.

Generated commands will be of the form:
<IPMITOOL_ABSPATH> <GENERATED_FLAGS> <COMMAND> [SUB_COMMAND] [CMD_ARGS]
VALID_BOOT_DEVICES = ['none', 'pxe', 'disk', 'safe', 'diag', 'cdrom', 'bios', 'floppy']
get_chassis_status()
Returns:Map of IPMI chassis status data.
Return type:(dict)
Raises:CurieException on error.
get_event_log()

Dump System Event Log.

Returns:List of events represented as dict/JSON.
Return type:(list<dict>)
get_fru_info()

Dump FRU info.

Returns:List of FRU info dicts.
Return type:(list<dict>)
get_lan_config()

Get IP, MAC address, etc. for the node’s IPMI.

Returns:Map of IPMI lan cofiguration data.
Return type:(dict)
get_mac_addrs_supermicro()

Get MAC addresses for the node’s network cards.

NB: Returns only two addresses, second address is autogenerated.

Returns:MAC Addresses.
Return type:(list<str>)
is_powered_on()

Checks whether chassis power state is ‘on’.

Returns:(bool) True if powered on, else False.
power_cycle(async=False)

Power cycles the node associated with ‘self.__flags[“host”]’.

Parameters:
  • async (bool) – Optional. If False, making blocking calls to ‘power_off’
  • then 'power_on'. (and) –
  • True and node is powered off, performs async 'power_on' call, (If) –
  • issues the (otherwise) –
Returns:

True on success, else False.

Return type:

(bool)

power_off(async=False)

Powers off the node associated with ‘self.__flags[“host”]’.

Parameters:async (bool) – Optional. If False, block until power state is off.
Returns:True on success, else False.
Return type:(bool)
power_on(async=False)

Powers on the node associated with ‘self.__flags[“host”]’.

Parameters:async (bool) – Optional. If False, block until power state is on.
Returns:True on success, else False.
Return type:(bool)
set_bootdev(device)

Sets first bootdevice to device.on next boot for the node associated with ‘self.__flags[“host”]’.

Returns:True on success, else False.
Return type:(bool)
set_bootdev_pxe()

Forces PXE on next boot for the node associated with ‘self.__flags[“host”]’.

Returns:True on success, else False.
Return type:(bool)
class curie.ipmi_util.RedactedFlag(switch, value)

Bases: curie.ipmi_util.Flag

to_unredacted()
class curie.ipmi_util.RepeatedFlag(switch, value)

Bases: curie.ipmi_util.Flag

class curie.ipmi_util.SystemEvent(raw_ipmi_output)

Bases: object

FIELDS = ['event_id', 'timestamp', 'sensor', 'description', 'direction']
TIME_FORMAT = '%m/%d/%Y %H:%M:%S'

curie.json_util module

class curie.json_util.Enum

Bases: object

Class which provides “enum” functionality.

Declared as syntactic sugar. (Subclass ‘Enum’ rather than set metaclass).

class curie.json_util.EnumElement(name, value, parent_enum)

Bases: object

Data representing a particular value for an Enum class.

class curie.json_util.EnumMeta

Bases: type

Metaclass enabling syntactic sugar for ‘Enum’.

class curie.json_util.Field(data_type, required=False, strict=False, default=None)

Bases: object

Provides schema validation, type coercion, etc. for a field in e.g. JSON.

set_attr(obj, key, val)

Sets ‘key’ to ‘val’ on ‘obj’ where ‘key’ is defined by this field.

Performes appropriate validation and/or coercion.

Parameters:
  • obj (? extends JsonData) – Instance on which to set ‘key’.
  • key (str) – Name of key to set to ‘val’.
  • val ('self.data_type') – Value to which ‘key’ should be set on ‘obj’.
Raises:

TypeError propagated from ‘_validate_and_coerce’.

class curie.json_util.JsonData(*args, **kwargs)

Bases: _abcoll.MutableMapping

Map supporting conversion to/from JSON with schema checking, automatic type conversion, etc.

static camel_case_to_underscore(text)

Transformes camel-cased ‘text’ to underscore delmited text.

(e.g. camelCase to camel_case)

Parameters:text (str) – camel-cased text to transform.
Returns:(str) Transformed text.
dumps(sort_keys=True, indent=2, filter_empty=True, to_camel_case=True)

Serializes data into JSON string.

Parameters:
  • sort_keys (bool) – Optional. Whether to sort keys in serialized string. Default True.
  • indent (int) – Optional. Number of spaces per indent level. Default 2.
  • filter_empty (bool) – Optional. Whether to omit unset fields or provide their default values (or null). Default True.
  • to_camel_case (bool) – Optional. If True, convert underscore any delimited keys to camel-case. Default True.
Returns:

(str) serialized JSON representation of data.

json(filter_empty=True, recurse=True, to_camel_case=True)

Converts into JSON compatible dict.

Parameters:
  • filter_empty (bool) – Optional. Whether to filter unset fields or provide their default values (or null). Default True.
  • recurse (bool) – Optional. Whether to recursively convert fields to JSON compatible dicts. Default True.
  • to_camel_case (bool) – Optional. If True, convert underscore any delimited keys to camel-case. Default True.
Returns:

(dict) JSON serializable map.

static underscore_to_camel_case(text)

Transformes underscore delimted ‘text’ to camel-cased text.

(e.g. camel_case to camelCase)

Parameters:text (str) – underscore delimted text to transform.
Returns:(str) Transformed text.
class curie.json_util.JsonDataEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)

Bases: json.encoder.JSONEncoder

default(obj)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class curie.json_util.JsonDataMeta

Bases: abc.ABCMeta

Metaclass which allows for ‘JsonData’s syntactic sugar.

class curie.json_util.RepeatedField(data_type, required=False, strict=False, default=None)

Bases: curie.json_util.Field

Provides ‘Field’ functionality for fields whose data is a typed list.

append(val)
extend(lst)
set_attr(obj, key, val)

Sets ‘key’ to ‘val’ on ‘obj’ where ‘key’ is defined by this field.

Performes appropriate validation and/or coercion.

Parameters:
  • obj (? extends JsonData) – Instance on which to set ‘key’.
  • key (str) – Name of key to set to ‘val’.
  • val ('self.data_type') – Value to which ‘key’ should be set on ‘obj’.
Raises:

TypeError propagated from ‘_validate_and_coerce’.

curie.log module

curie.log.CHECK(expr, msg='')
curie.log.CHECK_EQ(expr1, expr2, msg='')
curie.log.CHECK_GE(expr1, expr2, msg='')
curie.log.CHECK_GT(expr1, expr2, msg='')
curie.log.CHECK_LE(expr1, expr2, msg='')
curie.log.CHECK_LT(expr1, expr2, msg='')
curie.log.CHECK_NE(expr1, expr2, msg='')
curie.log.initialize(log_file=None, debug_log_file=None, logtostderr=False, debug=False)

Initialize logging subsystem to log to the file ‘logfile’.

If gflags.FLAGS.logtostderr is True, a standard error stream handler is created.

Parameters:log_directory (basestring) – Optionally specify directory in which to create log files. If no directory is specified, no log files will be created.
curie.log.patch_trace()

curie.metrics_util module

class curie.metrics_util.MetricsUtil

Bases: object

static filter_results_map(results_map, metric_name_regex, instance_regex='.*')

Return a new filtered results map.

Parameters:
  • results_map (dict) – Results map to filter.
  • metric_name_regex (str) – Regex pattern to match against metric names.
  • instance_regex (str) – Regex pattern to match against instance names.
Returns:

(dict) Filtered results map.

static get_series(metric)

Convert a CurieMetric to pandas.Series.

Parameters:metric (CurieMetric) – Metric to convert.
Returns:(pandas.Series)
static metric_name(curie_metric)

Get the pretty, dot-delimited name of a CurieMetric.

Parameters:curie_metric (curie_metrics_pb2.CurieMetric) – Metric to convert to string.
Returns:(str) Name of the CurieMetric.
static pickle_xy_data2d(x_series, y_series, data_2d)

Takes an x_series (most likely timestamps) and a y_series, pickles the result and adds it to the data_2d protobuf.

Parameters:
  • x_series – (list) List of x values.
  • y_series – (list) List of y values.
  • data_2d – (curie_test_pb2.CurieTestResult.Data2D.Pickled2DData) Protobuf in which to insert the series data.
static sorted_results_map(results_map)

Return a new sorted results map.

Parameters:results_map (dict) – Results map to sort.
Returns:(dict) Sorted results map.

curie.mof_util module

curie.mof_util.generate_enum_definitions(path, cls_prop_map)

curie.name_util module

class curie.name_util.NameUtil

Bases: object

static entity_name(test, test_local_entity_name)

Returns a unique entity name for the entity with test-local name ‘test_local_entity_name’ to be used by ‘test’.

static filter_test_entity_names(entity_names, test_ids)
static filter_test_vm_names(vm_names, test_ids, include_goldimages=True)
static filter_test_vms(vms, test_ids, include_goldimages=True)

Given the list of CurieVMs ‘vms’, return a tuple where the first element is the subset of that list corresponding to the curie VMs for the specified tests and the second element is a list of the corresponding test IDs. If no test IDs are specified (empty list), then return information for all curie VMs in ‘vm_names’.

static get_vm_name_prefix()
static goldimage_vm_name(test, goldimage_name)

Returns a unique VM name for the goldimage VM for goldimage ‘goldimage_name’ to be used by ‘test’.

The output is limited to 80 characters for compliance with vCenter.

static goldimage_vmdisk_name(goldimage_name, disk_name)

Returns a unique name for a disk belonging to a goldimage VM.

static library_server_path(cluster_name, goldimage_name)

Returns a unique library server share path.

static sanitize_filename(filename)

Convert a string to a safe filename.

Any sequence of characters that are not a letter, a digit, a hyphen, or a period will be converted to an underscore.

Parameters:filename (str) – Filename to sanitize.

Returns: Sanitized filename.

static test_vm_name(test, test_local_vm_name)

Returns a unique VM name for the test VM with test-local name ‘test_local_vm_name’ to be used by ‘test’.

The output is limited to 80 characters for compliance with vCenter.

curie.node module

class curie.node.Node(cluster, node_id, node_index)

Bases: object

cluster()
classmethod get_management_software_property_name_map()

Gets map of management software specific values for node attributes.

Gets map of vendor-specific names for the standardized attributes in ‘NodePropertyNames’.

classmethod get_management_software_value_for_attribute(attr)

Get management software specific value for ‘attr’.

is_powered_on(*args, **kwargs)

Checks if node is currently powered on via OOB management specified in the node’s metadata.

Returns:(bool) True if node is powered on, else False.
is_powered_on_soft(sync_with_oob=True)

Checks if node is powered on from the management software.

The management software state will lag behind the hardware state.

If ‘sync_with_oob’ is True, sync with OOB reported hardware state.

Parameters:sync_with_oob (bool) – Optional. If True, sync with OOB hardware state.
Returns:(bool) True if powered on detected at the management server, False otherwise.
is_ready(check_power_state=True)

Checks node is in a ready state.

– Checks node is powered on (assumed true if check_power_state=False). – Checks relevant services are responsive.

Parameters:check_power_state (bool) – Optional. If False, skip power state checks.
Returns:(bool) True if node is powered on and relevant services are responding, else False.
metadata()
node_id()
node_index()
node_ip()
power_cycle(*args, **kwargs)

Power cycles the node using out-of-band management interface specified in the cluster’s metadata.

NB: In order to avoid our status polling racing the node’s power status,
invoke ‘power_off’ then ‘power_on’ in the synchronous case rather than issuing ‘chassis power cycle’.
Parameters:
  • async (bool) – If False, make synchronous calls to ‘power_off’ and
  • 'power_on'.
Raises:
  • CurieTestException if no suitable metadata exists, CurieException on
  • all other errors.
power_off(*args, **kwargs)

Powers off the node using out-of-band management interface specified in the cluster’s metadata.

Parameters:
  • sync_management_state (bool) – If true, wait until the management software
  • the power state is off. This is True by default in order to (detects) –
  • other management server methods that require power to be on from (prevent) –
  • unexpectedly. (failing) –
Raises:
  • CurieTestException if no suitable metadata exists, CurieException on
  • all other errors.
power_off_soft(timeout_secs=None, async=False)

Gracefully powers off node.

Parameters:
  • timeout_secs (int) – Timeout in seconds for power off task to complete.
  • async (bool) – If False, block until power state has changed to “off”.
Raises:

CurieException on all errors.

power_on(*args, **kwargs)

Powers on the node using out-of-band management interface specified in the cluster’s metadata.

Raises:
  • CurieTestException if no suitable metadata exists, CurieException on
  • all other errors.
sync_power_state()

Synchronize management software power state and OOB power state.

Returns:Map of Node IDs for ‘nodes’ to their respective power states.
Return type:dict
Raises:CurieTestException – If power states cannot be synchronized.
class curie.node.NodePropertyNames

Bases: object

POWERED_OFF = 'POWERED_OFF'
POWERED_ON = 'POWERED_ON'
UNKNOWN = 'UNKNOWN'
curie.node.get_node_management_util(cluster_metadata_pb)

Return the correct subclass of curie.node_util.NodeUtil.

Parameters:cluster_metadata_pb (curie.curie_server_state_pb2.CurieSettings) – The metadata for the cluster.
Returns:Subclass of curie.node_util.NodeUtil.
Return type:class
curie.node.get_power_management_util(oob_mgmt_info_pb)

Return the correct instance of curie.oob_management_util.OobManagementUtil.

Parameters:oob_mgmt_info_pb (curie.curie_server_state_pb2.CurieSettings.ClusterNode.NodeOutOfBandManagementInfo) – The metadata for the node’s power management controller.
Returns:
Instance of subclass of
curie.oob_management_util.OobManagementUtil.
Return type:object
curie.node.oob(functor)

curie.node_util module

class curie.node_util.NodeUtil

Bases: object

is_ready()

Performs vendor-specific checks to confirm basic node functionality.

Must be implemented by subclasses.

curie.null_oob_util module

Provides stub Out-of-Band management util for cases with no OoB support.

class curie.null_oob_util.NullOobUtil(*args, **kwargs)

Bases: curie.oob_management_util.OobManagementUtil

Dummy implementation of ‘OobManagementUtil’ interface. Wraps calls to ipmitool.

get_chassis_status()
Returns:Map of IPMI chassis status data.
Return type:(dict)
Raises:CurieException on error.
is_powered_on()

Checks whether chassis power state is ‘on’.

Returns:(bool) True if powered on, else False.
power_cycle(async=False)

Power cycles the node associated with ‘self.__flags[“host”]’.

Parameters:
  • async (bool) – Optional. If False, making blocking calls to ‘power_off’
  • then 'power_on'. (and) –
  • True and node is powered off, performs async 'power_on' call, (If) –
  • issues the (otherwise) –
Returns:

True on success, else False.

Return type:

(bool)

power_off(async=False)

Powers off the node associated with ‘self.__flags[“host”]’.

Parameters:async (bool) – Optional. If False, block until power state is off.
Returns:True on success, else False.
Return type:(bool)
power_on(async=False)

Powers on the node associated with ‘self.__flags[“host”]’.

Parameters:async (bool) – Optional. If False, block until power state is on.
Returns:True on success, else False.
Return type:(bool)

curie.nutanix_cluster_dp_mixin module

class curie.nutanix_cluster_dp_mixin.NutanixClusterDPMixin(cluster_metadata)

Bases: object

create_protection_domain(pd_name)

Create a protection domain.

protect_vms_protection_domain(pd_name, vms)

Protect the VMs with the protection domain.

snapshot_pd(pd_name)
snapshot_vms(vms, tag=None)

curie.nutanix_hyperv_cluster module

class curie.nutanix_hyperv_cluster.NutanixHypervCluster(cluster_metadata)

Bases: curie.nutanix_cluster_dp_mixin.NutanixClusterDPMixin, curie.hyperv_cluster.HyperVCluster

curie.nutanix_node_util module

class curie.nutanix_node_util.NutanixNodeUtil(node, rest_api_timeout_secs=60)

Bases: curie.node_util.NodeUtil

is_ready()

See ‘NodeUtil.is_ready’ documentation for further details.

Confirms node is ready by requesting node’s health info from Prism via SVM corresponding to the node.

curie.nutanix_rest_api_client module

class curie.nutanix_rest_api_client.FileHandleWithCallback(cb_progress, *args, **kwargs)

Bases: file

Provides a file object supporting a read callback exposing bytes read.

call_ctx()
enter_ctx()
exit_ctx(*args, **kwargs)
classmethod from_file(cb_progress, fh)
read([size]) → read at most size bytes, returned as a string.

If the size argument is negative or omitted, read until EOF is reached. Notice that when in non-blocking mode, less data than what was requested may be returned, even if no size parameter was given.

size()
exception curie.nutanix_rest_api_client.HttpRequestException(http_status_code, http_body)

Bases: exceptions.Exception

An internal exception class for raising exceptions for an HTTP request for errors that don’t already cause an instance of a derived class of requests.exceptions.RequestException to be raised.

class curie.nutanix_rest_api_client.NutanixMetadata(version=None, cluster_uuid=None, cluster_incarnation_id=None)

Bases: object

cluster_incarnation_id
cluster_uuid
version
class curie.nutanix_rest_api_client.NutanixRestApiClient(host, api_user, api_password, timeout_secs=None)

Bases: object

This class implements a Nutanix REST API client for v1 of the Nutanix REST API. For each REST API call that’s implemented in this class, the corresponding method returns a deserialized JSON response on success for a GET or raises a CurieException if an error occurs. For non-GET requests, there is no return value.

Reference: http://prismdevkit.com/nutanix-rest-api-explorer

Note: the documentation at the above URL should be interpreted only as a hint as to what the actual REST API is. There are inaccuracies (e.g., invalid URLs, etc.).

cleanup_nutanix_state(test_ids)

Clean up any Nutanix-cluster specific state for specified tests. If no test IDs are specified (empty list), then Nutanix-cluster specific state is cleaned up for all tests regardless of their state.

Assumption: all datastores for ‘test_ids’ are empty.

clusters_get(**kwargs)

Invokes /clusters [GET] to get cluster information for all clusters, or /containers/{id} [GET] to get information about a specific cluster. Either ‘cluster_id’ or ‘cluster_name’ (but not both) must be specified in the latter case.

If projection is provided as one of:
ALL, STATS, PERF_STATS, USAGE_STATS, HEALTH, ALERTS, ALERTS_COUNT

The query will be sent with URL params specifying the requested projection.

containers_create(**kwargs)

Invokes /containers [POST] to create a container. ‘request_dict’ is a Python dictionary corresponding to the ContainerDTO to use to create the container.

containers_delete(**kwargs)

Invokes /containers/{id} [DELETE] to delete the specified container. Either ‘container_id’ or ‘container_name’ must be specified but not both.

containers_get(**kwargs)

Invokes /containers [GET] to get information about all containers or /containers/{id} [GET] to get information about a specific container. Either ‘container_id’ or ‘container_name’ (but not both) must be specified in the latter case.

containers_update(**kwargs)

Invokes /containers [PUT] to update a container. ‘request_dict’ is a Python dictionary corresponding to the ContainerDTO to use to update the container.

datastores_applicable_to_cluster()

Invokes /containers/datastores [GET] checking for an HTTP 500 error.

datastores_create(**kwargs)

Invokes /containers/datastores/add_datastore [POST] to create a datastore for the container ‘container_name’. If ‘datastore_name’ is specified, use that name rather than ‘container_name’ for the datastore name.

datastores_delete(**kwargs)

Invokes /containers/datastores/remove_datastore [POST] to delete the datastore with the name ‘datastore_name’.

Parameters:
  • datastore_name (str) – Name of datastore to delete.
  • verify (bool) – Optional. If True, attempt to confirm datastore no longer exists prior to returning.
Raises:
  • CurieError<kTimeout> on timeout
  • HttpRequestException (reraised) on POST failure (unless datastore has – already been removed)
datastores_get(**kwargs)

Invokes /containers/datastores [GET] to get information about all NFS datastores.

deploy_ovf(name, host_id, ctr_id, ova_abs_path=None, ovf_abs_path=None, network_uuids=None)

Deploys VM defined by OVA (OVF) at ‘ova_abs_path’ (‘ovf_abs_path’) to host ‘host_id’ in container ‘ctr_id’ .

NB: Exactly one of ‘ova_abs_path’ or ‘ovf_abs_path’ must be specified.

Parameters:
  • name (str) – Name for the imported VM.
  • host_id (str) – UUID of host on which to deploy the VM.
  • ctr_id (str) – UUID of the container in which to deploy the VM disks.
  • ova_abs_path (str|None) – Absolute path for .ova to deploy.
  • ovf_abs_path (str|None) – Absolute path for .ovf file describing VM.
  • network_uuids (list<str>|None) – Optional. If provided, UUIDs of networks to which NICs should be attached. If None, networks will be chosen automatically.

Returns: JSON from API describing the deployed VM.

classmethod from_proto(proto, **kwargs)

Returns NutanixRestApiClient instance constructed with args from ‘proto’.

Parameters:
  • proto (PrismInfo|NutanixInfo|ConnectionParams) – Proto containing connection params for Prism.
  • **kwargs (dict) – Additional arguments to pass to the constructor.
Raises:

CurieException<kInvalidParameter> if the proto does not contain the – required fields.

genesis_clear_shutdown_token(**kwargs)

Invokes /genesis to issue a ‘ClusterManager.clear_shutdown_token’ RPC.

Returns:(bool) True if token is cleared, else False.
genesis_cluster_status(**kwargs)

Invokes /genesis to issue a ‘ClusterManager.status’ RPC to Genesis.

genesis_current_master(**kwargs)

Invokes /genesis to issue a ‘ClusterManager.request_shutdown_token’ RPC.

Returns:(bool) True if token is acquired, else False.
genesis_node_services_status(**kwargs)

Invokes /genesis to issue a ‘NodeManager.services_status’ RPC to Genesis.

genesis_prepare_node_for_shutdown(**kwargs)

Invokes /genesis to issue a ‘ClusterManager.prepare_node_for_shutdown’ RPC.

NB: The RPC blocks until shutdown token has been acquired.

genesis_shutdown_hypervisor(**kwargs)

Invokes /genesis to issue a ‘ClusterManager.shutdown_hypervisor’ RPC.

Returns:(bool) True on success, else False.
get_cluster_timestamp_usecs()
get_last_login_event_usecs()
get_nutanix_metadata(short_only=False, cached_ok=True)

Issue a Nutanix REST API call to try and fetch Nutanix-specific metadata. Attemps to lookup the NOS version running on the cluster, the cluster’s UUID, and its incarnation ID.

Parameters:
  • short_only (bool) – Optional. Whether to skip to fetching the short version rather than first trying for the full version. Default False.
  • cached_ok (bool) – Optional. If True, allow returning cached data if present. Default True.
Returns:

(NutanixMetadata) Instance where if a particular field is unavailable,

is it set to None.

get_pc_uuid(**kwargs)

Attempts to determine the UUID of a connected PrismCentral.

Returns: (str) UUID of the Prism Central if connected, otherwise None

ha_get(**kwargs)

Gets current HA configuration.

hosts_get(**kwargs)

Invokes /hosts [GET] to get a listing of host information for all hosts on the cluster.

NB: Only one of ‘host_ip’, ‘host_id’, or ‘host_name’ should be provided.

If ‘host_ip’ is provided, passes params:
{“searchString”: <host_ip>,
“searchAttributeList”: “ipv4_addresses”}
If ‘host_name’ is provided, passes params:
{“searchString”: <host_name>,
“searchAttributeList”: “name”}

If ‘host_id’ is provided, defers to ‘hosts_get_by_id’.

hosts_get_by_id(**kwargs)

Invokes /hosts/<host_id> [GET] to lookup information for ‘host_id’.

hosts_stats_get_by_id(**kwargs)

Invokes /hosts/<host_id>/stats [GET] to get stats information for a physical host in the cluster.

images_create(name, source_file, dest_ctr_id, annotation=None)

Creates new image by uploading ‘source_file’ as ‘name’ to ‘dest_ctr_id’.

images_delete(**kwargs)

Deletes images with UUIDs in ‘image_uuids’.

Returns:dict<str, str> Map of UUID to deletion task UUID.
images_get(**kwargs)

Retrieves list of images registered with the cluster image service.

networks_get(**kwargs)

Invokes /networks [GET] to retrieve a list of configured networks.

protection_domains_create(**kwargs)

Invokes /protection_domains [POST] to create a protection domain with the name ‘pd_name’.

protection_domains_delete(**kwargs)

Invokes /protection_domains/{name} [DELETE] to delete the protection domain with the name ‘pd_name’.

protection_domains_get(**kwargs)

Invokes /protection_domains [GET] to get information about all protection_domains or /protection_domains/{name} [GET] to get information about a specific protection domain.

protection_domains_oob_schedules(**kwargs)

Invokes /protection_domains/{name}/oob_schedules [POST] to protect the VMs using the protection domain ‘pd_name’. This oob_schedule is defaulted to take a snapshot immediately.

protection_domains_protect_vms(**kwargs)

Invokes /protection_domains/{name}/protect_vms [POST] to protect the specified list of VMs using the protection domain ‘pd_name’.

snapshot_create(**kwargs)
snapshots_delete(**kwargs)

Invokes /protection_domains/{name}/dr_snapshots/{snapshot_id} [DELETE] to delete either all snapshots for the specified protection domain (empty list in ‘snapshot_ids’) or a specified list of snapshots.

snapshots_get(**kwargs)

Invokes /protection_domains/{name}/dr_snapshots [GET] to get information about all snapshots for the protection_domain ‘protection_domain_name’.

snapshots_schedules_create(**kwargs)

Invokes /protection_domains/{name}/schedules [POST] to create a snapshot schedule for a protection domain. ‘request_dict’ is a Python dictionary corresponding to the policy for the protection domain snapshot schedule.

Example

request_dict = {“pdName” : “my_pd”,
“type” : “HOURLY”, “everyNth” : 1, “userStartTimeInUsecs” : now_usecs, “retentionPolicy” : {“localMaxSnapshots”: 4}}
snapshots_schedules_delete(**kwargs)

Invokes /protection_domains/{name}/schedules [DELETE] to delete all snapshot schedules for the protection domain with name ‘protection_domain_name’.

snapshots_schedules_get(**kwargs)

Invokes /protection_domains/{name}/schedules [GET] to get information about the periodic snapshot schedules for the protection_domain ‘protection_domain_name’.

tasks_get(**kwargs)

Fetch tasks via ‘GET /tasks/’

tasks_get_by_id(**kwargs)

Fetch a single task via ‘GET /tasks/{task_id}/.

vms_clone(**kwargs)
vms_create(**kwargs)
vms_delete(**kwargs)

Deletes all VMs specified by ‘vm_ids’.

Returns:
(dict) Map of VM IDs to corresponding deletion task UUIDs, or None if
the DELETE failed for a given ID.
vms_get(**kwargs)

Invokes /vms/ [GET] to list VM entites for cluster.

Note

If ‘vm_ip’ is set projection=HEALTH: will not return the healthSummary as part of the entity.

Parameters:
  • cvm_only (bool) – Optional. If True, filter entities, returning CVMs only.
  • vm_ip (str) – Optional. If provided, return only entities whose IP matches the provided address.
  • vm_name (str) – Optional. If provided, return only entities whose vmName matches the provided string.
  • projection (str) –
    Optional. If projection is provided as one of:
    ALL, STATS, PERF_STATS, USAGE_STATS, HEALTH, ALERTS, ALERTS_COUNT, BASIC_INFO

    The query will be sent with URL params specifying the requested projection.

  • drop_duplicates (bool) – If true, drop duplicates from the response “entities”. This is a workaround for ENG-75906.

NB: Provide at most one of ‘vm_ip’ and ‘vm_name’.

vms_get_by_id(**kwargs)

Invokes /vms/<vm_id> [GET] to lookup VM information for the VM ‘vm_id’.

Parameters:
  • vm_id (str) – UUID of VM to lookup.
  • projection (str) –
    Optional. If projection is provided as one of:
    ALL, STATS, PERF_STATS, USAGE_STATS, HEALTH, ALERTS, ALERTS_COUNT

    The query will be sent with URL params specifying the requested projection.

vms_get_by_id_mgmt_api(**kwargs)

Invokes /vms/<vm_id> [GET] to lookup VM information for the VM ‘vm_id’.

Parameters:
  • vm_id (str) – UUID of VM to lookup.
  • include_vm_disk_sizes (bool) – Optional. Whether to include disk sizes (in bytes). Default False.
  • include_address_assignments (bool) – Optional. Whether to include address assignments: Default False.
vms_migrate(**kwargs)

Migrates ‘vm_id’ to ‘host_id’.

vms_nic_add(**kwargs)

Adds a new NIC to ‘vm_id’ on the network ‘network_uuid’.

Parameters:
  • vm_id (str) – VM ID to which NIC should be added.
  • req (dict) – JSON request body.
Returns:

(dict/JSON) response

vms_power_op(**kwargs)

Performs power operation ‘op’ on all VMs specified by ‘vm_ids’.

Parameters:
  • vm_ids (list<str>) – List of VM IDs to which ‘op’ should be applied.
  • op (str) – Power op to apply to ‘vm_ids’. Should be one of “on”, “off”.
Returns:

(dict) Map of VM IDs to corresponding power-op task UUIDs, None if

the operation failed for a given ID, or True if the operation is a no-op.

Raises:

CurieException<kInvalidParameter> if ‘op’ is not a valid operation.

vms_set_power_state_for_vms(**kwargs)

Alter power state on ‘vm_id’ via ‘transition’.

Parameters:
  • vm_ids (list<str>) – VM IDs whose power state to change.
  • transition (str) – Power state in which to put ‘vm_id’. One of “acpi_reboot”, “acip_shutdown”, “on”, “off”, “powercycle”
  • host_ids (list<str>|None) – Optional. If provided, if ‘vm_id[ii]’ is being powered on or power cycled, it should be scheduled on ‘host_id[ii]’.
Returns:

(dict) Map of VM IDs to corresponding power-op task UUIDs, None if

the operation failed for a given ID, or True if the operation is a no-op.

class curie.nutanix_rest_api_client.PrismAPIVersions

Bases: object

Class to enumerate various public and private APIs exposed by Prism.

– ‘PRISM’ versions comprise versions of the documented public API. – Undocumented/internal APIs are given separate entries. – Public attributes are set to human-friendly names for ease of reading. – Tracks Nutanix version dependencies for the various APIs.

AOS_VERSION_REGEX = <_sre.SRE_Pattern object at 0x28281f0>
GENESIS_V1 = 'Genesis REST to RPC v1'
MIN_AOS_VERSION = (4, 0, 0, 0)
MIN_CE_VERSION = (2016, 12, 22)
PRISM_V1 = 'Prism REST v1'
RETRY_STATUS_SET = frozenset([502, 503])
classmethod get_aos_short_version(version_string)
classmethod is_applicable(api, version)
Parameters:
  • api (PrismAPIVersions version) – API whose compatibility to check.
  • version (str) – Nutanix version or fullversion string.
Returns:

(bool) Whether ‘api’ is valid for Nutanix release ‘version’.

class curie.nutanix_rest_api_client.TimeoutSession

Bases: requests.sessions.Session

Allows setting a timeout to be used for all requests during this session.

get_timeout()
send(request, **kwargs)

Send a given PreparedRequest.

Return type:requests.Response
set_timeout(timeout_secs)

Updates session timeout.

Parameters:timeout_secs (float|None) – Desired timeout in seconds (value must be coercable to float) or None to revert to the default ‘requests.Session’ behavior.
Returns:(bool) True on success, else False.
curie.nutanix_rest_api_client.nutanix_rest_api_method(func)

curie.nutanix_vsphere_cluster module

class curie.nutanix_vsphere_cluster.NutanixVsphereCluster(cluster_metadata)

Bases: curie.nutanix_cluster_dp_mixin.NutanixClusterDPMixin, curie.vsphere_cluster.VsphereCluster

curie.oob_management_util module

class curie.oob_management_util.OobManagementUtil

Bases: object

get_chassis_status()
is_powered_on()
power_cycle(async=False)
power_off(async=False)
power_on(async=False)

curie.os_util module

class curie.os_util.FileLock(path)

Bases: object

Lock acquired/released by creating/unlinking a file.

acquire()

Acquires lock by creating a file.

NB: Per manpage for ‘open’, this is subject to race conditions on NFS if either NFS versions < 3 or linux kerenel version < 2.6.

Returns:True on success, else False
release()

Releases lock by closing associated fd and removing associated file.

Raises:AssertionError on failure.
class curie.os_util.OsUtil

Bases: object

static write_and_rename(pathname, data, tmp_suffix='.tmp')

Create a temporary file with contents ‘data’, then rename the file to ‘pathname’. If ‘tmp_suffix’ is set, then the temporary file path will be ‘pathname’ with the suffix ‘tmp_suffix’ appended to it, else it will be a unique temporary file in the directory where ‘pathname’ resides.

Note that, on Unix, if pathname exists and is a file, it will be replaced silently if the user has permission.

curie.ova_util module

class curie.ova_util.CurieOva(abs_path)

Bases: object

close()
get_file_handle(name)
get_file_info(name)
parse()

Parse contained OVF.

class curie.ova_util.CurieOvf

Bases: object

classmethod parse_file(abs_path)
class curie.ova_util.VMDK4(path)

Bases: Struct

SECTOR_BYTES = 512
is_empty()
curie.ova_util.attrib_property(key=None, ns_alias=None, transform=None)
curie.ova_util.child_property(key, transform=None, required=False, multiple=False)
curie.ova_util.child_text_property(key, transform=None)
curie.ova_util.repeated_child_property(key, transform=None)

curie.prometheus module

exception curie.prometheus.PrometheusAPIError

Bases: exceptions.Exception

class curie.prometheus.PrometheusAdapter(host='localhost', port=9090, protocol='http')

Bases: object

Interface to a Prometheus server.

DATE_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
get_avg_disk_latency(**kwargs)

Convenience for querying the average disk latency for a VM Group.

The value reported is in microseconds.

Parameters:
  • vm_group (curie.vm_group.VMGroup) – VM Group of interest.
  • start (int, float, or datetime) – Start of the date range. See query_range for more details.
  • end (int, float, or datetime) – End of the date range. See query_range for more details.
  • step (str) – The query_range “step” parameter. See query_range for more details.
  • agg_func (str) – Function to use while aggregating the results. See _aggregate for more details.
  • lookback (str) – Amount of time into the past to look for the two most recent data points.
  • iops_floor (int) – Latency will be reported as NaN when samples are below iops_floor. This filters extreme latency values when the divisor is too small.
Returns:

Returned value from PrometheusAdapter.query_range.

Return type:

dict

Raises:

PrometheusAPIError – Passed through from PrometheusAdapter.query_range.

get_disk_octets(**kwargs)

Convenience for querying the disk bytes per second for a VM Group.

Parameters:
  • vm_group (curie.vm_group.VMGroup) – VM Group of interest.
  • start (int, float, or datetime) – Start of the date range. See query_range for more details.
  • end (int, float, or datetime) – End of the date range. See query_range for more details.
  • step (str) – The query_range “step” parameter. See query_range for more details.
  • agg_func (str) – Function to use while aggregating the results. See _aggregate for more details.
  • lookback (str) – Amount of time into the past to look for the two most recent data points.
Returns:

Returned value from PrometheusAdapter.query_range.

Return type:

dict

Raises:

PrometheusAPIError – Passed through from PrometheusAdapter.query_range.

get_disk_ops(**kwargs)

Convenience for querying the disk ops per second for a VM Group.

Parameters:
  • vm_group (curie.vm_group.VMGroup) – VM Group of interest.
  • start (int, float, or datetime) – Start of the date range. See query_range for more details.
  • end (int, float, or datetime) – End of the date range. See query_range for more details.
  • step (str) – The query_range “step” parameter. See query_range for more details.
  • agg_func (str) – Function to use while aggregating the results. See _aggregate for more details.
  • lookback (str) – Amount of time into the past to look for the two most recent data points.
Returns:

Returned value from PrometheusAdapter.query_range.

Return type:

dict

Raises:

PrometheusAPIError – Passed through from PrometheusAdapter.query_range.

query_range(query, start, end, step=None)

Low-level interface to Prometheus’ query_range API.

Parameters:
  • query (str) – The Prometheus-flavored query to perform.
  • start (int, float, or datetime) – Start of the date range. If int or float, will be interpreted as a UTC epoch timestamp.
  • end (int, float, or datetime) – End of the date range. If int or float, will be interpreted as a UTC epoch timestamp.
  • step (str) – The query_range “step” parameter, which is equivalent to the desired sampling interval.
Returns:

The response body’s “data” field.

Return type:

dict

Raises:

PrometheusAPIError – If the query fails.

curie.prometheus.scenario_target_config(scenario, worker_exporter_port=9100)

Generate a Prometheus target configuration for a Curie Scenario.

Parameters:
  • scenario (curie.scenario.Scenario) – Scenario of choice.
  • worker_exporter_port (int) – Port number of exporter on the worker VMs.
Returns:

The target configuration to be passed to Prometheus.

Return type:

dict

curie.prometheus.target_config(targets, **labels)

Create a Prometheus target configuration.

A target configuration describes a collection endpoint. The labels will be applied to data from the target (endpoint) on ingest.

Parameters:
  • targets (list of str) – IP address and port of each target.
  • **labels – Key/value pairs used as labels for data from the target.
Returns:

Target configuration that may be written to a file for Prometheus to

parse.

Return type:

dict

curie.prometheus.to_series(result, dropna=None)

Convert a result to a pandas.Series.

Parameters:
  • result (dict) – Result from a query data object.
  • dropna (bool) – If true, drop N/A values from the Series.
Returns:

Data expressed as a Series.

Return type:

pandas.Series

curie.prometheus.to_series_iter(data, dropna=None)

Yield pandas.Series objects from data from a query.

The series objects will be yielded in the same order as the results inside the query data object.

Parameters:
  • data (dict) – Data from a query.
  • dropna (bool) – If true, drop rows containing N/A values.
Yields:

pandas.Series

curie.prometheus.to_series_list(data, dropna=None)

Convert data from a query into a list of pandas.Series.

The list of series objects will be in the same order as the results inside the query data object.

Parameters:
  • data (dict) – Data from a query.
  • dropna (bool) – If true, drop rows containing N/A values.
Returns:

list of pandas.Series

curie.proto_util module

Utility for monkey-patching protoc generated message classes.

Provides support for associating encryption keys protobuf generated python Message classes, decryption of sensitive fields, and auto-redaction of sensitive fields when printing a human-friendly representation.

Example

>>> proto_patch_encryption_support(CurieSettings)
>>> settings = CurieSettings()
>>> settings.ParseFromString(open("input.bin").read())
>>> cluster = settings.clusters[0]
>>> vcenter_info = cluster.cluster_management_server_info
>>> vcenter_info.is_encrypted_field("vcenter_password")
True
>>> vcenter_info.decrypt_field("vcenter_username", key=<SOME_KEY>)
<PLAINTEXT USERNAME>
>>> cluster.set_encryption_key(<SOME_KEY>)
>>> vcenter_info.decrypt_field("vcenter_password")
<PLAINTEXT PASSWORD>
>>> print(vcenter_info)
...
vcenter_user: "<REDACTED>"
vcenter_password: "<REDACTED>"
vcenter_datacenter_name: "CLUSTER-DC"
vcenter_cluster_name: "CLUSTER"
...
curie.proto_util.proto_patch_encryption_support(proto)

Patches protobuf formatters if necessary as well as extending the message class ‘proto’ to support encrypted fields.

Parameters:proto (google.protobuf.message.Message) –
Returns:(google.protobuf.message.Message) Patched ‘proto’.

curie.punit_parser module

class curie.punit_parser.PUnit(unit_map=None, multiplier=1)

Bases: object

add_div_unit(unit)
add_unit(unit)
classmethod from_string(string)
set_multiplier(multiplier)
curie.punit_parser.p_base(p)

base : POSITIVE_WHOLE_NUMBER

curie.punit_parser.p_base_unit(p)
base-unit : SIMPLE_NAME
DECIBEL_BASE_UNIT
curie.punit_parser.p_divided_base_unit(p)

divided-base-unit : DIV base-unit

curie.punit_parser.p_error(p)
curie.punit_parser.p_exponent(p)
exponent : POSITIVE_WHOLE_NUMBER
PLUS POSITIVE_WHOLE_NUMBER
MINUS POSITIVE_WHOLE_NUMBER
curie.punit_parser.p_modifier1(p)

modifier1 : operator number

curie.punit_parser.p_modifier2(p)

modifier2 : operator base EXP exponent

curie.punit_parser.p_multiplied_base_unit(p)

multiplied-base-unit : TIMES base-unit

curie.punit_parser.p_number(p)
number : positive-number
PLUS positive-number
MINUS positive-number
curie.punit_parser.p_operator(p)
operator : TIMES
DIV
curie.punit_parser.p_positive_number(p)
positive-number : POSITIVE_WHOLE_NUMBER
POSITIVE_DECIMAL_NUMBER
curie.punit_parser.p_programmatic_unit(p)
programmatic-unit : punit-head punit-body punit-tail
punit-head punit-tail
curie.punit_parser.p_punit_body(p)
punit-body : punit-mult
punit-div
punit-mult punit-div
curie.punit_parser.p_punit_div(p)
punit-div : divided-base-unit
punit-div divided-base-unit
curie.punit_parser.p_punit_head(p)
punit-head :
base-unit
curie.punit_parser.p_punit_mult(p)
punit-mult : multiplied-base-unit
punit-mult multiplied-base-unit
curie.punit_parser.p_punit_tail(p)
punit-tail :
modifier1
modifier2
modifier1 modifier2
curie.punit_parser.t_DECIBEL_BASE_UNIT(t)
curie.punit_parser.t_POSITIVE_DECIMAL_NUMBER(t)

[1-9][0-9]*.[0-9]*

curie.punit_parser.t_POSITIVE_WHOLE_NUMBER(t)

[1-9][0-9]*

curie.punit_parser.t_SIMPLE_NAME(t)
curie.punit_parser.t_error(args)

curie.rpc_client module

class curie.rpc_client.RpcClient(ip, port=5000, path='/rpc')

Bases: curie.rpc_util.RpcClientUtil

Client to issue CurieRpcSvc RPCs to server at a given ‘ip’, ‘port’, and endpoint ‘path’.

DiscoverClusters(arg)
DiscoverClustersV2(arg, initial_timeout_secs=300.0, max_retries=0)
DiscoverNodes(arg)
DiscoverNodesV2(arg, initial_timeout_secs=300.0, max_retries=0)
ServerStatusGet(arg, initial_timeout_secs=0.5, max_retries=0)
SetEncryptionKey(arg)
TestCatalog(arg, initial_timeout_secs=0.5, max_retries=0)
TestStatus(arg, initial_timeout_secs=1.0, max_retries=0)
TestValidate(arg, initial_timeout_secs=10.0, max_retries=0)
UpdateAndValidateCluster(arg, initial_timeout_secs=300.0, max_retries=0)
initialize_server(encryption_key, timeout_secs=60)

Convenience method which handles waiting for server to be ready.

Handles:
– Polling server state during initialization. – Setting encryption key. – Blocking until recovery completes.
Parameters:
  • encryption_key (str) – Encryption key to set, encoded as hex string.
  • timeout_secs (number) – Optional. Maximum time in seconds to allow for server to become ready. Default 60.
Raises:
  • CurieException<kAuthenticationError> On failure to set encryption key.
  • CurieException<kTimeout> If server recovery does not otherwise complete – within ‘timeout_secs’.
  • CurieException<kInternalError> On encountering an unexpected server – state.

curie.rpc_util module

curie.rpc_util.RpcClientMeta(stub)
class curie.rpc_util.RpcClientUtil(ip, port, path)

Bases: object

Base class from which Curie protobuf RPC clients should derive.

Parameters:
  • ip (str) – RPC server IP address.
  • port (int) – RPC server port.
  • path (str) – RPC server endpoint path.
send_rpc(method_name, arg, max_retries=None, overall_timeout_secs=None)

Calls RPC ‘method_name’ with argument ‘arg’.

NB: Currently all RPCs are synchronous.

Parameters:
  • method_name (str) – Name of RPC method to be issued.
  • arg (protobuf) – Populated argument proto for the RPC ‘method_name’.
  • max_retries (int|None) –

    Optional. If provided, a non-negative integer specifying the maximum number of times to retry an RPC. If not provided, falls back to options specified in curie_extension.proto if any, else 0. (Default None)

    NB: Retries are only attempted on transport error, or when recieving a
    kRetry response.
  • overall_timeout_secs (numeric|None) – Optional. If provided, overall timeout in seconds which should be enforced (cumulative across any retries).
  • NB – If ‘overall_timeout_secs’ will be internally converted to a max_retry
  • If both 'overall_timeout_secs' and 'max_retries' are provided, (count.) –
  • will be given to the smaller of 'max_retries' and the retry (precedence) –
  • derived from 'overall_timeout_secs'. (count) –
Returns:

(ret, err) On success, ‘ret’ is the appropriate deserialized return proto and ‘err’ is None. On error, ‘ret’ is None, and err is the deserialized CurieError proto.

Raises:
  • TypeError if ‘arg’ is not a valid instance of the arg protobuf for – ‘method_name’.
  • (CurieError<kTimeout>) on timeout.
  • (CurieError<kRetry>) on connection error.
class curie.rpc_util.RpcServer(rpc_svc)

Bases: object

Given a protobuf service, returns a server instance providing two decorators:

@endpoint: Registers a flask request handler as an RPC endpoint. @handler(rpc_name): Registers decorated method as the handler for ‘rpc_name’.

Parameters:
  • rpc_svc (GeneratedServicesType) – Google protobuf service object for
  • RPC service to host. (the) –
WARNING_THRESHOLD_MSECS = 100
endpoint(functor)

Wrapper to convert a flask HTTP handler into an RPC endpoint. Expects the handler to return the flask.request object for the RPC.

handler(method_name)

Wrapper which registers the wrapped function as the handler for an RPC ‘method_name’.

curie.scenario module

class curie.scenario.Phase

Bases: enum.Enum

kPreSetup = 1
kRun = 3
kSetup = 2
kTeardown = 4
class curie.scenario.Scenario(name=None, id=None, display_name=None, cluster=None, source_directory=None, output_directory=None, readonly=False, prometheus_config_directory=None, prometheus_address=None, goldimages_directory=None, enable_experimental_metrics=False)

Bases: object

add_step(step, phase)

Add a step to be run as part of this scenario.

Parameters:
  • step (BaseStep) – Step to run.
  • phase (Enum) – Phase into which the step will be added.
Raises:

ValueError – If the phase is invalid.

cluster_stats_dir()

Returns a path to the Scenario’s cluster results.

If no output directory is configured, this returns None.

Returns:Path to the cluster results directory.
Return type:str or None
completed_steps()

Return a list of steps that have finished.

Returns:List of completed steps and their phases.
Return type:list of (Phase, BaseStep)
create_annotation(description)

Create an XAnnotation for this scenario.

Parameters:description (basestring) – Description for the annotation.
Returns:None
duration_secs()

Return the number of seconds that this scenario has been running.

If the scenario has not started, None will be returned. If the scenario is in progress, the duration is relative to the current time. If the scenario has finished, the total duration until the test stopped will be returned.

Returns:Duration, in seconds.
Return type:float or None
error_message()

Returns error message if one has occurred during the scenario, else None.

static find_configuration_files(root=None, filename='test.yml')

Return a list of file paths to scenario configuration files.

This searches for filename matches, and does not validate the configuration files themselves.

Parameters:
  • root (basestring or None) – Directory in which to recursively search. Setting root to None will search the default directory.
  • filename (basestring) – Filename of scenario configuration files.
Returns:

Absolute paths to scenario configuration files.

Return type:

list of str

itersteps()

Iterate this Scenario’s steps in execution order.

Yields:BaseStep – Each step.
join(timeout=None)

Wait for an active scenario to reach a terminal state.

To be more specific, this method blocks until all of the scenario’s worker threads have joined. It may be called while the scenario is already in a terminal state to ensure that all worker threads are properly cleaned up. This method is responsible for ensuring a terminal state is set.

Parameters:timeout (float or None) – Timeout parameter to pass to the join call for each thread.
Raises:RuntimeError – If the scenario is in a new state.
classmethod load_state(directory)

Load a scenario from the file system.

Parameters:directory (basestring) – Directory containing the state file. This should be the same as the Scenario’s output_directory.
phase_start_time_secs(phase)

Return the start time of a given phase, or None if it has not started.

Parameters:phase (Phase) – Phase of interest.
Returns:Seconds since epoch, or None.
Return type:float or None
remaining_steps()

Return a list of steps that have not finished.

Returns:List of remaining steps and their phases.
Return type:list of (Phase, BaseStep)
resource_path(relative_path)

Get an absolute path to a file associated with this scenario.

Scenarios are usually packaged with some extra configuration files, such as workload configuration files (e.g. .fio files). resource_path can be used to convert a path relative to the scenario’s base directory into an absolute path.

Parameters:relative_path (basestring) – Path relative to the scenario’s YAML file.
Returns:Absolute path to the desired resource.
Return type:str
results()

Returns the current results of this scenario.

save_state()

Save the state of the scenario to the file system.

should_stop()

Returns True if the scenario should stop cleanly as soon as possible.

start()

Begin running the scenario.

This method returns immediately.

Raises:RuntimeError – If the scenario is not in a new state.
status()

Returns the current status of this scenario.

stop()

Interrupt a running scenario, notifying it to cleanly stop.

This method returns immediately. If the scenario is new, it will be set in a canceled state. If the scenario is active, it will be set in a stopping state. If the scenario is terminal or already stopping, this method is a no-op.

test_dir()

Deprecated: Returns the Scenario’s output directory.

Returns:Absolute path to output directory.
Return type:basestring
test_id()

Deprecated: Returns the Scenario’s id.

Returns:id
Return type:basestring
to_curie_test_state_protobuf()

Return a Curie test state protobuf representing this Scenario.

Returns:Curie test state protobuf.
Return type:CurieTestState
verify_steps()

Verify that all steps will work with the current cluster configuration.

If verification succeeds, an empty list is returned.

Returns:Steps that failed to verify.
Return type:list of Step
wait_for(func, msg, timeout_secs, poll_secs=None)

Invoke ‘func’ every ‘poll_secs’ seconds until the boolean-ness of the returned value is True, in which case we return that value. If ‘timeout_secs’ seconds have elapsed, raises an exception. Otherwise, if the test is marked to stop, raises a ScenarioStoppedError.

Parameters:
  • func (callable) – Callable to poll.
  • msg (str) – Readable description of the action.
  • timeout_secs (int) – Maximum amount of time to wait for func to complete.
  • poll_secs (int) – Polling interval in seconds. None uses default polling interval.
Raises:
  • CurieTestException – If ‘func’ does not evaluate to True within ‘timeout_secs’ seconds.
  • ScenarioStoppedError – If the scenario is stopped before wait_for returns.
wait_for_all(funcs, msg, timeout_secs, poll_secs=None, skip_succeeded=True)

Invoke the callables in ‘funcs’ every ‘poll_secs’ seconds until the boolean-ness of all returned values are True, in which case those values are returned. If ‘timeout_secs’ seconds have elapsed since wait_for_all is invoked, an exception is raised. Otherwise, if the test is marked to stop, None is returned.

Parameters:
  • funcs (iterable) – List of callables to invoke.
  • msg (str) – Readable description of the action.
  • timeout_secs (int) – Maximum amount of time to wait for all funcs to complete.
  • poll_secs (int) – Polling interval in seconds. None uses default polling interval.
  • skip_succeeded (bool) – If True, do not re-invoke callables that have succeeded previously.
Raises:

CurieTestException – If all callables in ‘funcs’ do not evaluate to True within ‘timeout_secs’ seconds.

class curie.scenario.Status

Bases: enum.Enum

kCanceled = 7
kExecuting = 1
kFailed = 5
kFailing = 3
kInternalError = 8
kNotStarted = 0
kStopped = 6
kStopping = 2
kSucceeded = 4

curie.scenario_parser module

curie.scenario_parser.from_path(path, vars=None, *args, **kwargs)

Read a scenario configuration and construct a new scenario instance.

Parameters:
  • path (basestring) – Path to a configuration file. path may be a directory containing a single configuration file.
  • *args – Arguments passed to Scenario __init__.
  • **kwargs – Arguments passed to Scenario __init__.
Returns:

A new scenario instance.

Return type:

Scenario

curie.scenario_parser.from_yaml_str(yaml_str, vars=None, *args, **kwargs)

Construct a Scenario from a YAML string.

Parameters:
  • yaml_str (basestring) – YAML-formatted scenario description.
  • *args – Arguments passed to Scenario __init__.
  • **kwargs – Arguments passed to Scenario __init__.
Returns:

A new scenario instance.

Return type:

Scenario

curie.scenario_parser.load_with_variables(yaml_str, variables=None, variables_key='vars')

curie.scp_client module

class curie.scp_client.ScpClient(host, user, private_key_path=None)

Bases: object

transfer_from(remote_path, local_path, timeout_secs, recursive=False)

Transfer ‘remote_path’ on _host to ‘local_path’. ‘timeout_secs’ specifies a timeout on the transfer. ‘recursive’ specifies whether the transfer is recursive or not. Returns True on success, else False on failure or a timeout.

transfer_to(local_path, remote_path, timeout_secs, recursive=False)

Transfer ‘local_path’ to ‘remote_path’ on _host. ‘timeout_secs’ specifies a timeout on the transfer. ‘recursive’ specifies whether the transfer is recursive or not. Returns True on success, else False on failure or a timeout.

curie.task module

class curie.task.HypervTask(descriptor=None, task=None, state=None, task_id=None)

Bases: curie.task.Task

classmethod get_descriptor_class()
start()
update_from_json(task_json)

Updates state from JSON response

class curie.task.HypervTaskDescriptor(task_id=None, task_type=None, pre_task_msg='', post_task_msg='', create_task_func=None, task_func_args=None, task_func_kwargs=None, state=None, entity_name='', desired_state=<Enum TaskStatus::kSucceeded = 7>, is_complete_func=None, *args, **kwargs)

Bases: curie.task.TaskDescriptor

classmethod get_default_task_type()
classmethod get_task_class()
class curie.task.HypervTaskPoller(max_concurrent, poll_interval_secs=1, vmm=None)

Bases: curie.task.TaskPoller

Task poller which handles simulating batched task polling.

stop()

Attempts to cancel all remaining non-terminal tasks.

Returns:(int) Number of remaining tasks which could not be canceled.
class curie.task.PrismTask(prism_client, descriptor=None, task=None, state=None, task_id=None)

Bases: curie.task.Task

classmethod from_task_id(prism, task_id)
classmethod get_descriptor_class()
classmethod supports_batch_update()
update()
update_from_json(task_json)

Updates state from JSON response ‘task_json’.

class curie.task.PrismTaskDescriptor(task_id=None, task_type=None, pre_task_msg='', post_task_msg='', create_task_func=None, task_func_args=None, task_func_kwargs=None, state=None, entity_name='', desired_state=<Enum TaskStatus::kSucceeded = 7>, is_complete_func=None, *args, **kwargs)

Bases: curie.task.TaskDescriptor

classmethod get_default_task_type()
classmethod get_task_class()
class curie.task.PrismTaskPoller(max_concurrent, poll_interval_secs=1, prism_client=None, cutoff_usecs=None, **kwargs)

Bases: curie.task.TaskPoller

Task poller which handles simulating batched task polling.

class curie.task.Task(descriptor=None, task=None, state=None, task_id=None)

Bases: object

cancel()
classmethod from_descriptor(descriptor)
classmethod get_descriptor_class()
get_status()
id()
is_active()
is_cancelable()
is_ready()
is_terminal()
classmethod new(create_task_func, *args, **kwargs)
start()
classmethod supports_batch_update()
class curie.task.TaskDescriptor(task_id=None, task_type=None, pre_task_msg='', post_task_msg='', create_task_func=None, task_func_args=None, task_func_kwargs=None, state=None, entity_name='', desired_state=<Enum TaskStatus::kSucceeded = 7>, is_complete_func=None, *args, **kwargs)

Bases: object

classmethod get_default_task_type()
classmethod get_task_class()
has_succeeded()
is_complete()
class curie.task.TaskIdPlaceholder

Bases: object

Placeholder for task ID on descriptors for tasks which have not been started.

class curie.task.TaskPoller(max_concurrent, poll_interval_secs=1, **kwargs)

Bases: object

TaskPoller manages scheduling and polling ‘Task’s.

DEFAULT_MAX_PARALLEL = 100
DEFAULT_POLL_SECS = 1
add_task(task)

Adds ‘task’ to the batch.

classmethod execute_parallel_tasks(task_descriptors=None, tasks=None, poll_secs=1, max_parallel=100, timeout_secs=None, raise_on_failure=True, **kwargs)

Execute tasks specified by ‘task_desc_list’ in parallel.

Tasks may be provided by TaskDescriptor or Curie task instances.

Parameters:
  • task_descriptors (TaskDescriptor|iterable<TaskDescriptor>) – Descriptor or list of descriptors for tasks to execute.
  • tasks (Task|iterable<Task>) – Task instance or list of task instances to execute.
  • poll_secs (number) – Optional. Polling period in seconds. Default 1.
  • max_parallel (number) – Maximum number of concurrent tasks.
  • timeout_secs (number|None) – Timeout in seconds for all tasks to complete, or None for no timeout.
  • raise_on_failure (bool) – If True, raise a CurieTestException if one or more tasks fail. Otherwise, the task map will contain failed tasks.
Returns:

(dict<str, ?>) Map of task IDs to task output.

Raises:

CurieTestException – If one or more tasks fail. If any task does not complete within the timeout.

classmethod get_deadline_secs(timeout_secs)
classmethod get_default_timeout_secs()
classmethod get_timeout_secs(deadline)
start()

Starts executing tasks asynchronously.

stop()

Attempts to cancel all remaining non-terminal tasks.

Returns:(int) Number of remaining tasks which could not be canceled.
wait_for(task_id=None, timeout_secs=None)

Waits for a task to complete.

Parameters:
  • task_id (None|str) – If provided, it waits until the specified task is complete, otherwise it waits until any task is complete.
  • timeout_secs (None|Number) – If provided, timeout in seconds.
Returns:

(list<str>) List of task IDs which completed since the last time this

thread called wait_for. If ‘task_id’ is not None, this set is returned only if it contains ‘task_id’.

(None) Timeout, or tasks finished completed and requested ‘task_id’ was

never observed.

wait_for_all(timeout_secs=None)

Waits for all tasks to complete.

Parameters:timeout_secs (None|Number) – If provided, maximum wait time in seconds.
Returns:
(bool) True if tasks are complete, False if ‘timeout_secs’ is not None
and tasks did not complete within the timeout.
class curie.task.TaskState(status=<Enum TaskStatus::kNotStarted = 0>)

Bases: object

class curie.task.TaskStatus

Bases: curie.json_util.Enum

classmethod cannot_succeed(status)
classmethod is_active(status)
classmethod is_ready(status)
classmethod is_terminal(status)
kCanceled = <Enum TaskStatus::kCanceled = 5>
kExecuting = <Enum TaskStatus::kExecuting = 2>
kFailed = <Enum TaskStatus::kFailed = 6>
kInternalError = <Enum TaskStatus::kInternalError = 8>
kNotFound = <Enum TaskStatus::kNotFound = 4>
kNotStarted = <Enum TaskStatus::kNotStarted = 0>
kPending = <Enum TaskStatus::kPending = 1>
kSucceeded = <Enum TaskStatus::kSucceeded = 7>
kTimedOut = <Enum TaskStatus::kTimedOut = 3>
kUnknown = <Enum TaskStatus::kUnknown = -1>
class curie.task.VsphereTask(descriptor=None, task=None, state=None, task_id=None)

Bases: curie.task.Task

Encapsulates a vCenter task executed via pyVim.

classmethod from_vim_task(vim_task, desc=None)

Wraps existing ‘vim_task’ in a ‘VsphereTask’.

Parameters:vim_task (vim.Task) – Task to wrap.
Returns:(VsphereTask) VsphereTask wrapping ‘vim_task’.
classmethod get_descriptor_class()
is_cancelable()
update()
class curie.task.VsphereTaskDescriptor(task_id=None, task_type=None, pre_task_msg='', post_task_msg='', create_task_func=None, task_func_args=None, task_func_kwargs=None, state=None, entity_name='', desired_state=<Enum TaskStatus::kSucceeded = 7>, is_complete_func=None, *args, **kwargs)

Bases: curie.task.TaskDescriptor

classmethod get_default_task_type()
classmethod get_task_class()

curie.unix_agent module

class curie.unix_agent.CurieCmdState(cmd_id, proc=None, pid=None)

Bases: object

class curie.unix_agent.CurieUnixAgent(name='curie.unix_agent')

Bases: object

static cmd_dir(cmd_id, root=None)
static cmds_dir(root=None)
initialize()

Initialize agent state.

run()

Run the Flask server forever.

curie.unix_agent.curie_unix_agent_api_handler(func)

curie.unix_vm_mixin module

class curie.unix_vm_mixin.CurieUnixVmMixin

Bases: object

Mixin providing functionality for Unix VMs hosting CurieUnixAgent.

execute_async(cmd_id, cmd, user='nutanix')

See Vm.execute_async documentation.

execute_sync(cmd_id, cmd, timeout_secs, user='nutanix', include_output=False)

See Vm.execute_sync documentation.

is_accessible()

See Vm.is_accessible documentation.

path_exists(path)
stop_cmd(cmd_id)

Stop a command running on this VM.

The command specified by cmd_id must already be running.

Parameters:cmd_id – (str) ID of the command to stop.
Raises:CurieException – If stopping the command fails.
transfer_from(remote_path, local_path, timeout_secs, recursive=False)

See Vm.transfer_from documentation.

transfer_to(local_path, remote_path, timeout_secs, recursive=False)

See Vm.transfer_to documentation.

curie.util module

class curie.util.CurieUtil

Bases: object

IPV4_RE = <_sre.SRE_Pattern object>
UUID_RE = <_sre.SRE_Pattern object>
VALID_STR_SLICE_CHUNK_RE = <_sre.SRE_Pattern object>
static decrypt_aes256_cfb(ciphertext, key)

Decrypts Base64 encoded ‘ciphertext’ using ‘key’.

Parameters:
  • ciphertext (str) – Base64 encoded ciphertext to decrypt.
  • key (str) – Key to use for decryption, assumed to be a SHA-256 digest.
Returns:

(str) Decoded plaintext.

static encrypt_aes256_cfb(plaintext, key)

Encrypts ‘plaintext’ using ‘key’.

Parameters:
  • plaintext (str) – Text to encrypt.
  • key (str) – Key to use for encryption, assumed to be a SHA-256 digest.
Returns:

(str) Base64 encoded ciphertext.

static ipv4_to_ipv6(ipv4_address)

Converts an IPv4 address to the IPv4-mapped IPv6 address.

Parameters:ipv4_address (str) – IPv4 address to convert.
Returns:(str) v4-mapped v6 address
static is_ipv4_address(string)
Parameters:string (str) – Potential IPv4 address to test.
Returns:True if ‘string’ appears to be a valid IPv4 address, else False.
static is_uuid(string)
Parameters:string (str) – Potential UUID to test.
Returns:True if ‘string’ appears to be a UUID, else False.
static log_duration(wrapped, log_func=<bound method Logger.debug of <logging.Logger object>>)

Decorator to log the duration of the wrapped function.

Logs the total execution time in milliseconds.

Parameters:
  • wrapped – Function being profiled.
  • log_func – Optional log function to be called (defaults to log.debug)
Returns:

New function that wraps ‘wrapped’.

static monkey_patch_dummy_process()
Fix a known issue with ‘multiprocessing.dummy.DummyProcess’:
See https://bugs.python.org/issue14881.
static monkey_patch_werkzeug_logger()

Override ‘werkzeug._internal._log’ with a method that discards all output for log type ‘info’.

static ping_ip(ip)

Attempts to send a single ECHO_REQUEST packet to ‘ip’ and confirm receipt of the corresponding reply.

Returns:(bool) True on success, else False.
static resolve_hostname(hostname, timeout=1)
Parameters:
  • hostname ((str)) – Hostname whose IP to resolve.
  • timeout (number) – Timeout in seconds.
Returns:

(str) Resolved IP address of ‘hostname’.

Raises:

CurieException on error.

static slice_with_string(sequence, slice_str)

Perform fancy slicing as described by a string.

Also performs the task of converting negative indices to positive. This is done so that the consumer of this method can write meaningful log messages and annotations. For example, if a test is supposed to power off the last node in the cluster (i.e. slice_str is “-1”) with a sequence size of 4, the index returned is 4 so an annotation can read “Powering off node 4” instead of “Powering off node -1”, which would look suspicious or incorrect to a user.

Parameters:
  • sequence (list or other sequence) – Thing to slice
  • slice_str (str) – Comma-separated slices, such as “0”, “1:”, “0, 1, 2”, “0:2, 3”, “0:2, 3:4, :-1”, etc.

Returns (OrderedDict): Map of indices to items in the sequence.

static timed_command(cmd, timeout_secs, formatted_cmd=None, interval_secs=0.1)

Execute ‘cmd’ with a timeout of ‘timeout_secs’. On a timeout, the underlying command being executed is killed.

Parameters:
  • cmd (str) – Command to run.
  • timeout_secs (int) – Maximum number of seconds to wait for the command to finish.
  • formatted_cmd (str) – If not None, it will be used in place of ‘cmd’ when writing human-readable logs.
  • interval_secs (float) – Command polling interval.
Returns:

(rv, stdout, stderr) if command is executed within ‘timeout_secs’. (-1, None, None) on timeout or other error.

static wait_for(func, msg, timeout_secs, poll_secs=None)

Invoke ‘func’ every ‘poll_secs’ seconds until the boolean-ness of the returned value is True, in which case we return that value. Otherwise, or if ‘timeout_secs’ seconds have elapsed, we return None.

Parameters:
  • func (callable) – Callable to poll.
  • msg (str) – Readable description of the action.
  • timeout_secs (int) – Maximum amount of time to wait for func to complete.
  • poll_secs (int) – Polling interval in seconds. None uses default polling interval.
static wait_for_any(callables, msg, timeout_secs, poll_secs=None)

Invoke each item in ‘callables’ every ‘poll_secs’ seconds until the boolean-ness of any of the returned values are True, in which case we return that value. Otherwise, or if ‘timeout_secs’ seconds have elapsed, we return None.

Parameters:
  • callables (sequence of callable) – Callables to poll.
  • msg (str) – Readable description of the action.
  • timeout_secs (int) – Maximum amount of time to wait for func to complete.
  • poll_secs (int) – Polling interval in seconds. None uses default polling interval.
class curie.util.ReleaseLock(lock, recursive=False)

Bases: object

Context manager which releases lock on entry and reacquires on exit.

If ‘recursive’ is True, repeatedly releases lock until it is not owned, and subsequently reacquires it an appropriate number of times.

curie.util.get_cluster_class(cluster_metadata)

Returns the subclass of Cluster corresponding to the hypervisor type specified in ‘cluster_metadata’.

Returns:(Subclass of Cluster)
curie.util.get_optional_vim_attr(vim_object, attr_name)

Returns either the attribute value for the attribute ‘attr_name’ on the object ‘vim_object’, else None if the attribute isn’t set.

curie.version module

curie.vm module

class curie.vm.Vm(vm_params)

Bases: object

check_cmd(cmd_id, desired_state=1)

Check if a command has reached a desired state.

Parameters:
  • cmd_id (str) – ID of the command to check.
  • desired_state (CmdStatus) – Desired command state.
Returns:

CmdStatus protobuf on success, and None if the command is in progress.

Raises:

CurieTestException if the command has reached a terminal state that is – different from the desired state.

cluster()
execute_async(cmd_id, cmd, user='nutanix')

Asynchronously execute ‘cmd’ as the given user. ‘cmd_id’ must be unique amongst all commands executed on this VM.

execute_sync(cmd_id, cmd, timeout_secs, user='nutanix', include_output=False)

Synchronously execute ‘cmd’ as the given user with the given timeout. ‘cmd_id’ must be unique amongst all commands executed on this VM. ‘include_output’ indicates whether stdout and stderr should be included in the return value (both are None if this is False). Returns rv, stdout, stderr for ‘cmd’.

Note: this method should only be used for commands that don’t generate large amounts of stdout/stderr.

is_accessible()

Returns True if the virtual machine is accessible for guest OS operations for the test. This is a stronger test than if the virtual machine is powered on or not, since it’s possible the virtual machine is powered on but is still booting and hasn’t started up key services.

is_cvm()
is_powered_on()

Returns True if the VM is powered on, else False.

NB: This method only checks the VM’s power state. It does not guarantee that the VM is accessible (cf. ‘Vm.is_accessible’)

Returns:(bool) True if VM is powered on, else False.
node_id()
transfer_from(remote_path, local_path, timeout_secs, recursive=False)

Transfer ‘remote_path’ on VM to ‘local_path’. Returns True on success.

transfer_to(local_path, remote_path, timeout_secs, recursive=False)

Transfer ‘local_path’ to ‘remote_path’ on VM. Returns True on success.

vm_id()
vm_ip()
vm_name()
wait_for_cmd(cmd_id, timeout_secs, poll_secs=30, desired_state=1)

Wait up to ‘timeout_secs’ for the command with ID ‘cmd_id’ to reach the state ‘desired_state’. Returns a CmdStatus protobuf for the command on success, else raises CurieTestException if either a timeout occurs or the command has reached a terminal state that is different from the desired state.

class curie.vm.VmDescriptor(name=None, memory_mb=None, num_cores=None, num_vcpus=None, vm_uuid=None, host_uuid=None, container_uuid=None, vmdisk_uuid_list=None, attached_disks=None, annotation=None)

Bases: object

classmethod from_prism_entity_json(vm_json)
to_ahv_vm_clone_spec(name_list, ctr_uuid=None)
to_ahv_vm_create_spec()
to_ahv_vm_nic_create_spec(network_uuid)
to_ahv_vmdisk_create_spec(size_bytes)
class curie.vm.VmParams(cluster, vm_id)

Bases: object

cluster
is_cvm
node_id
vm_id
vm_ip
vm_name

curie.vmm_client module

class curie.vmm_client.VmmClient(address, username, password, host_address=None, host_username=None, host_password=None, library_server_address=None, library_server_username=None, library_server_password=None, library_server_share_path=None)

Bases: object

clean_library_server(target_dir, vm_name_prefix)
clean_vmm(cluster_name, target_dir, vm_name_prefix)
clone_vm(cluster_name, base_vm_id, vm_name, vm_datastore_path)
convert_to_template(cluster_name, template_name)
create_vm(cluster_name, vm_template_name, vm_host_map, vm_datastore_path, data_disks)
create_vm_template(cluster_name, vm_name, vm_host_id, goldimage_disk_path, vm_datastore_path, vmm_network_name, vcpus=1, ram_mb=1024)
delete(path, **kwargs)
get(path, **kwargs)
get_clusters(cluster_name=None, cluster_type=None)

Return clusters.

Parameters:
  • cluster_name (str) – Cluster name filter (RegEx).
  • cluster_type (str) – Cluster type can be one of: Unknown, VirtualServer, HyperV, VMWareVC, VMWareESX, XENServer.
get_library_shares()

Returns all library shares on VMM server.

get_nodes(cluster_name, nodes=None)
get_vms(cluster_name, vm_input_list=None)
head(path, **kwargs)
is_logged_in
static is_nutanix_cvm(vm)
login(max_retries=5, timeout=90.0)
logout()
migrate_vm(cluster_name, vm_host_map, vm_datastore_path)
migrate_vm_datastore(cluster_name, vm_datastore_map)
nodes_power_state(cluster_name, nodes)
options(path, **kwargs)
patch(path, **kwargs)
post(path, **kwargs)
put(path, **kwargs)
refresh_vms(cluster_name, vm_input_list=None)
update_library(goldimage_disk_path)
upload_image(goldimage_disk_list, goldimage_target_dir, transfer_type=None)
url(path)

Construct the correct URL.

Parameters:path (str) – URL path.
Returns:URL
vm_get_job_status(task_id_list)
vm_stop_job(task_id_list)
vms_delete(cluster_name, vm_ids, force_delete=False)
vms_set_possible_owners_for_vms(cluster_name, task_req_list)
vms_set_power_state_for_vms(cluster_name, task_req_list)
vms_set_snapshot(cluster_name, task_req_list)
exception curie.vmm_client.VmmClientException

Bases: curie.exception.CurieTestException

curie.vsan_node_util module

class curie.vsan_node_util.VsanNodeUtil(node)

Bases: curie.node_util.NodeUtil

is_ready()

See ‘NodeUtil.is_ready’ documentation for further details.

Confirms node is ready by requesting node’s health info from Vsphere corresponding to the node.

Raises:CurieTestException – If the VsanNodeUtil’s node is not found (passed through from __get_vim_host).

curie.vsphere_cluster module

class curie.vsphere_cluster.VsphereCluster(cluster_metadata)

Bases: curie.cluster.Cluster

cleanup(test_ids=())

Shutdown and remove all curie VMs from this cluster.

Raises:CurieException if cluster is not ready for cleanup after 40 minutes.
clone_vms(vm, vm_names, node_ids=(), datastore_name=None, max_parallel_tasks=None, linked_clone=False)

Clones ‘vm’ and creates the VMs with names ‘vm_names’.

Parameters:
  • CurieVM (vm) – Base VM that clones will be created from.
  • list of strings (vm_names) – One clone will be created for each name in list.
  • list of node ids (node_ids) – If provided, must be the same length as ‘vm_names’, then ‘vm_names[xx]’ will be cloned to ‘node_ids[xx]’. Otherwise VMs will be cloned to random nodes on cluster.
  • datastore_name – If provided, name of datastore VMs will be cloned to. Otherwise the VMs will be created on the datastore associated with the curie server’s settings for this cluster.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
  • linked_clone (bool) – Whether or not the clones should be “normal” full clones or linked clones.
Returns:

List of cloned VMs.

collect_performance_stats(**kwargs)

Collect performance statistics for all nodes in the cluster.

Optional arguments ‘start_time_secs’ and ‘end_time_secs’ can be used to limit the results to a specific time range. Note that these times are relative to the vSphere clock. If the clock of the Curie server is not synchronized, the samples returned might appear to be outside of the given time boundaries.

Parameters:
  • start_time_secs (int) – Optionally specify the oldest sample to return, in seconds since epoch.
  • end_time_secs (int) – Optionally specify the newest sample to return, in seconds since epoch.
  • max_samples (int) – Optionally specify the maximum number of samples to get per counter. Defaults to the latest fifteen samples, unless a time range is specified.
Returns:

(dict) Dict of list of curie_metrics_pb2.CurieMetric. Top level dict

keyed by node ID. List contains one entry per metric.

create_vm(goldimages_directory, goldimage_name, vm_name, vcpus=1, ram_mb=1024, node_id=None, datastore_name=None, data_disks=())

See ‘Cluster.create_vm’ for documentation.

datastore_visible(datastore_name)

Returns True if the datastore with name ‘datastore_name’ is visible on all nodes of the cluster.

delete_vms(vms, ignore_errors=False, max_parallel_tasks=None)

Delete VMs.

Parameters:
  • vm_names – List of VM names to power on.
  • bool (ignore_errors) – The default value is False which requires all destroy tasks to complete with “success”. Set to True to disable this check.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
Raises:

CurieTestException – - If any VM is not already powered off. - All VMs are not destroyed with in the timeout. - Destroy task fails and ignore_errors is False.

disable_drs_vms(vms)

Disable DRS on VMs.

Parameters:vms – list of CurieVms: List of VMs disable DRS on.
disable_ha_vms(vms)

Disable HA on VMs.

Parameters:vms – list of CurieVms: List of VMs disable HA on.
enable_ha_vms(vms)

Enable HA on VMs.

Parameters:vms – list of CurieVms: List of VMs enable HA on.
get_power_state_for_nodes(nodes)

See ‘Cluster.get_power_state_for_nodes’ for documentation.

get_power_state_for_vms(vms)

See ‘Cluster.get_power_state_for_vms’ for documentation.

import_vm(goldimages_directory, goldimage_name, vm_name, node_id=None)

Creates a VM from the specified gold image. If ‘node_id’ is specified, the VM is created on that node, else a random node is selected. The VM will be created on the datastore associated with the curie server’s settings for this cluster.

is_drs_enabled()

See ‘Cluster.is_drs_enabled’ for documentation.

is_ha_enabled()

See ‘Cluster.is_ha_enabled’ for documentation.

classmethod metrics()
migrate_vms(vms, nodes, max_parallel_tasks=None)

Move ‘vms’ to ‘nodes’.

For each VM ‘vms[xx]’ move to the corresponding Node ‘nodes[xx]’.

Parameters:
  • list of CurieVms (vms) – List of VMs to migrate.
  • list of CurieClusterNodes (nodes) – Must be the same length as ‘vms’. Each VM in ‘vms’ wll be moved to the corresponding node in ‘nodes’.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel.
nodes()

Returns a list of Node objects for the nodes in the cluster.

power_off_nodes_soft(nodes, timeout_secs=None, async=False)

See ‘Cluster.power_off_nodes_soft’ for definition.

power_off_vms(vms, max_parallel_tasks=None)

Powers off VMs.

Parameters:
  • vms – List of VMs to power on.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
Raises:

CurieTestException – VMs fail to power off within the timeout.

power_on_vms(vms, max_parallel_tasks=None)

See ‘Cluster.power_on_vms’ for documentation.

refresh_datastores()

Refreshes datastores state for all nodes in vCenter. This is necessary in case changes have been made directly on ESX nodes and the ESX nodes fail to synchronize this state with vCenter.

relocate_vms_datastore(vms, datastore_names, max_parallel_tasks=None)

Relocate ‘vms’ to ‘datastore_names’.

snapshot_vms(vms, snapshot_names, snapshot_descriptions=(), max_parallel_tasks=None)

For each VM with name ‘vm_names[xx]’ on the cluster ‘vim_cluster’, creates a snapshot with snapshot name ‘snapshot_names[xx]’ and optional description ‘snapshot_descriptions[xx]’.

Args

vms list of CurieVMs: List of VMs to create snapshots for. snapshot_names list of strings: Names for snapshot which must be the same

length as ‘vms’.
snapshot_descriptions List of strings: List of descriptions for each
snapshot corresponding to ‘vms’ and ‘snapshot_names’. If provided it must be the same length as ‘vms’.
max_parallel_tasks int: The number of VMs to power on in parallel. The
default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
sync_power_state_for_nodes(nodes, timeout_secs=2400)

See ‘Cluster.sync_power_state_for_nodes’ for documentation.

update_metadata(include_reporting_fields)

Update the cluster’s metadata with additional information (if available) about the corresponding cluster. If ‘include_reporting_fields’ is True, also include additional information intended for reporting.

Note: this should only be called before the test begins executing steps in the kSetup, kRun, and kTeardown phases.

vms()

Returns a list of VM objects for the VMs in the cluster.

curie.vsphere_node module

class curie.vsphere_node.VsphereNode(cluster, node_id, node_index)

Bases: curie.node.Node

classmethod get_management_software_property_name_map()

See ‘Node.get_node_property_map’ for documentation.

power_off_soft(timeout_secs=None, async=False)

See ‘Node.power_off_soft’ for documentation.

curie.vsphere_unix_vm module

class curie.vsphere_unix_vm.VsphereUnixVm(vm_params)

Bases: curie.unix_vm_mixin.CurieUnixVmMixin, curie.vsphere_vm.VsphereVm

curie.vsphere_vcenter module

class curie.vsphere_vcenter.VsphereVcenter(vcenter_host, vcenter_user, vcenter_password)

Bases: object

Class for interacting with vCenter for a specific cluster.

clone_vms(vim_vm, vim_datacenter, vim_cluster, vim_datastore, vm_names, host_names=(), max_parallel_tasks=None, linked_clone=False)

Clones ‘vm’ and creates the VMs with names ‘vm_names’.

Parameters:
  • vim_vm (vim.VirtualMachine) – Base VM to clone.
  • vim_datacenter (vim.Datacenter) – Datacenter containing ‘vim_cluster’.
  • vim_cluster (vim.ComputeResource) – Cluster hosting ‘vim_vm’.
  • vim_datastore (vim.Datastore) – DS where clone files will reside.
  • vm_names (list<strings>) – List of names to assign the clones.
  • host_names (list<str>) – Optional. If provided, a list of host_ids which must be the same length as ‘vm_names’. When present, ‘vm_names[xx]’ will be cloned to ‘host_name[xx]’. If not specified, VMs will be cloned to a random host on cluster.
  • max_parallel_tasks (int) – The number of VMs to power on in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
  • linked_clone (bool) – Whether or not the clones should be “normal” full clones or linked clones.
Returns:

List of cloned VMs.

Raises:

CurieTestException if fail to complete clones within the timeout.

collect_cluster_performance_stats(**kwargs)

Simple interface to collect relevant vSphere cluster statistics.

The arguments to this method are directly passed through to the vim.PerfQuerySpec argument of the same name.

For more information about VMware PerfQuerySpec, which serves as the basis for this interface, visit the VMware documentation here: https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.PerformanceManager.QuerySpec.html

Parameters:
  • vim_cluster (vim.ClusterComputeResource) – Cluster from which performance statistics will be gathered.
  • metrics (list of curie_metrics_pb2.CurieMetric) – Metrics to collect from the cluster.
  • vim_perf_query_spec_start_time (datetime) – Optionally specify the oldest (exclusive) sample to return. This defaults to the vSphere default start time, which is one hour ago.
  • vim_perf_query_spec_end_time (datetime) – Optionally specify the newest (inclusive) sample to return. This defaults to the vSphere default end time, which is now.
  • vim_perf_query_spec_max_sample (int) – Optionally specify the maximum number of samples to return. This defaults to the vSphere default, which is that “the most recent sample (or samples), unless a time range is specified.”
Returns:

(dict) Dict of list of curie_metrics_pb2.CurieMetric. Top level dict

keyed by node ID. List contains one entry per metric. If an error occurs during collection on a node, None will be inserted instead of a list.

create_vm(vm_name, vim_datacenter, vim_cluster, vim_datastore, vim_network, vim_host, os_disk_path, ram_mb=1024, vcpus=1, data_disks=(), num_scsi_controllers=4)

Create a new VM on the cluster with the provided attributes.

VM’s created by this method automatically use VMXNet3 for network connectivity and scsi paravirtual controllers for storage. The number of controllers is automatically set to 4 and data disks are distributed across the controllers evenly in a sequential fashion.

Parameters:
  • vm_name (str) – Name of the VM
  • vim_datacenter (vim.datacenter) – Data center to place the VM
  • vim_cluster (vim.cluster) – Cluster to place the VM
  • vim_datastore (vim.datastore) – Datastore to use for storage
  • vim_network (vim.network) – Network to connect the VM to
  • vim_host (vim.host) – Host to place the VM on.
  • os_disk_path (str) – Full local path to the vmdk to use as the OS disk.
  • ram_mb (int) – RAM to be allocated to the VM. Defaults to 1GB.
  • vcpus (int) – Number of vCPUs to allocate to the VM. Defaults to 1.
  • data_disks (list) – List of additional disk sizes to allocate to the VM in gigabytes. e.g. [1,1] will create 2 disks of 1 GB each.
  • num_scsi_controllers (int) – Number of SCSI controllers.
Returns:

vim.vm

delete_datastore_folder_path(folder_path, vim_datastore, vim_datacenter)
delete_vms(vim_cluster, vm_names, ignore_errors=False, max_parallel_tasks=None)

Delete VMs.

Parameters:
  • vim_cluster – Cluster object containing the vms.
  • vm_names – List of VM names to power on.
  • bool (ignore_errors) – The default value is False which requires all destroy tasks to complete with “success”. Set to True to disable this check.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
Raises:

CurieTestException – - If any VM is not already powered off. - All VMs are not destroyed with in the timeout. - Destroy task fails and ignore_errors is False.

disable_drs_vms(vim_cluster, vim_vms)

Disable DRS on all the vim_vms in vim_cluster.

Parameters:
  • vim_cluster (vim.Cluster) – Cluster object containing the vms.
  • vim_vms – (list<vim.VirtualMachine>): vim VMs on which to disable DRS.
Raises:

CurieTestException if DRS configuration for cluster does not allow for – per-vm overrides.

disable_ha_vms(vim_cluster, vim_vms)

Disable HA on all the vim_vms in vim_cluster.

Parameters:
  • vim_cluster (vim.Cluster) – Cluster object containing the vms.
  • vim_vms – (list<vim.VirtualMachine>): vim VMs on which to disable HA.
disconnect_hosts(vim_hosts, timeout_secs=60)

Disconnect ‘vim_hosts’ from vCenter.

Parameters:
  • vim_hosts (list<vim.HostSystem>) –
  • timeout_secs (number) – Optional. Timeout for disconnect tasks.
fill_cluster_metadata(vim_cluster, metadata, include_reporting_fields)

Fills in the cluster metadata ‘metadata’ corresponding to the cluster ‘vim_cluster’ with additional information (if available).

Parameters:
  • vim_cluster (vim.ClusterComputeResource) – vSphere cluster.
  • metadata (CurieSettings.Cluster) – cluster metadata.
  • include_reporting_fields (bool) – fill in fields intended for reporting.
Raises:
  • CurieException – if any of the nodes already specified in ‘metadata’
  • aren’t found in the cluster.
find_datastore_paths(pattern, vim_datastore)

Find paths in a datastore that matches the provided pattern.

Parameters:
  • pattern – (str) pattern to match. Example: __curie_goldimage*
  • vim_datastore – (vim_datastore object) Datastore to search

Returns: (list) of paths in the datastore

find_snapshot_vm(vim_vm, snapshot_name)

Find a snapshot for a VM if present.

Parameters:
  • vim_vm (vim.VM) – vim object for a VM to search snapshot tree.
  • snapshot_name (string) – Name of the snapshot to try and find.
Returns:

The snapshot object if the snapshot is found, otherwise None is returned.

classmethod from_proto(proto)

Returns VsphereVcenter instance constructed with arguments from ‘proto’.

Parameters:proto (VcenterInfo|VcenterConnectionParams|ConnectionParams) – Proto containing connection params for vCenter.
Raises:CurieException<kInvalidParameter> if the proto does not contain the – required fields.
classmethod get_esx_versions(vim_cluster, nodes=None)

Determine the versions and build numbers for ESX on the cluster nodes.

Parameters:
  • vim_cluster (vim.ClusterComputeResource) – cluster to determine version of ESX running on its nodes.
  • nodes (list<CurieSettings.Node>) – If provided, a subset of the cluster’s nodes whose information to return.
Returns:

list of tuples containing ESX version and build strings for the cluster nodes. If the ESX version and build string for a node can’t be determined, we use (“”, “”).

Return type:

list<(str, str)>

classmethod get_esx_versions_for_vim_host(vim_host)
Returns:(str, str) ESX version string, ESX build string for ‘vim_host’ on success, (“”, “”) if unable to access the ‘config’ key on the vim_host.
get_vcenter_version_info()
get_vim_perf_counter_by_metric(**kwargs)

Return a CounterInfo object corresponding to a CurieMetric.

If no mapping exists for the given metric, None is returned.

Parameters:metric (curie_metrics_pb2.CurieMetric) – CurieMetric being matched.
Returns:(vim.PerformanceManager.CounterInfo)
classmethod get_vim_vm_ip_address(vim_vm)

Attempts to lookup VM IP from ‘vim_vm’ guest information.

Returns:
(str|None) IPv4 address for ‘vim_vm’ if VM has a primary IP and it is an
IPv4, else None.
classmethod get_vsan_version(vim_cluster)

Queries host CIM endpoint to determine VSAN vib version.

Parameters:
  • vim_cluster (vim.ClusterComputeResource) – cluster to determine version of
  • running on its nodes. (VSAN) –
Returns:

VSAN versions for the cluster nodes. If the VSAN version can’t be determined, returns None

Return type:

(str)

import_ovf(ovf_str, vmdk_dir, vim_datacenter, vim_cluster, vim_datastore, vim_network, vm_name, host_name=None, guest_os_type='unix', extra_config=None)

Creates a VM with name ‘vm_name’ from the given OVF string. If ‘host_name’ is specified, the VM is created on that node, else a random node is selected. The VM will be created on the datastore ‘vim_datastore’ on the cluster ‘vim_cluster’ in the VM folder for ‘vim_datastore’. If ‘vim_network’ is specified, use that network for all network interfaces for the VM.

import_vm(goldimages_directory, goldimage_name, vim_datacenter, vim_cluster, vim_datastore, vim_network, vm_name, host_name=None)

Creates a VM with name ‘vm_name’ from the specified gold image. If ‘host_name’ is specified, the VM is created on that node, else a random node is selected. The VM will be created on the datastore ‘vim_datastore’ on the cluster ‘vim_cluster’ in the VM folder for ‘vim_datastore’. If ‘vim_network’ is specified, use that network for all network interfaces for the VM.

is_drs_enabled(vim_cluster)

Checks whether ‘vim_cluster’ has DRS enabled.

Returns:(bool) True if DRS is enabled, else False.
Parameters:vim_cluster (vim.ClusterComputeResource) – vSphere cluster.
is_ha_enabled(vim_cluster)

Checks whether ‘vim_cluster’ has HA enabled.

Returns:(bool) True if HA is enabled, else False.
Parameters:vim_cluster (vim.ClusterComputeResource) – vSphere cluster.
lookup_cluster(vim_datacenter, cluster_name)
lookup_datacenter(datacenter_name)
lookup_datastore(vim_cluster, datastore_name)
lookup_hosts(vim_cluster, host_names)

Look up all the nodes with names ‘host_names’ on cluster ‘vim_cluster’.

Returns:
(list<vim.HostSystem>) vim objects for hosts corresponding to
’host_names’.
Raises:CurieTestException if any node is not found.
lookup_network(vim_datacenter, network_name)
lookup_vm(vim_cluster, vm_name)
lookup_vms(vim_cluster, vm_names=None)

Look up all the VMs with names ‘vm_names’ on cluster ‘vim_cluster’. Returns a list of VirtualMachine objects or raises a CurieTestException if any VM is not found.

migrate_vms(vim_vms, vim_hosts, max_parallel_tasks=None)

Move ‘vim_vms’ to ‘vim_hosts’. (VMotion)

Parameters:
  • vim_vms (list<vim.VirtualMachine>) – vim VMs to move.
  • vim_hosts (list<vim.Host>) – vim Hosts to move Vim VMs to.
  • max_parallel_tasks (int) – The number of VMs to migrate in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
power_off_hosts(vim_cluster, vim_hosts, timeout_secs)

Power off ‘vim_hosts’ on ‘vim_cluster’ via the managing vCenter.

NB: Although this method waits for the vim tasks to complete, it is essentially asynchronous. The vim tasks do not block until the host has actually powered off, only until the power off request is acknowledged.

Parameters:
  • vim_cluster (vim.ClusterComputeResource) – Cluster to which ‘nodes’ belong.
  • vim_hosts (list<vim.HostSystem>) – List of hosts to power off.
  • timeout_secs (int) – Timeout in seconds for all nodes to complete their power off tasks.
Raises:
  • CurieTestException (dodged) if all nodes do not complete their power
  • off tasks within ‘timeout_secs’.
power_off_vms(vim_cluster, vm_names, max_parallel_tasks=None)

Powers off VMs.

Parameters:
  • vim_cluster – Cluster object containing the vms.
  • vm_names – List of VM names to power on.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
Raises:

CurieTestException – VMs fail to power off within the timeout.

power_on_vms(vim_cluster, vm_names, max_parallel_tasks=None)

Powers on VMs and verifies that an IP address is assigned.

Parameters:
  • vim_cluster – Cluster object containing the vms.
  • vm_names – List of VM names to power on.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
Raises:
  • CurieTestException – VMs fail to acquire an IP address within the
  • timeout.
reconnect_hosts(vim_hosts, timeout_secs=60)

Reconnect ‘vim_hosts’ to vCenter.

Parameters:
  • vim_hosts (list<vim.HostSystem>) –
  • timeout_secs (number) – Optional. Timeout for reconnect tasks.
refresh_datastores(vim_cluster)

Refreshes datastores state for all nodes in ‘vim_cluster’ in vCenter. This is necessary in case changes have been made directly on ESX nodes and the ESX nodes fail to synchronize this state with vCenter.

Parameters:vim_cluster (vim.ClusterComputeResource) – vSphere cluster.
reload_hosts(vim_hosts)

Reload ‘vim_hosts’ in vCenter.

Parameters:vim_hosts (list<vim.HostSystem>) –
relocate_vms_datastore(vim_vms, vim_datastores, max_parallel_tasks=None)

Relocate ‘vim_vms’ to ‘vim_datastores’. (Storage VMotion)

Parameters:
  • vim_vms (list<vim.VirtualMachine>) – vim VMs to move.
  • vim_datastores (list<vim.Datastore>) – vim Datastores to move Vim VMs to.
  • max_parallel_tasks (int) – The number of VMs to relocate in parallel. The
  • value is FLAGS.vsphere_vcenter_max_parallel_tasks. (default) –
snapshot_vms(vim_cluster, vm_names, snapshot_names, snapshot_descriptions=(), max_parallel_tasks=None)

For each VM with name ‘vm_names[xx]’ on the cluster ‘vim_cluster’, creates a snapshot with snapshot name ‘snapshot_names[xx]’ and optional description ‘snapshot_descriptions[xx]’.

Parameters:
  • vim_cluster – Cluster object containing the vms.
  • vm_names – List of VM names to power on.
  • list or tuple of descriptions (snapshot_descriptions) – If non-empty, snapshot descriptions must be specified for all snapshots being created.
  • int (max_parallel_tasks) – The number of VMs to power on in parallel. The default value is FLAGS.vsphere_vcenter_max_parallel_tasks.
Raises:

CurieTestException – Snapshots are not created within the timeout.

upload_vmdk(local_path, remote_path, vim_host, vim_datastore)

Uploads a VMDK to a target datastore via a specific host.

Parameters:
  • local_path (str) – Full path to the VMDK in the local filesystem.
  • remote_path (str) – Target location within a remote datastore.
  • vim_host (vim.Host) – The host to use for uploading.
  • vim_datastore (vim.Datastore) – The datastore to upload the VMDK to and where the remote_path is assumed.
Returns:

None

classmethod vim_vm_is_nutanix_cvm(vim_vm)
walk(vim_object=None)

Perform a depth-first walk of ‘vim_object’.

Note that only vim.Folders and vim.hostFolders will be enumerated, meaning that datastores, networks, and VMs will not be yielded. These objects exist within a datacenter’s datastoreFolder, networkFolder, and vmFolder properties.

Parameters:vim_object – Object in which to walk. Defaults to the root folder.
Yields:object – Each vim object.

curie.vsphere_vm module

class curie.vsphere_vm.VsphereVm(vm_params)

Bases: curie.vm.Vm

is_powered_on()

See ‘CurieVM.is_powered_on’ for documentation.

curie.xml_util module

Util for building simple classes based on XML data.

To create a node, define a class, setting __metaclass__ to XmlMeta, and setting the class-level attribute _DESCRIPTOR to an instance of XmlElementDescriptor.

Child nodes may be created by subclassing.

Example, to represent the following:
<TAG>
<NESTED_TAG>
Some text

</NESTED_TAG>

</TAG>

One might define:

class Tag(object):
_DESCRIPTOR = XmlElementDescriptor(“TAG”) __metaclass__ = XmlMeta
class NestedTag(Tag):

_DESCRIPTOR = XmlElementDescriptor(“NESTED_TAG”)

def __init__(self, text):
self.__node = self._DESCRIPTOR.clone() self.__node.text = text super(NestedTag, self).__init__(self.__node)

data = NestedTag(“Some text”) print(data.xml(True))

<?xml version=‘1.0’ encoding=’ASCII’?> <TAG>

<NESTED_TAG>Some text</NESTED_TAG>

<TAG>

class curie.xml_util.XmlData(node)

Bases: object

headers()
lookup_xpath(xpath)

Returns first node at ‘xpath’ relative to self.node()’s root tree.

node()
root()
xml(pretty=False, xml_declaration=True)
static xpath()
class curie.xml_util.XmlElementDescriptor(tag, attrs=None)

Bases: object

attrs()
clone()

Returns a clone of the prototype which may be used/modified as desired.

tag()
classmethod xml_py_type_cast(xml_type, value)

Cast the string ‘value’ of XML type ‘xml_type’ to appropriate python type.

If an appropriate type is not found, defaults to returning ‘value’ as a string.

Parameters:
  • xml_type (str) – XML type attribute associated with ‘value’.
  • value (str) – XML serialized value, originally of type ‘xml_type’.
Returns:

‘value’ cast to appropriate type if found, else ‘value’ as a string.

xpath()
class curie.xml_util.XmlMeta(name, bases, dct)

Bases: type

Module contents