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,4 +1,4 @@
1
- require 'misty/http/client'
1
+ require 'misty/client_pack'
2
2
 
3
3
  def request_header
4
4
  {'Accept' => 'application/json; q=1.0'}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: misty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilles Dubreuil
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2017-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -130,10 +130,12 @@ files:
130
130
  - lib/misty/auth.rb
131
131
  - lib/misty/auth/auth_v2.rb
132
132
  - lib/misty/auth/auth_v3.rb
133
+ - lib/misty/auth/errors.rb
133
134
  - lib/misty/auth/name.rb
134
135
  - lib/misty/autoload.rb
136
+ - lib/misty/client.rb
137
+ - lib/misty/client_pack.rb
135
138
  - lib/misty/cloud.rb
136
- - lib/misty/http/client.rb
137
139
  - lib/misty/http/direct.rb
138
140
  - lib/misty/http/header.rb
139
141
  - lib/misty/http/method_builder.rb
@@ -153,6 +155,7 @@ files:
153
155
  - lib/misty/openstack/cinder/v3.rb
154
156
  - lib/misty/openstack/designate/designate_v2.rb
155
157
  - lib/misty/openstack/designate/v2.rb
158
+ - lib/misty/openstack/extension.rb
156
159
  - lib/misty/openstack/freezer/freezer_v1.rb
157
160
  - lib/misty/openstack/freezer/v1.rb
158
161
  - lib/misty/openstack/glance/glance_v1.rb
@@ -210,10 +213,10 @@ files:
210
213
  - test/unit/auth/name_test.rb
211
214
  - test/unit/auth_helper.rb
212
215
  - test/unit/auth_test.rb
216
+ - test/unit/client_test.rb
213
217
  - test/unit/cloud/requests_test.rb
214
218
  - test/unit/cloud/services_test.rb
215
219
  - test/unit/cloud_test.rb
216
- - test/unit/http/client_test.rb
217
220
  - test/unit/http/direct_test.rb
218
221
  - test/unit/http/header_test.rb
219
222
  - test/unit/http/method_builder_test.rb
@@ -221,6 +224,7 @@ files:
221
224
  - test/unit/microversion_test.rb
222
225
  - test/unit/misty_test.rb
223
226
  - test/unit/openstack/APIs_test.rb
227
+ - test/unit/openstack/extension_test.rb
224
228
  - test/unit/service_helper.rb
225
229
  - test/unit/services_test.rb
226
230
  - test/unit/test_helper.rb
@@ -1,108 +0,0 @@
1
- require 'misty/http/net_http'
2
- require 'misty/http/method_builder'
3
- require 'misty/http/request'
4
- require 'misty/http/direct'
5
- require 'misty/http/header'
6
-
7
- module Misty
8
- module HTTP
9
- class Client
10
- class Options
11
- attr_accessor :base_path, :base_url, :headers, :interface, :region_id,
12
- :service_names, :ssl_verify_mode, :version
13
- end
14
-
15
- class InvalidDataError < StandardError; end
16
-
17
- include Misty::HTTP::NetHTTP
18
- include Misty::HTTP::MethodBuilder
19
- include Misty::HTTP::Request
20
- include Misty::HTTP::Direct
21
-
22
- INTERFACES = %w{admin public internal}
23
-
24
- attr_reader :headers, :microversion
25
-
26
- def requests
27
- list = []
28
- self.class.api.each do |_path, verbs|
29
- verbs.each do |_verb, requests|
30
- list << requests
31
- end
32
- end
33
- list.flatten.sort
34
- end
35
-
36
- # Options - Values shown are the default
37
- # Base path can be forced (Not recommended, mainly used for test purposes)
38
- # :base_path => nil
39
- # URL can be forced (Helps when setup is broken)
40
- # :base_url => nil
41
- # Optional headers
42
- # :headers => {}
43
- # Endpoint type (admin, public or internal)
44
- # :interface => "public"
45
- # Region ID
46
- # :region_id => "regionOne"
47
- # Service name
48
- # The Service names are pre defined but more can be added using this option.
49
- # :service_name
50
- # SSL Verify Mode
51
- # :ssl_verify_mode => true
52
- # (micro)version: Can be numbered (3.1) or by state (CURRENT, LATEST or SUPPORTED)
53
- # :version => "CURRENT"
54
- def initialize(auth, config, options = {})
55
- @auth = auth
56
- @config = config
57
- @options = setup(options)
58
- @uri = URI.parse(@auth.get_url(@options.service_names, @options.region_id, @options.interface))
59
- @base_path = @options.base_path ? @options.base_path : @uri.path
60
- @base_path = @base_path.chomp('/')
61
- @version = nil
62
- @microversion = false
63
- @headers = Misty::HTTP::Header.new(@config.headers.get.clone)
64
- @headers.add('X-Auth-Token' => @auth.get_token.to_s)
65
- @headers.add(microversion_header) if microversion
66
- @headers.add(@options.headers) unless @options.headers.empty?
67
- end
68
-
69
- # Sub classes to override
70
- # When a catalog provides a base path and the Service API definition containts the generic equivalent as prefix
71
- # then the preifx is redundant and must be removed from the path.
72
- # For example:
73
- # Catalog provides 'http://192.0.2.21:8004/v1/48985e6b8da145699d411f12a3459fca'
74
- # and Service API has '/v1/{tenant_id}/stacks'
75
- # then the path prefix is ignored and path is only '/stacks'
76
- def self.prefix_path_to_ignore
77
- ''
78
- end
79
-
80
- private
81
-
82
- def baseclass
83
- self.class.to_s.split('::')[-1]
84
- end
85
-
86
- def setup(params)
87
- options = Options.new()
88
- options.base_path = params[:base_path] ? params[:base_path] : nil
89
- options.base_url = params[:base_url] ? params[:base_url] : nil
90
- options.headers = params[:headers] ? params[:headers] : {}
91
- options.interface = params[:interface] ? params[:interface] : @config.interface
92
- options.region_id = params[:region_id] ? params[:region_id] : @config.region_id
93
- options.service_names = params[:service_name] ? self.class.service_names << params[:service_name] : self.class.service_names
94
- options.ssl_verify_mode = params[:ssl_verify_mode].nil? ? @config.ssl_verify_mode : params[:ssl_verify_mode]
95
- options.version = params[:version] ? params[:version] : 'CURRENT'
96
-
97
- unless INTERFACES.include?(options.interface)
98
- raise InvalidDataError, "Options ':interface' must be one of #{INTERFACES}"
99
- end
100
-
101
- unless options.ssl_verify_mode == !!options.ssl_verify_mode
102
- raise InvalidDataError, "Options ':ssl_verify_mode' must be a boolean"
103
- end
104
- options
105
- end
106
- end
107
- end
108
- end