knife-cloud 1.2.0.rc.0 → 1.2.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.
- checksums.yaml +4 -4
- data/lib/chef/knife/cloud/exceptions.rb +1 -0
- data/lib/chef/knife/cloud/fog/service.rb +66 -9
- data/lib/knife-cloud/version.rb +1 -1
- data/spec/unit/fog_service_spec.rb +28 -3
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ee4f881dd2d188f7667e32dd23170942f908827
|
4
|
+
data.tar.gz: c2eb79c92ecbe38059ded6138802f67ce7531f45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9de1b62043893d528a727d619be4f77448b8fa72b02650b28f77a202630a8976177c6210c5c113ce36bdd18acb370c8de976565de211457e6b854e8b6e986f68
|
7
|
+
data.tar.gz: 590e7718a81e42b18d99a13d4bc2535b5eef192fdcc8f82939d4da0db3ae2e42e019651a886c41353f8447c66c5328ab64183b979bbfd901adc647cf8890bfa0
|
@@ -128,7 +128,7 @@ class Chef
|
|
128
128
|
def handle_excon_exception(exception_class, e)
|
129
129
|
error_message = if e.response
|
130
130
|
response = Chef::JSONCompat.from_json(e.response.body)
|
131
|
-
"Unknown server error (#{response[
|
131
|
+
"Unknown server error (#{response[response.keys[0]]['code']}): #{response[response.keys[0]]['message']}"
|
132
132
|
else
|
133
133
|
"Unknown server error : #{e.message}"
|
134
134
|
end
|
@@ -138,14 +138,74 @@ class Chef
|
|
138
138
|
|
139
139
|
def list_resource_configurations
|
140
140
|
begin
|
141
|
-
|
141
|
+
connection.flavors.all
|
142
142
|
rescue Excon::Errors::BadRequest => e
|
143
143
|
handle_excon_exception(CloudExceptions::CloudAPIException, e)
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
+
def list_addresses
|
148
|
+
connection.addresses.all
|
149
|
+
rescue Excon::Errors::BadRequest => e
|
150
|
+
handle_excon_exception(CloudExceptions::CloudAPIException, e)
|
151
|
+
end
|
152
|
+
|
153
|
+
def release_address(address_id)
|
154
|
+
response = get_address(address_id)
|
155
|
+
msg_pair('IP address', get_address_ip(response))
|
156
|
+
puts
|
157
|
+
ui.confirm('Do you really want to delete this ip')
|
158
|
+
connection.release_address(address_id)
|
159
|
+
rescue Fog::Compute::OpenStack::NotFound => e
|
160
|
+
error_message = 'Floating ip not found.'
|
161
|
+
ui.error(error_message)
|
162
|
+
raise CloudExceptions::NotFoundError, "#{e.message}"
|
163
|
+
rescue Excon::Errors::BadRequest => e
|
164
|
+
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
165
|
+
end
|
166
|
+
|
167
|
+
def get_address_ip(response)
|
168
|
+
response.body['floating_ip']['ip'] if response.body['floating_ip']
|
169
|
+
end
|
170
|
+
|
171
|
+
def get_address(address_id)
|
172
|
+
connection.get_address(address_id)
|
173
|
+
rescue Excon::Errors::BadRequest => e
|
174
|
+
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
175
|
+
end
|
176
|
+
|
177
|
+
def allocate_address(pool = nil)
|
178
|
+
response = connection.allocate_address(pool)
|
179
|
+
response.body
|
180
|
+
rescue Fog::Compute::OpenStack::NotFound => e
|
181
|
+
error_message = 'Floating ip pool not found.'
|
182
|
+
ui.error(error_message)
|
183
|
+
raise CloudExceptions::NotFoundError, "#{e.message}"
|
184
|
+
rescue Excon::Errors::Forbidden => e
|
185
|
+
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
186
|
+
rescue Excon::Errors::BadRequest => e
|
187
|
+
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
188
|
+
end
|
189
|
+
|
190
|
+
def associate_address(*args)
|
191
|
+
connection.associate_address(*args)
|
192
|
+
rescue Excon::Errors::BadRequest => e
|
193
|
+
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
194
|
+
end
|
195
|
+
|
196
|
+
def disassociate_address(*args)
|
197
|
+
connection.disassociate_address(*args)
|
198
|
+
rescue Fog::Compute::OpenStack::NotFound
|
199
|
+
error_message = 'Floating ip not found.'
|
200
|
+
ui.error(error_message)
|
201
|
+
rescue Excon::Errors::UnprocessableEntity => e
|
202
|
+
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
203
|
+
rescue Excon::Errors::BadRequest => e
|
204
|
+
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
205
|
+
end
|
206
|
+
|
147
207
|
def delete_server_on_failure(server = nil)
|
148
|
-
server.destroy
|
208
|
+
server.destroy unless server.nil?
|
149
209
|
end
|
150
210
|
|
151
211
|
def add_api_endpoint
|
@@ -157,11 +217,9 @@ class Chef
|
|
157
217
|
end
|
158
218
|
|
159
219
|
def get_server(instance_id)
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
164
|
-
end
|
220
|
+
connection.servers.get(instance_id)
|
221
|
+
rescue Excon::Errors::BadRequest => e
|
222
|
+
handle_excon_exception(CloudExceptions::KnifeCloudError, e)
|
165
223
|
end
|
166
224
|
|
167
225
|
def get_image(name_or_id)
|
@@ -193,7 +251,6 @@ class Chef
|
|
193
251
|
image_info = connection.images.get(image)
|
194
252
|
!image_info.nil? ? image_info.platform == 'windows' : false
|
195
253
|
end
|
196
|
-
|
197
254
|
end
|
198
255
|
end
|
199
256
|
end
|
data/lib/knife-cloud/version.rb
CHANGED
@@ -82,7 +82,7 @@ describe Chef::Knife::Cloud::FogService do
|
|
82
82
|
|
83
83
|
it "sets the provided attributes with supplied values" do
|
84
84
|
expect(@server_def[:state] == "Inactive").to be true
|
85
|
-
end
|
85
|
+
end
|
86
86
|
end
|
87
87
|
|
88
88
|
["servers", "images", "networks"].each do |resource_type|
|
@@ -93,9 +93,9 @@ describe Chef::Knife::Cloud::FogService do
|
|
93
93
|
:connection
|
94
94
|
end
|
95
95
|
context "list #{resource_type}" do
|
96
|
-
|
96
|
+
|
97
97
|
it "lists #{resource_type} of the current cloud service provider account." do
|
98
|
-
allow(instance).to receive_message_chain(resource.to_sym, "#{resource_type}".to_sym, :all)
|
98
|
+
allow(instance).to receive_message_chain(resource.to_sym, "#{resource_type}".to_sym, :all)
|
99
99
|
instance.method("list_#{resource_type}").call
|
100
100
|
end
|
101
101
|
|
@@ -135,4 +135,29 @@ describe Chef::Knife::Cloud::FogService do
|
|
135
135
|
expect { instance.delete_server(server_name) }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ServerDeleteError, error_message)
|
136
136
|
end
|
137
137
|
end
|
138
|
+
|
139
|
+
context '#release_address' do
|
140
|
+
before(:each) do
|
141
|
+
allow(instance).to receive(:add_api_endpoint)
|
142
|
+
allow(Fog::Compute).to receive(:new).with({:provider => 'Any Cloud Provider'})
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'releases address successfully' do
|
146
|
+
address_id = 'test-addres-id'
|
147
|
+
@address = TestResource.new('body' => { 'floating_ip' =>
|
148
|
+
{ 'instance_id' => nil,
|
149
|
+
'ip' => '127.0.0.1',
|
150
|
+
'fixed_ip' => nil,
|
151
|
+
'id' => 'test-addres-id',
|
152
|
+
'pool' => 'public-110'
|
153
|
+
}
|
154
|
+
})
|
155
|
+
instance.ui = double
|
156
|
+
expect(instance).to receive(:get_address).and_return(@address)
|
157
|
+
expect(instance).to receive(:msg_pair).with('IP address', '127.0.0.1')
|
158
|
+
expect(instance.ui).to receive(:confirm)
|
159
|
+
allow(instance.connection).to receive(:release_address)
|
160
|
+
instance.release_address(address_id)
|
161
|
+
end
|
162
|
+
end
|
138
163
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaustubh Deorukhkar
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-07-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: knife-windows
|
@@ -214,9 +214,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
216
|
requirements:
|
217
|
-
- - "
|
217
|
+
- - ">="
|
218
218
|
- !ruby/object:Gem::Version
|
219
|
-
version:
|
219
|
+
version: '0'
|
220
220
|
requirements: []
|
221
221
|
rubyforge_project:
|
222
222
|
rubygems_version: 2.2.2
|
@@ -246,4 +246,3 @@ test_files:
|
|
246
246
|
- spec/unit/unix_distribution_spec.rb
|
247
247
|
- spec/unit/windows_distribution_spec.rb
|
248
248
|
- spec/unit/winrm_bootstrap_protocol_spec.rb
|
249
|
-
has_rdoc:
|