mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #1987 from icco/documentation
[google] Add service level documentation and simple smoke tests.
This commit is contained in:
commit
327ad67f96
7 changed files with 149 additions and 0 deletions
28
lib/fog/google/README.md
Normal file
28
lib/fog/google/README.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Fog with Google
|
||||
|
||||
Fog currently supports two Google Cloud services: [Google Compute Engine](https://developers.google.com/compute/) and [Google Cloud Storage](https://developers.google.com/storage/). The main maintainer for the Google sections is @icco.
|
||||
|
||||
## Storage
|
||||
|
||||
Google Cloud Storage originally was very similar to Amazon's S3. Because of this, Fog implements the [XML GCS API](https://developers.google.com/storage/docs/xml-api-overview). We eventually want to move to the new [JSON API](https://developers.google.com/storage/docs/json_api/), once it has similar performance characteristics to the XML API. If this migration interests you, send us a pull request!
|
||||
|
||||
## Compute
|
||||
|
||||
Google Compute Engine is a Virtual Machine hosting service. Currently it is built on version [v1beta15](https://developers.google.com/compute/docs/reference/v1beta15/) of the GCE API.
|
||||
|
||||
Our implementation of the API currently supports
|
||||
|
||||
* Server creation, deletion and bootstrapping
|
||||
* All server "flavors" (micro and normal)
|
||||
* Persistent Disk creation and deletion
|
||||
* Image lookup
|
||||
|
||||
Features we are looking forward to implementing in the future:
|
||||
|
||||
* Network and Firewall configuration
|
||||
* Global Metadata support
|
||||
* Image creation
|
||||
|
||||
v1beta15 is still in beta, so we can imagine lots of changes to the API. If you are using Fog to interact with GCE, please keep Fog up to date and [file issues](https://github.com/fog/fog/issues?labels=google) for any anomalies you see.
|
||||
|
||||
Thanks!
|
17
lib/fog/google/Rakefile
Normal file
17
lib/fog/google/Rakefile
Normal file
|
@ -0,0 +1,17 @@
|
|||
namespace :google do
|
||||
namespace :smoke do
|
||||
|
||||
desc "Smoke tests for Google Compute Engine."
|
||||
task :compute do
|
||||
require 'fog'
|
||||
|
||||
puts "These smoke tests assume you have a file at ~/.fog which has your credentials for connecting to GCE."
|
||||
|
||||
Dir.glob("./examples/*.rb").each do |file|
|
||||
puts "Running #{file}:"
|
||||
require file
|
||||
test()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
9
lib/fog/google/examples/bootstrap.rb
Executable file
9
lib/fog/google/examples/bootstrap.rb
Executable file
|
@ -0,0 +1,9 @@
|
|||
def test
|
||||
connection = Fog::Compute.new({ :provider => "Google" })
|
||||
|
||||
server = connection.servers.bootstrap
|
||||
server.wait_for { sshable? }
|
||||
|
||||
raise "Could not bootstrap sshable server." unless server.ssh("whoami")
|
||||
raise "Cloud note delete server." unless server.destroy
|
||||
end
|
37
lib/fog/google/examples/create.rb
Executable file
37
lib/fog/google/examples/create.rb
Executable file
|
@ -0,0 +1,37 @@
|
|||
def test
|
||||
connection = Fog::Compute.new({ :provider => "Google" })
|
||||
|
||||
server = connection.servers.create(defaults = {
|
||||
:name => "fog-smoke-test-#{Time.now.to_i}",
|
||||
:image_name => "debian-7-wheezy-v20130522",
|
||||
: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'],
|
||||
})
|
||||
|
||||
# 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
|
19
lib/fog/google/examples/eric-fail.rb
Executable file
19
lib/fog/google/examples/eric-fail.rb
Executable file
|
@ -0,0 +1,19 @@
|
|||
def test
|
||||
connection = Fog::Compute.new({ :provider => "Google" })
|
||||
|
||||
server = connection.servers.create(defaults = {
|
||||
:name => "fog-smoke-test-#{Time.now.to_i}",
|
||||
:image_name => "debian-7-wheezy-v20130617",
|
||||
: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"),
|
||||
:username => 'root',
|
||||
:metadata => {'foo' => 'bar'}
|
||||
})
|
||||
sleep(30)
|
||||
|
||||
raise "Could not reload created server." unless server.reload
|
||||
raise "Could not create sshable server." unless server.ssh("whoami")
|
||||
raise "Cloud note delete server." unless server.destroy
|
||||
end
|
21
lib/fog/google/examples/launch_micro_instance.rb
Executable file
21
lib/fog/google/examples/launch_micro_instance.rb
Executable file
|
@ -0,0 +1,21 @@
|
|||
def test
|
||||
connection = Fog::Compute.new({ :provider => "Google" })
|
||||
time = Time.now.utc.to_i
|
||||
disk = connection.disks.create({:name => 'foggydisk', :size => 10, :zone_name => 'us-central1-a', :image_name => 'centos-6-v20130522'})
|
||||
|
||||
disk.wait_for { disk.ready? }
|
||||
params = {
|
||||
:name => "fog-smoke-test-#{Time.now.to_i}",
|
||||
:machine_type => "f1-micro",
|
||||
:zone_name => "us-central1-a",
|
||||
:disks => [ disk.get_as_boot_disk(true) ],
|
||||
:kernel => 'gce-v20130522',
|
||||
:user => ENV['USER']
|
||||
}
|
||||
|
||||
server = connection.servers.bootstrap params
|
||||
|
||||
raise "Could not bootstrap sshable server." unless server.ssh("whoami")
|
||||
raise "Could not delete server." unless server.destroy
|
||||
raise "Could not delete disk." unless disk.destroy
|
||||
end
|
18
lib/fog/google/examples/metadata.rb
Executable file
18
lib/fog/google/examples/metadata.rb
Executable file
|
@ -0,0 +1,18 @@
|
|||
def test
|
||||
connection = Fog::Compute.new({ :provider => "Google" })
|
||||
server = connection.servers.create(defaults = {
|
||||
:name => "fog-#{Time.now.to_i}",
|
||||
:image_name => "debian-7-wheezy-v20130522",
|
||||
: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
|
Loading…
Add table
Reference in a new issue