openstack 3.3.1 → 3.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6e25014771eb5812859b04fb7acf896ee96d34b
4
- data.tar.gz: b4a28117aa9ffc2e98a9aef0f0293450864b772a
3
+ metadata.gz: 17681562cf42cf5718e2a958b88b9506b122b8f1
4
+ data.tar.gz: 0cbe0dee7b6bc35079a2d7292a95640f8db18c77
5
5
  SHA512:
6
- metadata.gz: 51069cfbbf28c5bd741f0b1ba56f0bb73cedc453f9659ddcf1c0c73e1f39ad20c3b8922e22ea8c6060e736f0dcf6bafb00aca38126ebfa796e0ff3c5003e93c3
7
- data.tar.gz: d7193403695d267378a18e983dcbf1ae317e3102c6a3096df7a873a990d246ed56f34fade63c2e02af9099e76fc0c602dabd39aeb8faeb651cfaf6c11a3f28c3
6
+ metadata.gz: 8d6e9528a0fb31296cf2680d7d5168e0f9c271163b9d448b09ba6504cb60abe910ae007c0ed4bd7b921c72d259eec7ad406bc0eb7127d225a982d259b9973219
7
+ data.tar.gz: 3ba91eab865e7e3bbb8cb002b0e7bb02ef57f5170fa03c24bd37964a7598c3e5c8559cef43d627068f9d967b9ff8efd0fc53adf3ed4657d5eaa198b298c3e673
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.1
1
+ 3.3.2
@@ -221,6 +221,55 @@ module Compute
221
221
  JSON.parse(response.body)
222
222
  end
223
223
 
224
+ # Lists, creates, deletes, and updates the extra-specs or keys for a flavor.
225
+
226
+ # Creates extra specs for a flavor, by ID
227
+ #
228
+ # create_flavor_extra_specs('999aca87-5c8a-4862-92fe-deb8bb024b6b', { 'quota:disk_total_iops_sec' => 1000 })
229
+ # => { 'quota:disk_total_iops_sec' => 1000 }
230
+ def create_flavor_extra_specs(flavor_id, options)
231
+ data = JSON.generate(extra_specs: options)
232
+ response = @connection.req('POST', "/flavors/#{flavor_id}/os-extra_specs", data: data)
233
+ JSON.parse(response.body)['extra_specs']
234
+ end
235
+
236
+ # Lists all extra specs for a flavor, by ID.
237
+ #
238
+ # flavor_extra_specs('999aca87-5c8a-4862-92fe-deb8bb024b6b')
239
+ # => { 'quota:disk_total_iops_sec' => 1000 }
240
+ def flavor_extra_specs(flavor_id)
241
+ response = @connection.req('GET', "/flavors/#{flavor_id}/os-extra_specs")
242
+ JSON.parse(response.body)['extra_specs']
243
+ end
244
+
245
+ # Shows an extra spec, by key, for a flavor, by ID.
246
+ #
247
+ # flavor_extra_spec('999aca87-5c8a-4862-92fe-deb8bb024b6b', 'quota:disk_total_iops_sec')
248
+ # => { 'quota:disk_total_iops_sec' => 1000 }
249
+ def flavor_extra_spec(flavor_id, flavor_extra_spec_key)
250
+ response = @connection.req('GET', "/flavors/#{flavor_id}/os-extra_specs/#{flavor_extra_spec_key}")
251
+ JSON.parse(response.body)
252
+ end
253
+
254
+ # Updates an extra spec, by key, for a flavor, by ID.
255
+ #
256
+ # update_flavor_extra_spec('999aca87-5c8a-4862-92fe-deb8bb024b6b', 'quota:disk_total_iops_sec', 2000)
257
+ # => { 'quota:disk_total_iops_sec' => 2000 }
258
+ def update_flavor_extra_spec(flavor_id, flavor_extra_spec_key, new_value)
259
+ data = JSON.generate(flavor_extra_spec_key => new_value)
260
+ response = @connection.req('PUT', "/flavors/#{flavor_id}/os-extra_specs/#{flavor_extra_spec_key}", data: data)
261
+ JSON.parse(response.body)
262
+ end
263
+
264
+ # Deletes an extra spec, by key, for a flavor, by ID.
265
+ #
266
+ # delete_flavor_extra_spec('999aca87-5c8a-4862-92fe-deb8bb024b6b', 'quota:disk_total_iops_sec')
267
+ # => true
268
+ def delete_flavor_extra_spec(flavor_id, flavor_extra_spec_key)
269
+ @connection.req('DELETE', "/flavors/#{flavor_id}/os-extra_specs/#{flavor_extra_spec_key}")
270
+ true
271
+ end
272
+
224
273
  # Returns the current state of the programatic API limits. Each account has certain limits on the number of resources
225
274
  # allowed in the account, and a rate of API operations.
226
275
  #
@@ -102,9 +102,7 @@ module Compute
102
102
  # >> server.stop()
