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/network.rb
Carlos Sanchez 4c2736d0c2 [google][compute] Update to API v1
Simplify attachment of boot disk, get_as_boot_disk no longer needed
Add missing Disk.get_object method
Allow setting deviceName when attaching a disk
Add disks mocks
2013-12-19 21:37:46 +01:00

34 lines
957 B
Ruby

def test
connection = Fog::Compute.new({ :provider => "Google" })
# we create a new private network
connection.insert_network('my-private-network', '10.240.0.0/16')
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? }
server = connection.servers.create({
:name => name,
:disks => [disk],
: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"),
:network => 'my-private-network',
:external_ip => false,
:user => ENV['USER'],
})
# The network won't have any firewall rules, so we won't be able to ssh in.
server.wait_for { ready? }
raise "Could not delete server." unless server.destroy
end