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/eric-fail.rb
2014-04-01 16:24:14 +00:00

36 lines
897 B
Ruby
Executable file

def test
connection = Fog::Compute.new({ :provider => "Google" })
name = "fog-smoke-test-#{Time.now.to_i}"
zone = "us-central1-a"
disk = connection.disks.create({
:name => name,
:size_gb => 10,
:zone_name => zone,
:source_image => 'debian-7-wheezy-v20140318',
})
disk.wait_for { disk.ready? }
scopes = [
"https://www.googleapis.com/auth/compute",
"devstorage.full_control",
"userinfo.email"
]
server = connection.servers.create({
:name => name,
:disks => [disk],
:machine_type => "n1-standard-1",
:zone_name => zone,
:metadata => {'foo' => 'bar'},
:tags => ["t1", "t2", "t3"],
:servce_accounts => scopes
})
sleep(90)
raise "Could not reload created server." unless server.reload
raise "Could not create sshable server." unless server.ssh("whoami")
raise "Could not delete server." unless server.destroy
end