Created
April 15, 2013 11:20
-
-
Save mohitsethi/5387418 to your computer and use it in GitHub Desktop.
vsphere-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'pp' | |
| require 'fog' | |
| require 'highline/import' | |
| def get_password(prompt="Enter password:") | |
| ask(prompt) {|q| q.echo = false} | |
| end | |
| #user = gets.chomp | |
| pass = get_password() | |
| credentials = { | |
| :provider => "vsphere", | |
| :vsphere_username => "user.name", | |
| :vsphere_password => pass, | |
| :vsphere_server => "my_vcserver", | |
| :vsphere_ssl => true, | |
| :vsphere_expected_pubkey_hash => "my_hash", | |
| :vsphere_rev => "4.0" | |
| } | |
| connection = Fog::Compute.new(credentials) | |
| # MUST BE Ruby v 1.9 to use this hash style | |
| vms = connection.list_virtual_machines(datacenter: 'my_dc', folder: 'my_folder') | |
| puts vms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment