Created
February 28, 2014 02:16
-
-
Save fairchild/9263887 to your computer and use it in GitHub Desktop.
simple check if fog is working wtih cloud endpoint
This file contains 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
require 'fog' | |
auth_url = ENV['OS_AUTH_URL'] | |
username = ENV['OS_USERNAME'] | |
password = ENV['OS_PASSWORD'] | |
tenant = ENV['OS_TENANT_NAME'] # String | |
compute_client ||= ::Fog::Compute.new(:provider => :openstack, | |
:openstack_api_key => password , | |
:openstack_username => username , | |
:openstack_auth_url => auth_url , | |
:openstack_tenant => tenant | |
) | |
p compute_client | |
# Create VM | |
# Options include metadata, availability zone, etc... | |
begin | |
vm = compute_client.servers.list | |
rescue => e | |
puts JSON.parse(e.response.body)['badRequest']['message'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment