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.
python -m skytap.Environments running # or 'suspended', 'stopped', or 'busy'
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
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
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
skytap.models.SkytapGroup class for
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.
Set of Skytap environments.
Delete a given environment.
This is unrecoverable. Use with extreme caution.
Parameters: env – The
Returns: True if the environment was deleted. Return type: bool Raises:
envisn’t in the Environments set.
envs = skytap.Environments() target = envs envs.delete(target)
Count the total amount of storage in use.
Returns: Amount of storage used across all environments. Return type: int
envs = skytap.Environments() print(envs.storage()))
Count the total number of SVMs in use.
Returns: Number of SVMs used across all environments. Return type: int
envs = skytap.Environments() print(envs.svms())
Count the total number of VMs.
Returns: Number of VMs used across all environments. Return type: int
envs = skytap.Environments() print(envs.vm_count())