Make identity providers use uri_join_paths

Instead of defining the same _path function in each of these providers,
I have moved it to uri_join_paths in openstack-common. This change
simply makes use of that new function.

All tests pass.

Change-Id: Ie821d4210f1a34f6aa9f259d8b591f95c6304485
This commit is contained in:
Craig Tracey
2013-05-18 12:36:17 -04:00
parent 9665817131
commit a0c625c119
2 changed files with 8 additions and 18 deletions

View File

@@ -19,6 +19,7 @@
#
require "uri"
include ::Openstack
action :create_ec2 do
http = _new_http new_resource
@@ -144,18 +145,12 @@ def _new_http resource
end
# Just cats the request URI with the supplied path, returning a string
def _path uri, subject
[uri.request_uri, subject].join
end
# Short-cut for returning an Net::HTTP::Post to a path on the admin API endpoint.
# Headers and admin token validation are already performed. All
# the caller needs to do is call http.request, supplying the returned object
def _http_post resource, path
uri = ::URI.parse(resource.auth_uri)
path = _path uri, path
path = uri_join_paths uri.request_uri, path
request = Net::HTTP::Post.new(path)
_build_request resource, request
end
@@ -166,7 +161,7 @@ end
# the caller needs to do is call http.request, supplying the returned object
def _http_put resource, path
uri = ::URI.parse(resource.auth_uri)
path = _path uri, path
path = uri_join_paths uri.request_uri, path
request = Net::HTTP::Put.new(path)
_build_request resource, request
end
@@ -177,7 +172,7 @@ end
# the caller needs to do is call http.request, supplying the returned object
def _http_get resource, path
uri = ::URI.parse(resource.auth_uri)
path = _path uri, path
path = uri_join_paths uri.request_uri, path
request = Net::HTTP::Get.new(path)
_build_request resource, request
end

View File

@@ -19,6 +19,7 @@
#
require "uri"
include ::Openstack
action :create_service do
if node["openstack-identity"]["catalog"]["backend"] == "templated"
@@ -416,18 +417,12 @@ def _new_http resource
end
# Just cats the request URI with the supplied path, returning a string
def _path uri, subject
[uri.request_uri, subject].join
end
# Short-cut for returning an Net::HTTP::Post to a path on the admin API endpoint.
# Headers and bootstrap token validation are already performed. All
# the caller needs to do is call http.request, supplying the returned object
def _http_post resource, path
uri = ::URI.parse(resource.auth_uri)
path = _path uri, path
path = uri_join_paths uri.request_uri, path
request = Net::HTTP::Post.new(path)
_build_request resource, request
end
@@ -438,7 +433,7 @@ end
# the caller needs to do is call http.request, supplying the returned object
def _http_put resource, path
uri = ::URI.parse(resource.auth_uri)
path = _path uri, path
path = uri_join_paths uri.request_uri, path
request = Net::HTTP::Put.new(path)
_build_request resource, request
end
@@ -449,7 +444,7 @@ end
# the caller needs to do is call http.request, supplying the returned object
def _http_get resource, path
uri = ::URI.parse(resource.auth_uri)
path = _path uri, path
path = uri_join_paths uri.request_uri, path
request = Net::HTTP::Get.new(path)
_build_request resource, request
end