fog 1.31.0 → 1.32.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +53 -0
- data/Rakefile +5 -5
- data/fog.gemspec +6 -5
- data/lib/fog/cloudstack/models/compute/network.rb +1 -0
- data/lib/fog/openstack/compute.rb +41 -98
- data/lib/fog/openstack/core.rb +257 -118
- data/lib/fog/openstack/identity.rb +4 -0
- data/lib/fog/openstack/identity_v3.rb +10 -41
- data/lib/fog/openstack/models/baremetal/chassis_collection.rb +10 -4
- data/lib/fog/openstack/models/baremetal/drivers.rb +4 -2
- data/lib/fog/openstack/models/baremetal/nodes.rb +10 -4
- data/lib/fog/openstack/models/baremetal/ports.rb +10 -4
- data/lib/fog/openstack/models/compute/addresses.rb +4 -2
- data/lib/fog/openstack/models/compute/aggregate.rb +64 -0
- data/lib/fog/openstack/models/compute/aggregates.rb +28 -0
- data/lib/fog/openstack/models/compute/flavors.rb +5 -0
- data/lib/fog/openstack/models/compute/hosts.rb +4 -2
- data/lib/fog/openstack/models/compute/images.rb +2 -0
- data/lib/fog/openstack/models/compute/key_pairs.rb +4 -2
- data/lib/fog/openstack/models/compute/security_groups.rb +4 -2
- data/lib/fog/openstack/models/compute/servers.rb +2 -0
- data/lib/fog/openstack/models/compute/services.rb +7 -4
- data/lib/fog/openstack/models/compute/snapshots.rb +15 -2
- data/lib/fog/openstack/models/compute/volumes.rb +15 -2
- data/lib/fog/openstack/models/identity_v2/ec2_credentials.rb +6 -3
- data/lib/fog/openstack/models/identity_v2/roles.rb +5 -3
- data/lib/fog/openstack/models/identity_v2/tenants.rb +5 -3
- data/lib/fog/openstack/models/identity_v2/users.rb +7 -3
- data/lib/fog/openstack/models/identity_v3/domains.rb +7 -6
- data/lib/fog/openstack/models/identity_v3/endpoints.rb +5 -4
- data/lib/fog/openstack/models/identity_v3/groups.rb +5 -3
- data/lib/fog/openstack/models/identity_v3/os_credentials.rb +5 -3
- data/lib/fog/openstack/models/identity_v3/policies.rb +5 -3
- data/lib/fog/openstack/models/identity_v3/project.rb +1 -0
- data/lib/fog/openstack/models/identity_v3/projects.rb +7 -5
- data/lib/fog/openstack/models/identity_v3/role_assignments.rb +10 -5
- data/lib/fog/openstack/models/identity_v3/roles.rb +11 -5
- data/lib/fog/openstack/models/identity_v3/services.rb +5 -3
- data/lib/fog/openstack/models/identity_v3/users.rb +4 -2
- data/lib/fog/openstack/models/image/images.rb +10 -4
- data/lib/fog/openstack/models/network/floating_ips.rb +2 -0
- data/lib/fog/openstack/models/network/lb_health_monitors.rb +2 -0
- data/lib/fog/openstack/models/network/lb_members.rb +2 -0
- data/lib/fog/openstack/models/network/lb_pools.rb +2 -0
- data/lib/fog/openstack/models/network/lb_vips.rb +2 -0
- data/lib/fog/openstack/models/network/networks.rb +2 -0
- data/lib/fog/openstack/models/network/port.rb +1 -0
- data/lib/fog/openstack/models/network/ports.rb +2 -0
- data/lib/fog/openstack/models/network/routers.rb +2 -0
- data/lib/fog/openstack/models/network/security_group_rules.rb +2 -0
- data/lib/fog/openstack/models/network/security_groups.rb +2 -0
- data/lib/fog/openstack/models/network/subnets.rb +2 -0
- data/lib/fog/openstack/models/orchestration/events.rb +10 -6
- data/lib/fog/openstack/models/orchestration/resources.rb +4 -2
- data/lib/fog/openstack/models/orchestration/stack.rb +1 -1
- data/lib/fog/openstack/models/orchestration/stacks.rb +9 -1
- data/lib/fog/openstack/models/planning/plans.rb +4 -2
- data/lib/fog/openstack/models/planning/roles.rb +5 -2
- data/lib/fog/openstack/models/storage/directories.rb +4 -2
- data/lib/fog/openstack/models/storage/files.rb +2 -0
- data/lib/fog/openstack/models/volume/volume.rb +1 -0
- data/lib/fog/openstack/models/volume/volume_types.rb +2 -0
- data/lib/fog/openstack/models/volume/volumes.rb +13 -2
- data/lib/fog/openstack/network.rb +18 -97
- data/lib/fog/openstack/orchestration.rb +2 -0
- data/lib/fog/openstack/requests/baremetal/list_chassis.rb +2 -8
- data/lib/fog/openstack/requests/baremetal/list_chassis_detailed.rb +3 -9
- data/lib/fog/openstack/requests/baremetal/list_drivers.rb +4 -3
- data/lib/fog/openstack/requests/baremetal/list_nodes.rb +3 -9
- data/lib/fog/openstack/requests/baremetal/list_nodes_detailed.rb +3 -9
- data/lib/fog/openstack/requests/baremetal/list_ports.rb +3 -9
- data/lib/fog/openstack/requests/baremetal/list_ports_detailed.rb +3 -9
- data/lib/fog/openstack/requests/compute/add_aggregate_host.rb +30 -0
- data/lib/fog/openstack/requests/compute/create_aggregate.rb +42 -0
- data/lib/fog/openstack/requests/compute/delete_aggregate.rb +28 -0
- data/lib/fog/openstack/requests/compute/get_aggregate.rb +26 -0
- data/lib/fog/openstack/requests/compute/list_aggregates.rb +36 -0
- data/lib/fog/openstack/requests/compute/list_all_addresses.rb +4 -3
- data/lib/fog/openstack/requests/compute/list_flavors.rb +6 -5
- data/lib/fog/openstack/requests/compute/list_hosts.rb +4 -3
- data/lib/fog/openstack/requests/compute/list_key_pairs.rb +4 -3
- data/lib/fog/openstack/requests/compute/list_security_groups.rb +15 -2
- data/lib/fog/openstack/requests/compute/list_snapshots.rb +18 -4
- data/lib/fog/openstack/requests/compute/list_snapshots_detail.rb +27 -0
- data/lib/fog/openstack/requests/compute/list_volumes.rb +18 -4
- data/lib/fog/openstack/requests/compute/list_volumes_detail.rb +25 -0
- data/lib/fog/openstack/requests/compute/remove_aggregate_host.rb +30 -0
- data/lib/fog/openstack/requests/compute/update_aggregate.rb +37 -0
- data/lib/fog/openstack/requests/compute/update_aggregate_metadata.rb +30 -0
- data/lib/fog/openstack/requests/identity_v2/list_ec2_credentials.rb +23 -7
- data/lib/fog/openstack/requests/identity_v2/list_roles.rb +5 -4
- data/lib/fog/openstack/requests/identity_v2/list_tenants.rb +14 -8
- data/lib/fog/openstack/requests/identity_v2/list_users.rb +16 -4
- data/lib/fog/openstack/requests/identity_v3/auth_domains.rb +2 -7
- data/lib/fog/openstack/requests/identity_v3/auth_projects.rb +6 -11
- data/lib/fog/openstack/requests/identity_v3/list_domains.rb +7 -14
- data/lib/fog/openstack/requests/identity_v3/list_endpoints.rb +7 -14
- data/lib/fog/openstack/requests/identity_v3/list_group_users.rb +5 -13
- data/lib/fog/openstack/requests/identity_v3/list_groups.rb +14 -24
- data/lib/fog/openstack/requests/identity_v3/list_os_credentials.rb +7 -12
- data/lib/fog/openstack/requests/identity_v3/list_policies.rb +7 -11
- data/lib/fog/openstack/requests/identity_v3/list_projects.rb +14 -25
- data/lib/fog/openstack/requests/identity_v3/list_role_assignments.rb +21 -17
- data/lib/fog/openstack/requests/identity_v3/list_roles.rb +7 -25
- data/lib/fog/openstack/requests/identity_v3/list_services.rb +7 -13
- data/lib/fog/openstack/requests/identity_v3/list_users.rb +7 -15
- data/lib/fog/openstack/requests/image/list_public_images.rb +4 -3
- data/lib/fog/openstack/requests/image/list_public_images_detailed.rb +9 -6
- data/lib/fog/openstack/requests/network/create_port.rb +12 -11
- data/lib/fog/openstack/requests/network/create_subnet.rb +7 -7
- data/lib/fog/openstack/requests/network/get_port.rb +1 -0
- data/lib/fog/openstack/requests/network/update_port.rb +7 -6
- data/lib/fog/openstack/requests/orchestration/list_events.rb +46 -0
- data/lib/fog/openstack/requests/orchestration/list_resource_events.rb +7 -2
- data/lib/fog/openstack/requests/orchestration/list_resource_types.rb +3 -2
- data/lib/fog/openstack/requests/orchestration/list_resources.rb +27 -4
- data/lib/fog/openstack/requests/orchestration/list_stack_data.rb +2 -2
- data/lib/fog/openstack/requests/orchestration/list_stack_data_detailed.rb +49 -0
- data/lib/fog/openstack/requests/orchestration/list_stack_events.rb +6 -2
- data/lib/fog/openstack/requests/planning/list_plans.rb +4 -3
- data/lib/fog/openstack/requests/planning/list_roles.rb +3 -9
- data/lib/fog/openstack/requests/volume/create_volume.rb +2 -1
- data/lib/fog/openstack/requests/volume/list_snapshots.rb +16 -3
- data/lib/fog/openstack/requests/volume/list_snapshots_detailed.rb +27 -0
- data/lib/fog/openstack/requests/volume/list_volume_types.rb +6 -6
- data/lib/fog/openstack/requests/volume/list_volumes.rb +20 -7
- data/lib/fog/openstack/requests/volume/list_volumes_detailed.rb +49 -0
- data/lib/fog/openstack/volume.rb +1 -0
- data/lib/fog/ovirt/models/compute/server.rb +1 -0
- data/lib/fog/ovirt/models/compute/template.rb +1 -0
- data/lib/fog/rackspace/docs/queues.md +2 -2
- data/lib/fog/rackspace/models/block_storage/snapshot.rb +5 -1
- data/lib/fog/version.rb +1 -1
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +1 -1
- data/lib/tasks/changelog_task.rb +1 -0
- data/spec/fog/openstack/identity_v3/authv3_a.yml +55 -35
- data/spec/fog/openstack/identity_v3/authv3_b.yml +55 -35
- data/spec/fog/openstack/identity_v3/authv3_c.yml +159 -33
- data/spec/fog/openstack/identity_v3/authv3_project.yml +79 -35
- data/spec/fog/openstack/identity_v3/authv3_token.yml +377 -76
- data/spec/fog/openstack/identity_v3/authv3_unscoped.yml +298 -155
- data/spec/fog/openstack/identity_v3/authv3_unscoped_reauth.yml +371 -0
- data/spec/fog/openstack/identity_v3/idv3.yml +456 -41
- data/spec/fog/openstack/identity_v3/idv3_credential.yml +36 -30
- data/spec/fog/openstack/identity_v3/idv3_credential_crud.yml +223 -190
- data/spec/fog/openstack/identity_v3/idv3_domain.yml +64 -58
- data/spec/fog/openstack/identity_v3/idv3_domain_crud.yml +176 -393
- data/spec/fog/openstack/identity_v3/idv3_domain_group_roles_mutation.yml +277 -379
- data/spec/fog/openstack/identity_v3/idv3_domain_roles_mutation.yml +177 -204
- data/spec/fog/openstack/identity_v3/idv3_endpoint.yml +492 -174
- data/spec/fog/openstack/identity_v3/idv3_endpoints_crud.yml +669 -435
- data/spec/fog/openstack/identity_v3/idv3_group_crud_mutation.yml +378 -298
- data/spec/fog/openstack/identity_v3/idv3_other_region.yml +187 -0
- data/spec/fog/openstack/identity_v3/idv3_policy.yml +54 -46
- data/spec/fog/openstack/identity_v3/idv3_policy_crud.yml +137 -117
- data/spec/fog/openstack/identity_v3/idv3_project.yml +116 -86
- data/spec/fog/openstack/identity_v3/idv3_project_crud.yml +179 -387
- data/spec/fog/openstack/identity_v3/idv3_project_group_user_roles_mutation.yml +415 -556
- data/spec/fog/openstack/identity_v3/idv3_role.yml +108 -74
- data/spec/fog/openstack/identity_v3/idv3_role_crud.yml +160 -368
- data/spec/fog/openstack/identity_v3/idv3_service.yml +156 -94
- data/spec/fog/openstack/identity_v3/idv3_services_crud.yml +250 -306
- data/spec/fog/openstack/identity_v3/idv3_token.yml +195 -101
- data/spec/fog/openstack/identity_v3/idv3_user_crud.yml +276 -193
- data/spec/fog/openstack/identity_v3/idv3_users.yml +149 -219
- data/spec/fog/openstack/identity_v3_spec.rb +502 -474
- data/spec/fog/openstack/volume/volume_common_setup.yml +76 -0
- data/spec/fog/openstack/volume/volume_crud.yml +561 -0
- data/spec/fog/openstack/volume/volume_type_read.yml +120 -0
- data/spec/fog/openstack/volume_spec.rb +165 -0
- data/tests/openstack/requests/compute/aggregate_tests.rb +59 -0
- data/tests/openstack/requests/network/port_tests.rb +12 -11
- data/tests/openstack/requests/orchestration/stack_tests.rb +25 -0
- metadata +56 -14
- data/spec/fog/openstack/identity_v3/idv2_unscoped_token_v3.yml +0 -467
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7801c7c007b8ade9b3db8b3adbcccce77483a544
|
4
|
+
data.tar.gz: f4b0c047843cc79f845badafc9afeb2e9ba04167
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 444572699a31be8229aca465659aaabc11ddf16d81bfd103914561a82e11dc55f43ab57a2e254fd986eb53dbe4ef3b1f30dc9be25bc4ac09dded50eceb73dbc6
|
7
|
+
data.tar.gz: e74522ce110047b1f7bdeb6e4ae263ff5854fd4741d6af224dbded8046543196d26986cbb6e5d7b33717ed1ef848abb9bfac5932ca52f13f6490a2b6cc6909ad
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,56 @@
|
|
1
|
+
## 1.32.0 07/02/2015
|
2
|
+
*Hash* 3339ba764f099c1fab8c989510c427ac65dabeca
|
3
|
+
|
4
|
+
Statistic | Value
|
5
|
+
------------- | --------:
|
6
|
+
Collaborators | 2
|
7
|
+
Downloads | 10420612
|
8
|
+
Forks | 1453
|
9
|
+
Open Issues | 83
|
10
|
+
Watchers | 3538
|
11
|
+
|
12
|
+
**MVP!** Ladislav Smola
|
13
|
+
|
14
|
+
#### [cloudstack]
|
15
|
+
* Use `isdefault` in `listNetworks` response. thanks Yamashita Yuu
|
16
|
+
|
17
|
+
#### [misc]
|
18
|
+
* Various fixes & tweaks for OpenStack Identity V3 API & related tests. thanks Darren Hague
|
19
|
+
* Clamp fog-ecloud at 0.1.1 because 0.1.2 was causing a Travis build failure. thanks Darren Hague
|
20
|
+
* Reintroduce user_domain and project_domain Refactor - move repetitive code from compute & network to core. Tweak VCR config and Rakefile to make sure tests are run correctly. thanks Darren Hague
|
21
|
+
* Fix ruby 1.8.7 failure. thanks Darren Hague
|
22
|
+
* Add missing reference to openstack_project_name & simplify test code a little. thanks Darren Hague
|
23
|
+
* Adding OpenStack Host Aggregate support. thanks Ladislav Smola
|
24
|
+
* OpenStack Baremetal list methods unified interface. thanks Ladislav Smola
|
25
|
+
* We need to move all list methods to unified interface, where only Hash is passed as a first argument. The hash can have specific fields, that will be recognized and deleted. Rest of the Hash goes directly to request :query. thanks Ladislav Smola
|
26
|
+
* OpenStack Keystone and Ironic change all to detailed list. thanks Ladislav Smola
|
27
|
+
* OpenStack Cinder, Swift and Tuskar list methods unified interface. thanks Ladislav Smola
|
28
|
+
* OpenStack Compute list methods unified interface. thanks Ladislav Smola
|
29
|
+
* OpenStack Glance and Heat list methods unified interface. thanks Ladislav Smola
|
30
|
+
* Minor bugs from list methods unification. thanks Ladislav Smola
|
31
|
+
* Missing network init uri. thanks Ladislav Smola
|
32
|
+
* OpenStack missing list unification of Network and Volume. thanks Ladislav Smola
|
33
|
+
* Openstack security groups list typo. thanks Ladislav Smola
|
34
|
+
* Don't remove nil keys in OpenStack#create_subnet. thanks Matt Darby
|
35
|
+
* Send :force flag in Snapshot payload. thanks Matt Darby
|
36
|
+
* OpenStack create_volume: add metadata option. thanks Maurice Schreiber
|
37
|
+
* OpenStack volume model: add metadata attribute. thanks Maurice Schreiber
|
38
|
+
* OpenStack port: add security groups to model and update request. thanks Maurice Schreiber
|
39
|
+
* include core in identity_v3 mock. thanks Maurice Schreiber
|
40
|
+
* correct mock format, when there is no input given. thanks Maurice Schreiber
|
41
|
+
* Bump fog-aws dependency. thanks Quentin de Metz
|
42
|
+
* add missing new method call to example. thanks Ryan King
|
43
|
+
* first bits of a spec for Fog::OpenStack::Volume. thanks Stefan Majewsky
|
44
|
+
* test the model create() method instead of the create_volume request. thanks Stefan Majewsky
|
45
|
+
* Fix typo in vm_clone. thanks alan
|
46
|
+
* bump fog-core dep. thanks geemus
|
47
|
+
* comment attribute in ovirt. thanks karmab
|
48
|
+
* support security-group by create port. thanks kazuhiko yamashita
|
49
|
+
|
50
|
+
#### [openstack]
|
51
|
+
* Minor bugfixes & cleanups in identity_v3 test code. thanks Darren Hague
|
52
|
+
|
53
|
+
|
1
54
|
## 1.31.0 06/05/2015
|
2
55
|
*Hash* 8c653412b40dd82f82187b9710ccb9177dab3d98
|
3
56
|
|
data/Rakefile
CHANGED
@@ -54,7 +54,7 @@ end
|
|
54
54
|
|
55
55
|
GEM_NAME = "#{name}"
|
56
56
|
task :default => :test
|
57
|
-
task :travis => ['test', 'test:travis']
|
57
|
+
task :travis => ['test', 'test:travis', 'test:openstack_idv3']
|
58
58
|
|
59
59
|
Rake::TestTask.new do |t|
|
60
60
|
t.pattern = File.join("spec", "**", "*_spec.rb")
|
@@ -63,7 +63,10 @@ end
|
|
63
63
|
|
64
64
|
namespace :test do
|
65
65
|
mock = ENV['FOG_MOCK'] || 'true'
|
66
|
-
task :
|
66
|
+
task :openstack_idv3 do
|
67
|
+
sh("export FOG_MOCK=false && bundle exec rspec spec/fog/openstack/identity_v3_spec.rb")
|
68
|
+
end
|
69
|
+
task :travis => [:openstack_idv3] do
|
67
70
|
sh("export FOG_MOCK=#{mock} && bundle exec shindont")
|
68
71
|
end
|
69
72
|
task :vsphere do
|
@@ -78,9 +81,6 @@ namespace :test do
|
|
78
81
|
task :openstack do
|
79
82
|
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/openstack")
|
80
83
|
end
|
81
|
-
task :openstack_idv3 do
|
82
|
-
sh("export FOG_MOCK=#{mock} && bundle exec rspec spec/fog/openstack/identity_v3_spec.rb")
|
83
|
-
end
|
84
84
|
task :cloudstack do
|
85
85
|
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/cloudstack")
|
86
86
|
end
|
data/fog.gemspec
CHANGED
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
|
|
11
11
|
## If your rubyforge_project name is different, then edit it and comment out
|
12
12
|
## the sub! line in the Rakefile
|
13
13
|
s.name = "fog"
|
14
|
-
s.version = "1.
|
15
|
-
s.date = "2015-
|
14
|
+
s.version = "1.32.0"
|
15
|
+
s.date = "2015-07-02"
|
16
16
|
s.rubyforge_project = "fog"
|
17
17
|
|
18
18
|
## Make sure your summary is short. The description may be as long
|
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
s.rdoc_options = ["--charset=UTF-8"]
|
45
45
|
s.extra_rdoc_files = %w[README.md]
|
46
46
|
|
47
|
-
s.add_dependency("fog-core", "~> 1.
|
47
|
+
s.add_dependency("fog-core", "~> 1.32")
|
48
48
|
s.add_dependency("fog-json")
|
49
49
|
s.add_dependency("fog-xml", "~> 0.1.1")
|
50
50
|
|
@@ -53,9 +53,9 @@ Gem::Specification.new do |s|
|
|
53
53
|
|
54
54
|
# Modular providers (please keep sorted)
|
55
55
|
s.add_dependency("fog-atmos")
|
56
|
-
s.add_dependency("fog-aws", "
|
56
|
+
s.add_dependency("fog-aws", ">= 0.6.0")
|
57
57
|
s.add_dependency("fog-brightbox", "~> 0.4")
|
58
|
-
s.add_dependency("fog-ecloud")
|
58
|
+
s.add_dependency("fog-ecloud", "= 0.1.1")
|
59
59
|
s.add_dependency("fog-google", ">= 0.0.2")
|
60
60
|
s.add_dependency("fog-local")
|
61
61
|
s.add_dependency("fog-powerdns", ">= 0.1.1")
|
@@ -85,6 +85,7 @@ Gem::Specification.new do |s|
|
|
85
85
|
s.add_development_dependency("thor")
|
86
86
|
s.add_development_dependency("yard")
|
87
87
|
s.add_development_dependency("rspec-core")
|
88
|
+
s.add_development_dependency("rspec-expectations")
|
88
89
|
s.add_development_dependency("vcr")
|
89
90
|
s.add_development_dependency("webmock")
|
90
91
|
|
@@ -38,6 +38,7 @@ module Fog
|
|
38
38
|
attribute :canuse_for_deploy, :aliases => 'canusefordeploy'
|
39
39
|
attribute :is_persistent, :aliases => 'ispersistent', :type => :boolean
|
40
40
|
attribute :display_network, :aliases => 'displaynetwork'
|
41
|
+
attribute :is_default, :aliases => 'isdefault', :type => :boolean
|
41
42
|
|
42
43
|
# restart network - will return a job
|
43
44
|
def restart(options={})
|
@@ -10,12 +10,15 @@ module Fog
|
|
10
10
|
:openstack_api_key, :openstack_username, :openstack_identity_endpoint,
|
11
11
|
:current_user, :current_tenant, :openstack_region,
|
12
12
|
:openstack_endpoint_type,
|
13
|
-
:openstack_project_name,
|
14
|
-
:openstack_project_domain, :openstack_user_domain
|
13
|
+
:openstack_project_name, :openstack_project_id,
|
14
|
+
:openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
|
15
|
+
:openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id
|
15
16
|
|
16
17
|
## MODELS
|
17
18
|
#
|
18
19
|
model_path 'fog/openstack/models/compute'
|
20
|
+
model :aggregate
|
21
|
+
collection :aggregates
|
19
22
|
model :server
|
20
23
|
collection :servers
|
21
24
|
model :service
|
@@ -49,6 +52,17 @@ module Fog
|
|
49
52
|
#
|
50
53
|
request_path 'fog/openstack/requests/compute'
|
51
54
|
|
55
|
+
# Aggregate CRUD
|
56
|
+
request :list_aggregates
|
57
|
+
request :create_aggregate
|
58
|
+
request :update_aggregate
|
59
|
+
request :get_aggregate
|
60
|
+
request :update_aggregate
|
61
|
+
request :update_aggregate_metadata
|
62
|
+
request :add_aggregate_host
|
63
|
+
request :remove_aggregate_host
|
64
|
+
request :delete_aggregate
|
65
|
+
|
52
66
|
# Server CRUD
|
53
67
|
request :list_servers
|
54
68
|
request :list_servers_detail
|
@@ -164,6 +178,7 @@ module Fog
|
|
164
178
|
|
165
179
|
# Volume
|
166
180
|
request :list_volumes
|
181
|
+
request :list_volumes_detail
|
167
182
|
request :create_volume
|
168
183
|
request :get_volume_details
|
169
184
|
request :delete_volume
|
@@ -171,8 +186,10 @@ module Fog
|
|
171
186
|
request :detach_volume
|
172
187
|
request :get_server_volumes
|
173
188
|
|
189
|
+
# Snapshot
|
174
190
|
request :create_volume_snapshot
|
175
191
|
request :list_snapshots
|
192
|
+
request :list_snapshots_detail
|
176
193
|
request :get_snapshot_details
|
177
194
|
request :delete_snapshot
|
178
195
|
|
@@ -208,6 +225,15 @@ module Fog
|
|
208
225
|
:security_groups => {},
|
209
226
|
:addresses => {}
|
210
227
|
},
|
228
|
+
:aggregates => [{
|
229
|
+
"availability_zone" => "nova",
|
230
|
+
"created_at" => "2012-11-16T06:22:23.032493",
|
231
|
+
"deleted" => false,
|
232
|
+
"deleted_at" => nil,
|
233
|
+
"id" => 1,
|
234
|
+
"name" => "name",
|
235
|
+
"updated_at" => nil
|
236
|
+
}],
|
211
237
|
:images => {
|
212
238
|
"0e09fbd6-43c5-448a-83e9-0d3d05f9747e" => {
|
213
239
|
"id"=>"0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
|
@@ -266,18 +292,14 @@ module Fog
|
|
266
292
|
@data = nil
|
267
293
|
end
|
268
294
|
|
269
|
-
|
270
|
-
@openstack_username = options[:openstack_username]
|
271
|
-
@openstack_user_domain = options[:openstack_user_domain] || options[:openstack_domain]
|
272
|
-
@openstack_project_domain = options[:openstack_project_domain] || options[:openstack_domain] || 'Default'
|
273
|
-
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
274
|
-
|
275
|
-
@current_tenant = options[:openstack_tenant]
|
276
|
-
@current_tenant_id = options[:openstack_tenant_id]
|
295
|
+
include Fog::OpenStack::Core
|
277
296
|
|
297
|
+
def initialize(options={})
|
278
298
|
@auth_token = Fog::Mock.random_base64(64)
|
279
299
|
@auth_token_expiration = (Time.now.utc + 86400).iso8601
|
280
300
|
|
301
|
+
initialize_identity options
|
302
|
+
|
281
303
|
management_url = URI.parse(options[:openstack_auth_url])
|
282
304
|
management_url.port = 8774
|
283
305
|
management_url.path = '/v1.1/1'
|
@@ -296,77 +318,28 @@ module Fog
|
|
296
318
|
self.class.data.delete("#{@openstack_username}-#{@current_tenant}")
|
297
319
|
end
|
298
320
|
|
299
|
-
def credentials
|
300
|
-
{ :provider => 'openstack',
|
301
|
-
:openstack_auth_url => @openstack_auth_uri.to_s,
|
302
|
-
:openstack_auth_token => @auth_token,
|
303
|
-
:openstack_management_url => @openstack_management_url,
|
304
|
-
:openstack_identity_endpoint => @openstack_identity_public_endpoint }
|
305
|
-
end
|
306
321
|
end
|
307
322
|
|
308
323
|
class Real
|
309
|
-
|
310
|
-
|
311
|
-
attr_reader :current_user
|
312
|
-
attr_reader :current_tenant
|
313
|
-
attr_reader :current_tenant_id
|
314
|
-
attr_reader :openstack_user_domain
|
315
|
-
attr_reader :openstack_project_domain
|
324
|
+
|
325
|
+
include Fog::OpenStack::Core
|
316
326
|
|
317
327
|
def initialize(options={})
|
318
|
-
|
319
|
-
@auth_token = options[:openstack_auth_token]
|
320
|
-
@openstack_identity_public_endpoint = options[:openstack_identity_endpoint]
|
321
|
-
|
322
|
-
unless @auth_token
|
323
|
-
missing_credentials = Array.new
|
324
|
-
@openstack_api_key = options[:openstack_api_key]
|
325
|
-
@openstack_username = options[:openstack_username]
|
326
|
-
@openstack_user_domain = options[:openstack_user_domain] || options[:openstack_domain]
|
327
|
-
@openstack_project_domain = options[:openstack_project_domain] || options[:openstack_domain] || 'Default'
|
328
|
-
|
329
|
-
missing_credentials << :openstack_api_key unless @openstack_api_key
|
330
|
-
missing_credentials << :openstack_username unless @openstack_username
|
331
|
-
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
332
|
-
end
|
328
|
+
initialize_identity options
|
333
329
|
|
334
|
-
@
|
335
|
-
@openstack_tenant_id = options[:openstack_tenant_id]
|
336
|
-
@openstack_user_domain = options[:openstack_user_domain] || options[:openstack_domain]
|
337
|
-
@openstack_project_domain = options[:openstack_project_domain] || options[:openstack_domain] || 'Default'
|
338
|
-
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
339
|
-
@openstack_management_url = options[:openstack_management_url]
|
340
|
-
@openstack_must_reauthenticate = false
|
330
|
+
@openstack_identity_service_type = options[:openstack_identity_service_type] || 'identity'
|
341
331
|
@openstack_service_type = options[:openstack_service_type] || ['nova', 'compute']
|
342
332
|
@openstack_service_name = options[:openstack_service_name]
|
343
|
-
@openstack_identity_service_type = options[:openstack_identity_service_type] || 'identity'
|
344
|
-
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'publicURL'
|
345
|
-
@openstack_region = options[:openstack_region]
|
346
333
|
|
347
334
|
@connection_options = options[:connection_options] || {}
|
348
335
|
|
349
|
-
|
350
|
-
@current_tenant = options[:current_tenant]
|
351
|
-
|
352
|
-
authenticate
|
336
|
+
authenticate_compute
|
353
337
|
|
354
338
|
@persistent = options[:persistent] || false
|
355
339
|
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
356
340
|
end
|
357
341
|
|
358
|
-
|
359
|
-
{ :provider => 'openstack',
|
360
|
-
:openstack_user_domain => @openstack_user_domain,
|
361
|
-
:openstack_project_domain => @openstack_project_domain,
|
362
|
-
:openstack_auth_url => @openstack_auth_uri.to_s,
|
363
|
-
:openstack_auth_token => @auth_token,
|
364
|
-
:openstack_management_url => @openstack_management_url,
|
365
|
-
:openstack_identity_endpoint => @openstack_identity_public_endpoint,
|
366
|
-
:openstack_region => @openstack_region,
|
367
|
-
:current_user => @current_user,
|
368
|
-
:current_tenant => @current_tenant }
|
369
|
-
end
|
342
|
+
|
370
343
|
|
371
344
|
def reload
|
372
345
|
@connection.reset
|
@@ -386,7 +359,7 @@ module Fog
|
|
386
359
|
rescue Excon::Errors::Unauthorized => error
|
387
360
|
if error.response.body != 'Bad username or password' # token expiration
|
388
361
|
@openstack_must_reauthenticate = true
|
389
|
-
|
362
|
+
authenticate_compute
|
390
363
|
retry
|
391
364
|
else # Bad Credentials
|
392
365
|
raise error
|
@@ -409,35 +382,8 @@ module Fog
|
|
409
382
|
|
410
383
|
private
|
411
384
|
|
412
|
-
def
|
413
|
-
|
414
|
-
options = {
|
415
|
-
:openstack_api_key => @openstack_api_key,
|
416
|
-
:openstack_username => @openstack_username,
|
417
|
-
:openstack_user_domain => @openstack_user_domain,
|
418
|
-
:openstack_project_domain => @openstack_project_domain,
|
419
|
-
:openstack_auth_token => @openstack_must_reauthenticate ? nil : @auth_token,
|
420
|
-
:openstack_auth_uri => @openstack_auth_uri,
|
421
|
-
:openstack_region => @openstack_region,
|
422
|
-
:openstack_tenant => @openstack_tenant,
|
423
|
-
:openstack_tenant_id => @openstack_tenant_id,
|
424
|
-
:openstack_service_type => @openstack_service_type,
|
425
|
-
:openstack_service_name => @openstack_service_name,
|
426
|
-
:openstack_identity_service_type => @openstack_identity_service_type,
|
427
|
-
:openstack_endpoint_type => @openstack_endpoint_type
|
428
|
-
}
|
429
|
-
|
430
|
-
credentials = Fog::OpenStack.authenticate(options, @connection_options)
|
431
|
-
|
432
|
-
@current_user = credentials[:user]
|
433
|
-
@current_tenant = credentials[:tenant]
|
434
|
-
|
435
|
-
@openstack_must_reauthenticate = false
|
436
|
-
@auth_token = credentials[:token]
|
437
|
-
@auth_token_expiration = credentials[:expires]
|
438
|
-
@openstack_management_url = credentials[:server_management_url]
|
439
|
-
@openstack_identity_public_endpoint = credentials[:identity_public_endpoint]
|
440
|
-
end
|
385
|
+
def authenticate_compute
|
386
|
+
authenticate
|
441
387
|
|
442
388
|
uri = URI.parse(@openstack_management_url)
|
443
389
|
@host = uri.host
|
@@ -449,9 +395,6 @@ module Fog
|
|
449
395
|
"OpenStack compute binding only supports version 2 (a.k.a. 1.1)")
|
450
396
|
end
|
451
397
|
|
452
|
-
@port = uri.port
|
453
|
-
@scheme = uri.scheme
|
454
|
-
|
455
398
|
# Not all implementations have identity service in the catalog
|
456
399
|
if @openstack_identity_public_endpoint || @openstack_management_url
|
457
400
|
@identity_connection = Fog::Core::Connection.new(
|
data/lib/fog/openstack/core.rb
CHANGED
@@ -53,6 +53,127 @@ module Fog
|
|
53
53
|
service(:baremetal, 'Baremetal')
|
54
54
|
service(:planning, 'Planning')
|
55
55
|
|
56
|
+
module Core
|
57
|
+
attr_reader :auth_token
|
58
|
+
attr_reader :auth_token_expiration
|
59
|
+
attr_reader :current_user
|
60
|
+
attr_reader :current_tenant
|
61
|
+
attr_reader :openstack_domain_name
|
62
|
+
attr_reader :openstack_user_domain
|
63
|
+
attr_reader :openstack_project_domain
|
64
|
+
attr_reader :openstack_domain_id
|
65
|
+
attr_reader :openstack_user_domain_id
|
66
|
+
attr_reader :openstack_project_domain_id
|
67
|
+
|
68
|
+
def initialize_identity options
|
69
|
+
@openstack_auth_token = options[:openstack_auth_token]
|
70
|
+
@auth_token ||= options[:openstack_auth_token]
|
71
|
+
@openstack_identity_public_endpoint = options[:openstack_identity_endpoint]
|
72
|
+
|
73
|
+
@openstack_username = options[:openstack_username]
|
74
|
+
@openstack_userid = options[:openstack_userid]
|
75
|
+
|
76
|
+
@openstack_domain_name = options[:openstack_domain_name]
|
77
|
+
@openstack_user_domain = options[:openstack_user_domain]
|
78
|
+
@openstack_project_domain = options[:openstack_project_domain]
|
79
|
+
@openstack_domain_id = options[:openstack_domain_id]
|
80
|
+
@openstack_user_domain_id = options[:openstack_user_domain_id]
|
81
|
+
@openstack_project_domain_id = options[:openstack_project_domain_id]
|
82
|
+
|
83
|
+
@openstack_project_name = options[:openstack_project_name]
|
84
|
+
@openstack_tenant = options[:openstack_tenant]
|
85
|
+
@openstack_tenant_id = options[:openstack_tenant_id]
|
86
|
+
|
87
|
+
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
88
|
+
|
89
|
+
@openstack_management_url = options[:openstack_management_url]
|
90
|
+
|
91
|
+
@openstack_must_reauthenticate = false
|
92
|
+
|
93
|
+
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'publicURL'
|
94
|
+
@openstack_region = options[:openstack_region]
|
95
|
+
|
96
|
+
unless @auth_token
|
97
|
+
missing_credentials = Array.new
|
98
|
+
@openstack_api_key = options[:openstack_api_key]
|
99
|
+
@openstack_username = options[:openstack_username]
|
100
|
+
@openstack_userid = options[:openstack_userid]
|
101
|
+
|
102
|
+
missing_credentials << :openstack_api_key unless @openstack_api_key
|
103
|
+
unless @openstack_username || @openstack_userid
|
104
|
+
missing_credentials << 'openstack_username or openstack_userid'
|
105
|
+
end
|
106
|
+
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
107
|
+
end
|
108
|
+
|
109
|
+
@current_user = options[:current_user]
|
110
|
+
@current_tenant = options[:current_tenant]
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
def credentials
|
115
|
+
{ :provider => 'openstack',
|
116
|
+
:openstack_domain_name => @openstack_domain_name,
|
117
|
+
:openstack_user_domain => @openstack_user_domain,
|
118
|
+
:openstack_project_domain => @openstack_project_domain,
|
119
|
+
:openstack_domain_id => @openstack_domain_id,
|
120
|
+
:openstack_user_domain_id => @openstack_user_domain_id,
|
121
|
+
:openstack_project_domain_id => @openstack_project_domain_id,
|
122
|
+
:openstack_auth_url => @openstack_auth_uri.to_s,
|
123
|
+
:openstack_auth_token => @auth_token,
|
124
|
+
:openstack_management_url => @openstack_management_url,
|
125
|
+
:openstack_identity_endpoint => @openstack_identity_public_endpoint,
|
126
|
+
:openstack_region => @openstack_region,
|
127
|
+
:current_user => @current_user,
|
128
|
+
:current_tenant => @current_tenant }
|
129
|
+
end
|
130
|
+
|
131
|
+
private
|
132
|
+
def authenticate
|
133
|
+
if !@openstack_management_url || @openstack_must_reauthenticate
|
134
|
+
options = {
|
135
|
+
:openstack_tenant => @openstack_tenant,
|
136
|
+
:openstack_tenant_id => @openstack_tenant_id,
|
137
|
+
:openstack_api_key => @openstack_api_key,
|
138
|
+
:openstack_username => @openstack_username,
|
139
|
+
:openstack_userid => @openstack_userid,
|
140
|
+
:openstack_user_domain => @openstack_user_domain,
|
141
|
+
:openstack_project_domain => @openstack_project_domain,
|
142
|
+
:openstack_user_domain_id => @openstack_user_domain_id,
|
143
|
+
:openstack_project_domain_id => @openstack_project_domain_id,
|
144
|
+
:openstack_domain_name => @openstack_domain_name,
|
145
|
+
:openstack_project_name => @openstack_project_name,
|
146
|
+
:openstack_domain_id => @openstack_domain_id,
|
147
|
+
:openstack_project_id => @openstack_project_id,
|
148
|
+
:openstack_auth_uri => @openstack_auth_uri,
|
149
|
+
:openstack_auth_token => @openstack_must_reauthenticate ? nil : @openstack_auth_token,
|
150
|
+
:openstack_service_type => @openstack_service_type,
|
151
|
+
:openstack_service_name => @openstack_service_name,
|
152
|
+
:openstack_endpoint_type => @openstack_endpoint_type,
|
153
|
+
:openstack_region => @openstack_region
|
154
|
+
}
|
155
|
+
|
156
|
+
credentials = Fog::OpenStack.authenticate(options, @connection_options)
|
157
|
+
|
158
|
+
@current_user = credentials[:user]
|
159
|
+
@current_tenant = credentials[:tenant]
|
160
|
+
|
161
|
+
@openstack_must_reauthenticate = false
|
162
|
+
@auth_token = credentials[:token]
|
163
|
+
@openstack_management_url = credentials[:server_management_url]
|
164
|
+
else
|
165
|
+
@auth_token = @openstack_auth_token
|
166
|
+
end
|
167
|
+
@openstack_management_uri = URI.parse(@openstack_management_url)
|
168
|
+
|
169
|
+
@host = @openstack_management_uri.host
|
170
|
+
@path = @openstack_management_uri.path
|
171
|
+
@port = @openstack_management_uri.port
|
172
|
+
@scheme = @openstack_management_uri.scheme
|
173
|
+
true
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
56
177
|
def self.authenticate(options, connection_options = {})
|
57
178
|
case options[:openstack_auth_uri].path
|
58
179
|
when /v1(\.\d+)?/
|
@@ -175,8 +296,7 @@ module Fog
|
|
175
296
|
|
176
297
|
# Keystone Style Auth
|
177
298
|
def self.authenticate_v3(options, connection_options = {})
|
178
|
-
uri
|
179
|
-
tenant_name = options[:openstack_tenant]
|
299
|
+
uri = options[:openstack_auth_uri]
|
180
300
|
project_name = options[:openstack_project_name]
|
181
301
|
service_type = options[:openstack_service_type]
|
182
302
|
service_name = options[:openstack_service_name]
|
@@ -184,11 +304,11 @@ module Fog
|
|
184
304
|
endpoint_type = map_endpoint_type(options[:openstack_endpoint_type] || 'publicURL')
|
185
305
|
openstack_region = options[:openstack_region]
|
186
306
|
|
187
|
-
|
307
|
+
token, body = retrieve_tokens_v3 options, connection_options
|
188
308
|
|
189
|
-
service =
|
309
|
+
service = get_service_v3(body, service_type, service_name, openstack_region)
|
190
310
|
|
191
|
-
options[:unscoped_token] =
|
311
|
+
options[:unscoped_token] = token
|
192
312
|
|
193
313
|
unless service
|
194
314
|
unless project_name
|
@@ -196,8 +316,8 @@ module Fog
|
|
196
316
|
:expects => [200],
|
197
317
|
:headers => {'Content-Type' => 'application/json',
|
198
318
|
'Accept' => 'application/json',
|
199
|
-
'X-Auth-Token' =>
|
200
|
-
:method
|
319
|
+
'X-Auth-Token' => token},
|
320
|
+
:method => 'GET'
|
201
321
|
}
|
202
322
|
user_id = body['token']['user']['id']
|
203
323
|
response = Fog::Core::Connection.new(
|
@@ -205,34 +325,34 @@ module Fog
|
|
205
325
|
|
206
326
|
projects_body = Fog::JSON.decode(response.body)
|
207
327
|
if projects_body['projects'].empty?
|
208
|
-
|
328
|
+
options[:openstack_domain_id] = body['token']['user']['domain']['id']
|
209
329
|
else
|
210
330
|
options[:openstack_project_name] = projects_body['projects'].first['name']
|
211
|
-
options[:
|
331
|
+
options[:openstack_domain_id] = projects_body['projects'].first['domain_id']
|
212
332
|
end
|
213
333
|
end
|
214
334
|
|
215
|
-
|
335
|
+
token, body = retrieve_tokens_v3(options, connection_options)
|
336
|
+
service = get_service_v3(body, service_type, service_name, openstack_region)
|
337
|
+
end
|
216
338
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
:headers => {'Content-Type' => 'application/json',
|
222
|
-
'Accept' => 'application/json',
|
223
|
-
'X-Auth-Token' => token_headers['X-Subject-Token']},
|
224
|
-
:method => 'GET'
|
225
|
-
})
|
226
|
-
body = Fog::JSON.decode(response.body)
|
227
|
-
if body['projects'].empty?
|
228
|
-
raise Fog::Errors::NotFound.new('No Tenant Found')
|
229
|
-
else
|
230
|
-
options[:openstack_tenant] = body['projects'].first['name']
|
231
|
-
end
|
339
|
+
unless service
|
340
|
+
available_services = body['token']['catalog'].map { |service|
|
341
|
+
service['type']
|
342
|
+
}.sort.join ', '
|
232
343
|
|
233
|
-
|
234
|
-
|
235
|
-
|
344
|
+
available_regions = body['token']['catalog'].map { |service|
|
345
|
+
service['endpoints'].map { |endpoint|
|
346
|
+
endpoint['region']
|
347
|
+
}.uniq
|
348
|
+
}.uniq.sort.join ', '
|
349
|
+
|
350
|
+
missing = service_type.join ', '
|
351
|
+
|
352
|
+
message = "Could not find service #{missing}#{(' in region '+openstack_region) if openstack_region}."+
|
353
|
+
" Have #{available_services}#{(' in regions '+available_regions) if openstack_region}"
|
354
|
+
|
355
|
+
raise Fog::Errors::NotFound, message
|
236
356
|
end
|
237
357
|
|
238
358
|
service['endpoints'] = service['endpoints'].select do |endpoint|
|
@@ -243,48 +363,34 @@ module Fog
|
|
243
363
|
raise Fog::Errors::NotFound.new("No endpoints available for region '#{openstack_region}'")
|
244
364
|
end if openstack_region
|
245
365
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
}.sort.join ', '
|
250
|
-
|
251
|
-
missing = service_type.join ', '
|
252
|
-
|
253
|
-
message = "Could not find service #{missing}. Have #{available}"
|
254
|
-
|
255
|
-
raise Fog::Errors::NotFound, message
|
366
|
+
regions = service["endpoints"].map { |e| e['region'] }.uniq
|
367
|
+
if regions.count > 1
|
368
|
+
raise Fog::Errors::NotFound.new("Multiple regions available choose one of these '#{regions.join(',')}'")
|
256
369
|
end
|
257
370
|
|
258
|
-
|
259
|
-
body['token']['roles'].each do |r|
|
260
|
-
admin = true if r["name"] == "admin"
|
261
|
-
end
|
371
|
+
identity_service = get_service_v3(body, identity_service_type) if identity_service_type
|
262
372
|
|
263
|
-
|
264
|
-
|
265
|
-
raise Fog::Errors::NotFound.new("Multiple regions available choose one of these '#{regions.join(',')}'")
|
266
|
-
end
|
373
|
+
management_url = service['endpoints'].find { |e| e['interface']==endpoint_type }['url']
|
374
|
+
identity_url = identity_service['endpoints'].find { |e| e['interface']=='public' }['url'] if identity_service
|
267
375
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
376
|
+
if body['token']['project']
|
377
|
+
tenant = body['token']['project']['name']
|
378
|
+
else
|
379
|
+
tenant = body['token']['user']['project']['name'] if body['token']['user']['project']
|
380
|
+
end
|
272
381
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
:current_user_id => body['token']['user']['id'],
|
283
|
-
:unscoped_token => options[:unscoped_token]
|
382
|
+
return {
|
383
|
+
:user => body['token']['user']['name'],
|
384
|
+
:tenant => tenant,
|
385
|
+
:identity_public_endpoint => identity_url,
|
386
|
+
:server_management_url => management_url,
|
387
|
+
:token => token,
|
388
|
+
:expires => body['token']['expires_at'],
|
389
|
+
:current_user_id => body['token']['user']['id'],
|
390
|
+
:unscoped_token => options[:unscoped_token]
|
284
391
|
}
|
285
392
|
end
|
286
393
|
|
287
|
-
|
288
394
|
def self.get_service(body, service_type=[], service_name=nil)
|
289
395
|
if not body['access'].nil?
|
290
396
|
body['access']['serviceCatalog'].find do |s|
|
@@ -340,87 +446,120 @@ module Fog
|
|
340
446
|
end
|
341
447
|
|
342
448
|
def self.retrieve_tokens_v3(options, connection_options = {})
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
449
|
+
|
450
|
+
api_key = options[:openstack_api_key].to_s
|
451
|
+
username = options[:openstack_username].to_s
|
452
|
+
userid = options[:openstack_userid]
|
453
|
+
domain_id = options[:openstack_domain_id]
|
454
|
+
domain_name = options[:openstack_domain_name]
|
455
|
+
project_domain = options[:openstack_project_domain]
|
456
|
+
project_domain_id = options[:openstack_project_domain_id]
|
457
|
+
user_domain = options[:openstack_user_domain]
|
458
|
+
user_domain_id = options[:openstack_user_domain_id]
|
459
|
+
project_name = options[:openstack_project_name]
|
460
|
+
project_id = options[:openstack_project_id]
|
461
|
+
auth_token = options[:openstack_auth_token] || options[:unscoped_token]
|
462
|
+
uri = options[:openstack_auth_uri]
|
354
463
|
|
355
464
|
connection = Fog::Core::Connection.new(uri.to_s, false, connection_options)
|
356
|
-
request_body = {:auth =>
|
465
|
+
request_body = {:auth => {}}
|
466
|
+
|
467
|
+
scope = {}
|
468
|
+
|
469
|
+
if project_name || project_id
|
470
|
+
scope[:project] = if project_id.nil? then
|
471
|
+
if project_domain || project_domain_id
|
472
|
+
{:name => project_name, :domain => project_domain_id.nil? ? {:name => project_domain} : {:id => project_domain_id}}
|
473
|
+
else
|
474
|
+
{:name => project_name, :domain => domain_id.nil? ? {:name => domain_name} : {:id => domain_id}}
|
475
|
+
end
|
476
|
+
else
|
477
|
+
{:id => project_id}
|
478
|
+
end
|
479
|
+
elsif domain_name || domain_id
|
480
|
+
scope[:domain] = domain_id.nil? ? {:name => domain_name} : {:id => domain_id}
|
481
|
+
else
|
482
|
+
# unscoped token
|
483
|
+
end
|
357
484
|
|
358
485
|
if auth_token
|
359
|
-
request_body[:auth][:
|
360
|
-
|
486
|
+
request_body[:auth][:identity] = {
|
487
|
+
:methods => %w{token},
|
488
|
+
:token => {
|
489
|
+
:id => auth_token
|
490
|
+
}
|
361
491
|
}
|
362
492
|
else
|
363
493
|
request_body[:auth][:identity] = {
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
494
|
+
:methods => %w{password},
|
495
|
+
:password => {
|
496
|
+
:user => {
|
497
|
+
:password => api_key
|
498
|
+
}
|
369
499
|
}
|
370
|
-
}
|
371
500
|
}
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
:id => tenant_id
|
376
|
-
}
|
377
|
-
}
|
501
|
+
|
502
|
+
if userid
|
503
|
+
request_body[:auth][:identity][:password][:user][:id] = userid
|
378
504
|
else
|
379
|
-
|
380
|
-
:
|
381
|
-
|
382
|
-
}
|
383
|
-
|
384
|
-
|
385
|
-
unless userdomain.to_s.empty?
|
386
|
-
request_body[:auth][:identity][:password][:user][:domain] = {
|
387
|
-
:name => userdomain
|
388
|
-
}
|
389
|
-
end
|
390
|
-
unless project_domain.to_s.empty?
|
391
|
-
request_body[:auth][:scope][:project][:domain] = {
|
392
|
-
:name => project_domain
|
393
|
-
}
|
505
|
+
if user_domain || user_domain_id
|
506
|
+
request_body[:auth][:identity][:password][:user].merge! :domain => user_domain_id.nil? ? {:name => user_domain} : {:id => user_domain_id}
|
507
|
+
elsif domain_name || domain_id
|
508
|
+
request_body[:auth][:identity][:password][:user].merge! :domain => domain_id.nil? ? {:name => domain_name} : {:id => domain_id}
|
509
|
+
end
|
510
|
+
request_body[:auth][:identity][:password][:user][:name] = username
|
394
511
|
end
|
512
|
+
|
395
513
|
end
|
514
|
+
request_body[:auth][:scope] = scope unless scope.empty?
|
515
|
+
|
516
|
+
puts "request_body: #{request_body}" if user_domain=='Default2'
|
396
517
|
|
397
518
|
response = connection.request({
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
519
|
+
:expects => [201],
|
520
|
+
:headers => {'Content-Type' => 'application/json'},
|
521
|
+
:body => Fog::JSON.encode(request_body),
|
522
|
+
:method => 'POST',
|
523
|
+
:path => (uri.path and not uri.path.empty?) ? uri.path : 'v2.0'
|
524
|
+
})
|
525
|
+
|
526
|
+
puts "response.body: #{response.body}" if user_domain=='Default2'
|
527
|
+
|
528
|
+
[response.headers["X-Subject-Token"], Fog::JSON.decode(response.body)]
|
529
|
+
end
|
530
|
+
|
531
|
+
def self.get_service_v3(hash, service_type=[], service_name=nil, region=nil)
|
532
|
+
|
533
|
+
services = hash['token']['catalog'].find_all do |s|
|
534
|
+
if service_name.nil? or service_name.empty?
|
535
|
+
service_type.include?(s['type'])
|
536
|
+
else
|
537
|
+
service_type.include?(s['type']) and s['name'] == service_name
|
538
|
+
end
|
539
|
+
end if hash['token']['catalog']
|
540
|
+
|
541
|
+
services.find do |s|
|
542
|
+
region.nil? or s['endpoints'].any? { |ep| ep['region'] == region }
|
543
|
+
end if services
|
404
544
|
|
405
|
-
return Fog::JSON.decode(response.body), response.headers
|
406
545
|
end
|
407
546
|
|
408
547
|
def self.get_supported_version(supported_versions, uri, auth_token, connection_options = {})
|
409
548
|
connection = Fog::Core::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}", false, connection_options)
|
410
549
|
response = connection.request({
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
550
|
+
:expects => [200, 204, 300],
|
551
|
+
:headers => {'Content-Type' => 'application/json',
|
552
|
+
'Accept' => 'application/json',
|
553
|
+
'X-Auth-Token' => auth_token},
|
554
|
+
:method => 'GET'
|
555
|
+
})
|
417
556
|
|
418
557
|
body = Fog::JSON.decode(response.body)
|
419
558
|
version = nil
|
420
559
|
unless body['versions'].empty?
|
421
560
|
supported_version = body['versions'].find do |x|
|
422
561
|
x["id"].match(supported_versions) &&
|
423
|
-
|
562
|
+
(x["status"] == "CURRENT" || x["status"] == "SUPPORTED")
|
424
563
|
end
|
425
564
|
version = supported_version["id"] if supported_version
|
426
565
|
end
|
@@ -433,7 +572,7 @@ module Fog
|
|
433
572
|
end
|
434
573
|
|
435
574
|
# CGI.escape, but without special treatment on spaces
|
436
|
-
def self.escape(str,extra_exclude_chars = '')
|
575
|
+
def self.escape(str, extra_exclude_chars = '')
|
437
576
|
str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do
|
438
577
|
'%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
|
439
578
|
end
|