knife-google 1.3.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +1 -0
- data/.travis.yml +15 -3
- data/CHANGELOG.md +4 -6
- data/Gemfile +3 -9
- data/README.md +208 -355
- data/RELEASE_NOTES.md +8 -17
- data/Rakefile +8 -49
- data/knife-google.gemspec +20 -17
- data/lib/chef/knife/cloud/google_service.rb +491 -0
- data/lib/chef/knife/cloud/google_service_helpers.rb +62 -0
- data/lib/chef/knife/cloud/google_service_options.rb +58 -0
- data/lib/chef/knife/google_disk_create.rb +40 -44
- data/lib/chef/knife/google_disk_delete.rb +22 -40
- data/lib/chef/knife/google_disk_list.rb +57 -51
- data/lib/chef/knife/google_project_quotas.rb +59 -0
- data/lib/chef/knife/google_region_list.rb +43 -102
- data/lib/chef/knife/google_region_quotas.rb +77 -0
- data/lib/chef/knife/google_server_create.rb +224 -505
- data/lib/chef/knife/google_server_delete.rb +20 -78
- data/lib/chef/knife/google_server_list.rb +42 -53
- data/lib/chef/knife/google_server_show.rb +44 -0
- data/lib/chef/knife/google_zone_list.rb +39 -50
- data/lib/knife-google/version.rb +3 -2
- data/spec/cloud/google_service_helpers_spec.rb +120 -0
- data/spec/cloud/google_service_spec.rb +832 -0
- data/spec/google_disk_create_spec.rb +72 -0
- data/spec/google_disk_delete_spec.rb +64 -0
- data/spec/google_disk_list_spec.rb +93 -0
- data/spec/google_project_quotas_spec.rb +63 -0
- data/spec/google_region_list_spec.rb +65 -0
- data/spec/google_region_quotas_spec.rb +108 -0
- data/spec/google_server_create_spec.rb +177 -0
- data/spec/google_server_delete_spec.rb +39 -0
- data/spec/google_server_list_spec.rb +77 -0
- data/spec/google_server_show_spec.rb +60 -0
- data/spec/google_zone_list_spec.rb +59 -0
- metadata +91 -114
- data/CONTRIB.md +0 -64
- data/lib/chef/knife/google_base.rb +0 -76
- data/lib/chef/knife/google_project_list.rb +0 -178
- data/lib/chef/knife/google_setup.rb +0 -31
- data/lib/google/compute.rb +0 -47
- data/lib/google/compute/client.rb +0 -216
- data/lib/google/compute/config.rb +0 -23
- data/lib/google/compute/creatable_resource_collection.rb +0 -55
- data/lib/google/compute/deletable_resource_collection.rb +0 -51
- data/lib/google/compute/disk.rb +0 -38
- data/lib/google/compute/exception.rb +0 -30
- data/lib/google/compute/firewall.rb +0 -65
- data/lib/google/compute/global_operation.rb +0 -60
- data/lib/google/compute/image.rb +0 -29
- data/lib/google/compute/listable_resource_collection.rb +0 -33
- data/lib/google/compute/machine_type.rb +0 -36
- data/lib/google/compute/mixins/utils.rb +0 -58
- data/lib/google/compute/network.rb +0 -29
- data/lib/google/compute/project.rb +0 -76
- data/lib/google/compute/region.rb +0 -31
- data/lib/google/compute/region_operation.rb +0 -62
- data/lib/google/compute/resource.rb +0 -81
- data/lib/google/compute/resource_collection.rb +0 -78
- data/lib/google/compute/server.rb +0 -88
- data/lib/google/compute/server/attached_disk.rb +0 -39
- data/lib/google/compute/server/network_interface.rb +0 -38
- data/lib/google/compute/server/network_interface/access_config.rb +0 -35
- data/lib/google/compute/server/serial_port_output.rb +0 -31
- data/lib/google/compute/snapshot.rb +0 -30
- data/lib/google/compute/version.rb +0 -19
- data/lib/google/compute/zone.rb +0 -34
- data/lib/google/compute/zone_operation.rb +0 -62
- data/spec/chef/knife/google_base_spec.rb +0 -46
- data/spec/chef/knife/google_disk_create_spec.rb +0 -37
- data/spec/chef/knife/google_disk_delete_spec.rb +0 -64
- data/spec/chef/knife/google_disk_list_spec.rb +0 -36
- data/spec/chef/knife/google_region_list_spec.rb +0 -32
- data/spec/chef/knife/google_server_create_spec.rb +0 -138
- data/spec/chef/knife/google_server_delete_spec.rb +0 -127
- data/spec/chef/knife/google_server_list_spec.rb +0 -39
- data/spec/chef/knife/google_setup_spec.rb +0 -24
- data/spec/chef/knife/google_zone_list_spec.rb +0 -32
- data/spec/data/client.json +0 -14
- data/spec/data/compute-v1.json +0 -6734
- data/spec/data/disk.json +0 -14
- data/spec/data/firewall.json +0 -13
- data/spec/data/global_operation.json +0 -36
- data/spec/data/image.json +0 -12
- data/spec/data/machine_type.json +0 -24
- data/spec/data/network.json +0 -10
- data/spec/data/project.json +0 -21
- data/spec/data/region.json +0 -23
- data/spec/data/serial_port_output.json +0 -5
- data/spec/data/server.json +0 -46
- data/spec/data/snapshot.json +0 -12
- data/spec/data/zone.json +0 -22
- data/spec/data/zone_operation.json +0 -36
- data/spec/google/compute/disk_spec.rb +0 -115
- data/spec/google/compute/firewall_spec.rb +0 -129
- data/spec/google/compute/global_operation_spec.rb +0 -62
- data/spec/google/compute/image_spec.rb +0 -75
- data/spec/google/compute/machine_type_spec.rb +0 -53
- data/spec/google/compute/network_spec.rb +0 -68
- data/spec/google/compute/project_spec.rb +0 -71
- data/spec/google/compute/region_spec.rb +0 -51
- data/spec/google/compute/server_spec.rb +0 -118
- data/spec/google/compute/snapshot_spec.rb +0 -57
- data/spec/google/compute/zone_operation_spec.rb +0 -62
- data/spec/google/compute/zone_spec.rb +0 -51
- data/spec/spec_helper.rb +0 -45
- data/spec/support/mocks.rb +0 -62
- data/spec/support/resource_examples.rb +0 -70
- data/spec/support/spec_google_base.rb +0 -60
@@ -1,57 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
require 'spec_helper'
|
15
|
-
|
16
|
-
describe Google::Compute::Snapshot do
|
17
|
-
|
18
|
-
before(:each) do
|
19
|
-
@mock_api_client=double(Google::APIClient, :authorization= => {}, :auto_refresh_token= => {})
|
20
|
-
@mock_api_client.stub(:discovered_api).and_return(mock_compute)
|
21
|
-
Google::APIClient.stub(:new).and_return(@mock_api_client)
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:client) do
|
25
|
-
Google::Compute::Client.from_json(mock_data_file(Google::Compute::Client))
|
26
|
-
end
|
27
|
-
|
28
|
-
it_should_behave_like Google::Compute::Resource
|
29
|
-
|
30
|
-
it '#get should return an individual snapshot' do
|
31
|
-
@mock_api_client.should_receive(:execute).
|
32
|
-
with(:api_method => mock_compute.snapshots.get,
|
33
|
-
:parameters => {'snapshot' => 'mock-snapshot', :project => 'mock-project'}, :body_object => nil).
|
34
|
-
and_return(mock_response(Google::Compute::Snapshot))
|
35
|
-
snapshot = client.snapshots.get('mock-snapshot')
|
36
|
-
snapshot.should be_a_kind_of Google::Compute::Snapshot
|
37
|
-
snapshot.name.should eq('mock-snapshot')
|
38
|
-
end
|
39
|
-
|
40
|
-
it '#list should return an array of snapshots' do
|
41
|
-
@mock_api_client.should_receive(:execute).
|
42
|
-
with(:api_method => mock_compute.snapshots.list,
|
43
|
-
:parameters => {:project => 'mock-project'}, :body_object => nil).
|
44
|
-
and_return(mock_response(Google::Compute::Snapshot, true))
|
45
|
-
snapshots = client.snapshots.list
|
46
|
-
snapshots.should_not be_empty
|
47
|
-
snapshots.all?{|s| s.is_a?(Google::Compute::Snapshot)}.should be_true
|
48
|
-
end
|
49
|
-
|
50
|
-
it '#delete should delete an existing snapshot' do
|
51
|
-
@mock_api_client.should_receive(:execute).
|
52
|
-
with(:api_method => mock_compute.snapshots.delete,
|
53
|
-
:parameters => {:project => 'mock-project', 'snapshot' => 'mock-snapshot'}, :body_object => nil).
|
54
|
-
and_return(mock_response(Google::Compute::GlobalOperation))
|
55
|
-
o = client.snapshots.delete('mock-snapshot')
|
56
|
-
end
|
57
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
require 'spec_helper'
|
15
|
-
|
16
|
-
describe Google::Compute::ZoneOperation do
|
17
|
-
|
18
|
-
before(:each) do
|
19
|
-
@mock_api_client=double(Google::APIClient, :authorization= => {}, :auto_refresh_token= => {})
|
20
|
-
@mock_api_client.stub(:discovered_api).and_return(mock_compute)
|
21
|
-
Google::APIClient.stub(:new).and_return(@mock_api_client)
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:client) do
|
25
|
-
Google::Compute::Client.from_json(mock_data_file(Google::Compute::Client))
|
26
|
-
end
|
27
|
-
|
28
|
-
it_should_behave_like Google::Compute::Resource
|
29
|
-
|
30
|
-
it '#list should return an array of zone operations' do
|
31
|
-
@mock_api_client.should_receive(:execute).
|
32
|
-
with(:api_method => mock_compute.zone_operations.list,
|
33
|
-
:parameters => { :project => 'mock-project'}, :body_object => nil).
|
34
|
-
and_return(mock_response(Google::Compute::ZoneOperation, true))
|
35
|
-
|
36
|
-
operations = client.zoneOperations.list
|
37
|
-
operations.should_not be_empty
|
38
|
-
operations.all?{|o| o.is_a?(Google::Compute::ZoneOperation)}.should be_true
|
39
|
-
end
|
40
|
-
|
41
|
-
it '#get should return an individual zone operation' do
|
42
|
-
@mock_api_client.should_receive(:execute).
|
43
|
-
with(:api_method => mock_compute.zone_operations.get,
|
44
|
-
:parameters => {'zoneOperation' => 'mock-zone-operation', :project => 'mock-project'}, :body_object => nil).
|
45
|
-
and_return(mock_response(Google::Compute::ZoneOperation))
|
46
|
-
|
47
|
-
operation = client.zoneOperations.get('mock-zone-operation')
|
48
|
-
operation.should be_a_kind_of Google::Compute::ZoneOperation
|
49
|
-
operation.name.should eq('mock-zone-operation')
|
50
|
-
operation.should respond_to(:progress)
|
51
|
-
operation.start_time.should be_a_kind_of(Time)
|
52
|
-
end
|
53
|
-
|
54
|
-
it '#delete should delete an existing zone operation' do
|
55
|
-
@mock_api_client.should_receive(:execute).
|
56
|
-
with(:api_method => mock_compute.zone_operations.delete,
|
57
|
-
:parameters => {'zoneOperation' => 'mock-zone-operation', :project => 'mock-project'}, :body_object => nil).
|
58
|
-
and_return(mock_response)
|
59
|
-
|
60
|
-
client.zoneOperations.delete('mock-zone-operation')
|
61
|
-
end
|
62
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'spec_helper'
|
16
|
-
|
17
|
-
describe Google::Compute::Zone do
|
18
|
-
|
19
|
-
before(:each) do
|
20
|
-
@mock_api_client=double(Google::APIClient, :authorization= => {}, :auto_refresh_token= => {})
|
21
|
-
@mock_api_client.stub(:discovered_api).and_return(mock_compute)
|
22
|
-
Google::APIClient.stub(:new).and_return(@mock_api_client)
|
23
|
-
end
|
24
|
-
|
25
|
-
let(:client) do
|
26
|
-
Google::Compute::Client.from_json(mock_data_file(Google::Compute::Client))
|
27
|
-
end
|
28
|
-
|
29
|
-
it_should_behave_like Google::Compute::Resource
|
30
|
-
|
31
|
-
it '#get should return an individual zone' do
|
32
|
-
@mock_api_client.should_receive(:execute).
|
33
|
-
with(:api_method => mock_compute.zones.get,
|
34
|
-
:parameters => {'zone' => 'mock-zone', :project => 'mock-project'}, :body_object => nil).
|
35
|
-
and_return(mock_response(Google::Compute::Zone))
|
36
|
-
zone = client.zones.get('mock-zone')
|
37
|
-
zone.should be_a_kind_of Google::Compute::Zone
|
38
|
-
zone.name.should eq('mock-zone')
|
39
|
-
end
|
40
|
-
|
41
|
-
it '#list should return an array of zones' do
|
42
|
-
@mock_api_client.should_receive(:execute).
|
43
|
-
with(:api_method => mock_compute.zones.list,
|
44
|
-
:parameters => { :project => 'mock-project'}, :body_object => nil).
|
45
|
-
and_return(mock_response(Google::Compute::Zone, true))
|
46
|
-
zones = client.zones.list
|
47
|
-
zones.should_not be_empty
|
48
|
-
zones.all?{|zone| zone.is_a?(Google::Compute::Zone)}.should be_true
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#
|
15
|
-
|
16
|
-
require 'simplecov'
|
17
|
-
SimpleCov.start do
|
18
|
-
add_filter "/spec/"
|
19
|
-
add_filter "/.bundle/"
|
20
|
-
add_filter "/pkg/"
|
21
|
-
add_filter "/pkg/"
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'google/compute'
|
25
|
-
|
26
|
-
require 'support/resource_examples'
|
27
|
-
require 'support/mocks'
|
28
|
-
|
29
|
-
require 'chef'
|
30
|
-
require 'chef/knife/google_server_create'
|
31
|
-
require 'chef/knife/google_server_delete'
|
32
|
-
require 'chef/knife/google_server_list'
|
33
|
-
require 'chef/knife/google_disk_list'
|
34
|
-
require 'chef/knife/google_disk_create'
|
35
|
-
require 'chef/knife/google_disk_delete'
|
36
|
-
require 'chef/knife/google_region_list'
|
37
|
-
require 'chef/knife/google_zone_list'
|
38
|
-
require 'chef/knife/google_setup'
|
39
|
-
|
40
|
-
require 'support/spec_google_base'
|
41
|
-
|
42
|
-
RSpec.configure do |config|
|
43
|
-
config.include SpecData
|
44
|
-
config.include Mocks
|
45
|
-
end
|
data/spec/support/mocks.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module Mocks
|
16
|
-
SPEC_DATA_FOLDER = File.expand_path('../../data', __FILE__)
|
17
|
-
|
18
|
-
def mock_data(klass)
|
19
|
-
return File.read(mock_data_file(klass))
|
20
|
-
end
|
21
|
-
|
22
|
-
def mock_list_data(klass)
|
23
|
-
return '{"items":[' + File.read(mock_data_file(klass)) + ']}'
|
24
|
-
end
|
25
|
-
|
26
|
-
def mock_data_file(klass)
|
27
|
-
class_name = klass.name.split('::').last.snake_case
|
28
|
-
if class_name == "instance"
|
29
|
-
json_file = File.expand_path(File.join(SPEC_DATA_FOLDER, 'server.json'))
|
30
|
-
else
|
31
|
-
json_file = File.expand_path(File.join(SPEC_DATA_FOLDER, class_name + '.json'))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def instance_from_mock_data(klass)
|
36
|
-
klass.new(mock_hash(klass))
|
37
|
-
end
|
38
|
-
|
39
|
-
def mock_hash(klass)
|
40
|
-
MultiJson.load(mock_data(klass))
|
41
|
-
end
|
42
|
-
|
43
|
-
def mock_compute
|
44
|
-
@compute ||=
|
45
|
-
begin
|
46
|
-
data_file = File.join(SPEC_DATA_FOLDER, 'compute-v1.json')
|
47
|
-
u = Addressable::URI.parse('URI:https://www.googleapis.com/discovery/v1/apis/compute/v1/rest')
|
48
|
-
compute = Google::APIClient::API.new(u, MultiJson.load(File.read(data_file)))
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def mock_response(klass=nil, list = false)
|
53
|
-
body = if klass.nil?
|
54
|
-
nil
|
55
|
-
elsif list
|
56
|
-
mock_list_data(klass)
|
57
|
-
else
|
58
|
-
mock_data(klass)
|
59
|
-
end
|
60
|
-
double(klass, :success? => true, :response => double('some', :body => body))
|
61
|
-
end
|
62
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
shared_examples Google::Compute::Resource do
|
16
|
-
|
17
|
-
let (:resource) do
|
18
|
-
instance_from_mock_data(described_class)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should be of compute# kind" do
|
22
|
-
resource.kind.should match('compute#')
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should be a subclass of Google::Compute::Resource" do
|
26
|
-
resource.should be_a_kind_of(Google::Compute::Resource)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "#id should have a valid id" do
|
30
|
-
resource.id.should be_a_kind_of(Integer)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "#creation_timestamp should have a valid creation timestamp" do
|
34
|
-
unless resource.creation_timestamp.nil?
|
35
|
-
resource.creation_timestamp.should be_a_kind_of(Time)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it "#type should have same type is class" do
|
40
|
-
# TODO(erjohnso): {global, zone}operations are not resources
|
41
|
-
# and instances are servers
|
42
|
-
if ["globaloperation", "zoneoperation"].include? resource.class.class_name
|
43
|
-
resource.type.downcase.should eq("operation")
|
44
|
-
elsif resource.class.class_name == "server"
|
45
|
-
resource.type.downcase.should eq("instance")
|
46
|
-
else
|
47
|
-
resource.type.downcase.should eq(resource.class.class_name)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should have a valid description" do
|
52
|
-
# TODO(erjohnso): {global, zone}operations are not resources
|
53
|
-
# mock-{zone, global}-operation
|
54
|
-
unless resource.name.split('-').last == "operation"
|
55
|
-
resource.description.should_not be_nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
it "#project should have a valid project name" do
|
60
|
-
resource.project.should_not be_nil
|
61
|
-
end
|
62
|
-
|
63
|
-
it "#self_link should have a valid https self link" do
|
64
|
-
URI.parse(resource.self_link).should be_a_kind_of(URI::HTTPS)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "#to_s should return its name when converted to string" do
|
68
|
-
resource.to_s.should eq(resource.name)
|
69
|
-
end
|
70
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'spec_helper'
|
16
|
-
require 'google/compute'
|
17
|
-
|
18
|
-
module SpecData
|
19
|
-
SPEC_DATA_DIR = File.expand_path('../../data', __FILE__)
|
20
|
-
|
21
|
-
def stored_instance
|
22
|
-
@instance ||= Google::Compute::Server.new(load_json("server.json"))
|
23
|
-
end
|
24
|
-
|
25
|
-
def stored_global_operation
|
26
|
-
@global_operation ||= Google::Compute::GlobalOperation.new(load_json("global_operation.json"))
|
27
|
-
end
|
28
|
-
|
29
|
-
def stored_zone_operation
|
30
|
-
@zone_operation ||= Google::Compute::ZoneOperation.new(load_json("zone_operation.json"))
|
31
|
-
end
|
32
|
-
|
33
|
-
def stored_disk
|
34
|
-
@disk ||= Google::Compute::Disk.new(load_json("disk.json"))
|
35
|
-
end
|
36
|
-
|
37
|
-
def stored_region
|
38
|
-
@region ||= Google::Compute::Region.new(load_json("region.json"))
|
39
|
-
end
|
40
|
-
|
41
|
-
def stored_zone
|
42
|
-
@zone ||= Google::Compute::Zone.new(load_json("zone.json"))
|
43
|
-
end
|
44
|
-
|
45
|
-
def stored_image
|
46
|
-
@image ||= Google::Compute::Image.new(load_json("image.json"))
|
47
|
-
end
|
48
|
-
|
49
|
-
def stored_machine_type
|
50
|
-
@machine_type ||= Google::Compute::MachineType.new(load_json("machine_type.json"))
|
51
|
-
end
|
52
|
-
|
53
|
-
def stored_network
|
54
|
-
@network ||= Google::Compute::Network.new(load_json 'network.json')
|
55
|
-
end
|
56
|
-
|
57
|
-
def load_json file
|
58
|
-
MultiJson.load(File.read("#{SPEC_DATA_DIR}/#{file}"))
|
59
|
-
end
|
60
|
-
end
|