Skip to content

Instantly share code, notes, and snippets.

@n1zyy
Created February 15, 2012 00:36
Show Gist options
  • Select an option

  • Save n1zyy/1832069 to your computer and use it in GitHub Desktop.

Select an option

Save n1zyy/1832069 to your computer and use it in GitHub Desktop.
Tinkering with deltacloud-client
# Nothing revolutionary, but here are some random examples of interacting
# with deltacloud-client using Conductor's Rails console.
# Find the mock provider (because it's what I wanted to use)
provider = Provider.find_by_name 'mock'
# Get its account (modify this if you don't actually want the first one)
account = provider.provider_accounts.first
# Get a connection
# (The 'mockuser' and 'mockpassword' credentials are not really secrets...)
>> c = account.connect
# => #<DeltaCloud::API:0x7fce58f0c3b8 @api_uri=#<URI::HTTP:0x7fce58f268d0 URL:http://localhost:3002/api>, verbosefalse, entry_points{:images=>"http://localhost:3002/api/images", :storage_volumes=>"http://localhost:3002/api/storage_volumes", :hardware_profiles=>"http://localhost:3002/api/hardware_profiles", :storage_snapshots=>"http://localhost:3002/api/storage_snapshots", :buckets=>"http://localhost:3002/api/buckets", :instances=>"http://localhost:3002/api/instances", :keys=>"http://localhost:3002/api/keys", :drivers=>"http://localhost:3002/api/drivers", :instance_states=>"http://localhost:3002/api/instance_states", :realms=>"http://localhost:3002/api/realms"}, password"mockpassword", api_version"0.5.0", api_provider"", features{:instances=>[:hardware_profiles, :user_name, :user_data, :authentication_key]}, username"mockuser", driver_name"mock", api_driver"mock"
# Get a list of instances:
c.instances
# Find an instance
instance = c.instance('inst1')
# Interact with it
i.state
# => "RUNNING"
i.public_addresses
# => [{:type=>"hostname", :address=>"Mock_mock_aa57b1ab-f565-4a7a-b054-58ef5af1a053.inst1.public.com"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment