vmpooler 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vmpooler/api/v1.rb +5 -3
- data/lib/vmpooler/version.rb +1 -1
- data/lib/vmpooler.rb +26 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70b24a35b7082f6c1230b2153836109c2c27179a
|
4
|
+
data.tar.gz: 5b96e190335f98a0ca345875d0125d3394d929b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1ea025eb7111e2c8531edbd4195510adc596bed536277a401d89a7fe8260149502803ffc1543d4df53debcbe58d1b702ec828967aba3633e497707df677c55e
|
7
|
+
data.tar.gz: 51e71c11aba30a7f16616f4e1eea3657e1f65ba35531de070593105ad2cb1d10e720b49bb042b72dce6b42d89be5714db9dec20fea989f81607d4f8c00f74b55
|
data/lib/vmpooler/api/v1.rb
CHANGED
@@ -40,8 +40,8 @@ module Vmpooler
|
|
40
40
|
template_backends = [template]
|
41
41
|
aliases = Vmpooler::API.settings.config[:alias]
|
42
42
|
if aliases
|
43
|
-
template_backends
|
44
|
-
|
43
|
+
template_backends = template_backends + aliases[template] if aliases[template].is_a?(Array)
|
44
|
+
template_backends << aliases[template] if aliases[template].is_a?(String)
|
45
45
|
pool_index = pool_index(pools)
|
46
46
|
weighted_pools = {}
|
47
47
|
template_backends.each do |t|
|
@@ -61,7 +61,9 @@ module Vmpooler
|
|
61
61
|
template_backends.delete(selection)
|
62
62
|
template_backends.unshift(selection)
|
63
63
|
else
|
64
|
-
|
64
|
+
first = template_backends.sample
|
65
|
+
template_backends.delete(first)
|
66
|
+
template_backends.unshift(first)
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
data/lib/vmpooler/version.rb
CHANGED
data/lib/vmpooler.rb
CHANGED
@@ -47,21 +47,21 @@ module Vmpooler
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# Set some configuration defaults
|
50
|
-
parsed_config[:config]['task_limit'] = ENV['TASK_LIMIT'] || parsed_config[:config]['task_limit'] || 10
|
51
|
-
parsed_config[:config]['migration_limit'] = ENV['MIGRATION_LIMIT'] if ENV['MIGRATION_LIMIT']
|
52
|
-
parsed_config[:config]['vm_checktime'] = ENV['VM_CHECKTIME'] || parsed_config[:config]['vm_checktime'] || 1
|
53
|
-
parsed_config[:config]['vm_lifetime'] = ENV['VM_LIFETIME'] || parsed_config[:config]['vm_lifetime'] || 24
|
54
|
-
parsed_config[:config]['prefix'] = ENV['
|
50
|
+
parsed_config[:config]['task_limit'] = string_to_int(ENV['TASK_LIMIT']) || parsed_config[:config]['task_limit'] || 10
|
51
|
+
parsed_config[:config]['migration_limit'] = string_to_int(ENV['MIGRATION_LIMIT']) if ENV['MIGRATION_LIMIT']
|
52
|
+
parsed_config[:config]['vm_checktime'] = string_to_int(ENV['VM_CHECKTIME']) || parsed_config[:config]['vm_checktime'] || 1
|
53
|
+
parsed_config[:config]['vm_lifetime'] = string_to_int(ENV['VM_LIFETIME']) || parsed_config[:config]['vm_lifetime'] || 24
|
54
|
+
parsed_config[:config]['prefix'] = ENV['PREFIX'] || parsed_config[:config]['prefix'] || ''
|
55
55
|
|
56
56
|
parsed_config[:config]['logfile'] = ENV['LOGFILE'] if ENV['LOGFILE']
|
57
57
|
|
58
58
|
parsed_config[:config]['site_name'] = ENV['SITE_NAME'] if ENV['SITE_NAME']
|
59
|
-
parsed_config[:config]['domain'] = ENV['
|
59
|
+
parsed_config[:config]['domain'] = ENV['DOMAIN'] if ENV['DOMAIN']
|
60
60
|
parsed_config[:config]['clone_target'] = ENV['CLONE_TARGET'] if ENV['CLONE_TARGET']
|
61
|
-
parsed_config[:config]['timeout'] = ENV['TIMEOUT'] if ENV['TIMEOUT']
|
62
|
-
parsed_config[:config]['vm_lifetime_auth'] = ENV['VM_LIFETIME_AUTH'] if ENV['VM_LIFETIME_AUTH']
|
63
|
-
parsed_config[:config]['max_tries'] = ENV['MAX_TRIES'] if ENV['MAX_TRIES']
|
64
|
-
parsed_config[:config]['retry_factor'] = ENV['RETRY_FACTOR'] if ENV['RETRY_FACTOR']
|
61
|
+
parsed_config[:config]['timeout'] = string_to_int(ENV['TIMEOUT']) if ENV['TIMEOUT']
|
62
|
+
parsed_config[:config]['vm_lifetime_auth'] = string_to_int(ENV['VM_LIFETIME_AUTH']) if ENV['VM_LIFETIME_AUTH']
|
63
|
+
parsed_config[:config]['max_tries'] = string_to_int(ENV['MAX_TRIES']) if ENV['MAX_TRIES']
|
64
|
+
parsed_config[:config]['retry_factor'] = string_to_int(ENV['RETRY_FACTOR']) if ENV['RETRY_FACTOR']
|
65
65
|
parsed_config[:config]['create_folders'] = ENV['CREATE_FOLDERS'] if ENV['CREATE_FOLDERS']
|
66
66
|
parsed_config[:config]['create_template_delta_disks'] = ENV['CREATE_TEMPLATE_DELTA_DISKS'] if ENV['CREATE_TEMPLATE_DELTA_DISKS']
|
67
67
|
parsed_config[:config]['experimental_features'] = ENV['EXPERIMENTAL_FEATURES'] if ENV['EXPERIMENTAL_FEATURES']
|
@@ -70,26 +70,26 @@ module Vmpooler
|
|
70
70
|
|
71
71
|
parsed_config[:redis] = parsed_config[:redis] || {}
|
72
72
|
parsed_config[:redis]['server'] = ENV['REDIS_SERVER'] || parsed_config[:redis]['server'] || 'localhost'
|
73
|
-
parsed_config[:redis]['port'] = ENV['REDIS_PORT'] if ENV['REDIS_PORT']
|
73
|
+
parsed_config[:redis]['port'] = string_to_int(ENV['REDIS_PORT']) if ENV['REDIS_PORT']
|
74
74
|
parsed_config[:redis]['password'] = ENV['REDIS_PASSWORD'] if ENV['REDIS_PASSWORD']
|
75
|
-
parsed_config[:redis]['data_ttl'] = ENV['REDIS_DATA_TTL'] || parsed_config[:redis]['data_ttl'] || 168
|
75
|
+
parsed_config[:redis]['data_ttl'] = string_to_int(ENV['REDIS_DATA_TTL']) || parsed_config[:redis]['data_ttl'] || 168
|
76
76
|
|
77
77
|
parsed_config[:statsd] = parsed_config[:statsd] || {} if ENV['STATSD_SERVER']
|
78
78
|
parsed_config[:statsd]['server'] = ENV['STATSD_SERVER'] if ENV['STATSD_SERVER']
|
79
79
|
parsed_config[:statsd]['prefix'] = ENV['STATSD_PREFIX'] if ENV['STATSD_PREFIX']
|
80
|
-
parsed_config[:statsd]['port'] = ENV['STATSD_PORT'] if ENV['STATSD_PORT']
|
80
|
+
parsed_config[:statsd]['port'] = string_to_int(ENV['STATSD_PORT']) if ENV['STATSD_PORT']
|
81
81
|
|
82
82
|
parsed_config[:graphite] = parsed_config[:graphite] || {} if ENV['GRAPHITE_SERVER']
|
83
83
|
parsed_config[:graphite]['server'] = ENV['GRAPHITE_SERVER'] if ENV['GRAPHITE_SERVER']
|
84
84
|
parsed_config[:graphite]['prefix'] = ENV['GRAPHITE_PREFIX'] if ENV['GRAPHITE_PREFIX']
|
85
|
-
parsed_config[:graphite]['port'] = ENV['GRAPHITE_PORT'] if ENV['GRAPHITE_PORT']
|
85
|
+
parsed_config[:graphite]['port'] = string_to_int(ENV['GRAPHITE_PORT']) if ENV['GRAPHITE_PORT']
|
86
86
|
|
87
87
|
parsed_config[:auth] = parsed_config[:auth] || {} if ENV['AUTH_PROVIDER']
|
88
88
|
if parsed_config.has_key? :auth
|
89
89
|
parsed_config[:auth]['provider'] = ENV['AUTH_PROVIDER'] if ENV['AUTH_PROVIDER']
|
90
90
|
parsed_config[:auth][:ldap] = parsed_config[:auth][:ldap] || {} if parsed_config[:auth]['provider'] == 'ldap'
|
91
91
|
parsed_config[:auth][:ldap]['host'] = ENV['LDAP_HOST'] if ENV['LDAP_HOST']
|
92
|
-
parsed_config[:auth][:ldap]['port'] = ENV['LDAP_PORT'] if ENV['LDAP_PORT']
|
92
|
+
parsed_config[:auth][:ldap]['port'] = string_to_int(ENV['LDAP_PORT']) if ENV['LDAP_PORT']
|
93
93
|
parsed_config[:auth][:ldap]['base'] = ENV['LDAP_BASE'] if ENV['LDAP_BASE']
|
94
94
|
parsed_config[:auth][:ldap]['user_object'] = ENV['LDAP_USER_OBJECT'] if ENV['LDAP_USER_OBJECT']
|
95
95
|
end
|
@@ -108,10 +108,11 @@ module Vmpooler
|
|
108
108
|
parsed_config[:pool_names] << pool['name']
|
109
109
|
if pool['alias']
|
110
110
|
if pool['alias'].is_a?(Array)
|
111
|
-
pool['alias'].each do |
|
111
|
+
pool['alias'].each do |pool_alias|
|
112
112
|
parsed_config[:alias] ||= {}
|
113
|
-
parsed_config[:alias][
|
114
|
-
parsed_config[:
|
113
|
+
parsed_config[:alias][pool_alias] = [pool['name']] unless parsed_config[:alias].key? pool_alias
|
114
|
+
parsed_config[:alias][pool_alias] << pool['name'] unless parsed_config[:alias][pool_alias].include? pool['name']
|
115
|
+
parsed_config[:pool_names] << pool_alias
|
115
116
|
end
|
116
117
|
elsif pool['alias'].is_a?(String)
|
117
118
|
parsed_config[:alias][pool['alias']] = pool['name']
|
@@ -175,4 +176,11 @@ module Vmpooler
|
|
175
176
|
end
|
176
177
|
pools_hash
|
177
178
|
end
|
179
|
+
|
180
|
+
def self.string_to_int(s)
|
181
|
+
# Returns a integer if input is a string
|
182
|
+
return if s.nil?
|
183
|
+
return unless s =~ /\d/
|
184
|
+
return Integer(s)
|
185
|
+
end
|
178
186
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmpooler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pickup
|