Skip to content

Instantly share code, notes, and snippets.

@fairchild
Created February 28, 2014 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fairchild/9263887 to your computer and use it in GitHub Desktop.
Save fairchild/9263887 to your computer and use it in GitHub Desktop.
simple check if fog is working wtih cloud endpoint
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