fog-openstack 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fog-openstack.gemspec +1 -1
- data/lib/fog/openstack.rb +3 -2
- data/lib/fog/openstack/core.rb +3 -0
- data/lib/fog/openstack/identity_v3.rb +1 -1
- data/lib/fog/openstack/models/identity_v3/projects.rb +19 -6
- data/lib/fog/openstack/requests/compute/create_server.rb +7 -10
- data/lib/fog/openstack/version.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: a5ef3d5e9db5c4a3630e0f142fb5969346b249a2
|
4
|
+
data.tar.gz: 86a67a59a76c82967d7f834c8d0c4fce73391ec1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 064950f848ead6d4791df03194d7b991dd793c8717c42beb0e383f400339560f6633e379709c1dd6239876172f60ef4f8c18eae906e3446ea7c405933193cce8
|
7
|
+
data.tar.gz: 4ac6a0c3d149c410d9bbbda237fe14b4d6ab862b4a29a3dc92e4ce96860ce3fc9eb4b6e788d3c93a2be34bd2311ccd87d02ec4d28a0233594e1fdcefbc3d553a
|
data/fog-openstack.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency 'fog-core', '>= 1.
|
22
|
+
spec.add_dependency 'fog-core', '>= 1.38'
|
23
23
|
spec.add_dependency 'fog-json', '>= 1.0'
|
24
24
|
spec.add_dependency 'fog-xml', '>= 0.1'
|
25
25
|
spec.add_dependency 'ipaddress', '>= 0.8'
|
data/lib/fog/openstack.rb
CHANGED
@@ -365,6 +365,7 @@ module Fog
|
|
365
365
|
auth_token = options[:openstack_auth_token] || options[:unscoped_token]
|
366
366
|
uri = options[:openstack_auth_uri]
|
367
367
|
omit_default_port = options[:openstack_auth_omit_default_port]
|
368
|
+
cache_ttl = options[:openstack_cache_ttl] || 0
|
368
369
|
|
369
370
|
connection = Fog::Core::Connection.new(uri.to_s, false, connection_options)
|
370
371
|
request_body = {:auth => {}}
|
@@ -420,7 +421,7 @@ module Fog
|
|
420
421
|
|
421
422
|
path = (uri.path and not uri.path.empty?) ? uri.path : 'v3'
|
422
423
|
|
423
|
-
response, expires = @@token_cache[{body
|
424
|
+
response, expires = @@token_cache[{:body => request_body, :path => path}] if cache_ttl > 0
|
424
425
|
|
425
426
|
unless response && expires > Time.now
|
426
427
|
request = {
|
@@ -433,7 +434,7 @@ module Fog
|
|
433
434
|
request[:omit_default_port] = omit_default_port unless omit_default_port.nil?
|
434
435
|
|
435
436
|
response = connection.request(request)
|
436
|
-
@@token_cache[{body
|
437
|
+
@@token_cache[{:body => request_body, :path => path}] = response, Time.now + cache_ttl if cache_ttl > 0
|
437
438
|
end
|
438
439
|
|
439
440
|
[response.headers["X-Subject-Token"], Fog::JSON.decode(response.body)]
|
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 :openstack_cache_ttl
|
5
6
|
attr_reader :auth_token_expiration
|
6
7
|
attr_reader :current_user
|
7
8
|
attr_reader :current_user_id
|
@@ -27,6 +28,8 @@ module Fog
|
|
27
28
|
@openstack_must_reauthenticate = false
|
28
29
|
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'publicURL'
|
29
30
|
|
31
|
+
@openstack_cache_ttl = options[:openstack_cache_ttl] || 0
|
32
|
+
|
30
33
|
unless @auth_token
|
31
34
|
missing_credentials = Array.new
|
32
35
|
|
@@ -15,7 +15,7 @@ module Fog
|
|
15
15
|
:openstack_user_domain_id, :openstack_project_domain_id,
|
16
16
|
:openstack_api_key, :openstack_current_user_id, :openstack_userid, :openstack_username,
|
17
17
|
:current_user, :current_user_id, :current_tenant,
|
18
|
-
:provider, :openstack_identity_prefix, :openstack_endpoint_path_matches
|
18
|
+
:provider, :openstack_identity_prefix, :openstack_endpoint_path_matches, :openstack_cache_ttl
|
19
19
|
|
20
20
|
model_path 'fog/openstack/models/identity_v3'
|
21
21
|
model :domain
|
@@ -12,10 +12,16 @@ module Fog
|
|
12
12
|
Fog::Identity::OpenStack::V3::Project.use_cache(@@cache)
|
13
13
|
|
14
14
|
def all(options = {})
|
15
|
-
|
16
|
-
|
15
|
+
if service.openstack_cache_ttl > 0
|
16
|
+
cached_project, expires = @@cache[{:token => service.auth_token, :options => options}]
|
17
|
+
return cached_project if cached_project && expires > Time.now
|
18
|
+
end
|
19
|
+
|
17
20
|
project_to_cache = load_response(service.list_projects(options), 'projects')
|
18
|
-
|
21
|
+
if service.openstack_cache_ttl > 0
|
22
|
+
@@cache[{:token => service.auth_token, :options => options}] = [project_to_cache,
|
23
|
+
Time.now + service.openstack_cache_ttl]
|
24
|
+
end
|
19
25
|
return project_to_cache
|
20
26
|
end
|
21
27
|
|
@@ -32,8 +38,11 @@ module Fog
|
|
32
38
|
if options.is_a? Symbol # Deal with a single option being passed on its own
|
33
39
|
options = [options]
|
34
40
|
end
|
35
|
-
|
36
|
-
|
41
|
+
|
42
|
+
if service.openstack_cache_ttl > 0
|
43
|
+
cached_project, expires = @@cache[{:token => service.auth_token, :id => id, :options => options}]
|
44
|
+
return cached_project if cached_project && expires > Time.now
|
45
|
+
end
|
37
46
|
project_hash = service.get_project(id, options).body['project']
|
38
47
|
top_project = project_from_hash(project_hash, service)
|
39
48
|
if options.include? :subtree_as_list
|
@@ -42,7 +51,11 @@ module Fog
|
|
42
51
|
if options.include? :parents_as_list
|
43
52
|
top_project.parents.map! {|proj_hash| project_from_hash(proj_hash['project'], service)}
|
44
53
|
end
|
45
|
-
|
54
|
+
|
55
|
+
if service.openstack_cache_ttl > 0
|
56
|
+
@@cache[{:token => service.auth_token, :id => id, :options => options}] = [
|
57
|
+
top_project, Time.now + service.openstack_cache_tt]
|
58
|
+
end
|
46
59
|
return top_project
|
47
60
|
end
|
48
61
|
|
@@ -6,10 +6,10 @@ module Fog
|
|
6
6
|
data = {
|
7
7
|
'server' => {
|
8
8
|
'flavorRef' => flavor_ref,
|
9
|
-
'imageRef' => image_ref,
|
10
9
|
'name' => name
|
11
10
|
}
|
12
11
|
}
|
12
|
+
data['server']['imageRef'] = image_ref if image_ref
|
13
13
|
|
14
14
|
vanilla_options = ['metadata', 'accessIPv4', 'accessIPv6',
|
15
15
|
'availability_zone', 'user_data', 'key_name',
|
@@ -59,15 +59,12 @@ module Fog
|
|
59
59
|
|
60
60
|
if (block_device_mapping = options['block_device_mapping_v2'])
|
61
61
|
data['server']['block_device_mapping_v2'] = [block_device_mapping].flatten.collect do |mapping|
|
62
|
-
{
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
'uuid' => mapping[:uuid],
|
69
|
-
'volume_size' => mapping[:volume_size],
|
70
|
-
}
|
62
|
+
entered_block_device_mapping = {}
|
63
|
+
[:boot_index, :delete_on_termination, :destination_type, :device_name, :source_type, :uuid,
|
64
|
+
:volume_size].each do |index|
|
65
|
+
entered_block_device_mapping[index.to_s] = mapping[index] if mapping.key?(index)
|
66
|
+
end
|
67
|
+
entered_block_device_mapping
|
71
68
|
end
|
72
69
|
elsif (block_device_mapping = options['block_device_mapping'])
|
73
70
|
data['server']['block_device_mapping'] = [block_device_mapping].flatten.collect do |mapping|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-openstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Darby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.38'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.38'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fog-json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|