misty 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -23
- data/lib/misty/auth.rb +24 -19
- data/lib/misty/auth/auth_v2.rb +12 -12
- data/lib/misty/auth/auth_v3.rb +15 -15
- data/lib/misty/autoload.rb +27 -27
- data/lib/misty/cloud.rb +2 -1
- data/lib/misty/http/client.rb +17 -15
- data/lib/misty/http/method_builder.rb +1 -1
- data/lib/misty/http/net_http.rb +12 -7
- data/lib/misty/http/request.rb +13 -7
- data/lib/misty/misty.rb +30 -30
- data/lib/misty/openstack/aodh/v2.rb +1 -1
- data/lib/misty/openstack/ceilometer/v2.rb +1 -1
- data/lib/misty/openstack/cinder/v1.rb +2 -2
- data/lib/misty/openstack/cinder/v2.rb +2 -2
- data/lib/misty/openstack/cinder/v3.rb +2 -2
- data/lib/misty/openstack/designate/v2.rb +1 -1
- data/lib/misty/openstack/freezer/v1.rb +1 -1
- data/lib/misty/openstack/glance/v1.rb +1 -1
- data/lib/misty/openstack/glance/v2.rb +1 -1
- data/lib/misty/openstack/heat/v1.rb +2 -2
- data/lib/misty/openstack/ironic/v1.rb +2 -2
- data/lib/misty/openstack/karbor/v1.rb +1 -1
- data/lib/misty/openstack/keystone/v2_0.rb +2 -2
- data/lib/misty/openstack/keystone/v3.rb +2 -2
- data/lib/misty/openstack/magnum/v1.rb +2 -2
- data/lib/misty/openstack/manila/v2.rb +2 -2
- data/lib/misty/openstack/microversion.rb +9 -9
- data/lib/misty/openstack/murano/v1.rb +1 -1
- data/lib/misty/openstack/neutron/v2_0.rb +1 -1
- data/lib/misty/openstack/nova/v2_1.rb +4 -4
- data/lib/misty/openstack/octavia/v2_0.rb +1 -1
- data/lib/misty/openstack/sahara/v1_1.rb +1 -1
- data/lib/misty/openstack/searchlight/v1.rb +1 -1
- data/lib/misty/openstack/senlin/v1.rb +1 -1
- data/lib/misty/openstack/swift/v1.rb +1 -1
- data/lib/misty/openstack/tacker/v1_0.rb +1 -1
- data/lib/misty/openstack/trove/v1_0.rb +1 -1
- data/lib/misty/openstack/zaqar/v2.rb +1 -1
- data/lib/misty/services.rb +1 -1
- data/lib/misty/version.rb +1 -1
- data/test/integration/compute_test.rb +17 -17
- data/test/integration/network_test.rb +16 -16
- data/test/integration/orchestration_test.rb +51 -51
- data/test/integration/test_helper.rb +7 -7
- data/test/unit/auth/name_test.rb +53 -53
- data/test/unit/auth_test.rb +151 -152
- data/test/unit/cloud/requests_test.rb +58 -58
- data/test/unit/cloud/services_test.rb +62 -62
- data/test/unit/cloud_test.rb +48 -48
- data/test/unit/http/client_test.rb +21 -28
- data/test/unit/http/direct_test.rb +31 -31
- data/test/unit/http/method_builder_test.rb +42 -42
- data/test/unit/http/request_test.rb +33 -33
- data/test/unit/misty_test.rb +28 -28
- data/test/unit/openstack/APIs_test.rb +3 -3
- data/test/unit/openstack/microversion_test.rb +14 -14
- data/test/unit/service_helper.rb +4 -4
- data/test/unit/services_test.rb +5 -5
- data/test/unit/test_helper.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90247f6d9f8410d55769850fbb2e2e6332e35e7d
|
4
|
+
data.tar.gz: 73c5cb98cf6826bfe7256e90e592498b25ab9500
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0cc5cfae68ecfe28122303f1f7b0a909faf9baf33441db4d85700e2e86c08f68e4dba0465476621a91b63eb1c7d1fe4530b9cf7f4753438c1bdb6b448d1bce5
|
7
|
+
data.tar.gz: bb19851c6bd284bc0ef9d74eb740f84300f714fb33beb6ee16b6f94e3d86630bb59d622270ef3daed9d54753681b8b9cfbb5e3143638f5b0de23ba40b06be5c2
|
data/README.md
CHANGED
@@ -46,11 +46,11 @@ gem install misty
|
|
46
46
|
require 'misty'
|
47
47
|
|
48
48
|
auth_v3 = {
|
49
|
-
:url =>
|
50
|
-
:user =>
|
51
|
-
:password =>
|
52
|
-
:domain =>
|
53
|
-
:project =>
|
49
|
+
:url => 'http://localhost:5000',
|
50
|
+
:user => 'admin',
|
51
|
+
:password => 'secret',
|
52
|
+
:domain => 'default',
|
53
|
+
:project => 'admin',
|
54
54
|
:project_domain_id => 'default'
|
55
55
|
}
|
56
56
|
|
@@ -59,7 +59,7 @@ openstack = Misty::Cloud.new(:auth => auth_v3)
|
|
59
59
|
puts openstack.compute.list_servers.body
|
60
60
|
puts openstack.compute.list_flavors.body
|
61
61
|
networks = openstack.network.list_networks
|
62
|
-
network_id = networks.body[
|
62
|
+
network_id = networks.body['networks'][0]['id']
|
63
63
|
network = openstack.network.show_network_details(network_id)
|
64
64
|
puts network.body
|
65
65
|
```
|
@@ -76,7 +76,7 @@ Each service name (i.e. `compute`) is the object handling API requests.
|
|
76
76
|
openstack = Misty::Cloud.new(:auth => { ... })
|
77
77
|
openstack.compute.list_servers
|
78
78
|
openstack.network.list_networks
|
79
|
-
openstack.network.create_network(
|
79
|
+
openstack.network.create_network('network': {'name': 'my-network'})
|
80
80
|
```
|
81
81
|
|
82
82
|
To obtain the list of supported services:
|
@@ -197,12 +197,12 @@ Keystone v3 is default recommended version:
|
|
197
197
|
|
198
198
|
```ruby
|
199
199
|
auth = {
|
200
|
-
:url =>
|
201
|
-
:user =>
|
202
|
-
:user_domain =>
|
203
|
-
:password =>
|
204
|
-
:project =>
|
205
|
-
:project_domain =>
|
200
|
+
:url => 'http://localhost:5000',
|
201
|
+
:user => 'admin',
|
202
|
+
:user_domain => 'default',
|
203
|
+
:password => 'secret',
|
204
|
+
:project => 'admin',
|
205
|
+
:project_domain => 'default'
|
206
206
|
}
|
207
207
|
}
|
208
208
|
```
|
@@ -211,10 +211,10 @@ Alternatively, using IDs:
|
|
211
211
|
|
212
212
|
```ruby
|
213
213
|
auth = {
|
214
|
-
:url =>
|
215
|
-
:user_id =>
|
216
|
-
:password =>
|
217
|
-
:project_id =>
|
214
|
+
:url => 'http://localhost:5000',
|
215
|
+
:user_id => '48985e6b8da145699d411f12a3459fca',
|
216
|
+
:password => 'secret',
|
217
|
+
:project_id => '8e1e232f6cbb4116bbef715d8a0afe6e',
|
218
218
|
}
|
219
219
|
}
|
220
220
|
```
|
@@ -223,10 +223,10 @@ Provide the tenant details, Misty will detect it's using v2.0 for authentication
|
|
223
223
|
|
224
224
|
```ruby
|
225
225
|
auth = {
|
226
|
-
:url =>
|
227
|
-
:user =>
|
228
|
-
:password =>
|
229
|
-
:tenant =>
|
226
|
+
:url => 'http://localhost:5000',
|
227
|
+
:user => 'admin',
|
228
|
+
:password => 'secret',
|
229
|
+
:tenant => 'admin',
|
230
230
|
}
|
231
231
|
```
|
232
232
|
### Logging parameters
|
@@ -300,13 +300,13 @@ The following options are available:
|
|
300
300
|
|
301
301
|
Example:
|
302
302
|
```ruby
|
303
|
-
openstack = Misty::Cloud.new(:auth => auth, :log_level => 0, :identity => {:region_id =>
|
303
|
+
openstack = Misty::Cloud.new(:auth => auth, :log_level => 0, :identity => {:region_id => 'regionTwo'}, :compute => {:version => '2.27', :interface => 'admin'})
|
304
304
|
```
|
305
305
|
|
306
306
|
## Direct REST HTTP Methods
|
307
307
|
To send requests directly use the 'get', 'delete', 'post' and 'put' methods directly:
|
308
308
|
```ruby
|
309
|
-
openstack.network.post(
|
309
|
+
openstack.network.post('/v2.0/qos/policies/48985e6b8da145699d411f12a3459fca/dscp_marking_rules', data)
|
310
310
|
```
|
311
311
|
# Requirements
|
312
312
|
|
data/lib/misty/auth.rb
CHANGED
@@ -17,48 +17,53 @@ module Misty
|
|
17
17
|
attr_reader :catalog, :token
|
18
18
|
|
19
19
|
def self.factory(auth, config)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
http = Misty::HTTP::NetHTTP.net_http(URI.parse(auth[:url]), config.ssl_verify_mode, config.log)
|
24
|
-
end
|
25
|
-
|
26
|
-
if auth[:tenant_id] || auth[:tenant]
|
27
|
-
return Misty::AuthV2.new(auth, http)
|
28
|
-
else
|
29
|
-
return Misty::AuthV3.new(auth, http)
|
30
|
-
end
|
20
|
+
version = auth[:tenant_id] || auth[:tenant] ? 'V2' : 'V3'
|
21
|
+
klass = Object.const_get("Misty::Auth#{version}")
|
22
|
+
klass.new(auth, config)
|
31
23
|
end
|
32
24
|
|
33
|
-
def initialize(auth,
|
25
|
+
def initialize(auth, config)
|
34
26
|
if auth[:context]
|
35
27
|
# bypass the authentication by given token catalog and expire date
|
36
28
|
@token = auth[:context][:token]
|
37
29
|
@catalog = auth[:context][:catalog]
|
38
30
|
@expires = auth[:context][:expires]
|
39
31
|
else
|
40
|
-
|
32
|
+
raise URLError, 'No URL provided' if auth[:url].nil? || auth[:url].empty?
|
33
|
+
@uri = URI.parse(auth[:url])
|
34
|
+
@config = config
|
41
35
|
# autheticate
|
42
36
|
@credentials = set_credentials(auth)
|
43
37
|
@token, @catalog, @expires = set(authenticate)
|
44
38
|
end
|
39
|
+
#byebug unless config.is_a?(Misty::Cloud::Config)
|
45
40
|
end
|
46
41
|
|
47
42
|
def authenticate
|
48
|
-
|
49
|
-
|
50
|
-
|
43
|
+
Misty::HTTP::NetHTTP.http_request(
|
44
|
+
@uri, ssl_verify_mode: @config.ssl_verify_mode, log: @config.log
|
45
|
+
) do |connection|
|
46
|
+
response = connection.post(self.class.path, @credentials.to_json,
|
47
|
+
Misty::HEADER_JSON)
|
48
|
+
unless response.code =~ /200|201/
|
49
|
+
raise AuthenticationError,
|
50
|
+
"Response code=#{response.code}, Msg=#{response.msg}"
|
51
|
+
end
|
52
|
+
response
|
53
|
+
end
|
51
54
|
end
|
52
55
|
|
53
56
|
def expired?
|
54
|
-
|
57
|
+
if @expires.nil? || @expires.empty?
|
58
|
+
raise ExpiryError, 'Missing token expiration data'
|
59
|
+
end
|
55
60
|
Time.parse(@expires) < Time.now.utc
|
56
61
|
end
|
57
62
|
|
58
63
|
def get_endpoint(service_names, region, interface)
|
59
64
|
@catalog.each do |catalog|
|
60
|
-
if service_names.include? catalog[
|
61
|
-
return catalog_endpoints(catalog[
|
65
|
+
if service_names.include? catalog['type']
|
66
|
+
return catalog_endpoints(catalog['endpoints'], region, interface)
|
62
67
|
end
|
63
68
|
end
|
64
69
|
raise CatalogError, "No service found with either #{service_names} name, region #{region}, interface #{interface}"
|
data/lib/misty/auth/auth_v2.rb
CHANGED
@@ -3,12 +3,12 @@ require 'misty/auth'
|
|
3
3
|
module Misty
|
4
4
|
class AuthV2 < Misty::Auth
|
5
5
|
def self.path
|
6
|
-
|
6
|
+
'/v2.0/tokens'
|
7
7
|
end
|
8
8
|
|
9
9
|
def catalog_endpoints(endpoints, region, interface)
|
10
10
|
endpoints.each do |endpoint|
|
11
|
-
if endpoint[
|
11
|
+
if endpoint['region'] == region && endpoint["#{interface}URL"]
|
12
12
|
return endpoint["#{interface}URL"]
|
13
13
|
end
|
14
14
|
end
|
@@ -16,28 +16,28 @@ module Misty
|
|
16
16
|
|
17
17
|
def credentials
|
18
18
|
if @token
|
19
|
-
identity = {
|
19
|
+
identity = { 'token': { 'id': @token } }
|
20
20
|
else
|
21
21
|
raise Misty::Auth::CredentialsError, "#{self.class}: User name is required" if @user.name.nil?
|
22
22
|
raise Misty::Auth::CredentialsError, "#{self.class}: User password is required" if @user.password.nil?
|
23
|
-
identity = {
|
23
|
+
identity = { 'passwordCredentials': user_credentials }
|
24
24
|
end
|
25
25
|
|
26
26
|
if @tenant.id
|
27
|
-
identity.merge!(
|
27
|
+
identity.merge!('tenantId': @tenant.id)
|
28
28
|
elsif @tenant.name
|
29
|
-
identity.merge!(
|
29
|
+
identity.merge!('tenantName': @tenant.name)
|
30
30
|
else
|
31
31
|
raise Misty::Auth::CredentialsError, "#{self.class}: No tenant available"
|
32
32
|
end
|
33
33
|
|
34
|
-
{
|
34
|
+
{ 'auth': identity }
|
35
35
|
end
|
36
36
|
|
37
37
|
def user_credentials
|
38
38
|
{
|
39
|
-
|
40
|
-
|
39
|
+
'username': @user.name,
|
40
|
+
'password': @user.password
|
41
41
|
}
|
42
42
|
end
|
43
43
|
|
@@ -49,9 +49,9 @@ module Misty
|
|
49
49
|
|
50
50
|
def set(response)
|
51
51
|
payload = JSON.load(response.body)
|
52
|
-
token = payload[
|
53
|
-
catalog = payload[
|
54
|
-
expires = payload[
|
52
|
+
token = payload['access']['token']['id']
|
53
|
+
catalog = payload['access']['serviceCatalog']
|
54
|
+
expires = payload['access']['token']['expires']
|
55
55
|
[token, catalog, expires]
|
56
56
|
end
|
57
57
|
|
data/lib/misty/auth/auth_v3.rb
CHANGED
@@ -3,13 +3,13 @@ require 'misty/auth'
|
|
3
3
|
module Misty
|
4
4
|
class AuthV3 < Misty::Auth
|
5
5
|
def self.path
|
6
|
-
|
6
|
+
'/v3/auth/tokens'
|
7
7
|
end
|
8
8
|
|
9
9
|
def catalog_endpoints(endpoints, region, interface)
|
10
10
|
endpoints.each do |endpoint|
|
11
|
-
if endpoint[
|
12
|
-
return endpoint[
|
11
|
+
if endpoint['region_id'] == region && endpoint['interface'] == interface
|
12
|
+
return endpoint['url']
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -17,27 +17,27 @@ module Misty
|
|
17
17
|
def credentials
|
18
18
|
if @token
|
19
19
|
identity = {
|
20
|
-
|
21
|
-
|
20
|
+
'methods': ['token'],
|
21
|
+
'token': { 'id': @token }
|
22
22
|
}
|
23
23
|
else
|
24
24
|
identity = {
|
25
|
-
|
26
|
-
|
25
|
+
'methods': ['password'],
|
26
|
+
'password': @user.identity
|
27
27
|
}
|
28
28
|
end
|
29
29
|
{
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
'auth': {
|
31
|
+
'identity': identity,
|
32
|
+
'scope': scope
|
33
33
|
}
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
37
|
def get_endpoint_url(endpoints, region, interface)
|
38
|
-
endpoint = endpoints.select { |ep| ep[
|
38
|
+
endpoint = endpoints.select { |ep| ep['region_id'] == region && ep['interface'] == interface }
|
39
39
|
raise CatalogError, "No endpoint available for region '#{region}' and interface '#{interface}'" unless endpoint
|
40
|
-
endpoint[0][
|
40
|
+
endpoint[0]['url']
|
41
41
|
end
|
42
42
|
|
43
43
|
def scope
|
@@ -48,9 +48,9 @@ module Misty
|
|
48
48
|
|
49
49
|
def set(response)
|
50
50
|
payload = JSON.load(response.body)
|
51
|
-
token = response[
|
52
|
-
catalog = payload[
|
53
|
-
expires = payload[
|
51
|
+
token = response['x-subject-token']
|
52
|
+
catalog = payload['token']['catalog']
|
53
|
+
expires = payload['token']['expires_at']
|
54
54
|
[token, catalog, expires]
|
55
55
|
end
|
56
56
|
|
data/lib/misty/autoload.rb
CHANGED
@@ -1,99 +1,99 @@
|
|
1
1
|
module Misty
|
2
2
|
module Openstack
|
3
3
|
module Aodh
|
4
|
-
autoload :V2,
|
4
|
+
autoload :V2, 'misty/openstack/aodh/v2'
|
5
5
|
end
|
6
6
|
|
7
7
|
module Ceilometer
|
8
|
-
autoload :V2,
|
8
|
+
autoload :V2, 'misty/openstack/ceilometer/v2'
|
9
9
|
end
|
10
10
|
|
11
11
|
module Cinder
|
12
|
-
autoload :V1,
|
13
|
-
autoload :V2,
|
14
|
-
autoload :V3,
|
12
|
+
autoload :V1, 'misty/openstack/cinder/v1'
|
13
|
+
autoload :V2, 'misty/openstack/cinder/v2'
|
14
|
+
autoload :V3, 'misty/openstack/cinder/v3'
|
15
15
|
end
|
16
16
|
|
17
17
|
module Designate
|
18
|
-
autoload :V2,
|
18
|
+
autoload :V2, 'misty/openstack/designate/v2'
|
19
19
|
end
|
20
20
|
|
21
21
|
module Freezer
|
22
|
-
autoload :V1,
|
22
|
+
autoload :V1, 'misty/openstack/freezer/v1'
|
23
23
|
end
|
24
24
|
|
25
25
|
module Glance
|
26
|
-
autoload :V1,
|
27
|
-
autoload :V2,
|
26
|
+
autoload :V1, 'misty/openstack/glance/v1'
|
27
|
+
autoload :V2, 'misty/openstack/glance/v2'
|
28
28
|
end
|
29
29
|
|
30
30
|
module Heat
|
31
|
-
autoload :V1,
|
31
|
+
autoload :V1, 'misty/openstack/heat/v1'
|
32
32
|
end
|
33
33
|
|
34
34
|
module Ironic
|
35
|
-
autoload :V1,
|
35
|
+
autoload :V1, 'misty/openstack/ironic/v1'
|
36
36
|
end
|
37
37
|
|
38
38
|
module Karbor
|
39
|
-
autoload :V1,
|
39
|
+
autoload :V1, 'misty/openstack/karbor/v1'
|
40
40
|
end
|
41
41
|
|
42
42
|
module Keystone
|
43
|
-
autoload :V3,
|
44
|
-
autoload :V2_0,
|
43
|
+
autoload :V3, 'misty/openstack/keystone/v3'
|
44
|
+
autoload :V2_0, 'misty/openstack/keystone/v2_0'
|
45
45
|
end
|
46
46
|
|
47
47
|
module Magnum
|
48
|
-
autoload :V1,
|
48
|
+
autoload :V1, 'misty/openstack/magnum/v1'
|
49
49
|
end
|
50
50
|
|
51
51
|
module Manila
|
52
|
-
autoload :V2,
|
52
|
+
autoload :V2, 'misty/openstack/manila/v2'
|
53
53
|
end
|
54
54
|
|
55
55
|
module Murano
|
56
|
-
autoload :V1,
|
56
|
+
autoload :V1, 'misty/openstack/murano/v1'
|
57
57
|
end
|
58
58
|
|
59
59
|
module Neutron
|
60
|
-
autoload :V2_0,
|
60
|
+
autoload :V2_0, 'misty/openstack/neutron/v2_0'
|
61
61
|
end
|
62
62
|
|
63
63
|
module Nova
|
64
|
-
autoload :V2_1,
|
64
|
+
autoload :V2_1, 'misty/openstack/nova/v2_1'
|
65
65
|
end
|
66
66
|
|
67
67
|
module Octavia
|
68
|
-
autoload :V2_0,
|
68
|
+
autoload :V2_0, 'misty/openstack/octavia/v2_0'
|
69
69
|
end
|
70
70
|
|
71
71
|
module Sahara
|
72
|
-
autoload :V1_1,
|
72
|
+
autoload :V1_1, 'misty/openstack/sahara/v1_1'
|
73
73
|
end
|
74
74
|
|
75
75
|
module Searchlight
|
76
|
-
autoload :V1,
|
76
|
+
autoload :V1, 'misty/openstack/searchlight/v1'
|
77
77
|
end
|
78
78
|
|
79
79
|
module Senlin
|
80
|
-
autoload :V1,
|
80
|
+
autoload :V1, 'misty/openstack/senlin/v1'
|
81
81
|
end
|
82
82
|
|
83
83
|
module Swift
|
84
|
-
autoload :V1,
|
84
|
+
autoload :V1, 'misty/openstack/swift/v1'
|
85
85
|
end
|
86
86
|
|
87
87
|
module Tacker
|
88
|
-
autoload :V1_0,
|
88
|
+
autoload :V1_0, 'misty/openstack/tacker/v1_0'
|
89
89
|
end
|
90
90
|
|
91
91
|
module Trove
|
92
|
-
autoload :V1_0,
|
92
|
+
autoload :V1_0, 'misty/openstack/trove/v1_0'
|
93
93
|
end
|
94
94
|
|
95
95
|
module Zaqar
|
96
|
-
autoload :V2,
|
96
|
+
autoload :V2, 'misty/openstack/zaqar/v2'
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
data/lib/misty/cloud.rb
CHANGED
@@ -4,7 +4,7 @@ require 'misty/auth/auth_v3'
|
|
4
4
|
module Misty
|
5
5
|
class Cloud
|
6
6
|
class Config
|
7
|
-
attr_accessor :auth, :content_type, :interface, :log, :region_id, :ssl_verify_mode
|
7
|
+
attr_accessor :auth, :content_type, :interface, :log, :region_id, :ssl_verify_mode, :headers
|
8
8
|
end
|
9
9
|
|
10
10
|
attr_reader :auth
|
@@ -27,6 +27,7 @@ module Misty
|
|
27
27
|
config.log.level = params[:log_level] ? params[:log_level] : Misty::LOG_LEVEL
|
28
28
|
config.region_id = params[:region_id] ? params[:region_id] : Misty::REGION_ID
|
29
29
|
config.ssl_verify_mode = params.key?(:ssl_verify_mode) ? params[:ssl_verify_mode] : Misty::SSL_VERIFY_MODE
|
30
|
+
config.headers = params[:headers]
|
30
31
|
config
|
31
32
|
end
|
32
33
|
|