Sha256: 3875f8ae6ebdbe01969f4ef47ba8ed6282255364270db29611d188f906fe97fe

Contents?: true

Size: 1.3 KB

Versions: 17

Compression:

Stored size: 1.3 KB

Contents

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? }

  server = connection.servers.create(defaults = {
    :name => "fog-smoke-test-#{Time.now.to_i}",
    :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"),
    :user => ENV['USER'],
    :tags => ["fog"]
  })

  # My own wait_for because it hides errors
  duration = 0
  interval = 5
  timeout = 600
  start = Time.now
  until server.sshable? || duration > timeout
    # puts duration
    # puts " ----- "

    server.reload

    # p "ready?: #{server.ready?}"
    # p "public_ip_address: #{server.public_ip_address.inspect}"
    # p "public_key: #{server.public_key.inspect}"
    # p "metadata: #{server.metadata.inspect}"
    # p "sshable?: #{server.sshable?}"

    sleep(interval.to_f)
    duration = Time.now - start
  end

  raise "Could not bootstrap sshable server." unless server.ssh("whoami")
  raise "Cloud note delete server." unless server.destroy
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
fog-1.21.0 lib/fog/google/examples/create.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/google/examples/create.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/google/examples/create.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/google/examples/create.rb
fog-1.20.0 lib/fog/google/examples/create.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/google/examples/create.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/google/examples/create.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/google/examples/create.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/google/examples/create.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/google/examples/create.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/google/examples/create.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/google/examples/create.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/google/examples/create.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/google/examples/create.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/google/examples/create.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/google/examples/create.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/google/examples/create.rb