knife-google 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +4 -0
- data/README.md +34 -7
- data/lib/chef/knife/google_base.rb +1 -0
- data/lib/chef/knife/google_server_create.rb +49 -8
- data/lib/chef/knife/google_server_delete.rb +9 -7
- data/lib/chef/knife/google_server_list.rb +15 -15
- data/lib/google/compute/client.rb +26 -18
- data/lib/google/compute/creatable_resource_collection.rb +6 -0
- data/lib/google/compute/exception.rb +2 -0
- data/lib/knife-google/version.rb +1 -1
- data/spec/chef/knife/google_base_spec.rb +1 -1
- data/spec/chef/knife/google_server_create_spec.rb +36 -16
- data/spec/chef/knife/google_server_delete_spec.rb +22 -0
- data/spec/chef/knife/google_server_list_spec.rb +13 -14
- data/spec/data/{compute-v1beta14.json → compute-v1beta15.json} +4122 -1228
- data/spec/data/disk.json +2 -2
- data/spec/data/firewall.json +2 -2
- data/spec/data/global_operation.json +3 -3
- data/spec/data/image.json +2 -2
- data/spec/data/kernel.json +1 -1
- data/spec/data/machine_type.json +3 -3
- data/spec/data/network.json +1 -1
- data/spec/data/project.json +1 -1
- data/spec/data/serial_port_output.json +1 -1
- data/spec/data/server.json +6 -6
- data/spec/data/snapshot.json +2 -2
- data/spec/data/zone.json +1 -1
- data/spec/data/zone_operation.json +3 -3
- data/spec/google/compute/disk_spec.rb +17 -7
- data/spec/google/compute/firewall_spec.rb +27 -26
- data/spec/google/compute/global_operation_spec.rb +6 -6
- data/spec/google/compute/image_spec.rb +11 -11
- data/spec/google/compute/kernel_spec.rb +4 -4
- data/spec/google/compute/machine_type_spec.rb +4 -4
- data/spec/google/compute/network_spec.rb +9 -9
- data/spec/google/compute/project_spec.rb +14 -14
- data/spec/google/compute/server_spec.rb +23 -23
- data/spec/google/compute/snapshot_spec.rb +6 -18
- data/spec/google/compute/zone_operation_spec.rb +6 -6
- data/spec/google/compute/zone_spec.rb +5 -4
- data/spec/support/mocks.rb +2 -2
- metadata +112 -117
| @@ -27,10 +27,10 @@ describe Google::Compute::Kernel do | |
| 27 27 |  | 
| 28 28 | 
             
              it_should_behave_like Google::Compute::Resource
         | 
| 29 29 |  | 
| 30 | 
            -
              it  | 
| 30 | 
            +
              it '#get should return an individual kernel' do
         | 