103
103
  # => true
104
104
  def stop()
105
- data = JSON.generate(:suspend => nil)
106
- puts data
107
- pp "About to post ACTION"
105
+ data = JSON.generate('os-stop' => nil)
108
106
  response = @compute.connection.csreq("POST",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/action",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)
109
107
  OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
110
108
  true
@@ -116,8 +114,8 @@ module Compute
116
114
  #
117
115
  # >> server.start()
118
116
  # => true
119
- def start()
120
- data = JSON.generate(:resume => nil)
117
+ def start
118
+ data = JSON.generate('os-start' => nil)
121
119
  response = @compute.connection.csreq("POST",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/action",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)
122
120
  OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
123
121
  true
@@ -390,6 +388,16 @@ module Compute
390
388
  true
391
389
  end
392
390
 
391
+ # List volume attachments for an instance
392
+ #
393
+ # >> server.get_volume_attachments
394
+ # => array
395
+ def get_volume_attachments
396
+ response = @compute.connection.req('GET', "/servers/#{@id}/os-volume_attachments")
397
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
398
+ JSON.parse(response.body)['volumeAttachments']
399
+ end
400
+
393
401
  end
394
402
  end
395
403
  end
@@ -5,6 +5,7 @@ module Volume
5
5
 
6
6
  attr_accessor :connection
7
7
  attr_reader :volumes_native
8
+ attr_reader :volume_path
8
9
 
9
10
  def initialize(connection)
10
11
  @connection = connection
@@ -30,7 +31,7 @@ module Volume
30
31
  response = @connection.csreq("POST",@connection.service_host,"#{@connection.service_path}/#{@volume_path}",@connection.service_port,@connection.service_scheme,{'content-type' => 'application/json'},data)
31
32
  OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
32
33
  volume_info = JSON.parse(response.body)["volume"]
33
- volume = OpenStack::Volume::Volume.new(volume_info)
34
+ volume = OpenStack::Volume::Volume.new(self, volume_info)
34
35
  end
35
36
 
36
37
  #no options documented in API at Nov 2012
@@ -38,7 +39,7 @@ module Volume
38
39
  def list_volumes
39
40
  response = @connection.req("GET", "/#{@volume_path}")
40
41
  volumes_hash = JSON.parse(response.body)["volumes"]
41
- volumes_hash.inject([]){|res, current| res << OpenStack::Volume::Volume.new(current); res}
42
+ volumes_hash.inject([]){|res, current| res << OpenStack::Volume::Volume.new(self, current); res}
42
43
  end
43
44
  alias :volumes :list_volumes
44
45
 
@@ -46,7 +47,7 @@ module Volume
46
47
  def get_volume(vol_id)
47
48
  response = @connection.req("GET", "/#{@volume_path}/#{vol_id}")
48
49
  volume_hash = JSON.parse(response.body)["volume"]
49
- OpenStack::Volume::Volume.new(volume_hash)
50
+ OpenStack::Volume::Volume.new(self, volume_hash)
50
51
  end
51
52
  alias :volume :get_volume
52
53
 
@@ -3,6 +3,7 @@ module OpenStack
3
3
  class Volume
4
4
 
5
5
  attr_reader :id
6
+ attr_reader :connection
6
7
  attr_reader :display_name
7
8
  attr_reader :display_description
8
9
  attr_reader :size
@@ -14,7 +15,18 @@ module OpenStack
14
15
  attr_reader :created_at
15
16
  attr_reader :status
16
17
 
17
- def initialize(volume_info)
18
+ def initialize(connection, volume_info)
19
+ @connection = connection.connection
20
+ @volume_path = connection.volume_path
21
+ self.populate(volume_info)
22
+ end
23
+
24
+ def populate(volume_info = nil)
25
+ if not volume_info and @id
26
+ response = @connection.req("GET", "/#{@volume_path}/#{@id}")
27
+ volume_info = JSON.parse(response.body)["volume"]
28
+ end
29
+
18
30
  @id = volume_info["id"]
19
31
  @display_name = volume_info["display_name"] || volume_info["displayName"]
20
32
  @display_description = volume_info["display_description"] || volume_info["displayDescription"]
@@ -28,6 +40,22 @@ module OpenStack
28
40
  @status = volume_info["status"]
29
41
  end
30
42
 
43
+ def extend!(size)
44
+ data = JSON.generate({'os-extend' => {'new_size' => size}})
45
+ response = @connection.req('POST', "/#{@volume_path}/#{@id}/action", {:data => data})
46
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
47
+ self.populate
48
+ true
49
+ end
50
+
51
+ def status!(status)
52
+ data = JSON.generate({'os-reset_status' => {'status' => status}})
53
+ response = @connection.req('POST', "/#{@volume_path}/#{@id}/action", {:data => data})
54
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
55
+ self.populate
56
+ true
57
+ end
58
+
31
59
  end
32
60
  end
33
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Prince