Overview#
vRealize Automation Idem plugin autogenerated from swagger files.
Virtual environment#
It is recommended to use a Python virtual environment for development purposes in order to avoid taining your local environment:
# Create virtual env
virtualenv .virtualenv -p python3.10
# For bash/zsh shell
source .virtualenv/bin/activate
# For fish shell
source .virtualenv/bin/activate.fish
How to use the plugin#
Installation from source#
The following command installs the plugin from source:
# Clone this repository
git clone https://gitlab.com/vmware/idem/idem-vra.git
# Install
pip install .
Credentials#
The plugin requires a valid set of credentials to communicate with the remote vRA instance. The credentials are contained in a credentials.yaml file which is then encrypted and the decryption key is persisted as an environment variable.
Create credentials.yaml
file:
vra:
default:
vra_url: <vra-hostname>
refresh_token: <refresh-token>
default_org_id: <organization-id>
Encrypt the credentials. This will create an encrypted credentials file
called credentials.yaml.fernet
and will output the decryption key.
Record this key in a safe place as it is going to be required by Idem
for credentials decryption.
idem encrypt credentials.yaml
In order to ease credentials usage locally, you can optionally create a shell script that automatically loads the encrypted credentials and the decryption key as environment variables:
# For Bash/zShell - credentials.sh
export ACCT_FILE=$(pwd)/credentials.yaml.fernet
export ACCT_KEY=<decryption key>
# For Fish shell - credentials.fish
set -x ACCT_FILE (pwd)/credentials.yaml.fernet
set -x ACCT_KEY <decryption key>
Source the helper script:
# For Bash/zShell
source credentials.sh
# For Fish shell
source credentials.fish
Plugin configurations#
--extras='{"debug-clients": true}'
- Enable client libraries debug logs
Example calls#
# Get all projects
idem exec "vra.iaas.project.get_projects" --log-level=DEBUG
# Get the first 2 cloud accounts
idem exec "vra.iaas.cloudaccount.get_cloud_accounts" top=2 --log-level=DEBUG
# Get a project by id
idem exec "vra.iaas.project.get_project" p_id=2fd4a830-6fce-4065-b00c-42fb70c035b0 --log-level=DEBUG
# Get a cloud account named 'AWS'
idem exec "vra.iaas.cloudaccount.get_cloud_accounts" filter="(name eq 'AWS')" top=1 --log-level=DEBUG
# Count cloud accounts whose name begin with 'VCenter'
idem exec "vra.iaas.cloudaccount.get_cloud_accounts" filter="(name eq 'VCenter*')" --output=json | jq '.ret.number_of_elements'
# Create a new project with cloud zones
idem exec "vra.iaas.project.create_project" name='My Project' zoneAssignmentConfigurations=[{ 'zoneId': 'fcad1c25-9882-4d83-adfc-c73fe87fccbd'}] --log-level=DEBUG
# REST request wrapper - GET with query parameters
idem exec vra.rest.request path=/iaas/api/zones method=get query_params={'$filter': "(name eq 'My Zone')"}
# Describe calls
idem describe vra.iaas.cloudaccount --log-level=DEBUG
idem describe vra.iaas.project --log-level=DEBUG
idem describe "vra.iaas.*" --output=yaml > green.sls
idem describe "vra.catalog.*" --log-level=DEBUG
idem refresh "vra.iaas.*" --log-level=DEBUG --output=yaml > my-vra.yaml
# State calls
idem state green.sls --test
# Doc calls
idem doc states.vra
idem doc exec.vra.iaas.storageprofile