fog-openstack 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -28
- data/docs/workflow.md +129 -0
- data/examples/workflow/workflow-examples.rb +387 -0
- data/gemfiles/Gemfile-1.9 +1 -0
- data/lib/fog/openstack.rb +5 -1
- data/lib/fog/openstack/baremetal.rb +14 -38
- data/lib/fog/openstack/compute.rb +4 -33
- data/lib/fog/openstack/core.rb +104 -50
- data/lib/fog/openstack/identity.rb +2 -1
- data/lib/fog/openstack/identity_v2.rb +0 -2
- data/lib/fog/openstack/identity_v3.rb +0 -2
- data/lib/fog/openstack/image_v1.rb +6 -6
- data/lib/fog/openstack/image_v2.rb +7 -6
- data/lib/fog/openstack/introspection.rb +10 -35
- data/lib/fog/openstack/metering.rb +16 -35
- data/lib/fog/openstack/monitoring.rb +5 -31
- data/lib/fog/openstack/network.rb +5 -34
- data/lib/fog/openstack/nfv.rb +10 -35
- data/lib/fog/openstack/orchestration.rb +5 -40
- data/lib/fog/openstack/planning.rb +11 -36
- data/lib/fog/openstack/requests/compute/get_limits.rb +8 -7
- data/lib/fog/openstack/requests/network/update_router.rb +1 -1
- data/lib/fog/openstack/requests/workflow_v2/create_action.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/create_action_execution.rb +31 -0
- data/lib/fog/openstack/requests/workflow_v2/create_cron_trigger.rb +55 -0
- data/lib/fog/openstack/requests/workflow_v2/create_environment.rb +31 -0
- data/lib/fog/openstack/requests/workflow_v2/create_execution.rb +30 -0
- data/lib/fog/openstack/requests/workflow_v2/create_workbook.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/create_workflow.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/delete_action.rb +25 -0
- data/lib/fog/openstack/requests/workflow_v2/delete_action_execution.rb +25 -0
- data/lib/fog/openstack/requests/workflow_v2/delete_cron_trigger.rb +25 -0
- data/lib/fog/openstack/requests/workflow_v2/delete_environment.rb +25 -0
- data/lib/fog/openstack/requests/workflow_v2/delete_execution.rb +25 -0
- data/lib/fog/openstack/requests/workflow_v2/delete_workbook.rb +25 -0
- data/lib/fog/openstack/requests/workflow_v2/delete_workflow.rb +25 -0
- data/lib/fog/openstack/requests/workflow_v2/get_action.rb +27 -0
- data/lib/fog/openstack/requests/workflow_v2/get_action_execution.rb +26 -0
- data/lib/fog/openstack/requests/workflow_v2/get_cron_trigger.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/get_environment.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/get_execution.rb +26 -0
- data/lib/fog/openstack/requests/workflow_v2/get_task.rb +27 -0
- data/lib/fog/openstack/requests/workflow_v2/get_workbook.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/get_workflow.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/list_action_executions.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/list_actions.rb +30 -0
- data/lib/fog/openstack/requests/workflow_v2/list_cron_triggers.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/list_environments.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/list_executions.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/list_services.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/list_tasks.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/list_workbooks.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/list_workflows.rb +30 -0
- data/lib/fog/openstack/requests/workflow_v2/rerun_task.rb +33 -0
- data/lib/fog/openstack/requests/workflow_v2/update_action.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/update_action_execution.rb +33 -0
- data/lib/fog/openstack/requests/workflow_v2/update_environment.rb +31 -0
- data/lib/fog/openstack/requests/workflow_v2/update_execution.rb +33 -0
- data/lib/fog/openstack/requests/workflow_v2/update_workbook.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/update_workflow.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/validate_action.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/validate_workbook.rb +28 -0
- data/lib/fog/openstack/requests/workflow_v2/validate_workflow.rb +28 -0
- data/lib/fog/openstack/storage.rb +4 -35
- data/lib/fog/openstack/version.rb +1 -1
- data/lib/fog/openstack/volume_v1.rb +7 -5
- data/lib/fog/openstack/volume_v2.rb +7 -5
- data/lib/fog/openstack/workflow.rb +12 -0
- data/lib/fog/openstack/workflow_v2.rb +160 -0
- metadata +48 -95
- data/lib/fog/openstack/common.rb +0 -44
- data/tests/openstack/models/compute/images_tests.rb +0 -13
- data/tests/openstack/models/compute/security_group_tests.rb +0 -54
- data/tests/openstack/models/compute/server_tests.rb +0 -220
- data/tests/openstack/models/compute/service_tests.rb +0 -17
- data/tests/openstack/models/image/image_tests.rb +0 -36
- data/tests/openstack/models/image/images_tests.rb +0 -19
- data/tests/openstack/models/network/floating_ip_tests.rb +0 -35
- data/tests/openstack/models/network/floating_ips_tests.rb +0 -19
- data/tests/openstack/models/network/ike_policies_tests.rb +0 -28
- data/tests/openstack/models/network/ike_policy_tests.rb +0 -36
- data/tests/openstack/models/network/ipsec_policies_tests.rb +0 -26
- data/tests/openstack/models/network/ipsec_policy_tests.rb +0 -36
- data/tests/openstack/models/network/ipsec_site_connection_tests.rb +0 -50
- data/tests/openstack/models/network/ipsec_site_connections_tests.rb +0 -32
- data/tests/openstack/models/network/lb_health_monitor_tests.rb +0 -52
- data/tests/openstack/models/network/lb_health_monitors_tests.rb +0 -21
- data/tests/openstack/models/network/lb_member_tests.rb +0 -28
- data/tests/openstack/models/network/lb_members_tests.rb +0 -21
- data/tests/openstack/models/network/lb_pool_tests.rb +0 -53
- data/tests/openstack/models/network/lb_pools_tests.rb +0 -20
- data/tests/openstack/models/network/lb_vip_tests.rb +0 -39
- data/tests/openstack/models/network/lb_vips_tests.rb +0 -21
- data/tests/openstack/models/network/network_tests.rb +0 -61
- data/tests/openstack/models/network/networks_tests.rb +0 -21
- data/tests/openstack/models/network/port_tests.rb +0 -28
- data/tests/openstack/models/network/ports_tests.rb +0 -25
- data/tests/openstack/models/network/router_tests.rb +0 -39
- data/tests/openstack/models/network/routers_tests.rb +0 -21
- data/tests/openstack/models/network/security_group_rule_tests.rb +0 -27
- data/tests/openstack/models/network/security_group_rules_tests.rb +0 -25
- data/tests/openstack/models/network/security_group_tests.rb +0 -17
- data/tests/openstack/models/network/security_groups_tests.rb +0 -16
- data/tests/openstack/models/network/subnet_tests.rb +0 -30
- data/tests/openstack/models/network/subnets_tests.rb +0 -27
- data/tests/openstack/models/network/vpn_service_tests.rb +0 -27
- data/tests/openstack/models/network/vpn_services_tests.rb +0 -22
- data/tests/openstack/models/nfv/vnf_tests.rb +0 -35
- data/tests/openstack/models/nfv/vnfd_tests.rb +0 -23
- data/tests/openstack/models/nfv/vnfds_tests.rb +0 -31
- data/tests/openstack/models/nfv/vnfs_tests.rb +0 -38
- data/tests/openstack/models/planning/.gitkeep +0 -0
- data/tests/openstack/models/planning/plan_tests.rb +0 -51
- data/tests/openstack/models/planning/plans_tests.rb +0 -18
- data/tests/openstack/models/planning/role_tests.rb +0 -14
- data/tests/openstack/models/storage/file_tests.rb +0 -251
- data/tests/openstack/requests/compute/address_tests.rb +0 -58
- data/tests/openstack/requests/compute/aggregate_tests.rb +0 -59
- data/tests/openstack/requests/compute/availability_zone_tests.rb +0 -18
- data/tests/openstack/requests/compute/flavor_tests.rb +0 -95
- data/tests/openstack/requests/compute/helper.rb +0 -41
- data/tests/openstack/requests/compute/image_tests.rb +0 -58
- data/tests/openstack/requests/compute/keypair_tests.rb +0 -30
- data/tests/openstack/requests/compute/limit_tests.rb +0 -59
- data/tests/openstack/requests/compute/quota_tests.rb +0 -60
- data/tests/openstack/requests/compute/security_group_tests.rb +0 -61
- data/tests/openstack/requests/compute/server_tests.rb +0 -289
- data/tests/openstack/requests/compute/service_tests.rb +0 -33
- data/tests/openstack/requests/compute/tenant_tests.rb +0 -19
- data/tests/openstack/requests/compute/volume_tests.rb +0 -38
- data/tests/openstack/requests/image/image_tests.rb +0 -135
- data/tests/openstack/requests/metering/event_tests.rb +0 -17
- data/tests/openstack/requests/metering/meter_tests.rb +0 -52
- data/tests/openstack/requests/metering/resource_tests.rb +0 -19
- data/tests/openstack/requests/network/ike_policy_tests.rb +0 -65
- data/tests/openstack/requests/network/ipsec_policy_tests.rb +0 -65
- data/tests/openstack/requests/network/ipsec_site_connection_tests.rb +0 -82
- data/tests/openstack/requests/network/lb_health_monitor_tests.rb +0 -93
- data/tests/openstack/requests/network/lb_member_tests.rb +0 -60
- data/tests/openstack/requests/network/lb_pool_tests.rb +0 -80
- data/tests/openstack/requests/network/lb_vip_tests.rb +0 -71
- data/tests/openstack/requests/network/network_tests.rb +0 -107
- data/tests/openstack/requests/network/port_tests.rb +0 -66
- data/tests/openstack/requests/network/quota_tests.rb +0 -65
- data/tests/openstack/requests/network/router_tests.rb +0 -73
- data/tests/openstack/requests/network/security_group_rule_tests.rb +0 -58
- data/tests/openstack/requests/network/security_group_tests.rb +0 -43
- data/tests/openstack/requests/network/subnet_tests.rb +0 -66
- data/tests/openstack/requests/network/vpn_service_tests.rb +0 -61
- data/tests/openstack/requests/nfv/vnf_tests.rb +0 -70
- data/tests/openstack/requests/nfv/vnfd_tests.rb +0 -44
- data/tests/openstack/requests/orchestration/stack_tests.rb +0 -64
- data/tests/openstack/requests/planning/.gitkeep +0 -0
- data/tests/openstack/requests/planning/plan_tests.rb +0 -65
- data/tests/openstack/requests/planning/role_tests.rb +0 -16
- data/tests/openstack/requests/storage/container_tests.rb +0 -64
- data/tests/openstack/requests/storage/large_object_tests.rb +0 -372
- data/tests/openstack/requests/storage/object_tests.rb +0 -208
- data/tests/openstack/requests/volume/availability_zone_tests.rb +0 -13
- data/tests/openstack/requests/volume/quota_tests.rb +0 -50
- data/tests/openstack/requests/volume/volume_type_tests.rb +0 -32
data/gemfiles/Gemfile-1.9
CHANGED
data/lib/fog/openstack.rb
CHANGED
@@ -3,7 +3,6 @@ require 'fog/core'
|
|
3
3
|
require 'fog/json'
|
4
4
|
|
5
5
|
require 'fog/openstack/core'
|
6
|
-
require 'fog/openstack/common'
|
7
6
|
require 'fog/openstack/errors'
|
8
7
|
|
9
8
|
require 'fog/openstack/compute'
|
@@ -62,6 +61,10 @@ module Fog
|
|
62
61
|
autoload :OpenStack, File.expand_path('../fog/openstack/monitoring', __FILE__)
|
63
62
|
end
|
64
63
|
|
64
|
+
module Workflow
|
65
|
+
autoload :OpenStack, File.expand_path('../openstack/workflow', __FILE__)
|
66
|
+
end
|
67
|
+
|
65
68
|
module OpenStack
|
66
69
|
extend Fog::Provider
|
67
70
|
|
@@ -78,6 +81,7 @@ module Fog
|
|
78
81
|
service(:planning, 'Planning')
|
79
82
|
service(:introspection, 'Introspection')
|
80
83
|
service(:monitoring, 'Monitoring')
|
84
|
+
service(:workflow, 'Workflow')
|
81
85
|
|
82
86
|
@@token_cache = {}
|
83
87
|
|
@@ -248,7 +248,12 @@ module Fog
|
|
248
248
|
class Real
|
249
249
|
include Fog::OpenStack::Core
|
250
250
|
|
251
|
-
|
251
|
+
# NOTE: uncommenting this should be treated as api-change!
|
252
|
+
# def self.not_found_class
|
253
|
+
# Fog::Baremetal::OpenStack::NotFound
|
254
|
+
# end
|
255
|
+
|
256
|
+
def initialize(options = {})
|
252
257
|
initialize_identity options
|
253
258
|
|
254
259
|
@openstack_service_type = options[:openstack_service_type] || ['baremetal']
|
@@ -257,51 +262,22 @@ module Fog
|
|
257
262
|
@connection_options = options[:connection_options] || {}
|
258
263
|
|
259
264
|
authenticate
|
265
|
+
set_api_path
|
260
266
|
|
267
|
+
@persistent = options[:persistent] || false
|
268
|
+
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
269
|
+
end
|
270
|
+
|
271
|
+
private
|
272
|
+
|
273
|
+
def set_api_path
|
261
274
|
unless @path.match(SUPPORTED_VERSIONS)
|
262
275
|
@path = "/" + Fog::OpenStack.get_supported_version(SUPPORTED_VERSIONS,
|
263
276
|
@openstack_management_uri,
|
264
277
|
@auth_token,
|
265
278
|
@connection_options)
|
266
279
|
end
|
267
|
-
|
268
|
-
@persistent = options[:persistent] || false
|
269
|
-
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
270
|
-
end
|
271
|
-
|
272
|
-
def request(params)
|
273
|
-
begin
|
274
|
-
response = @connection.request(params.merge({
|
275
|
-
:headers => {
|
276
|
-
'Content-Type' => 'application/json',
|
277
|
-
'X-Auth-Token' => @auth_token
|
278
|
-
}.merge!(params[:headers] || {}),
|
279
|
-
:path => "#{@path}/#{params[:path]}"#,
|
280
|
-
}))
|
281
|
-
rescue Excon::Errors::Unauthorized => error
|
282
|
-
if error.response.body != 'Bad username or password' # token expiration
|
283
|
-
@openstack_must_reauthenticate = true
|
284
|
-
authenticate
|
285
|
-
retry
|
286
|
-
else # bad credentials
|
287
|
-
raise error
|
288
|
-
end
|
289
|
-
rescue Excon::Errors::HTTPStatusError => error
|
290
|
-
raise case error
|
291
|
-
when Excon::Errors::NotFound
|
292
|
-
Fog::Compute::OpenStack::NotFound.slurp(error)
|
293
|
-
else
|
294
|
-
error
|
295
|
-
end
|
296
|
-
end
|
297
|
-
unless response.body.empty?
|
298
|
-
response.body = Fog::JSON.decode(response.body)
|
299
|
-
end
|
300
|
-
response
|
301
280
|
end
|
302
|
-
|
303
|
-
private
|
304
|
-
|
305
281
|
end
|
306
282
|
end
|
307
283
|
end
|
@@ -341,6 +341,10 @@ module Fog
|
|
341
341
|
class Real
|
342
342
|
include Fog::OpenStack::Core
|
343
343
|
|
344
|
+
def self.not_found_class
|
345
|
+
Fog::Compute::OpenStack::NotFound
|
346
|
+
end
|
347
|
+
|
344
348
|
def initialize(options = {})
|
345
349
|
initialize_identity options
|
346
350
|
|
@@ -361,39 +365,6 @@ module Fog
|
|
361
365
|
@persistent = options[:persistent] || false
|
362
366
|
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
363
367
|
end
|
364
|
-
|
365
|
-
def request(params)
|
366
|
-
begin
|
367
|
-
response = @connection.request(params.merge(:headers => {
|
368
|
-
'Content-Type' => 'application/json',
|
369
|
-
'Accept' => 'application/json',
|
370
|
-
'X-Auth-Token' => @auth_token
|
371
|
-
}.merge!(params[:headers] || {}),
|
372
|
-
:path => "#{@path}/#{params[:path]}",
|
373
|
-
:query => params[:query]))
|
374
|
-
rescue Excon::Errors::Unauthorized => error
|
375
|
-
if error.response.body != 'Bad username or password' # token expiration
|
376
|
-
@openstack_must_reauthenticate = true
|
377
|
-
authenticate
|
378
|
-
retry
|
379
|
-
else # Bad Credentials
|
380
|
-
raise error
|
381
|
-
end
|
382
|
-
rescue Excon::Errors::HTTPStatusError => error
|
383
|
-
raise case error
|
384
|
-
when Excon::Errors::NotFound
|
385
|
-
Fog::Compute::OpenStack::NotFound.slurp(error)
|
386
|
-
else
|
387
|
-
error
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
if !response.body.empty? && response.get_header('Content-Type') == 'application/json'
|
392
|
-
response.body = Fog::JSON.decode(response.body)
|
393
|
-
end
|
394
|
-
|
395
|
-
response
|
396
|
-
end
|
397
368
|
end
|
398
369
|
end
|
399
370
|
end
|
data/lib/fog/openstack/core.rb
CHANGED
@@ -2,6 +2,7 @@ module Fog
|
|
2
2
|
module OpenStack
|
3
3
|
module Core
|
4
4
|
attr_accessor :auth_token
|
5
|
+
attr_reader :unscoped_token
|
5
6
|
attr_reader :openstack_cache_ttl
|
6
7
|
attr_reader :auth_token_expiration
|
7
8
|
attr_reader :current_user
|
@@ -16,39 +17,46 @@ module Fog
|
|
16
17
|
attr_reader :openstack_project_domain_id
|
17
18
|
attr_reader :openstack_identity_prefix
|
18
19
|
|
19
|
-
|
20
|
+
# fallback
|
21
|
+
def self.not_found_class
|
22
|
+
Fog::Compute::OpenStack::NotFound
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize_identity(options)
|
20
26
|
# Create @openstack_* instance variables from all :openstack_* options
|
21
|
-
options.select{|x|x.to_s.start_with? 'openstack'}.each do |openstack_param, value|
|
27
|
+
options.select { |x| x.to_s.start_with? 'openstack' }.each do |openstack_param, value|
|
22
28
|
instance_variable_set "@#{openstack_param}".to_sym, value
|
23
29
|
end
|
24
30
|
|
25
|
-
@auth_token
|
31
|
+
@auth_token ||= options[:openstack_auth_token]
|
26
32
|
@openstack_identity_public_endpoint = options[:openstack_identity_endpoint]
|
27
33
|
|
28
|
-
@openstack_auth_uri
|
29
|
-
@openstack_must_reauthenticate
|
34
|
+
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
35
|
+
@openstack_must_reauthenticate = false
|
30
36
|
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'publicURL'
|
31
37
|
|
32
38
|
@openstack_cache_ttl = options[:openstack_cache_ttl] || 0
|
33
39
|
|
34
|
-
|
35
|
-
|
40
|
+
if @auth_token
|
41
|
+
@openstack_can_reauthenticate = false
|
42
|
+
else
|
43
|
+
missing_credentials = []
|
36
44
|
|
37
45
|
missing_credentials << :openstack_api_key unless @openstack_api_key
|
38
46
|
unless @openstack_username || @openstack_userid
|
39
47
|
missing_credentials << 'openstack_username or openstack_userid'
|
40
48
|
end
|
41
49
|
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
50
|
+
@openstack_can_reauthenticate = true
|
42
51
|
end
|
43
52
|
|
44
53
|
@current_user = options[:current_user]
|
45
54
|
@current_user_id = options[:current_user_id]
|
46
55
|
@current_tenant = options[:current_tenant]
|
47
|
-
|
48
56
|
end
|
49
57
|
|
50
58
|
def credentials
|
51
|
-
options =
|
59
|
+
options = {
|
52
60
|
:provider => 'openstack',
|
53
61
|
:openstack_auth_url => @openstack_auth_uri.to_s,
|
54
62
|
:openstack_auth_token => @auth_token,
|
@@ -56,63 +64,109 @@ module Fog
|
|
56
64
|
:current_user => @current_user,
|
57
65
|
:current_user_id => @current_user_id,
|
58
66
|
:current_tenant => @current_tenant,
|
59
|
-
:unscoped_token => @unscoped_token
|
60
|
-
|
67
|
+
:unscoped_token => @unscoped_token
|
68
|
+
}
|
69
|
+
openstack_options.merge options
|
70
|
+
end
|
71
|
+
|
72
|
+
def reload
|
73
|
+
@connection.reset
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def request(params, parse_json = true)
|
79
|
+
retried = false
|
80
|
+
begin
|
81
|
+
response = @connection.request(params.merge(
|
82
|
+
:headers => {
|
83
|
+
'Content-Type' => 'application/json',
|
84
|
+
'Accept' => 'application/json',
|
85
|
+
'X-Auth-Token' => @auth_token
|
86
|
+
}.merge!(params[:headers] || {}),
|
87
|
+
:path => "#{@path}/#{params[:path]}"
|
88
|
+
))
|
89
|
+
rescue Excon::Errors::Unauthorized => error
|
90
|
+
# token expiration and token renewal possible
|
91
|
+
if error.response.body != 'Bad username or password' && @openstack_can_reauthenticate && !retried
|
92
|
+
@openstack_must_reauthenticate = true
|
93
|
+
authenticate
|
94
|
+
set_api_path
|
95
|
+
retried = true
|
96
|
+
retry
|
97
|
+
# bad credentials or token renewal not possible
|
98
|
+
else
|
99
|
+
raise error
|
100
|
+
end
|
101
|
+
rescue Excon::Errors::HTTPStatusError => error
|
102
|
+
raise case error
|
103
|
+
when Excon::Errors::NotFound
|
104
|
+
self.class.not_found_class.slurp(error)
|
105
|
+
else
|
106
|
+
error
|
107
|
+
end
|
61
108
|
end
|
62
109
|
|
63
|
-
|
64
|
-
|
110
|
+
if !response.body.empty? && response.get_header('Content-Type').match('application/json')
|
111
|
+
# TODO: remove parse_json in favor of :raw_body
|
112
|
+
response.body = Fog::JSON.decode(response.body) if parse_json && !params[:raw_body]
|
65
113
|
end
|
66
114
|
|
67
|
-
|
115
|
+
response
|
116
|
+
end
|
117
|
+
|
118
|
+
def set_api_path
|
119
|
+
# if the service supports multiple versions, do the selection here
|
120
|
+
end
|
68
121
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
options
|
122
|
+
def openstack_options
|
123
|
+
options = {}
|
124
|
+
# Create a hash of (:openstack_*, value) of all the @openstack_* instance variables
|
125
|
+
instance_variables.select { |x| x.to_s.start_with? '@openstack' }.each do |openstack_param|
|
126
|
+
option_name = openstack_param.to_s[1..-1]
|
127
|
+
options[option_name.to_sym] = instance_variable_get openstack_param
|
77
128
|
end
|
129
|
+
options
|
130
|
+
end
|
78
131
|
|
79
|
-
|
80
|
-
|
132
|
+
def authenticate
|
133
|
+
if !@openstack_management_url || @openstack_must_reauthenticate
|
81
134
|
|
82
|
-
|
135
|
+
options = openstack_options
|
83
136
|
|
84
|
-
|
137
|
+
options[:openstack_auth_token] = @openstack_must_reauthenticate ? nil : @openstack_auth_token
|
85
138
|
|
86
|
-
|
139
|
+
credentials = Fog::OpenStack.authenticate(options, @connection_options)
|
87
140
|
|
88
|
-
|
89
|
-
|
90
|
-
|
141
|
+
@current_user = credentials[:user]
|
142
|
+
@current_user_id = credentials[:current_user_id]
|
143
|
+
@current_tenant = credentials[:tenant]
|
91
144
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
145
|
+
@openstack_must_reauthenticate = false
|
146
|
+
@auth_token = credentials[:token]
|
147
|
+
@openstack_management_url = credentials[:server_management_url]
|
148
|
+
@unscoped_token = credentials[:unscoped_token]
|
149
|
+
else
|
150
|
+
@auth_token = @openstack_auth_token
|
151
|
+
end
|
152
|
+
@openstack_management_uri = URI.parse(@openstack_management_url)
|
100
153
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
154
|
+
@host = @openstack_management_uri.host
|
155
|
+
@path = @openstack_management_uri.path
|
156
|
+
@path.sub!(%r{/$}, '')
|
157
|
+
@port = @openstack_management_uri.port
|
158
|
+
@scheme = @openstack_management_uri.scheme
|
106
159
|
|
107
|
-
|
108
|
-
|
109
|
-
|
160
|
+
# Not all implementations have identity service in the catalog
|
161
|
+
if @openstack_identity_public_endpoint || @openstack_management_url
|
162
|
+
@identity_connection = Fog::Core::Connection.new(
|
110
163
|
@openstack_identity_public_endpoint || @openstack_management_url,
|
111
|
-
false, @connection_options
|
112
|
-
|
113
|
-
|
114
|
-
true
|
164
|
+
false, @connection_options
|
165
|
+
)
|
115
166
|
end
|
167
|
+
|
168
|
+
true
|
116
169
|
end
|
117
170
|
end
|
118
171
|
end
|
172
|
+
end
|
@@ -42,13 +42,14 @@ module Fog
|
|
42
42
|
end
|
43
43
|
|
44
44
|
class Real
|
45
|
+
include Fog::OpenStack::Core
|
46
|
+
|
45
47
|
DEFAULT_SERVICE_TYPE_V3 = %w(identity_v3 identityv3 identity).collect(&:freeze).freeze
|
46
48
|
DEFAULT_SERVICE_TYPE = %w(identity).collect(&:freeze).freeze
|
47
49
|
|
48
50
|
def self.not_found_class
|
49
51
|
Fog::Identity::OpenStack::NotFound
|
50
52
|
end
|
51
|
-
include Fog::OpenStack::Common
|
52
53
|
|
53
54
|
def initialize(options = {})
|
54
55
|
if options.respond_to?(:config_service?) && options.config_service?
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'fog/openstack/common'
|
2
|
-
|
3
1
|
require 'fog/openstack/image'
|
4
2
|
|
5
3
|
module Fog
|
@@ -103,7 +101,6 @@ module Fog
|
|
103
101
|
def self.not_found_class
|
104
102
|
Fog::Image::OpenStack::NotFound
|
105
103
|
end
|
106
|
-
include Fog::OpenStack::Common
|
107
104
|
|
108
105
|
def initialize(options = {})
|
109
106
|
initialize_identity options
|
@@ -115,16 +112,19 @@ module Fog
|
|
115
112
|
@connection_options = options[:connection_options] || {}
|
116
113
|
|
117
114
|
authenticate
|
115
|
+
set_api_path
|
116
|
+
|
117
|
+
@persistent = options[:persistent] || false
|
118
|
+
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
119
|
+
end
|
118
120
|
|
121
|
+
def set_api_path
|
119
122
|
unless @path.match(SUPPORTED_VERSIONS)
|
120
123
|
@path = Fog::OpenStack.get_supported_version_path(SUPPORTED_VERSIONS,
|
121
124
|
@openstack_management_uri,
|
122
125
|
@auth_token,
|
123
126
|
@connection_options)
|
124
127
|
end
|
125
|
-
|
126
|
-
@persistent = options[:persistent] || false
|
127
|
-
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'fog/openstack/common'
|
2
|
-
|
3
1
|
require 'fog/openstack/image'
|
4
2
|
|
5
3
|
module Fog
|
@@ -107,10 +105,10 @@ module Fog
|
|
107
105
|
|
108
106
|
class Real
|
109
107
|
include Fog::OpenStack::Core
|
108
|
+
|
110
109
|
def self.not_found_class
|
111
110
|
Fog::Image::OpenStack::NotFound
|
112
111
|
end
|
113
|
-
include Fog::OpenStack::Common
|
114
112
|
|
115
113
|
def initialize(options = {})
|
116
114
|
initialize_identity options
|
@@ -122,16 +120,19 @@ module Fog
|
|
122
120
|
@connection_options = options[:connection_options] || {}
|
123
121
|
|
124
122
|
authenticate
|
123
|
+
set_api_path
|
125
124
|
|
125
|
+
@persistent = options[:persistent] || false
|
126
|
+
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
127
|
+
end
|
128
|
+
|
129
|
+
def set_api_path
|
126
130
|
unless @path.match(SUPPORTED_VERSIONS)
|
127
131
|
@path = Fog::OpenStack.get_supported_version_path(SUPPORTED_VERSIONS,
|
128
132
|
@openstack_management_uri,
|
129
133
|
@auth_token,
|
130
134
|
@connection_options)
|
131
135
|
end
|
132
|
-
|
133
|
-
@persistent = options[:persistent] || false
|
134
|
-
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
135
136
|
end
|
136
137
|
end
|
137
138
|
end
|