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/metadata.rb

31 lines
802 B
Ruby
Raw Normal View History

2013-07-24 21:46:20 -04:00
def test
connection = Fog::Compute.new({ :provider => "Google" })
name = "fog-smoke-test-#{Time.now.to_i}"
disk = connection.disks.create({
:name => name,
:size_gb => 10,
:zone_name => 'us-central1-a',
:source_image => 'debian-7-wheezy-v20131120',
})
disk.wait_for { disk.ready? }
2014-02-19 07:30:59 -05:00
server = connection.servers.create(defaults = {
:name => name,
:disks => [disk],
2013-07-24 21:46:20 -04:00
:machine_type => "n1-standard-1",
:zone_name => "us-central1-a",
:private_key_path => File.expand_path("~/.ssh/id_rsa"),
:public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
})
server.wait_for { ready? }
server.metadata["test"] = "foo"
raise "Metadata was not set." unless server.metadata["test"] == "foo"
raise "Could not delete server." unless server.destroy
end