Environments

Skytap API object wrapping Skytap Environments.

This roughly translates to the Skytap API call of /v2/configurations REST call, but gives us better access to the bits and pieces of the environments.

Accessing via command line

If accessed via the command line this will return the environments from Skytap in a JSON format:

python -m skytap.Environments

If you know the environment you want information on, you can also specify it directly. You can search by id or by a part of the environment name:

python -m skytap.Environments 12345
python -m skytap.Environments test

Additionally, you can search on some other crieria of a group to get a set you’re looking for.

Runstate:

python -m skytap.Environments running  # or 'suspended',
    'stopped', or 'busy'

Region:

python -m skytap.Environments us-west

Accessing via Python

After you’ve installed skytap and added import skytap to your script, you can access the Skytap environments by the skytap.Environments object.

Example:

envs = skytap.Environments()
for e in envs:
    print (e.name)

Each environment has many things you can do with it - see the skytap.models.Environment object for actions you can take on an individual environment.

On the full list of environments, you can also get a vm count, svm count, get global storage, and delete environments. Each action is documented, below.

Environments can also perform any of the actions of other SkytapGroup objects. See the documentation on the skytap.models.SkytapGroup class for information there.

Note

Some pieces of a given environment, specifically notes and user_data, are only available via additional calls to the API. These fields will not exist when first creating the environments object, but any direct access to those fields will trigger the API call behind the scenes.

This is important if you’re listing the entire contents (say, sending it to a JSON) - these fields won’t be included if you haven’t made that direct access.

This is by design to conserve API calls as most usage doesn’t need or use those fields.

class skytap.Environments.Environments

Bases: skytap.models.SkytapGroup.SkytapGroup

Set of Skytap environments.

delete(env)

Delete a given environment.

Warning

This is unrecoverable. Use with extreme caution.

Parameters:env – The Environment to delete.
Returns:True if the environment was deleted.
Return type:bool
Raises:KeyError – If env isn’t in the Environments set.

Example:

envs = skytap.Environments()
target = envs[12345]
envs.delete(target)
storage()

Count the total amount of storage in use.

Returns:Amount of storage used across all environments.
Return type:int

Example:

envs = skytap.Environments()
print(envs.storage()))
svms()

Count the total number of SVMs in use.

Returns:Number of SVMs used across all environments.
Return type:int

Example:

envs = skytap.Environments()
print(envs.svms())
vm_count()

Count the total number of VMs.

Returns:Number of VMs used across all environments.
Return type:int

Example:

envs = skytap.Environments()
print(envs.vm_count())