mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[google] fix service_account scopes
This commit is contained in:
parent
0e2e478511
commit
d5de2f0b67
2 changed files with 23 additions and 7 deletions
|
@ -2,25 +2,31 @@ def test
|
||||||
connection = Fog::Compute.new({ :provider => "Google" })
|
connection = Fog::Compute.new({ :provider => "Google" })
|
||||||
|
|
||||||
name = "fog-smoke-test-#{Time.now.to_i}"
|
name = "fog-smoke-test-#{Time.now.to_i}"
|
||||||
|
zone = "us-central1-a"
|
||||||
|
|
||||||
disk = connection.disks.create({
|
disk = connection.disks.create({
|
||||||
:name => name,
|
:name => name,
|
||||||
:size_gb => 10,
|
:size_gb => 10,
|
||||||
:zone_name => 'us-central1-a',
|
:zone_name => zone,
|
||||||
:source_image => 'debian-7-wheezy-v20131120',
|
:source_image => 'debian-7-wheezy-v20140318',
|
||||||
})
|
})
|
||||||
|
|
||||||
disk.wait_for { disk.ready? }
|
disk.wait_for { disk.ready? }
|
||||||
|
|
||||||
|
scopes = [
|
||||||
|
"https://www.googleapis.com/auth/compute",
|
||||||
|
"devstorage.full_control",
|
||||||
|
"userinfo.email"
|
||||||
|
]
|
||||||
|
|
||||||
server = connection.servers.create({
|
server = connection.servers.create({
|
||||||
:name => name,
|
:name => name,
|
||||||
:disks => [disk],
|
:disks => [disk],
|
||||||
:machine_type => "n1-standard-1",
|
:machine_type => "n1-standard-1",
|
||||||
:zone_name => "us-central1-a",
|
:zone_name => zone,
|
||||||
:private_key_path => File.expand_path("~/.ssh/id_rsa"),
|
:metadata => {'foo' => 'bar'},
|
||||||
:public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
|
:tags => ["t1", "t2", "t3"],
|
||||||
:username => 'root',
|
:servce_accounts => scopes
|
||||||
:metadata => {'foo' => 'bar'}
|
|
||||||
})
|
})
|
||||||
sleep(90)
|
sleep(90)
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,16 @@ module Fog
|
||||||
'tags' => tags
|
'tags' => tags
|
||||||
}.delete_if {|key, value| value.nil?}
|
}.delete_if {|key, value| value.nil?}
|
||||||
|
|
||||||
|
if service_accounts
|
||||||
|
options['serviceAccounts'] = [{
|
||||||
|
"kind" => "compute#serviceAccount",
|
||||||
|
"email" => "default",
|
||||||
|
"scopes" => service_accounts.map {
|
||||||
|
|w| w.start_with?("https://") ? w : "https://www.googleapis.com/auth/#{w}"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
end
|
||||||
|
|
||||||
service.insert_server(name, zone_name, options)
|
service.insert_server(name, zone_name, options)
|
||||||
data = service.backoff_if_unfound {service.get_server(self.name, self.zone_name).body}
|
data = service.backoff_if_unfound {service.get_server(self.name, self.zone_name).body}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue