mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[openstack] Update Reinitialization Process of Existing Auth Token
This commit is contained in:
parent
df3c374e33
commit
c643bd8e03
3 changed files with 45 additions and 17 deletions
|
@ -6,9 +6,10 @@ module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class OpenStack < Fog::Service
|
class OpenStack < Fog::Service
|
||||||
|
|
||||||
requires :openstack_api_key, :openstack_username, :openstack_auth_url
|
requires :openstack_auth_url
|
||||||
recognizes :openstack_auth_token, :openstack_management_url,
|
recognizes :openstack_auth_token, :openstack_management_url,
|
||||||
:persistent, :openstack_service_name, :openstack_tenant
|
:persistent, :openstack_service_name, :openstack_tenant,
|
||||||
|
:openstack_api_key, :openstack_username
|
||||||
|
|
||||||
## MODELS
|
## MODELS
|
||||||
#
|
#
|
||||||
|
@ -190,11 +191,20 @@ module Fog
|
||||||
attr_reader :auth_token
|
attr_reader :auth_token
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
@openstack_api_key = options[:openstack_api_key]
|
@openstack_auth_token = options[:openstack_auth_token]
|
||||||
@openstack_username = options[:openstack_username]
|
|
||||||
|
unless @openstack_auth_token
|
||||||
|
missing_credentials = Array.new
|
||||||
|
@openstack_api_key = options[:openstack_api_key]
|
||||||
|
@openstack_username = options[:openstack_username]
|
||||||
|
|
||||||
|
missing_credentials << :openstack_api_key unless @openstack_api_key
|
||||||
|
missing_credentials << :openstack_username unless @openstack_username
|
||||||
|
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
||||||
|
end
|
||||||
|
|
||||||
@openstack_tenant = options[:openstack_tenant]
|
@openstack_tenant = options[:openstack_tenant]
|
||||||
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
||||||
@openstack_auth_token = options[:openstack_auth_token]
|
|
||||||
@openstack_management_url = options[:openstack_management_url]
|
@openstack_management_url = options[:openstack_management_url]
|
||||||
@openstack_must_reauthenticate = false
|
@openstack_must_reauthenticate = false
|
||||||
@openstack_service_name = options[:openstack_service_name] || ['nova', 'compute']
|
@openstack_service_name = options[:openstack_service_name] || ['nova', 'compute']
|
||||||
|
|
|
@ -5,9 +5,10 @@ module Fog
|
||||||
module Identity
|
module Identity
|
||||||
class OpenStack < Fog::Service
|
class OpenStack < Fog::Service
|
||||||
|
|
||||||
requires :openstack_api_key, :openstack_username, :openstack_auth_url
|
requires :openstack_auth_url
|
||||||
recognizes :openstack_auth_token, :openstack_management_url, :persistent,
|
recognizes :openstack_auth_token, :openstack_management_url, :persistent,
|
||||||
:openstack_service_name, :openstack_tenant
|
:openstack_service_name, :openstack_tenant,
|
||||||
|
:openstack_api_key, :openstack_username
|
||||||
|
|
||||||
model_path 'fog/openstack/models/identity'
|
model_path 'fog/openstack/models/identity'
|
||||||
model :tenant
|
model :tenant
|
||||||
|
@ -49,7 +50,6 @@ module Fog
|
||||||
request :list_roles
|
request :list_roles
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def self.data
|
def self.data
|
||||||
@data ||= Hash.new do |hash, key|
|
@data ||= Hash.new do |hash, key|
|
||||||
|
@ -84,11 +84,20 @@ module Fog
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
require 'multi_json'
|
||||||
|
|
||||||
@openstack_api_key = options[:openstack_api_key]
|
@openstack_auth_token = options[:openstack_auth_token]
|
||||||
@openstack_username = options[:openstack_username]
|
|
||||||
|
unless @openstack_auth_token
|
||||||
|
missing_credentials = Array.new
|
||||||
|
@openstack_api_key = options[:openstack_api_key]
|
||||||
|
@openstack_username = options[:openstack_username]
|
||||||
|
|
||||||
|
missing_credentials << :openstack_api_key unless @openstack_api_key
|
||||||
|
missing_credentials << :openstack_username unless @openstack_username
|
||||||
|
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
||||||
|
end
|
||||||
|
|
||||||
@openstack_tenant = options[:openstack_tenant]
|
@openstack_tenant = options[:openstack_tenant]
|
||||||
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
||||||
@openstack_auth_token = options[:openstack_auth_token]
|
|
||||||
@openstack_management_url = options[:openstack_management_url]
|
@openstack_management_url = options[:openstack_management_url]
|
||||||
@openstack_must_reauthenticate = false
|
@openstack_must_reauthenticate = false
|
||||||
@openstack_service_name = options[:openstack_service_name] || ['identity']
|
@openstack_service_name = options[:openstack_service_name] || ['identity']
|
||||||
|
|
|
@ -5,9 +5,10 @@ module Fog
|
||||||
module Image
|
module Image
|
||||||
class OpenStack < Fog::Service
|
class OpenStack < Fog::Service
|
||||||
|
|
||||||
requires :openstack_api_key, :openstack_username, :openstack_auth_url
|
requires :openstack_auth_url
|
||||||
recognizes :openstack_auth_token, :openstack_management_url, :persistent,
|
recognizes :openstack_auth_token, :openstack_management_url, :persistent,
|
||||||
:openstack_service_name, :openstack_tenant
|
:openstack_service_name, :openstack_tenant,
|
||||||
|
:openstack_api_key, :openstack_username
|
||||||
|
|
||||||
model_path 'fog/openstack/models/image'
|
model_path 'fog/openstack/models/image'
|
||||||
|
|
||||||
|
@ -29,7 +30,6 @@ module Fog
|
||||||
request :delete_image
|
request :delete_image
|
||||||
request :get_image_by_id
|
request :get_image_by_id
|
||||||
|
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def self.data
|
def self.data
|
||||||
@data ||= Hash.new do |hash, key|
|
@data ||= Hash.new do |hash, key|
|
||||||
|
@ -63,10 +63,19 @@ module Fog
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
require 'multi_json'
|
||||||
|
|
||||||
@openstack_api_key = options[:openstack_api_key]
|
|
||||||
@openstack_username = options[:openstack_username]
|
|
||||||
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
|
||||||
@openstack_auth_token = options[:openstack_auth_token]
|
@openstack_auth_token = options[:openstack_auth_token]
|
||||||
|
|
||||||
|
unless @openstack_auth_token
|
||||||
|
missing_credentials = Array.new
|
||||||
|
@openstack_api_key = options[:openstack_api_key]
|
||||||
|
@openstack_username = options[:openstack_username]
|
||||||
|
|
||||||
|
missing_credentials << :openstack_api_key unless @openstack_api_key
|
||||||
|
missing_credentials << :openstack_username unless @openstack_username
|
||||||
|
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
||||||
@openstack_management_url = options[:openstack_management_url]
|
@openstack_management_url = options[:openstack_management_url]
|
||||||
@openstack_must_reauthenticate = false
|
@openstack_must_reauthenticate = false
|
||||||
@openstack_service_name = options[:openstack_service_name] || ['image']
|
@openstack_service_name = options[:openstack_service_name] || ['image']
|
||||||
|
|
Loading…
Reference in a new issue