openstack-compute 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -61,7 +61,7 @@ See the class definitions for documentation on specific methods and operations.
61
61
 
62
62
  == Authors
63
63
 
64
- By Dan Prince <dan.prince@rackspace.com>, Naveed Massjouni <naveedm9@gmail.com>
64
+ By Dan Prince <dprince@redhat.com>, Naveed Massjouni <naveedm9@gmail.com>
65
65
 
66
66
  Based on the Rackspace Cloud Servers Ruby API.
67
67
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.6
1
+ 1.1.7
@@ -7,6 +7,7 @@ module Compute
7
7
  # If it succeeds, it sets the svrmgmthost, svrmgtpath, svrmgmtport,
8
8
  # svrmgmtscheme, authtoken, and authok variables on the connection.
9
9
  # If it fails, it raises an exception.
10
+
10
11
  def self.init(conn)
11
12
  if conn.auth_path =~ /.*v2.0\/?$/
12
13
  AuthV20.new(conn)
@@ -19,6 +20,7 @@ module Compute
19
20
 
20
21
  private
21
22
  class AuthV20
23
+ attr_reader :uri
22
24
 
23
25
  def initialize(connection)
24
26
  begin
@@ -31,6 +33,8 @@ module Compute
31
33
  rescue
32
34
  raise OpenStack::Compute::Exception::Connection, "Unable to connect to #{server}"
33
35
  end
36
+
37
+ @uri = String.new
34
38
 
35
39
  auth_data = JSON.generate({ "auth" => { "passwordCredentials" => { "username" => connection.authuser, "password" => connection.authkey }, "tenantName" => connection.authtenant}})
36
40
  response = server.post(connection.auth_path.chomp("/")+"/tokens", auth_data, {'Content-Type' => 'application/json'})
@@ -38,26 +42,31 @@ module Compute
38
42
  resp_data=JSON.parse(response.body)
39
43
  connection.authtoken = resp_data['access']['token']['id']
40
44
  resp_data['access']['serviceCatalog'].each do |service|
41
- if service['type'] == connection.service_name
42
- uri = String.new
45
+ if connection.service_name
46
+ check_service_name = connection.service_name
47
+ else
48
+ check_service_name = service['name']
49
+ end
50
+ if service['type'] == connection.service_type and service['name'] == check_service_name
43
51
  endpoints = service["endpoints"]
44
52
  if connection.region
45
53
  endpoints.each do |ep|
46
- if ep["region"].upcase == connection.region.upcase
47
- uri = URI.parse(ep["publicURL"])
54
+ if ep["region"] and ep["region"].upcase == connection.region.upcase
55
+ @uri = URI.parse(ep["publicURL"])
48
56
  end
49
57
  end
50
- if uri == ''
51
- raise OpenStack::Compute::Exception::Authentication, "No API endpoint for region #{connection.region}"
52
- end
53
58
  else
54
- uri = URI.parse(endpoints[0]["publicURL"])
59
+ @uri = URI.parse(endpoints[0]["publicURL"])
60
+ end
61
+ if @uri == ""
62
+ raise OpenStack::Compute::Exception::Authentication, "No API endpoint for region #{connection.region}"
63
+ else
64
+ connection.svrmgmthost = @uri.host
65
+ connection.svrmgmtpath = @uri.path
66
+ connection.svrmgmtport = @uri.port
67
+ connection.svrmgmtscheme = @uri.scheme
68
+ connection.authok = true
55
69
  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
70
  end
62
71
  end
63
72
  else
@@ -88,9 +97,6 @@ module Compute
88
97
  uri = URI.parse(response["x-server-management-url"])
89
98
  connection.svrmgmthost = uri.host
90
99
  connection.svrmgmtpath = uri.path
91
- # Force the path into the v1.1 URL space
92
- connection.svrmgmtpath.sub!(/\/.*\/?/, '/v1.1/')
93
- connection.svrmgmtpath += connection.authtenant
94
100
  connection.svrmgmtport = uri.port
95
101
  connection.svrmgmtscheme = uri.scheme
96
102
  connection.authok = true
@@ -15,7 +15,8 @@ module Compute
15
15
  attr_reader :auth_port
16
16
  attr_reader :auth_scheme
17
17
  attr_reader :auth_path
18
- attr_accessor :service_name
18
+ attr_reader :service_name
19
+ attr_reader :service_type
19
20
  attr_reader :proxy_host
20
21
  attr_reader :proxy_port
21
22
  attr_reader :region
@@ -28,7 +29,8 @@ module Compute
28
29
  # :tenant - Your Openstack tenant *required*. Defaults to username.
29
30
  # :api_key - Your Openstack API key *required*
30
31
  # :auth_url - Configurable auth_url endpoint.
31
- # :service_name - (Optional for v2.0 auth only). The name of the compute service to use. Defaults to 'compute'.
32
+ # :service_name - (Optional for v2.0 auth only). The optional name of the compute service to use.
33
+ # :service_type - (Optional for v2.0 auth only). Defaults to "compute"
32
34
  # :region - (Optional for v2.0 auth only). The specific service region to use. Defaults to first returned region.
33
35
  # :retry_auth - Whether to retry if your auth token expires (defaults to true)
34
36
  # :proxy_host - If you need to connect through a proxy, supply the hostname here
@@ -40,7 +42,8 @@ module Compute
40
42
  @authkey = options[:api_key] || (raise Exception::MissingArgument, "Must supply an :api_key")
41
43
  @auth_url = options[:auth_url] || (raise Exception::MissingArgument, "Must supply an :auth_url")
42
44
  @authtenant = options[:authtenant] || @authuser
43
- @service_name = options[:service_name] || "compute"
45
+ @service_name = options[:service_name] || nil
46
+ @service_type = options[:service_type] || "compute"
44
47
  @region = options[:region] || @region = nil
45
48
  @is_debug = options[:is_debug]
46
49
 
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: 31
5
- prerelease: false
4
+ hash: 29
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 6
10
- version: 1.1.6
9
+ - 7
10
+ version: 1.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dan Prince
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-29 00:00:00 -05:00
19
- default_executable:
18
+ date: 2012-02-17 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: json
@@ -54,7 +53,6 @@ files:
54
53
  - lib/openstack/compute/metadata.rb
55
54
  - lib/openstack/compute/personalities.rb
56
55
  - lib/openstack/compute/server.rb
57
- has_rdoc: true
58
56
  homepage: https://launchpad.net/ruby-openstack-compute
59
57
  licenses: []
60
58
 
@@ -84,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
82
  requirements: []
85
83
 
86
84
  rubyforge_project:
87
- rubygems_version: 1.3.7
85
+ rubygems_version: 1.8.15
88
86
  signing_key:
89
87
  specification_version: 3
90
88
  summary: OpenStack Compute Ruby API