openstack-compute 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/openstack/compute/authentication.rb +1 -1
- data/lib/openstack/compute/connection.rb +2 -43
- data/lib/openstack/compute/image.rb +3 -1
- data/lib/openstack/compute/server.rb +0 -68
- data/lib/openstack/compute.rb +0 -1
- metadata +4 -6
- data/lib/openstack/compute/entity_manager.rb +0 -6
- data/lib/openstack/compute/shared_ip_group.rb +0 -54
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -22,7 +22,7 @@ module Compute
|
|
22
22
|
raise OpenStack::Compute::Exception::Connection, "Unable to connect to #{server}"
|
23
23
|
end
|
24
24
|
response = server.get(path,hdrhash)
|
25
|
-
if (response.code
|
25
|
+
if (response.code =~ /^20./)
|
26
26
|
connection.authtoken = response["x-auth-token"]
|
27
27
|
connection.svrmgmthost = URI.parse(response["x-server-management-url"]).host
|
28
28
|
connection.svrmgmtpath = URI.parse(response["x-server-management-url"]).path
|
@@ -79,7 +79,7 @@ module Compute
|
|
79
79
|
retry
|
80
80
|
rescue OpenStack::Compute::Exception::ExpiredAuthToken
|
81
81
|
raise OpenStack::Compute::Exception::Connection, "Authentication token expired and you have requested not to retry" if @retry_auth == false
|
82
|
-
|
82
|
+
OpenStack::Compute::Authentication.new(self)
|
83
83
|
retry
|
84
84
|
end
|
85
85
|
|
@@ -228,47 +228,6 @@ module Compute
|
|
228
228
|
end
|
229
229
|
alias :flavor :get_flavor
|
230
230
|
|
231
|
-
# Returns an array of hashes for all Shared IP Groups that are available. The :id key can be used to find that specific object.
|
232
|
-
#
|
233
|
-
# You can also provide :limit and :offset parameters to handle pagination.
|
234
|
-
#
|
235
|
-
# >> cs.list_shared_ip_groups
|
236
|
-
# => [{:name=>"New Group", :id=>127}]
|
237
|
-
def list_shared_ip_groups(options = {})
|
238
|
-
path = OpenStack::Compute.paginate(options).empty? ? "#{svrmgmtpath}/shared_ip_groups/detail" : "#{svrmgmtpath}/shared_ip_groups/detail?#{OpenStack::Compute.paginate(options)}"
|
239
|
-
response = csreq("GET",svrmgmthost,path,svrmgmtport,svrmgmtscheme)
|
240
|
-
OpenStack::Compute::Exception.raise_exception(response) unless response.code.match(/^20.$/)
|
241
|
-
OpenStack::Compute.symbolize_keys(JSON.parse(response.body)['sharedIpGroups'])
|
242
|
-
end
|
243
|
-
alias :shared_ip_groups :list_shared_ip_groups
|
244
|
-
|
245
|
-
# Returns a OpenStack::Compute::SharedIPGroup object for the IP group identified by the provided ID.
|
246
|
-
#
|
247
|
-
# >> sig = cs.get_shared_ip_group(127)
|
248
|
-
# => #<OpenStack::Compute::SharedIPGroup:0x10153ca30 ...>
|
249
|
-
def get_shared_ip_group(id)
|
250
|
-
OpenStack::Compute::SharedIPGroup.new(self,id)
|
251
|
-
end
|
252
|
-
alias :shared_ip_group :get_shared_ip_group
|
253
|
-
|
254
|
-
# Creates a new Shared IP group. Takes a hash as an argument.
|
255
|
-
#
|
256
|
-
# Valid hash keys are :name (required) and :server (optional), which indicates the one server to place into this group by default.
|
257
|
-
#
|
258
|
-
# >> sig = cs.create_shared_ip_group(:name => "Production Web", :server => 110917)
|
259
|
-
# => #<OpenStack::Compute::SharedIPGroup:0x101501d18 ...>
|
260
|
-
# >> sig.name
|
261
|
-
# => "Production Web"
|
262
|
-
# >> sig.servers
|
263
|
-
# => [110917]
|
264
|
-
def create_shared_ip_group(options)
|
265
|
-
data = JSON.generate(:sharedIpGroup => options)
|
266
|
-
response = csreq("POST",svrmgmthost,"#{svrmgmtpath}/shared_ip_groups",svrmgmtport,svrmgmtscheme,{'content-type' => 'application/json'},data)
|
267
|
-
OpenStack::Compute::Exception.raise_exception(response) unless response.code.match(/^20.$/)
|
268
|
-
ip_group = JSON.parse(response.body)['sharedIpGroup']
|
269
|
-
OpenStack::Compute::SharedIPGroup.new(self,ip_group['id'])
|
270
|
-
end
|
271
|
-
|
272
231
|
# Returns the current state of the programatic API limits. Each account has certain limits on the number of resources
|
273
232
|
# allowed in the account, and a rate of API operations.
|
274
233
|
#
|
@@ -322,7 +281,7 @@ module Compute
|
|
322
281
|
end
|
323
282
|
@http[server].start
|
324
283
|
rescue
|
325
|
-
raise
|
284
|
+
raise OpenStack::Compute::Exception::Connection, "Unable to connect to #{server}"
|
326
285
|
end
|
327
286
|
end
|
328
287
|
end
|
@@ -38,7 +38,9 @@ module Compute
|
|
38
38
|
@id = data['id']
|
39
39
|
@name = data['name']
|
40
40
|
@serverId = data['serverId']
|
41
|
-
|
41
|
+
if data['updated'] then
|
42
|
+
@updated = DateTime.parse(data['updated'])
|
43
|
+
end
|
42
44
|
@created = DateTime.parse(data['created'])
|
43
45
|
@status = data['status']
|
44
46
|
@progress = data['progress']
|
@@ -11,7 +11,6 @@ module Compute
|
|
11
11
|
attr_reader :hostId
|
12
12
|
attr_reader :imageId
|
13
13
|
attr_reader :flavorId
|
14
|
-
attr_reader :metadata
|
15
14
|
attr_accessor :adminPass
|
16
15
|
|
17
16
|
# This class is the representation of a single Server object. The constructor finds the server identified by the specified
|
@@ -55,7 +54,6 @@ module Compute
|
|
55
54
|
@hostId = data["hostId"]
|
56
55
|
@imageId = data["imageId"]
|
57
56
|
@flavorId = data["flavorId"]
|
58
|
-
@metadata = data["metadata"]
|
59
57
|
true
|
60
58
|
end
|
61
59
|
alias :refresh :populate
|
@@ -216,72 +214,6 @@ module Compute
|
|
216
214
|
true
|
217
215
|
end
|
218
216
|
|
219
|
-
# Provides information about the backup schedule for this server. Returns a hash of the form
|
220
|
-
# {"weekly" => state, "daily" => state, "enabled" => boolean}
|
221
|
-
#
|
222
|
-
# >> server.backup_schedule
|
223
|
-
# => {"weekly"=>"THURSDAY", "daily"=>"H_0400_0600", "enabled"=>true}
|
224
|
-
def backup_schedule
|
225
|
-
response = @connection.csreq("GET",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(@id.to_s)}/backup_schedule",@svrmgmtport,@svrmgmtscheme)
|
226
|
-
OpenStack::Compute::Exception.raise_exception(response) unless response.code.match(/^20.$/)
|
227
|
-
JSON.parse(response.body)['backupSchedule']
|
228
|
-
end
|
229
|
-
|
230
|
-
# Updates the backup schedule for the server. Takes a hash of the form: {:weekly => state, :daily => state, :enabled => boolean} as an argument.
|
231
|
-
# All three keys (:weekly, :daily, :enabled) must be provided or an exception will get raised.
|
232
|
-
#
|
233
|
-
# >> server.backup_schedule=({:weekly=>"THURSDAY", :daily=>"H_0400_0600", :enabled=>true})
|
234
|
-
# => {:weekly=>"THURSDAY", :daily=>"H_0400_0600", :enabled=>true}
|
235
|
-
def backup_schedule=(options)
|
236
|
-
data = JSON.generate('backupSchedule' => options)
|
237
|
-
response = @connection.csreq("POST",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/backup_schedule",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)
|
238
|
-
OpenStack::Compute::Exception.raise_exception(response) unless response.code.match(/^20.$/)
|
239
|
-
true
|
240
|
-
end
|
241
|
-
|
242
|
-
# Removes the existing backup schedule for the server, setting the backups to disabled.
|
243
|
-
#
|
244
|
-
# Returns true if the API call succeeds.
|
245
|
-
#
|
246
|
-
# >> server.disable_backup_schedule!
|
247
|
-
# => true
|
248
|
-
def disable_backup_schedule!
|
249
|
-
response = @connection.csreq("DELETE",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/backup_schedule",@svrmgmtport,@svrmgmtscheme)
|
250
|
-
OpenStack::Compute::Exception.raise_exception(response) unless response.code.match(/^20.$/)
|
251
|
-
true
|
252
|
-
end
|
253
|
-
|
254
|
-
# Share IP between servers in Shared IP group.
|
255
|
-
# Takes a hash of the form: {:sharedIpGroupId => "1234", :ipAddress => "67.23.10.132", :configureServer => false} as an argument.
|
256
|
-
# The :sharedIpGroupId key is required.
|
257
|
-
# The :ipAddress key is required.
|
258
|
-
# The :configureServer key is optional and defaults to false.
|
259
|
-
#
|
260
|
-
# >> server.share_ip(:sharedIpGroupId => 100, :ipAddress => "67.23.10.132")
|
261
|
-
# => true
|
262
|
-
def share_ip(options)
|
263
|
-
raise OpenStack::Compute::Exception::MissingArgument, "Shared IP Group ID must be supplied" unless options[:sharedIpGroupId]
|
264
|
-
raise OpenStack::Compute::Exception::MissingArgument, "Ip Address must be supplied" unless options[:ipAddress]
|
265
|
-
options[:configureServer] = false if options[:configureServer].nil?
|
266
|
-
data = JSON.generate(:shareIp => {:sharedIpGroupId => options[:sharedIpGroupId], :configureServer => options[:configureServer]})
|
267
|
-
response = @connection.csreq("PUT",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/ips/public/#{options[:ipAddress]}",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)
|
268
|
-
OpenStack::Compute::Exception.raise_exception(response) unless response.code.match(/^20.$/)
|
269
|
-
true
|
270
|
-
end
|
271
|
-
|
272
|
-
# Unshare an IP address.
|
273
|
-
# Takes a hash of the form: {:ipAddress => "67.23.10.132"} as an argument.
|
274
|
-
# The :ipAddress key is required.
|
275
|
-
#
|
276
|
-
# >> server.unshare_ip(:ipAddress => "67.23.10.132")
|
277
|
-
# => true
|
278
|
-
def unshare_ip(options)
|
279
|
-
raise OpenStack::Compute::Exception::MissingArgument, "Ip Address must be supplied" unless options[:ipAddress]
|
280
|
-
response = @connection.csreq("DELETE",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/ips/public/#{options[:ipAddress]}",@svrmgmtport,@svrmgmtscheme)
|
281
|
-
OpenStack::Compute::Exception.raise_exception(response) unless response.code.match(/^20.$/)
|
282
|
-
true
|
283
|
-
end
|
284
|
-
|
285
217
|
end
|
286
218
|
end
|
287
219
|
end
|
data/lib/openstack/compute.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstack-compute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dan Prince
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,12 +47,10 @@ files:
|
|
47
47
|
- lib/openstack/compute.rb
|
48
48
|
- lib/openstack/compute/authentication.rb
|
49
49
|
- lib/openstack/compute/connection.rb
|
50
|
-
- lib/openstack/compute/entity_manager.rb
|
51
50
|
- lib/openstack/compute/exception.rb
|
52
51
|
- lib/openstack/compute/flavor.rb
|
53
52
|
- lib/openstack/compute/image.rb
|
54
53
|
- lib/openstack/compute/server.rb
|
55
|
-
- lib/openstack/compute/shared_ip_group.rb
|
56
54
|
has_rdoc: true
|
57
55
|
homepage: https://launchpad.net/ruby-openstack-compute
|
58
56
|
licenses: []
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module OpenStack
|
2
|
-
module Compute
|
3
|
-
class SharedIPGroup
|
4
|
-
|
5
|
-
attr_reader :id
|
6
|
-
attr_reader :name
|
7
|
-
attr_reader :servers
|
8
|
-
|
9
|
-
# Creates a new Shared IP Group object, with information on the group identified by the ID number. Will most likely be called
|
10
|
-
# by the get_shared_ip_group method on a OpenStack::Compute::Connection object.
|
11
|
-
#
|
12
|
-
# >> sig = cs.get_shared_ip_group(127)
|
13
|
-
# => #<OpenStack::Compute::SharedIPGroup:0x101513798 ...>
|
14
|
-
# >> sig.name
|
15
|
-
# => "New Group"
|
16
|
-
def initialize(connection,id)
|
17
|
-
@connection = connection
|
18
|
-
@id = id
|
19
|
-
populate
|
20
|
-
end
|
21
|
-
|
22
|
-
# Makes the API call that populates the OpenStack::Compute::SharedIPGroup object with information on the group. Can also be called directly on
|
23
|
-
# an existing object to update its information.
|
24
|
-
#
|
25
|
-
# Returns true if the API call succeeds.
|
26
|
-
#
|
27
|
-
# >> sig.populate
|
28
|
-
# => true
|
29
|
-
def populate
|
30
|
-
response = @connection.csreq("GET",@connection.svrmgmthost,"#{@connection.svrmgmtpath}/shared_ip_groups/#{URI.escape(self.id.to_s)}",@connection.svrmgmtport,@connection.svrmgmtscheme)
|
31
|
-
OpenStack::Compute::Exception.raise_exception(response) unless response.code.match(/^20.$/)
|
32
|
-
data = JSON.parse(response.body)['sharedIpGroup']
|
33
|
-
@id = data['id']
|
34
|
-
@name = data['name']
|
35
|
-
@servers = data['servers']
|
36
|
-
true
|
37
|
-
end
|
38
|
-
alias :refresh :populate
|
39
|
-
|
40
|
-
# Deletes the Shared IP Group identified by the current object.
|
41
|
-
#
|
42
|
-
# Returns true if the API call succeeds.
|
43
|
-
#
|
44
|
-
# >> sig.delete!
|
45
|
-
# => true
|
46
|
-
def delete!
|
47
|
-
response = @connection.csreq("DELETE",@connection.svrmgmthost,"#{@connection.svrmgmtpath}/shared_ip_groups/#{URI.escape(self.id.to_s)}",@connection.svrmgmtport,@connection.svrmgmtscheme)
|
48
|
-
OpenStack::Compute::Exception.raise_exception(response) unless response.code.match(/^20.$/)
|
49
|
-
true
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|