1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/google/examples/launch_micro_instance.rb

30 lines
802 B
Ruby
Raw Normal View History

2013-07-24 18:46:20 -07:00
def test
connection = Fog::Compute.new({ :provider => "Google" })
time = Time.now.utc.to_i
disk = connection.disks.create({
2014-03-14 17:36:17 -07:00
:name => "foggydisk-#{time}",
:size_gb => 10,
:zone_name => 'us-central1-a',
:source_image => 'centos-6-v20131120',
})
2013-07-24 18:46:20 -07:00
disk.wait_for { disk.ready? }
params = {
:name => "fog-smoke-test-#{Time.now.to_i}",
:machine_type => "f1-micro",
:zone_name => "us-central1-a",
:disks => [ disk.get_as_boot_disk(true) ],
:user => ENV['USER']
2013-07-24 18:46:20 -07:00
}
server = connection.servers.bootstrap params
2013-07-24 18:46:20 -07:00
2014-03-14 17:36:17 -07:00
begin
raise "Could not bootstrap sshable server." unless server.ssh("whoami")
raise "Could not delete server." unless server.destroy
raise "Could not delete disk." unless disk.destroy
rescue Exception => e
p e.message
end
2013-07-24 18:46:20 -07:00
end