See http://www.contegix.com/solutions/cloud-hosting.php for more information on the Contegix Cloud.
- gem install httparty
Login into the Contegix Cloud, go to your account page, and get your API key.
Run the following from the Contegix Cloud client source directory:
sh> ./script/console
Set your API key, Contegix cloud base URL, and optional basic authentication information.
irb> Kronos.api_token = '84bd5f6162c79eb74f3c3d048408bea684cff73898370bacb3eee826e9e5f8ea'
irb> Kronos.base_uri = 'http://somehost.example.com'
irb> Kronos.basic_auth('username', 'password') # optional
Make a sample call.
irb> Kronos::Sample.hello
This should give you
=> Result code: 200, Location:
Work the machines
irb> Kronos::VirtualMachine.all
This will give you results like:
[#<Kronos::VirtualMachine:0x11c6ec4 @attributes={"name"=>"Host10", "template_uuid"=>"8af83d0beeb35605bb1b803d15832414", "resource_configuration_uuid"=>"d979bc02aeda53bf9bc3878a4ef2436e", "template_name"=>"EL5-64", "uuid"=>"00000010000000000000000000000000", "zone_uuid"=>nil, "zone_name"=>"us1", "resource_configuration_name"=>"1 CPU, 1024MB RAM, 80GB Disk", "ip_address"=>"10.10.102.110", "state"=>"powered_off"}>, #<Kronos::VirtualMachine:0x11c6eb0 @attributes={"name"=>"Host11", "template_uuid"=>"8af83d0beeb35605bb1b803d15832414", "resource_configuration_uuid"=>"bb6d88778e1150c99cf5c75347852a85", "template_name"=>"EL5-64", "uuid"=>"00000011000000000000000000000000", "zone_uuid"=>nil, "zone_name"=>"us1", "resource_configuration_name"=>"1 CPU, 1024MB RAM, 80GB Disk", "ip_address"=>"10.10.102.111", "state"=>"powered_off"}>, #<Kronos::VirtualMachine:0x11c6e9c @attributes={"name"=>"Host99", "template_uuid"=>"8af83d0beeb35605bb1b803d15832414", "resource_configuration_uuid"=>"b3bdcf9388c458e3907fff3f66421a52", "template_name"=>"EL5-64", "uuid"=>"00000099000000000000000000000000", "zone_uuid"=>nil, "zone_name"=>"us1", "resource_configuration_name"=>"1 CPU, 1024MB RAM, 80GB Disk", "ip_address"=>"10.10.102.111", "state"=>"destroyed"}>]
You could also do:
irb> Kronos::Template.all
irb> Kronos::Zone.all
irb> Kronos::ResourceConfiguration.all
If you know the UUID to any model, you can use Kronos::Template.find_by_uuid('youruuid')
to find it specifically
irb> zone = Kronos::Zone.all.first
irb> resource_config = Kronos::ResourceConfiguration.all.first
irb> template = Kronos::Template.all.first
irb> vm = Kronos::VirtualMachine.create!(:name => "My Cool VM", :resource_configuration_uuid => resource_config.uuid, :template_uuid => template.uuid, :zone_uuid => zone.uuid)
This vm object is a snapshot, so we have to reload it to get the latest status until the state is "powered_on".
irb> vm.poll_until_create_finished!
irb> vm.state # should return 'powered_on'
irb> vm = Kronos::VirtualMachine.find_by_uuid("some-vm-uuid")
irb> vm.state # (see below for valid state values)
irb> vm.stop!
irb> vm.start!
irb> vm.suspend!
irb> vm.start!
irb> vm.reboot!
Note that in all cases, these can take several seconds to complete. You'll probably want to do something like this until you get the state you want:
irb> vm.reload.state
irb> vm.stop!
irb> vm.reload.state # repeat until "powered_off"
irb> new_resource_configuration = Kronos::ResourceConfiguration.find_by_uuid("some other UUID ")
irb> vm.resize!(new_resource_configuration)
The vm MUST be powered off, and it takes several seconds to resize.
irb> vm.destroy!
irb> vm.reload.state # will print "destroyed"
- pending_deploy
- powered_on
- powered_off
- pending_start
- pending_stop
- pending_suspend
- suspended
- destroyed