misty 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/lib/misty/auth.rb +5 -13
  3. data/lib/misty/auth/auth_v2.rb +13 -11
  4. data/lib/misty/auth/auth_v3.rb +11 -9
  5. data/lib/misty/auth/errors.rb +12 -0
  6. data/lib/misty/auth/name.rb +4 -4
  7. data/lib/misty/client.rb +105 -0
  8. data/lib/misty/client_pack.rb +16 -0
  9. data/lib/misty/http/method_builder.rb +36 -20
  10. data/lib/misty/misty.rb +14 -0
  11. data/lib/misty/openstack/aodh/aodh_v2.rb +1 -1
  12. data/lib/misty/openstack/aodh/v2.rb +5 -8
  13. data/lib/misty/openstack/ceilometer/ceilometer_v2.rb +1 -1
  14. data/lib/misty/openstack/ceilometer/v2.rb +5 -8
  15. data/lib/misty/openstack/cinder/cinder_v1.rb +1 -1
  16. data/lib/misty/openstack/cinder/cinder_v2.rb +1 -1
  17. data/lib/misty/openstack/cinder/cinder_v3.rb +1 -1
  18. data/lib/misty/openstack/cinder/v1.rb +6 -9
  19. data/lib/misty/openstack/cinder/v2.rb +6 -9
  20. data/lib/misty/openstack/cinder/v3.rb +7 -10
  21. data/lib/misty/openstack/designate/designate_v2.rb +1 -1
  22. data/lib/misty/openstack/designate/v2.rb +5 -8
  23. data/lib/misty/openstack/extension.rb +33 -0
  24. data/lib/misty/openstack/freezer/freezer_v1.rb +1 -1
  25. data/lib/misty/openstack/freezer/v1.rb +5 -8
  26. data/lib/misty/openstack/glance/glance_v1.rb +1 -1
  27. data/lib/misty/openstack/glance/glance_v2.rb +1 -1
  28. data/lib/misty/openstack/glance/v1.rb +5 -8
  29. data/lib/misty/openstack/glance/v2.rb +5 -8
  30. data/lib/misty/openstack/heat/heat_v1.rb +1 -1
  31. data/lib/misty/openstack/heat/v1.rb +6 -9
  32. data/lib/misty/openstack/ironic/ironic_v1.rb +1 -1
  33. data/lib/misty/openstack/ironic/v1.rb +6 -9
  34. data/lib/misty/openstack/karbor/karbor_v1.rb +1 -1
  35. data/lib/misty/openstack/karbor/v1.rb +5 -8
  36. data/lib/misty/openstack/keystone/keystone_v2_0.rb +1 -1
  37. data/lib/misty/openstack/keystone/keystone_v2_0_ext.rb +2 -2
  38. data/lib/misty/openstack/keystone/keystone_v3.rb +1 -1
  39. data/lib/misty/openstack/keystone/keystone_v3_ext.rb +2 -2
  40. data/lib/misty/openstack/keystone/v2_0.rb +8 -10
  41. data/lib/misty/openstack/keystone/v3.rb +8 -10
  42. data/lib/misty/openstack/magnum/magnum_v1.rb +1 -1
  43. data/lib/misty/openstack/magnum/v1.rb +6 -9
  44. data/lib/misty/openstack/manila/manila_v2.rb +1 -1
  45. data/lib/misty/openstack/manila/v2.rb +6 -9
  46. data/lib/misty/openstack/murano/murano_v1.rb +1 -1
  47. data/lib/misty/openstack/murano/v1.rb +5 -8
  48. data/lib/misty/openstack/neutron/neutron_v2_0.rb +1 -1
  49. data/lib/misty/openstack/neutron/v2_0.rb +5 -8
  50. data/lib/misty/openstack/nova/nova_v2_1.rb +1 -1
  51. data/lib/misty/openstack/nova/v2_1.rb +7 -9
  52. data/lib/misty/openstack/octavia/octavia_v2_0.rb +1 -1
  53. data/lib/misty/openstack/octavia/v2_0.rb +5 -8
  54. data/lib/misty/openstack/sahara/sahara_v1_1.rb +1 -1
  55. data/lib/misty/openstack/sahara/v1_1.rb +5 -8
  56. data/lib/misty/openstack/searchlight/searchlight_v1.rb +1 -1
  57. data/lib/misty/openstack/searchlight/v1.rb +5 -8
  58. data/lib/misty/openstack/senlin/senlin_v1.rb +1 -1
  59. data/lib/misty/openstack/senlin/v1.rb +5 -8
  60. data/lib/misty/openstack/swift/swift_v1.rb +1 -1
  61. data/lib/misty/openstack/swift/v1.rb +17 -9
  62. data/lib/misty/openstack/tacker/tacker_v1_0.rb +1 -1
  63. data/lib/misty/openstack/tacker/v1_0.rb +5 -8
  64. data/lib/misty/openstack/trove/trove_v1_0.rb +1 -1
  65. data/lib/misty/openstack/trove/v1_0.rb +5 -8
  66. data/lib/misty/openstack/zaqar/v2.rb +5 -8
  67. data/lib/misty/openstack/zaqar/zaqar_v2.rb +1 -1
  68. data/lib/misty/version.rb +1 -1
  69. data/test/unit/{http/client_test.rb → client_test.rb} +20 -8
  70. data/test/unit/cloud/requests_test.rb +77 -5
  71. data/test/unit/cloud/services_test.rb +20 -5
  72. data/test/unit/http/header_test.rb +0 -1
  73. data/test/unit/http/method_builder_test.rb +4 -4
  74. data/test/unit/http/request_test.rb +29 -20
  75. data/test/unit/microversion_test.rb +1 -1
  76. data/test/unit/misty_test.rb +18 -0
  77. data/test/unit/openstack/APIs_test.rb +18 -13
  78. data/test/unit/openstack/extension_test.rb +68 -0
  79. data/test/unit/service_helper.rb +1 -1
  80. metadata +8 -4
  81. data/lib/misty/http/client.rb +0 -108
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::CeilometerV2
2
- def v2
2
+ def api
3
3
  {"/v2/resources"=>{:GET=>[:list_resources]},
4
4
  "/v2/resources/{resource_id}"=>{:GET=>[:show_ressource]},
5
5
  "/v2/meters"=>{:GET=>[:list_meters]},
@@ -1,17 +1,14 @@
1
- require 'misty/http/client'
2
1
  require 'misty/openstack/ceilometer/ceilometer_v2'
2
+ require 'misty/client_pack'
3
3
 
4
4
  module Misty
5
5
  module Openstack
6
6
  module Ceilometer
7
- class V2 < Misty::HTTP::Client
8
- extend Misty::Openstack::CeilometerV2
7
+ class V2
8
+ include Misty::Openstack::CeilometerV2
9
+ include Misty::ClientPack
9
10
 
10
- def self.api
11
- v2
12
- end
13
-
14
- def self.service_names
11
+ def service_names
15
12
  %w{metering}
16
13
  end
17
14
  end
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::CinderV1
2
- def v1
2
+ def api
3
3
  {"/v1/{admin_tenant_id}/os-quota-sets/{tenant_id}/detail/{user_id}"=>
4
4
  {:GET=>[:show_quota_details_for_user_v1]},
5
5
  "/v1/{tenant_id}/os-quota-sets/defaults"=>{:GET=>[:show_default_quotas]},
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::CinderV2
2
- def v2
2
+ def api
3
3
  {"/"=>{:GET=>[:list_api_versions]},
4
4
  "/v2/{tenant_id}/backups/detail"=>{:GET=>[:list_backups_with_details]},
5
5
  "/v2/{tenant_id}/backups/{backup_id}"=>
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::CinderV3
2
- def v3
2
+ def api
3
3
  {"/"=>{:GET=>[:list_all_api_versions]},
4
4
  "/v3"=>{:GET=>[:show_api_v3_details]},
5
5
  "/v3/{project_id}/extensions"=>{:GET=>[:list_known_api_extensions]},
@@ -1,21 +1,18 @@
1
- require 'misty/http/client'
2
1
  require 'misty/openstack/cinder/cinder_v1'
2
+ require 'misty/client_pack'
3
3
 
4
4
  module Misty
5
5
  module Openstack
6
6
  module Cinder
7
- class V1 < Misty::HTTP::Client
8
- extend Misty::Openstack::CinderV1
7
+ class V1
8
+ include Misty::Openstack::CinderV1
9
+ include Misty::ClientPack
9
10
 
10
- def self.api
11
- v1
12
- end
13
-
14
- def self.prefix_path_to_ignore
11
+ def prefix_path_to_ignore
15
12
  '/v1/{admin_tenant_id}/'
16
13
  end
17
14
 
18
- def self.service_names
15
+ def service_names
19
16
  %w{block-storage, block-store, volume}
20
17
  end
21
18
  end
@@ -1,21 +1,18 @@
1
- require 'misty/http/client'
2
1
  require 'misty/openstack/cinder/cinder_v2'
2
+ require 'misty/client_pack'
3
3
 
4
4
  module Misty
5
5
  module Openstack
6
6
  module Cinder
7
- class V2 < Misty::HTTP::Client
8
- extend Misty::Openstack::CinderV2
7
+ class V2
8
+ include Misty::Openstack::CinderV2
9
+ include Misty::ClientPack
9
10
 
10
- def self.api
11
- v2
12
- end
13
-
14
- def self.prefix_path_to_ignore
11
+ def prefix_path_to_ignore
15
12
  '/v2/{tenant_id}'
16
13
  end
17
14
 
18
- def self.service_names
15
+ def service_names
19
16
  %w{block-storage, block-store, volume}
20
17
  end
21
18
  end
@@ -1,23 +1,20 @@
1
- require 'misty/http/client'
2
- require 'misty/microversion'
3
1
  require 'misty/openstack/cinder/cinder_v3'
2
+ require 'misty/client_pack'
3
+ require 'misty/microversion'
4
4
 
5
5
  module Misty
6
6
  module Openstack
7
7
  module Cinder
8
- class V3 < Misty::HTTP::Client
9
- extend Misty::Openstack::CinderV3
8
+ class V3
9
+ include Misty::Openstack::CinderV3
10
+ include Misty::ClientPack
10
11
  include Misty::Microversion
11
12
 
12
- def self.api
13
- v3
14
- end
15
-
16
- def self.prefix_path_to_ignore
13
+ def prefix_path_to_ignore
17
14
  '/v3/{tenant_id}'
18
15
  end
19
16
 
20
- def self.service_names
17
+ def service_names
21
18
  %w{block-storage, block-store, volume}
22
19
  end
23
20
  end
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::DesignateV2
2
- def v2
2
+ def api
3
3
  {"/"=>{:GET=>[:list_all_api_versions]},
4
4
  "/v2/zones"=>{:POST=>[:create_zone], :GET=>[:list_zones]},
5
5
  "/v2/zones/{zone_id}"=>
@@ -1,17 +1,14 @@
1
- require 'misty/http/client'
2
1
  require 'misty/openstack/designate/designate_v2'
2
+ require 'misty/client_pack'
3
3
 
4
4
  module Misty
5
5
  module Openstack
6
6
  module Designate
7
- class V2 < Misty::HTTP::Client
8
- extend Misty::Openstack::DesignateV2
7
+ class V2
8
+ include Misty::Openstack::DesignateV2
9
+ include Misty::ClientPack
9
10
 
10
- def self.api
11
- v2
12
- end
13
-
14
- def self.service_names
11
+ def service_names
15
12
  %w{dns}
16
13
  end
17
14
  end
@@ -0,0 +1,33 @@
1
+ module Misty
2
+ module Openstack
3
+ module Extension
4
+ def api
5
+ @api_fusion ||= begin
6
+ list = super
7
+ api_ext.each do |key, value|
8
+ if list.include?(key)
9
+ target = list[key]
10
+ value.each do |verb, methods|
11
+ if target.has_key?(verb)
12
+ # Add methods to existing Verb
13
+ methods.each do |method|
14
+ raise RuntimeError, "#{key} => #{verb} already includes: #{method}" if target[verb].include?(method)
15
+ target[verb] << method
16
+ end
17
+ else
18
+ # Add Verb
19
+ target.merge!(verb => methods)
20
+ end
21
+ end
22
+ else
23
+ # Add Resource
24
+ list.merge!(key => value)
25
+ end
26
+ end
27
+ list
28
+ end
29
+ @api_fusion
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::FreezerV1
2
- def v1
2
+ def api
3
3
  {"/v1/backups"=>{:GET=>[:lists_backups]},
4
4
  "/v1/backups/{backup_id}"=>
5
5
  {:GET=>[:show_backups], :DELETE=>[:delete_backups]},
@@ -1,17 +1,14 @@
1
- require 'misty/http/client'
2
1
  require 'misty/openstack/freezer/freezer_v1'
2
+ require 'misty/client_pack'
3
3
 
4
4
  module Misty
5
5
  module Openstack
6
6
  module Freezer
7
- class V1 < Misty::HTTP::Client
8
- extend Misty::Openstack::FreezerV1
7
+ class V1
8
+ include Misty::Openstack::FreezerV1
9
+ include Misty::ClientPack
9
10
 
10
- def self.api
11
- v1
12
- end
13
-
14
- def self.service_names
11
+ def service_names
15
12
  %w{backup}
16
13
  end
17
14
  end
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::GlanceV1
2
- def v1
2
+ def api
3
3
  {"/v1/images"=>{:POST=>[:create_image], :GET=>[:list_images]},
4
4
  "/v1/images/detail"=>{:GET=>[:list_images_with_details]},
5
5
  "/v1/images/{image_id}"=>
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::GlanceV2
2
- def v2
2
+ def api
3
3
  {"/v2/images"=>{:POST=>[:create_an_image], :GET=>[:show_images]},
4
4
  "/v2/images/{image_id}"=>
5
5
  {:GET=>[:show_image_details],
@@ -1,17 +1,14 @@
1
- require 'misty/http/client'
2
1
  require 'misty/openstack/glance/glance_v1'
2
+ require 'misty/client_pack'
3
3
 
4
4
  module Misty
5
5
  module Openstack
6
6
  module Glance
7
- class V1 < Misty::HTTP::Client
8
- extend Misty::Openstack::GlanceV1
7
+ class V1
8
+ include Misty::Openstack::GlanceV1
9
+ include Misty::ClientPack
9
10
 
10
- def self.api
11
- v1
12
- end
13
-
14
- def self.service_names
11
+ def service_names
15
12
  %w{image}
16
13
  end
17
14
  end
@@ -1,17 +1,14 @@
1
- require 'misty/http/client'
2
1
  require 'misty/openstack/glance/glance_v2'
2
+ require 'misty/client_pack'
3
3
 
4
4
  module Misty
5
5
  module Openstack
6
6
  module Glance
7
- class V2 < Misty::HTTP::Client
8
- extend Misty::Openstack::GlanceV2
7
+ class V2
8
+ include Misty::Openstack::GlanceV2
9
+ include Misty::ClientPack
9
10
 
10
- def self.api
11
- v2
12
- end
13
-
14
- def self.service_names
11
+ def service_names
15
12
  %w{image}
16
13
  end
17
14
  end
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::HeatV1
2
- def v1
2
+ def api
3
3
  {"/v1/{tenant_id}/build_info"=>{:GET=>[:show_build_information]},
4
4
  "/"=>{:GET=>[:list_versions]},
5
5
  "/v1/{tenant_id}/stacks"=>
@@ -1,21 +1,18 @@
1
- require 'misty/http/client'
2
1
  require 'misty/openstack/heat/heat_v1'
2
+ require 'misty/client_pack'
3
3
 
4
4
  module Misty
5
5
  module Openstack
6
6
  module Heat
7
- class V1 < Misty::HTTP::Client
8
- extend Misty::Openstack::HeatV1
7
+ class V1
8
+ include Misty::Openstack::HeatV1
9
+ include Misty::ClientPack
9
10
 
10
- def self.api
11
- v1
12
- end
13
-
14
- def self.prefix_path_to_ignore
11
+ def prefix_path_to_ignore
15
12
  '/v1/{tenant_id}'
16
13
  end
17
14
 
18
- def self.service_names
15
+ def service_names
19
16
  %w{orchestration}
20
17
  end
21
18
  end
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::IronicV1
2
- def v1
2
+ def api
3
3
  {"/"=>{:GET=>[:list_api_versions]},
4
4
  "/v1/"=>{:GET=>[:show_v1_api]},
5
5
  "/v1/nodes"=>{:POST=>[:create_node], :GET=>[:list_nodes]},
@@ -1,19 +1,16 @@
1
- require 'misty/http/client'
2
- require 'misty/microversion'
3
1
  require 'misty/openstack/ironic/ironic_v1'
2
+ require 'misty/client_pack'
3
+ require 'misty/microversion'
4
4
 
5
5
  module Misty
6
6
  module Openstack
7
7
  module Ironic
8
- class V1 < Misty::HTTP::Client
9
- extend Misty::Openstack::IronicV1
8
+ class V1
9
+ include Misty::Openstack::IronicV1
10
+ include Misty::ClientPack
10
11
  include Misty::Microversion
11
12
 
12
- def self.api
13
- v1
14
- end
15
-
16
- def self.service_names
13
+ def service_names
17
14
  %w{baremetal}
18
15
  end
19
16
  end
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::KarborV1
2
- def v1
2
+ def api
3
3
  {"/v1/{tenant_id}/protectables"=>{:GET=>[:list_protectable_types]},
4
4
  "/v1/{tenant_id}/protectables/{protectable_type}"=>
5
5
  {:GET=>[:show_protectable_type]},
@@ -1,17 +1,14 @@
1
- require 'misty/http/client'
2
1
  require 'misty/openstack/karbor/karbor_v1'
2
+ require 'misty/client_pack'
3
3
 
4
4
  module Misty
5
5
  module Openstack
6
6
  module Karbor
7
- class V1 < Misty::HTTP::Client
8
- extend Misty::Openstack::KarborV1
7
+ class V1
8
+ include Misty::Openstack::KarborV1
9
+ include Misty::ClientPack
9
10
 
10
- def self.api
11
- v1
12
- end
13
-
14
- def self.service_names
11
+ def service_names
15
12
  %w{data-protection data-protection-orchestration}
16
13
  end
17
14
  end
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::KeystoneV2_0
2
- def v2_0
2
+ def api
3
3
  {"/v2.0/extensions/{alias}"=>{:GET=>[:show_extension_details]},
4
4
  "/v2.0/extensions"=>{:GET=>[:list_extensions]},
5
5
  "/v2.0/tenants"=>{:GET=>[:list_tenants]},
@@ -1,5 +1,5 @@
1
- module Misty::Openstack::KeystoneV2_0
2
- def v2_0_ext
1
+ module Misty::Openstack::KeystoneV2_0_ext
2
+ def api_ext
3
3
  {"/v2.0/users/{user_id}/OS-KSADM/enabled"=>{:PUT=>[:enable_disable_user]},
4
4
  "/v2.0/users/{user_id}/OS-KSADM/password"=>{:PUT=>[:set_user_password]},
5
5
  "/v2.0/users/{user_id}/OS-KSADM/tenant"=>{:PUT=>[:update_user_tenant]},
@@ -1,5 +1,5 @@
1
1
  module Misty::Openstack::KeystoneV3
2
- def v3
2
+ def api
3
3
  {"/v3/auth/tokens"=>
4
4
  {:POST=>
5
5
  [:password_authentication_with_unscoped_authorization,
@@ -1,5 +1,5 @@
1
- module Misty::Openstack::KeystoneV3
2
- def v3_ext
1
+ module Misty::Openstack::KeystoneV3_ext
2
+ def api_ext
3
3
  {"/v3/policies/{policy_id}/OS-ENDPOINT-POLICY/endpoints/{endpoint_id}"=>
4
4
  {:PUT=>[:associate_policy_and_endpoint],
5
5
  :GET=>[:verify_a_policy_and_endpoint_association],
@@ -1,20 +1,18 @@
1
- require 'misty/http/client'
2
1
  require 'misty/openstack/keystone/keystone_v2_0'
3
2
  require 'misty/openstack/keystone/keystone_v2_0_ext'
3
+ require 'misty/client_pack'
4
+ require 'misty/openstack/extension'
4
5
 
5
6
  module Misty
6
7
  module Openstack
7
8
  module Keystone
8
- class V2_0 < Misty::HTTP::Client
9
- extend Misty::Openstack::KeystoneV2_0
9
+ class V2_0
10
+ include Misty::Openstack::KeystoneV2_0
11
+ include Misty::Openstack::KeystoneV2_0_ext
12
+ include Misty::ClientPack
13
+ include Misty::Openstack::Extension
10
14
 
11
- def self.api
12
- api = v2_0
13
- api.merge!(v2_0_ext)
14
- api
15
- end
16
-
17
- def self.service_names
15
+ def service_names
18
16
  %w{identity}
19
17
  end
20
18
  end