Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/test-kitchen/vmware-vra-gem
A Ruby Gem for interacting with the VMware vRealize Automation system
https://github.com/test-kitchen/vmware-vra-gem
hacktoberfest managed-by-terraform ruby ruby-gem test-kitchen testing vmware-vra-gem vmware-vrealize-automation vra
Last synced: 16 days ago
JSON representation
A Ruby Gem for interacting with the VMware vRealize Automation system
- Host: GitHub
- URL: https://github.com/test-kitchen/vmware-vra-gem
- Owner: test-kitchen
- License: apache-2.0
- Created: 2015-07-17T21:06:47.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T05:57:28.000Z (about 1 year ago)
- Last Synced: 2024-04-14T04:20:55.386Z (8 months ago)
- Topics: hacktoberfest, managed-by-terraform, ruby, ruby-gem, test-kitchen, testing, vmware-vra-gem, vmware-vrealize-automation, vra
- Language: Ruby
- Homepage:
- Size: 285 KB
- Stars: 16
- Watchers: 27
- Forks: 32
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# VMware vRA Gem
[![Gem Version](https://badge.fury.io/rb/vmware-vra.svg)](http://badge.fury.io/rb/vmware-vra)
Client gem for interacting with VMware's vRealize Automation application.
Not all vRA functionality is included in this gem; only API calls necessary
to interact with the catalog, requests, and existing items is included.The primary goal of this gem is to provide a reusable set of methods in order
to create Chef plugins for knife, test-kitchen, and provisioning.## Versions
`1.7.0` version can and will support vRA 6 and below.
`2.0.0` version and forward will support vRA 7+.
`3.0.0` version and forward will support vRA 8+.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'vmware-vra'
```And then execute:
```shell
bundle
```Or install it yourself as:
```shell
gem install vmware-vra
```## Usage
First, load in the gem.
```shell
require 'vra'
=> true
```Then, set up your client object. You will need to know your domain from your vRA administrator.
```shell
client = Vra::Client.new(username: '[email protected]', password: 'mypassword', domain: 'domain.corp.local', base_url: 'https://vra.corp.local', verify_ssl: true)
=> #
```### Catalog Types
To list all the catalog types:
```shell
client.catalog.all_types
=> [#"com.vmw.vro.workflow", ... ]
```### Catalog Sources
To list all the catalog sources:
```shell
client.catalog.all_sources
[# [# #
```### Catalog Items
To list all items in the catalog:
```shell
client.catalog.all_items
=> [#, # [#, #
[#"oe-centos-1633598756_bp",
...>
]
```### Requesting Deployments
When you are ready to request a deployment using a catalog, create a new deployment object:
```shell
request = client.catalog.request(
catalog_id,
image_mapping: 'VRA-nc-lnx-ce8.4-Docker',
flavor_mapping: 'Small',
name: 'CentOS VRA8 Test',
project_id: project_id,
version: '1'
)
=>
# #deployment.status
=> "IN_PROGRESS"
```You can refresh your deployment object to get the latest status:
```shell
deployment.refresh && deployment.status
=> "SUCCESSFUL"
```You can also save the deployment ID for later, and create a new deployment object at your leisure to follow-up on your deployment request:
```shell
deployment.id
=> "aed22465-02db-481d-b55a-cefe216096a2"new_deployment = client.deployments.by_id('aed22465-02db-481d-b55a-cefe216096a2')
=> #new_deployment.status
=> "CREATE_SUCCESSFUL"
```### Deployment Resources
When the deployment request is successful, you can query the resources created as the result of your request. Assuming that the catalog item blueprint we requested only creates a single VM, we can get that resource and learn more information about it:
```shell
resource = deployment.resources.first
=> #resource.network_interfaces
=> [{"NETWORK_ADDRESS"=>"192.168.110.203", "NETWORK_MAC_ADDRESS"=>"00:50:56:ae:1d:c7", "NETWORK_NAME"=>"vxw-dvs-35-virtualwire-2-sid-5000-Edge_Transport"}]resource.ip_addresses
=> ["192.168.110.203"]resource.name
=> "hol-dev-32"
```If you have the resource_id and the deployment object, you can fetch the resources details as follows
```shell
resource.id
=> "331fd10b-f2a2-40ae-86bc-1255c1ee9a6d"new_resource = deployment.resource_by_id('331fd10b-f2a2-40ae-86bc-1255c1ee9a6d')
=> #new_resource.name
=> "hol-dev-32"
```### Deleting a deployment from vRA
When you no longer need the VM, you can destroy the deployment which will delete all the associated resources as well.
The method will return a request object you can query for status:```shell
destroy_req = deployment.destroy
=> #destroy_req.status
=> "SUCCESSFUL"
```You can also list all resources and requests you have permission to see with these methods:
```shell
deployment.resources
deployment.requests
```### Pagination
vRA paginates API requests where lists of items are returned. By default, this gem will ask vRA to provide items in groups of 20. However, as reported in [Issue 10](https://github.com/chef-partners/vmware-vra-gem/issues/10), it appears vRA may have a pagination bug. You can change the default page size from 20 to a value of your choice by passing in a `page_size` option when setting up the client:
```ruby
vra = Vra::Client.new(username: '[email protected]', password: 'mypassword', domain: 'domain.corp.local', base_url: 'https://vra.corp.local', verify_ssl: true, page_size: 100)
```... or setting `page_size` on the client object after you've created it:
```ruby
client.page_size = 100
```### Debugging
To aid diagnosis of deep API issues, set the following environment variable to enable logging of all API requests. Note that this will include requests to retrieve the bearer token.
MacOS/Linux:
```ruby
export VRA_HTTP_TRACE=1
```Windows:
```powershell
$env:VRA_HTTP_TRACE=1
```## License and Authors
Author:: Chef Partner Engineering ()
Copyright:: Copyright (c) 2022 Chef Software, Inc.
License:: Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the License at```text
http://www.apache.org/licenses/LICENSE-2.0
```Unless required by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing permissions
and limitations under the License.## Contributing
1. Fork it ( )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request