openstack-compute 1.1.1 → 1.1.2
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/VERSION +1 -1
- data/lib/openstack/compute/address.rb +38 -0
- data/lib/openstack/compute/authentication.rb +26 -14
- data/lib/openstack/compute/connection.rb +6 -3
- data/lib/openstack/compute/server.rb +16 -1
- data/lib/openstack/compute.rb +1 -0
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module OpenStack
|
2
|
+
module Compute
|
3
|
+
|
4
|
+
class AddressList < Array
|
5
|
+
def [](index)
|
6
|
+
addresses = Array.new
|
7
|
+
if index.class == Symbol then
|
8
|
+
self.each do |address|
|
9
|
+
if address.label == index.to_s then
|
10
|
+
addresses << address.address
|
11
|
+
end
|
12
|
+
end
|
13
|
+
addresses
|
14
|
+
else
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Address
|
21
|
+
|
22
|
+
attr_reader :address
|
23
|
+
attr_reader :label
|
24
|
+
attr_reader :version
|
25
|
+
|
26
|
+
def initialize(label, address, version = 4)
|
27
|
+
@label = label
|
28
|
+
if address.class == Hash then
|
29
|
+
@address = address["addr"]
|
30
|
+
@version = address["version"]
|
31
|
+
else
|
32
|
+
@address = address
|
33
|
+
@version = version
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -32,23 +32,35 @@ module Compute
|
|
32
32
|
raise OpenStack::Compute::Exception::Connection, "Unable to connect to #{server}"
|
33
33
|
end
|
34
34
|
|
35
|
-
auth_data = JSON.generate({ "passwordCredentials" => { "username" => connection.authuser, "password" => connection.authkey }})
|
35
|
+
auth_data = JSON.generate({ "auth" => { "passwordCredentials" => { "username" => connection.authuser, "password" => connection.authkey }}})
|
36
36
|
response = server.post(connection.auth_path.chomp("/")+"/tokens", auth_data, {'Content-Type' => 'application/json'})
|
37
37
|
if (response.code =~ /^20./)
|
38
38
|
resp_data=JSON.parse(response.body)
|
39
|
-
connection.authtoken = resp_data['
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
39
|
+
connection.authtoken = resp_data['access']['token']['id']
|
40
|
+
resp_data['access']['serviceCatalog'].each do |service|
|
41
|
+
if service['type'] == connection.service_name
|
42
|
+
uri = String.new
|
43
|
+
endpoints = service["endpoints"]
|
44
|
+
if connection.region
|
45
|
+
endpoints.each do |ep|
|
46
|
+
if ep["region"].upcase == connection.region.upcase
|
47
|
+
uri = URI.parse(ep["publicURL"])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
if uri == ''
|
51
|
+
raise OpenStack::Compute::Exception::Authentication, "No API endpoint for region #{connection.region}"
|
52
|
+
end
|
53
|
+
else
|
54
|
+
uri = URI.parse(endpoints[0]["publicURL"])
|
55
|
+
end
|
56
|
+
connection.svrmgmthost = uri.host
|
57
|
+
connection.svrmgmtpath = uri.path
|
58
|
+
connection.svrmgmtport = uri.port
|
59
|
+
connection.svrmgmtscheme = uri.scheme
|
60
|
+
connection.authok = true
|
61
|
+
else
|
62
|
+
connection.authok = false
|
63
|
+
end
|
52
64
|
end
|
53
65
|
else
|
54
66
|
connection.authtoken = false
|
@@ -18,6 +18,7 @@ module Compute
|
|
18
18
|
attr_accessor :service_name
|
19
19
|
attr_reader :proxy_host
|
20
20
|
attr_reader :proxy_port
|
21
|
+
attr_reader :region
|
21
22
|
|
22
23
|
# Creates a new OpenStack::Compute::Connection object. Uses OpenStack::Compute::Authentication to perform the login for the connection.
|
23
24
|
#
|
@@ -27,7 +28,8 @@ module Compute
|
|
27
28
|
# :tenant - Your Openstack tenant *required*. Defaults to username.
|
28
29
|
# :api_key - Your Openstack API key *required*
|
29
30
|
# :auth_url - Configurable auth_url endpoint.
|
30
|
-
# :service_name - (Optional for v2.0 auth only). The name of the compute service to use. Defaults to '
|
31
|
+
# :service_name - (Optional for v2.0 auth only). The name of the compute service to use. Defaults to 'compute'.
|
32
|
+
# :region - (Optional for v2.0 auth only). The specific service region to use. Defaults to first returned region.
|
31
33
|
# :retry_auth - Whether to retry if your auth token expires (defaults to true)
|
32
34
|
# :proxy_host - If you need to connect through a proxy, supply the hostname here
|
33
35
|
# :proxy_port - If you need to connect through a proxy, supply the port here
|
@@ -38,7 +40,8 @@ module Compute
|
|
38
40
|
@authkey = options[:api_key] || (raise Exception::MissingArgument, "Must supply an :api_key")
|
39
41
|
@auth_url = options[:auth_url] || (raise Exception::MissingArgument, "Must supply an :auth_url")
|
40
42
|
@authtenant = options[:authtenant] || @authuser
|
41
|
-
@service_name = options[:service_name] || "
|
43
|
+
@service_name = options[:service_name] || "compute"
|
44
|
+
@region = options[:region] || @region = nil
|
42
45
|
@is_debug = options[:is_debug]
|
43
46
|
|
44
47
|
auth_uri=nil
|
@@ -341,7 +344,7 @@ module Compute
|
|
341
344
|
data.push({:path => svrpath, :contents => b64})
|
342
345
|
itemcount += 1
|
343
346
|
end
|
344
|
-
|
347
|
+
data
|
345
348
|
end
|
346
349
|
|
347
350
|
end
|
@@ -8,6 +8,8 @@ module Compute
|
|
8
8
|
attr_reader :name
|
9
9
|
attr_reader :status
|
10
10
|
attr_reader :progress
|
11
|
+
attr_reader :accessipv4
|
12
|
+
attr_reader :accessipv6
|
11
13
|
attr_reader :addresses
|
12
14
|
attr_reader :hostId
|
13
15
|
attr_reader :image
|
@@ -51,7 +53,7 @@ module Compute
|
|
51
53
|
@name = data["name"]
|
52
54
|
@status = data["status"]
|
53
55
|
@progress = data["progress"]
|
54
|
-
@addresses =
|
56
|
+
@addresses = get_addresses(data["addresses"])
|
55
57
|
@metadata = OpenStack::Compute::ServerMetadata.new(@connection, @id)
|
56
58
|
@hostId = data["hostId"]
|
57
59
|
@image = data["image"]
|
@@ -222,6 +224,19 @@ module Compute
|
|
222
224
|
@adminPass = password
|
223
225
|
end
|
224
226
|
|
227
|
+
def get_addresses(address_info)
|
228
|
+
address_list = OpenStack::Compute::AddressList.new
|
229
|
+
address_info.each do |label, addr|
|
230
|
+
addr.each do |address|
|
231
|
+
address_list << OpenStack::Compute::Address.new(label,address)
|
232
|
+
if address_list.last.version == 4 && (!@accessipv4 || accessipv4 == "") then
|
233
|
+
@accessipv4 = address_list.last.address
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
address_list
|
238
|
+
end
|
239
|
+
|
225
240
|
end
|
226
241
|
end
|
227
242
|
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: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
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-10-
|
18
|
+
date: 2011-10-19 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- README.rdoc
|
46
46
|
- VERSION
|
47
47
|
- lib/openstack/compute.rb
|
48
|
+
- lib/openstack/compute/address.rb
|
48
49
|
- lib/openstack/compute/authentication.rb
|
49
50
|
- lib/openstack/compute/connection.rb
|
50
51
|
- lib/openstack/compute/exception.rb
|