| 31 31 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 32 32 | 
             
                  with(:api_method=>mock_compute.kernels.get, 
         | 
| 33 | 
            -
                       :parameters=>{ | 
| 33 | 
            +
                       :parameters=>{'kernel'=>'mock-kernel', :project=>'mock-project'},:body_object=>nil).
         | 
| 34 34 | 
             
                       and_return(mock_response(Google::Compute::Kernel))
         | 
| 35 35 |  | 
| 36 36 | 
             
                kernel = client.kernels.get('mock-kernel')
         | 
| @@ -38,10 +38,10 @@ describe Google::Compute::Kernel do | |
| 38 38 | 
             
                kernel.name.should eq('mock-kernel')
         | 
| 39 39 | 
             
              end
         | 
| 40 40 |  | 
| 41 | 
            -
              it  | 
| 41 | 
            +
              it '#list should return an array of kernels' do
         | 
| 42 42 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 43 43 | 
             
                  with(:api_method=>mock_compute.kernels.list, 
         | 
| 44 | 
            -
                       :parameters=>{ :project=> | 
| 44 | 
            +
                       :parameters=>{ :project=>'mock-project'},:body_object=>nil).
         | 
| 45 45 | 
             
                       and_return(mock_response(Google::Compute::Kernel, true))
         | 
| 46 46 | 
             
                kernels = client.kernels.list
         | 
| 47 47 | 
             
                kernels.all?{|kernel| kernel.is_a?(Google::Compute::Kernel)}.should be_true
         | 
| @@ -29,11 +29,11 @@ describe Google::Compute::MachineType do | |
| 29 29 |  | 
| 30 30 | 
             
              it_should_behave_like Google::Compute::Resource
         | 
| 31 31 |  | 
| 32 | 
            -
              it  | 
| 32 | 
            +
              it '#get should return an individual machine types' do
         | 
| 33 33 |  | 
| 34 34 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 35 35 | 
             
                  with(:api_method=>mock_compute.machine_types.get, 
         | 
| 36 | 
            -
                       :parameters=>{ | 
| 36 | 
            +
                       :parameters=>{'machineType'=>'mock-machine-type', :project=>'mock-project'},:body_object=>nil).
         | 
| 37 37 | 
             
                       and_return(mock_response(Google::Compute::MachineType))
         | 
| 38 38 |  | 
| 39 39 | 
             
                machine_type = client.machine_types.get('mock-machine-type')
         | 
| @@ -41,10 +41,10 @@ describe Google::Compute::MachineType do | |
| 41 41 | 
             
                machine_type.name.should eq('mock-machine-type')
         | 
| 42 42 | 
             
                machine_type.guest_cpus.should be_a_kind_of(Fixnum)
         | 
| 43 43 | 
             
              end
         | 
| 44 | 
            -
              it  | 
| 44 | 
            +
              it '#list should return an array of machine types' do
         | 
| 45 45 | 
             
              @mock_api_client.should_receive(:execute).
         | 
| 46 46 | 
             
                with(:api_method=>mock_compute.machine_types.list, 
         | 
| 47 | 
            -
                     :parameters=>{ :project=> | 
| 47 | 
            +
                     :parameters=>{ :project=>'mock-project'},:body_object=>nil).
         | 
| 48 48 | 
             
                     and_return(mock_response(Google::Compute::MachineType, true))
         | 
| 49 49 | 
             
                mts = client.machine_types.list
         | 
| 50 50 | 
             
                mts.should_not be_empty
         | 
| @@ -27,10 +27,10 @@ describe Google::Compute::Network do | |
| 27 27 |  | 
| 28 28 | 
             
              it_should_behave_like Google::Compute::Resource
         | 
| 29 29 |  | 
| 30 | 
            -
              it  | 
| 30 | 
            +
              it '#get should return an individual network' do
         | 
| 31 31 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 32 32 | 
             
                  with(:api_method=>mock_compute.networks.get, 
         | 
| 33 | 
            -
                       :parameters=>{ | 
| 33 | 
            +
                       :parameters=>{'network'=>'mock-network', :project=>'mock-project'},:body_object=>nil).
         | 
| 34 34 | 
             
                       and_return(mock_response(Google::Compute::Network))
         | 
| 35 35 | 
             
                network = client.networks.get('mock-network')
         | 
| 36 36 | 
             
                network.should be_a_kind_of Google::Compute::Network
         | 
| @@ -38,30 +38,30 @@ describe Google::Compute::Network do | |
| 38 38 | 
             
                network.should respond_to(:ip_v4_range)
         | 
| 39 39 | 
             
              end
         | 
| 40 40 |  | 
| 41 | 
            -
              it  | 
| 41 | 
            +
              it '#list should return an array of networks' do
         | 
| 42 42 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 43 43 | 
             
                  with(:api_method=>mock_compute.networks.list, 
         | 
| 44 | 
            -
                       :parameters=>{ :project=> | 
| 44 | 
            +
                       :parameters=>{ :project=>'mock-project'},:body_object=>nil).
         | 
| 45 45 | 
             
                       and_return(mock_response(Google::Compute::Network, true))
         | 
| 46 46 | 
             
                networks = client.networks.list
         | 
| 47 47 | 
             
                networks.should_not be_empty
         | 
| 48 48 | 
             
                networks.all?{|n| n.is_a?(Google::Compute::Network)}.should be_true
         | 
| 49 49 | 
             
              end
         | 
| 50 50 |  | 
| 51 | 
            -
              it  | 
| 51 | 
            +
              it '#create should create a new network' do
         | 
| 52 52 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 53 53 | 
             
                  with(:api_method=>mock_compute.networks.insert, 
         | 
| 54 | 
            -
                       :parameters=>{ :project=> | 
| 55 | 
            -
                       :body_object=>{:name=> | 
| 54 | 
            +
                       :parameters=>{ :project=>'mock-project'},
         | 
| 55 | 
            +
                       :body_object=>{:name=>'mock-network', :IPv4Range=>'122.12.0.0/16'}).
         | 
| 56 56 | 
             
                       and_return(mock_response(Google::Compute::GlobalOperation))
         | 
| 57 57 | 
             
                o = client.networks.create(:name=>'mock-network', :IPv4Range=>'122.12.0.0/16')
         | 
| 58 58 | 
             
                o.should be_a_kind_of Google::Compute::GlobalOperation
         | 
| 59 59 | 
             
              end
         | 
| 60 60 |  | 
| 61 | 
            -
              it  | 
| 61 | 
            +
              it '#delete should delete an existing network' do
         | 
| 62 62 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 63 63 | 
             
                  with(:api_method=>mock_compute.networks.delete, 
         | 
| 64 | 
            -
                       :parameters=>{ | 
| 64 | 
            +
                       :parameters=>{'network'=>'mock-network', :project=>'mock-project'},:body_object=>nil).
         | 
| 65 65 | 
             
                       and_return(mock_response(Google::Compute::GlobalOperation))
         | 
| 66 66 | 
             
                client.networks.delete('mock-network')
         | 
| 67 67 | 
             
              end
         | 
| @@ -27,16 +27,16 @@ describe Google::Compute::Project do | |
| 27 27 |  | 
| 28 28 | 
             
              it_should_behave_like Google::Compute::Resource
         | 
| 29 29 |  | 
| 30 | 
            -
              it  | 
| 30 | 
            +
              it '#get should return an individual project' do
         | 
| 31 31 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 32 32 | 
             
                  with(:api_method=>mock_compute.projects.get, 
         | 
| 33 | 
            -
                       :parameters=>{:project=> | 
| 33 | 
            +
                       :parameters=>{:project=>'mock-project','project'=>'mock-project'},:body_object=>nil).
         | 
| 34 34 | 
             
                       and_return(mock_response(Google::Compute::Project))
         | 
| 35 35 | 
             
                project = client.projects.get('mock-project')
         | 
| 36 36 | 
             
                project.should be_a_kind_of Google::Compute::Project
         | 
| 37 37 | 
             
              end
         | 
| 38 38 |  | 
| 39 | 
            -
              describe  | 
| 39 | 
            +
              describe '#setCommonInstanceMetadata'
         | 
| 40 40 |  | 
| 41 41 | 
             
                before(:each) do
         | 
| 42 42 | 
             
                  Google::Compute::Resource.any_instance.stub(:update!)
         | 
| @@ -47,25 +47,25 @@ describe Google::Compute::Project do | |
| 47 47 | 
             
                                                merge(:dispatcher=>client.dispatcher))
         | 
| 48 48 | 
             
                end
         | 
| 49 49 |  | 
| 50 | 
            -
                it  | 
| 50 | 
            +
                it 'should be able to add common instance metadata' do
         | 
| 51 51 | 
             
                  @mock_api_client.should_receive(:execute).
         | 
| 52 52 | 
             
                    with(:api_method=>mock_compute.projects.set_common_instance_metadata, 
         | 
| 53 | 
            -
                       :parameters=>{:project=> | 
| 54 | 
            -
                       :body_object=>{ | 
| 55 | 
            -
                          | 
| 56 | 
            -
                           { | 
| 53 | 
            +
                       :parameters=>{:project=>'mock-project'},
         | 
| 54 | 
            +
                       :body_object=>{'kind'=>'compute#metadata', 
         | 
| 55 | 
            +
                         'items'=>[{'key'=>'mock-key', 'value'=>'mock-value'}, 
         | 
| 56 | 
            +
                           {'key'=>'testKey', 'value'=>'testValue'}]}).
         | 
| 57 57 | 
             
                           and_return(mock_response)
         | 
| 58 | 
            -
                  project.add_common_instance_metadata!( | 
| 58 | 
            +
                  project.add_common_instance_metadata!('testKey'=>'testValue')
         | 
| 59 59 | 
             
                end
         | 
| 60 60 |  | 
| 61 | 
            -
                it  | 
| 61 | 
            +
                it 'should be able to remove common instance metadata' do
         | 
| 62 62 | 
             
                  @mock_api_client.should_receive(:execute).
         | 
| 63 63 | 
             
                    with(:api_method=>mock_compute.projects.set_common_instance_metadata, 
         | 
| 64 | 
            -
                       :parameters=>{:project=> | 
| 65 | 
            -
                       :body_object=>{ | 
| 66 | 
            -
                          | 
| 64 | 
            +
                       :parameters=>{:project=>'mock-project'},
         | 
| 65 | 
            +
                       :body_object=>{'kind'=>'compute#metadata', 
         | 
| 66 | 
            +
                         'items'=>[]}).
         | 
| 67 67 | 
             
                           and_return(mock_response)
         | 
| 68 | 
            -
                  project.remove_common_instance_metadata!( | 
| 68 | 
            +
                  project.remove_common_instance_metadata!('mock-key'=>'mock-value')
         | 
| 69 69 | 
             
                end
         | 
| 70 70 | 
             
            end
         | 
| 71 71 |  | 
| @@ -27,43 +27,43 @@ describe Google::Compute::Server do | |
| 27 27 |  | 
| 28 28 | 
             
              it_should_behave_like Google::Compute::Resource
         | 
| 29 29 |  | 
| 30 | 
            -
              it  | 
| 30 | 
            +
              it '#get should return an individual Server' do
         | 
| 31 31 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 32 32 | 
             
                  with(:api_method=>mock_compute.instances.get, 
         | 
| 33 | 
            -
                       :parameters=>{:instance=> | 
| 33 | 
            +
                       :parameters=>{:instance=>'mock-instance', :project=>'mock-project', :zone=>'mock-zone'},:body_object=>nil).
         | 
| 34 34 | 
             
                       and_return(mock_response(Google::Compute::Server))
         | 
| 35 | 
            -
                instance = client.instances.get(:name=>'mock-instance', :zone=> | 
| 35 | 
            +
                instance = client.instances.get(:name=>'mock-instance', :zone=>'mock-zone')
         | 
| 36 36 | 
             
                instance.should be_a_kind_of Google::Compute::Server
         | 
| 37 37 | 
             
                instance.name.should eq('mock-instance')
         | 
| 38 38 | 
             
                instance.disks.should be_a_kind_of(Array)
         | 
| 39 39 | 
             
                instance.network_interfaces.should be_a_kind_of(Array)
         | 
| 40 40 | 
             
              end
         | 
| 41 41 |  | 
| 42 | 
            -
              it  | 
| 42 | 
            +
              it '#list should return an array of Servers' do
         | 
| 43 43 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 44 44 | 
             
                  with(:api_method=>mock_compute.instances.list, 
         | 
| 45 | 
            -
                       :parameters=>{:project=> | 
| 45 | 
            +
                       :parameters=>{:project=>'mock-project', :zone=>'mock-zone'},:body_object=>nil).
         | 
| 46 46 | 
             
                       and_return(mock_response(Google::Compute::Server,true))
         | 
| 47 | 
            -
                instances = client.instances.list(:zone=> | 
| 47 | 
            +
                instances = client.instances.list(:zone=>'mock-zone')
         | 
| 48 48 | 
             
                instances.should_not be_empty
         | 
| 49 49 | 
             
                instances.all?{|i| i.is_a?(Google::Compute::Server)}.should be_true
         | 
| 50 50 | 
             
              end
         | 
| 51 51 |  | 
| 52 | 
            -
              it  | 
| 53 | 
            -
                project_url ='https://www.googleapis.com/compute/ | 
| 52 | 
            +
              it '#create should create an server' do
         | 
| 53 | 
            +
                project_url ='https://www.googleapis.com/compute/v1beta15/projects/mock-project'
         | 
| 54 54 | 
             
                zone = project_url + '/zones/europe-west1-a'
         | 
| 55 | 
            -
                disk = project_url + zone + '/disks/ | 
| 55 | 
            +
                disk = project_url + zone + '/disks/mock-disk'
         | 
| 56 56 | 
             
                machine_type = project_url + '/global/machineTypes/n1-highcpu-2'
         | 
| 57 | 
            -
                image = 'https://www.googleapis.com/compute/ | 
| 57 | 
            +
                image = 'https://www.googleapis.com/compute/v1beta15/projects/debian-cloud/global/images/debian-7'
         | 
| 58 58 | 
             
                network = project_url + '/global/networks/api-network'
         | 
| 59 | 
            -
                access_config = { | 
| 59 | 
            +
                access_config = {'name' => 'External NAT', 'type' => 'ONE_TO_ONE_NAT'}
         | 
| 60 60 |  | 
| 61 61 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 62 62 | 
             
                  with(:api_method=>mock_compute.instances.insert, 
         | 
| 63 | 
            -
                       :parameters=>{:project=> | 
| 63 | 
            +
                       :parameters=>{:project=>'mock-project', :zone=>'mock-zone'},
         | 
| 64 64 | 
             
                       :body_object=>{:name =>'mock-instance',
         | 
| 65 65 | 
             
                         :image => image,
         | 
| 66 | 
            -
                         :zone =>  | 
| 66 | 
            +
                         :zone => 'mock-zone',
         | 
| 67 67 | 
             
                         :disks => [disk],
         | 
| 68 68 | 
             
                         :machineType => machine_type,
         | 
| 69 69 | 
             
                         :metadata =>{'items'=>[{'key'=>'someKey','value'=>'someValue'}]},
         | 
| @@ -78,23 +78,23 @@ describe Google::Compute::Server do | |
| 78 78 | 
             
                                            :machineType =>machine_type,
         | 
| 79 79 | 
             
                                            :disks=>[disk],
         | 
| 80 80 | 
             
                                            :metadata=>{'items'=>[{'key'=>'someKey','value'=>'someValue'}]},
         | 
| 81 | 
            -
                                            :zone=> | 
| 81 | 
            +
                                            :zone=>'mock-zone',
         | 
| 82 82 | 
             
                                            :networkInterfaces => [{'network'=>network,
         | 
| 83 83 | 
             
                                              'accessConfigs' => [access_config]
         | 
| 84 84 | 
             
                                              }]
         | 
| 85 85 | 
             
                                          )
         | 
| 86 86 | 
             
              end
         | 
| 87 87 |  | 
| 88 | 
            -
              it  | 
| 88 | 
            +
              it '#delete should delete an server' do
         | 
| 89 89 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 90 90 | 
             
                  with(:api_method=>mock_compute.instances.delete, 
         | 
| 91 | 
            -
                       :parameters=>{:project=> | 
| 91 | 
            +
                       :parameters=>{:project=>'mock-project', :instance=>'mock-instance', :zone=>'mock-zone'},
         | 
| 92 92 | 
             
                       :body_object=>nil).
         | 
| 93 93 | 
             
                       and_return(mock_response(Google::Compute::ZoneOperation))
         | 
| 94 | 
            -
                o = client.instances.delete(:instance=>'mock-instance', :zone=> | 
| 94 | 
            +
                o = client.instances.delete(:instance=>'mock-instance', :zone=>'mock-zone')
         | 
| 95 95 | 
             
              end
         | 
| 96 96 |  | 
| 97 | 
            -
              describe  | 
| 97 | 
            +
              describe 'with a specific server' do
         | 
| 98 98 |  | 
| 99 99 | 
             
                before(:each) do
         | 
| 100 100 | 
             
                  Google::Compute::Resource.any_instance.stub(:update!)
         | 
| @@ -105,17 +105,17 @@ describe Google::Compute::Server do | |
| 105 105 | 
             
                                                merge(:dispatcher=>client.dispatcher))
         | 
| 106 106 | 
             
                end
         | 
| 107 107 |  | 
| 108 | 
            -
                it  | 
| 108 | 
            +
                it '#addAccessConfig should add access config to an existing server' do
         | 
| 109 109 | 
             
                end
         | 
| 110 110 |  | 
| 111 | 
            -
                it  | 
| 111 | 
            +
                it '#deleteAccessConfig should delete access config to an existing server' do
         | 
| 112 112 | 
             
                end
         | 
| 113 113 |  | 
| 114 | 
            -
                it  | 
| 115 | 
            -
                  zone =  | 
| 114 | 
            +
                it '#serialPort should return serial port output of an existing server' do
         | 
| 115 | 
            +
                  zone = 'https://www.googleapis.com/compute/v1beta15/projects/mock-project/zones/mock-zone'
         | 
| 116 116 | 
             
                  @mock_api_client.should_receive(:execute).
         | 
| 117 117 | 
             
                    with(:api_method=>mock_compute.instances.get_serial_port_output, 
         | 
| 118 | 
            -
                       :parameters=>{:project=> | 
| 118 | 
            +
                       :parameters=>{:project=>'mock-project',:instance=>'mock-instance', :zone=>zone},
         | 
| 119 119 | 
             
                       :body_object=>nil).
         | 
| 120 120 | 
             
                       and_return(mock_response(Google::Compute::SerialPortOutput))
         | 
| 121 121 | 
             
                  instance.serial_port_output.should be_a_kind_of(Google::Compute::SerialPortOutput)
         | 
| @@ -27,42 +27,30 @@ describe Google::Compute::Snapshot do | |
| 27 27 |  | 
| 28 28 | 
             
              it_should_behave_like Google::Compute::Resource
         | 
| 29 29 |  | 
| 30 | 
            -
              it  | 
| 30 | 
            +
              it '#get should return an individual snapshot' do
         | 
| 31 31 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 32 32 | 
             
                  with(:api_method=>mock_compute.snapshots.get, 
         | 
| 33 | 
            -
                       :parameters=>{ | 
| 33 | 
            +
                       :parameters=>{'snapshot'=>'mock-snapshot', :project=>'mock-project'},:body_object=>nil).
         | 
| 34 34 | 
             
                       and_return(mock_response(Google::Compute::Snapshot))
         | 
| 35 35 | 
             
                snapshot = client.snapshots.get('mock-snapshot')
         | 
| 36 36 | 
             
                snapshot.should be_a_kind_of Google::Compute::Snapshot
         | 
| 37 37 | 
             
                snapshot.name.should eq('mock-snapshot')
         | 
| 38 38 | 
             
              end
         | 
| 39 39 |  | 
| 40 | 
            -
              it  | 
| 40 | 
            +
              it '#list should return an array of snapshots' do
         | 
| 41 41 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 42 42 | 
             
                  with(:api_method=>mock_compute.snapshots.list, 
         | 
| 43 | 
            -
                       :parameters=>{:project=> | 
| 43 | 
            +
                       :parameters=>{:project=>'mock-project'},:body_object=>nil).
         | 
| 44 44 | 
             
                       and_return(mock_response(Google::Compute::Snapshot,true))
         | 
| 45 45 | 
             
                snapshots = client.snapshots.list
         | 
| 46 46 | 
             
                snapshots.should_not be_empty
         | 
| 47 47 | 
             
                snapshots.all?{|s| s.is_a?(Google::Compute::Snapshot)}.should be_true
         | 
| 48 48 | 
             
              end
         | 
| 49 49 |  | 
| 50 | 
            -
              it  | 
| 51 | 
            -
                disk = 'https://www.googleapis.com/compute/v1beta13/projects/mock-project/disks/mock-disk'
         | 
| 52 | 
            -
                @mock_api_client.should_receive(:execute).
         | 
| 53 | 
            -
                  with(:api_method=>mock_compute.snapshots.insert, 
         | 
| 54 | 
            -
                       :parameters=>{:project=>"mock-project"},
         | 
| 55 | 
            -
                       :body_object=>{:name=>'api-snapshot', :sourceDisk=>disk}).
         | 
| 56 | 
            -
                       and_return(mock_response(Google::Compute::GlobalOperation))
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                o = client.snapshots.create(:name=>'api-snapshot', :sourceDisk=>disk)
         | 
| 59 | 
            -
                o.should be_a_kind_of Google::Compute::GlobalOperation
         | 
| 60 | 
            -
              end
         | 
| 61 | 
            -
             | 
| 62 | 
            -
              it "#delete should delete an existing snapshot" do
         | 
| 50 | 
            +
              it '#delete should delete an existing snapshot' do
         | 
| 63 51 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 64 52 | 
             
                  with(:api_method=>mock_compute.snapshots.delete, 
         | 
| 65 | 
            -
                       :parameters=>{:project=> | 
| 53 | 
            +
                       :parameters=>{:project=>'mock-project','snapshot'=>'mock-snapshot'},:body_object=>nil).
         | 
| 66 54 | 
             
                       and_return(mock_response(Google::Compute::GlobalOperation))
         | 
| 67 55 | 
             
                o =  client.snapshots.delete('mock-snapshot')
         | 
| 68 56 | 
             
              end
         | 
| @@ -27,10 +27,10 @@ describe Google::Compute::ZoneOperation do | |
| 27 27 |  | 
| 28 28 | 
             
              it_should_behave_like Google::Compute::Resource
         | 
| 29 29 |  | 
| 30 | 
            -
              it  | 
| 30 | 
            +
              it '#list should return an array of zone operations' do
         | 
| 31 31 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 32 32 | 
             
                  with(:api_method=>mock_compute.zone_operations.list, 
         | 
| 33 | 
            -
                       :parameters=>{ :project=> | 
| 33 | 
            +
                       :parameters=>{ :project=>'mock-project'},:body_object=>nil).
         | 
| 34 34 | 
             
                       and_return(mock_response(Google::Compute::ZoneOperation, true))
         | 
| 35 35 |  | 
| 36 36 | 
             
                operations = client.zoneOperations.list
         | 
| @@ -38,10 +38,10 @@ describe Google::Compute::ZoneOperation do | |
| 38 38 | 
             
                operations.all?{|o| o.is_a?(Google::Compute::ZoneOperation)}.should be_true
         | 
| 39 39 | 
             
              end
         | 
| 40 40 |  | 
| 41 | 
            -
              it  | 
| 41 | 
            +
              it '#get should return an individual zone operation' do
         | 
| 42 42 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 43 43 | 
             
                  with(:api_method=>mock_compute.zone_operations.get, 
         | 
| 44 | 
            -
                       :parameters=>{ | 
| 44 | 
            +
                       :parameters=>{'zoneOperation'=>'mock-zone-operation', :project=>'mock-project'},:body_object=>nil).
         | 
| 45 45 | 
             
                       and_return(mock_response(Google::Compute::ZoneOperation))
         | 
| 46 46 |  | 
| 47 47 | 
             
                operation = client.zoneOperations.get('mock-zone-operation')
         | 
| @@ -51,10 +51,10 @@ describe Google::Compute::ZoneOperation do | |
| 51 51 | 
             
                operation.start_time.should be_a_kind_of(Time)
         | 
| 52 52 | 
             
              end
         | 
| 53 53 |  | 
| 54 | 
            -
              it  | 
| 54 | 
            +
              it '#delete should delete an existing zone operation' do
         | 
| 55 55 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 56 56 | 
             
                  with(:api_method=>mock_compute.zone_operations.delete, 
         | 
| 57 | 
            -
                       :parameters=>{ | 
| 57 | 
            +
                       :parameters=>{'zoneOperation'=>'mock-zone-operation', :project=>'mock-project'},:body_object=>nil).
         | 
| 58 58 | 
             
                       and_return(mock_response)
         | 
| 59 59 |  | 
| 60 60 | 
             
                client.zoneOperations.delete('mock-zone-operation')
         | 
| @@ -28,23 +28,24 @@ describe Google::Compute::Zone do | |
| 28 28 |  | 
| 29 29 | 
             
              it_should_behave_like Google::Compute::Resource
         | 
| 30 30 |  | 
| 31 | 
            -
              it  | 
| 31 | 
            +
              it '#get should return an individual zone' do
         | 
| 32 32 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 33 33 | 
             
                  with(:api_method=>mock_compute.zones.get, 
         | 
| 34 | 
            -
                       :parameters=>{ | 
| 34 | 
            +
                       :parameters=>{'zone'=>'mock-zone', :project=>'mock-project'},:body_object=>nil).
         | 
| 35 35 | 
             
                       and_return(mock_response(Google::Compute::Zone))
         | 
| 36 36 | 
             
                zone = client.zones.get('mock-zone')
         | 
| 37 37 | 
             
                zone.should be_a_kind_of Google::Compute::Zone
         | 
| 38 38 | 
             
                zone.name.should eq('mock-zone')
         | 
| 39 39 | 
             
              end
         | 
| 40 40 |  | 
| 41 | 
            -
              it  | 
| 41 | 
            +
              it '#list should return an array of zones' do
         | 
| 42 42 | 
             
                @mock_api_client.should_receive(:execute).
         | 
| 43 43 | 
             
                  with(:api_method=>mock_compute.zones.list, 
         | 
| 44 | 
            -
                       :parameters=>{ :project=> | 
| 44 | 
            +
                       :parameters=>{ :project=>'mock-project'},:body_object=>nil).
         | 
| 45 45 | 
             
                       and_return(mock_response(Google::Compute::Zone, true))
         | 
| 46 46 | 
             
                zones = client.zones.list
         | 
| 47 47 | 
             
                zones.should_not be_empty
         | 
| 48 48 | 
             
                zones.all?{|zone| zone.is_a?(Google::Compute::Zone)}.should be_true
         | 
| 49 49 | 
             
              end
         | 
| 50 | 
            +
             | 
| 50 51 | 
             
            end
         | 
    
        data/spec/support/mocks.rb
    CHANGED
    
    | @@ -43,8 +43,8 @@ module Mocks | |
| 43 43 | 
             
              def mock_compute
         | 
| 44 44 | 
             
                @compute ||=
         | 
| 45 45 | 
             
                  begin
         | 
| 46 | 
            -
                    data_file = File.join(SPEC_DATA_FOLDER,'compute- | 
| 47 | 
            -
                    u = Addressable::URI.parse('URI:https://www.googleapis.com/discovery/v1/apis/compute/ | 
| 46 | 
            +
                    data_file = File.join(SPEC_DATA_FOLDER,'compute-v1beta15.json')
         | 
| 47 | 
            +
                    u = Addressable::URI.parse('URI:https://www.googleapis.com/discovery/v1/apis/compute/v1beta15/rest')
         | 
| 48 48 | 
             
                    compute = Google::APIClient::API.new(u,MultiJson.load(File.read(data_file)))
         | 
| 49 49 | 
             
                  end
         | 
| 50 50 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,15 +1,10 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: knife-google
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version | 
| 4 | 
            -
               | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.1.0
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 | 
            -
              segments: 
         | 
| 7 | 
            -
              - 1
         | 
| 8 | 
            -
              - 0
         | 
| 9 | 
            -
              - 0
         | 
| 10 | 
            -
              version: 1.0.0
         | 
| 11 6 | 
             
            platform: ruby
         | 
| 12 | 
            -
            authors: | 
| 7 | 
            +
            authors:
         | 
| 13 8 | 
             
            - Chiraq Jog
         | 
| 14 9 | 
             
            - Ranjib Dey
         | 
| 15 10 | 
             
            - James Tucker
         | 
| @@ -18,121 +13,131 @@ authors: | |
| 18 13 | 
             
            autorequire: 
         | 
| 19 14 | 
             
            bindir: bin
         | 
| 20 15 | 
             
            cert_chain: []
         | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 16 | 
            +
            date: 2013-08-14 00:00:00.000000000 Z
         | 
| 17 | 
            +
            dependencies:
         | 
| 18 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 25 19 | 
             
              name: chef
         | 
| 26 | 
            -
               | 
| 27 | 
            -
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 20 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 28 21 | 
             
                none: false
         | 
| 29 | 
            -
                requirements: | 
| 30 | 
            -
                - -  | 
| 31 | 
            -
                  - !ruby/object:Gem::Version | 
| 32 | 
            -
                    hash: 55
         | 
| 33 | 
            -
                    segments: 
         | 
| 34 | 
            -
                    - 0
         | 
| 35 | 
            -
                    - 10
         | 
| 36 | 
            -
                    - 0
         | 
| 22 | 
            +
                requirements:
         | 
| 23 | 
            +
                - - ! '>='
         | 
| 24 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 37 25 | 
             
                    version: 0.10.0
         | 
| 38 26 | 
             
              type: :runtime
         | 
| 39 | 
            -
              version_requirements: *id001
         | 
| 40 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 41 | 
            -
              name: google-api-client
         | 
| 42 27 | 
             
              prerelease: false
         | 
| 43 | 
            -
               | 
| 28 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 29 | 
            +
                none: false
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ! '>='
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: 0.10.0
         | 
| 34 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 35 | 
            +
              name: google-api-client
         | 
| 36 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 37 | 
             
                none: false
         | 
| 45 | 
            -
                requirements: | 
| 46 | 
            -
                - -  | 
| 47 | 
            -
                  - !ruby/object:Gem::Version | 
| 48 | 
            -
                     | 
| 49 | 
            -
                    segments: 
         | 
| 50 | 
            -
                    - 0
         | 
| 51 | 
            -
                    version: "0"
         | 
| 38 | 
            +
                requirements:
         | 
| 39 | 
            +
                - - ! '>='
         | 
| 40 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 41 | 
            +
                    version: '0'
         | 
| 52 42 | 
             
              type: :runtime
         | 
| 53 | 
            -
              version_requirements: *id002
         | 
| 54 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 55 | 
            -
              name: multi_json
         | 
| 56 43 | 
             
              prerelease: false
         | 
| 57 | 
            -
               | 
| 44 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 58 45 | 
             
                none: false
         | 
| 59 | 
            -
                requirements: | 
| 60 | 
            -
                - -  | 
| 61 | 
            -
                  - !ruby/object:Gem::Version | 
| 62 | 
            -
                     | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 46 | 
            +
                requirements:
         | 
| 47 | 
            +
                - - ! '>='
         | 
| 48 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 49 | 
            +
                    version: '0'
         | 
| 50 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 51 | 
            +
              name: multi_json
         | 
| 52 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 53 | 
            +
                none: false
         | 
| 54 | 
            +
                requirements:
         | 
| 55 | 
            +
                - - ! '>='
         | 
| 56 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 57 | 
            +
                    version: '0'
         | 
| 66 58 | 
             
              type: :runtime
         | 
| 67 | 
            -
              version_requirements: *id003
         | 
| 68 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 69 | 
            -
              name: mixlib-config
         | 
| 70 59 | 
             
              prerelease: false
         | 
| 71 | 
            -
               | 
| 60 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 61 | 
            +
                none: false
         | 
| 62 | 
            +
                requirements:
         | 
| 63 | 
            +
                - - ! '>='
         | 
| 64 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 65 | 
            +
                    version: '0'
         | 
| 66 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 67 | 
            +
              name: mixlib-config
         | 
| 68 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 69 | 
             
                none: false
         | 
| 73 | 
            -
                requirements: | 
| 74 | 
            -
                - -  | 
| 75 | 
            -
                  - !ruby/object:Gem::Version | 
| 76 | 
            -
                     | 
| 77 | 
            -
                    segments: 
         | 
| 78 | 
            -
                    - 0
         | 
| 79 | 
            -
                    version: "0"
         | 
| 70 | 
            +
                requirements:
         | 
| 71 | 
            +
                - - ! '>='
         | 
| 72 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 73 | 
            +
                    version: '0'
         | 
| 80 74 | 
             
              type: :runtime
         | 
| 81 | 
            -
              version_requirements: *id004
         | 
| 82 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 83 | 
            -
              name: rspec
         | 
| 84 75 | 
             
              prerelease: false
         | 
| 85 | 
            -
               | 
| 76 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 77 | 
            +
                none: false
         | 
| 78 | 
            +
                requirements:
         | 
| 79 | 
            +
                - - ! '>='
         | 
| 80 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 81 | 
            +
                    version: '0'
         | 
| 82 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 83 | 
            +
              name: rspec
         | 
| 84 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 85 | 
             
                none: false
         | 
| 87 | 
            -
                requirements: | 
| 88 | 
            -
                - -  | 
| 89 | 
            -
                  - !ruby/object:Gem::Version | 
| 90 | 
            -
                     | 
| 91 | 
            -
                    segments: 
         | 
| 92 | 
            -
                    - 0
         | 
| 93 | 
            -
                    version: "0"
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - ! '>='
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: '0'
         | 
| 94 90 | 
             
              type: :development
         | 
| 95 | 
            -
              version_requirements: *id005
         | 
| 96 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 97 | 
            -
              name: rake
         | 
| 98 91 | 
             
              prerelease: false
         | 
| 99 | 
            -
               | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                none: false
         | 
| 94 | 
            +
                requirements:
         | 
| 95 | 
            +
                - - ! '>='
         | 
| 96 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 97 | 
            +
                    version: '0'
         | 
| 98 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 99 | 
            +
              name: rake
         | 
| 100 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 101 | 
             
                none: false
         | 
| 101 | 
            -
                requirements: | 
| 102 | 
            -
                - -  | 
| 103 | 
            -
                  - !ruby/object:Gem::Version | 
| 104 | 
            -
                     | 
| 105 | 
            -
                    segments: 
         | 
| 106 | 
            -
                    - 0
         | 
| 107 | 
            -
                    version: "0"
         | 
| 102 | 
            +
                requirements:
         | 
| 103 | 
            +
                - - ! '>='
         | 
| 104 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 105 | 
            +
                    version: '0'
         | 
| 108 106 | 
             
              type: :development
         | 
| 109 | 
            -
              version_requirements: *id006
         | 
| 110 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 111 | 
            -
              name: simplecov
         | 
| 112 107 | 
             
              prerelease: false
         | 
| 113 | 
            -
               | 
| 108 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 109 | 
            +
                none: false
         | 
| 110 | 
            +
                requirements:
         | 
| 111 | 
            +
                - - ! '>='
         | 
| 112 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 113 | 
            +
                    version: '0'
         | 
| 114 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 115 | 
            +
              name: simplecov
         | 
| 116 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 117 | 
             
                none: false
         | 
| 115 | 
            -
                requirements: | 
| 116 | 
            -
                - -  | 
| 117 | 
            -
                  - !ruby/object:Gem::Version | 
| 118 | 
            -
                     | 
| 119 | 
            -
                    segments: 
         | 
| 120 | 
            -
                    - 0
         | 
| 121 | 
            -
                    version: "0"
         | 
| 118 | 
            +
                requirements:
         | 
| 119 | 
            +
                - - ! '>='
         | 
| 120 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 121 | 
            +
                    version: '0'
         | 
| 122 122 | 
             
              type: :development
         | 
| 123 | 
            -
               | 
| 123 | 
            +
              prerelease: false
         | 
| 124 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 125 | 
            +
                none: false
         | 
| 126 | 
            +
                requirements:
         | 
| 127 | 
            +
                - - ! '>='
         | 
| 128 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 129 | 
            +
                    version: '0'
         | 
| 124 130 | 
             
            description: Google Compute Engine Support for Chef's Knife Command
         | 
| 125 131 | 
             
            email: raggi@google.com
         | 
| 126 132 | 
             
            executables: []
         | 
| 127 | 
            -
             | 
| 128 133 | 
             
            extensions: []
         | 
| 129 | 
            -
             | 
| 130 | 
            -
            extra_rdoc_files: 
         | 
| 134 | 
            +
            extra_rdoc_files:
         | 
| 131 135 | 
             
            - README.md
         | 
| 132 136 | 
             
            - LICENSE
         | 
| 133 137 | 
             
            - CONTRIB.md
         | 
| 134 | 
            -
            files: | 
| 138 | 
            +
            files:
         | 
| 135 139 | 
             
            - .gitignore
         | 
| 140 | 
            +
            - .travis.yml
         | 
| 136 141 | 
             
            - CONTRIB.md
         | 
| 137 142 | 
             
            - Gemfile
         | 
| 138 143 | 
             
            - LICENSE
         | 
| @@ -186,7 +191,7 @@ files: | |
| 186 191 | 
             
            - spec/chef/knife/google_setup_spec.rb
         | 
| 187 192 | 
             
            - spec/chef/knife/google_zone_list_spec.rb
         | 
| 188 193 | 
             
            - spec/data/client.json
         | 
| 189 | 
            -
            - spec/data/compute- | 
| 194 | 
            +
            - spec/data/compute-v1beta15.json
         | 
| 190 195 | 
             
            - spec/data/disk.json
         | 
| 191 196 | 
             
            - spec/data/firewall.json
         | 
| 192 197 | 
             
            - spec/data/global_operation.json
         | 
| @@ -218,36 +223,26 @@ files: | |
| 218 223 | 
             
            - spec/support/spec_google_base.rb
         | 
| 219 224 | 
             
            homepage: http://wiki.opscode.com/display/chef
         | 
| 220 225 | 
             
            licenses: []
         | 
| 221 | 
            -
             | 
| 222 226 | 
             
            post_install_message: 
         | 
| 223 227 | 
             
            rdoc_options: []
         | 
| 224 | 
            -
             | 
| 225 | 
            -
            require_paths: 
         | 
| 228 | 
            +
            require_paths:
         | 
| 226 229 | 
             
            - lib
         | 
| 227 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement | 
| 230 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 228 231 | 
             
              none: false
         | 
| 229 | 
            -
              requirements: | 
| 230 | 
            -
              - -  | 
| 231 | 
            -
                - !ruby/object:Gem::Version | 
| 232 | 
            -
                   | 
| 233 | 
            -
             | 
| 234 | 
            -
                  - 0
         | 
| 235 | 
            -
                  version: "0"
         | 
| 236 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 232 | 
            +
              requirements:
         | 
| 233 | 
            +
              - - ! '>='
         | 
| 234 | 
            +
                - !ruby/object:Gem::Version
         | 
| 235 | 
            +
                  version: '0'
         | 
| 236 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 237 237 | 
             
              none: false
         | 
| 238 | 
            -
              requirements: | 
| 239 | 
            -
              - -  | 
| 240 | 
            -
                - !ruby/object:Gem::Version | 
| 241 | 
            -
                   | 
| 242 | 
            -
                  segments: 
         | 
| 243 | 
            -
                  - 0
         | 
| 244 | 
            -
                  version: "0"
         | 
| 238 | 
            +
              requirements:
         | 
| 239 | 
            +
              - - ! '>='
         | 
| 240 | 
            +
                - !ruby/object:Gem::Version
         | 
| 241 | 
            +
                  version: '0'
         | 
| 245 242 | 
             
            requirements: []
         | 
| 246 | 
            -
             | 
| 247 243 | 
             
            rubyforge_project: 
         | 
| 248 | 
            -
            rubygems_version: 1.8. | 
| 244 | 
            +
            rubygems_version: 1.8.23
         | 
| 249 245 | 
             
            signing_key: 
         | 
| 250 246 | 
             
            specification_version: 3
         | 
| 251 247 | 
             
            summary: Manage Google Compute Engine servers, disks, and zones
         | 
| 252 248 | 
             
            test_files: []
         | 
| 253 | 
            -
             |