Sha256: 9416868ad24b80c7c46468f43f9aa02869163c002fc7ba6b63bc04d8d3d7af01

Contents?: true

Size: 1.3 KB

Versions: 22

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",
    :private_key_path => File.expand_path("~/.ssh/id_rsa"),
    :public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
    :zone_name => "us-central1-a",
    :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 "Could not delete server." unless server.destroy
end

Version data entries

22 entries across 20 versions & 5 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-google-0.1.0/examples/create.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-google-0.1.0/examples/create.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-google-0.1.0/examples/create.rb
fog-google-0.1.3 examples/create.rb
fog-google-0.1.2 examples/create.rb
fog-google-0.1.1 examples/create.rb
fog-google-0.1.0 examples/create.rb
fog-google-0.0.9 examples/create.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-google-0.0.7/examples/create.rb
fog-google-0.0.7 examples/create.rb
fog-google-0.0.6 examples/create.rb
fog-google-0.0.5 examples/create.rb
fog-google-0.0.4 examples/create.rb
fog-google-0.0.3 examples/create.rb
fog-google-0.0.2 examples/create.rb
fog-1.29.0 lib/fog/google/examples/create.rb
fog-1.28.0 lib/fog/google/examples/create.rb
fog-1.27.0 lib/fog/google/examples/create.rb
fog-1.26.0 lib/fog/google/examples/create.rb
fog-1.25.0 lib/fog/google/examples/create.rb