lorj 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/core/core_process_setup.rb +9 -0
- data/lib/core/core_setup_ask.rb +1 -1
- data/lib/core/core_setup_init.rb +2 -2
- data/lib/core_process/cloud/process/keypairs.rb +115 -86
- data/lib/core_process/cloud/process/public_ip.rb +2 -0
- data/lib/lorj/version.rb +1 -1
- data/lib/lorj_account.rb +22 -13
- data/lib/prc_core_config.rb +1 -1
- data/spec/04_prc_core_config_spec.rb +24 -0
- data/spec/12_lorj_account_spec.rb +26 -2
- 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: 7b230339c53324a35d70056924d04caf83361556
|
4
|
+
data.tar.gz: 7e40d7041f4999a803f625a850067199ed1296ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c4117298308f75daf06230285ec3971e555315c876007f548a3a3207a201655f030f61c52e87ffcb18a9ac10308b9048ee3d1128faff26551da995b573454c5
|
7
|
+
data.tar.gz: b945fafa30d2f087c51a008ec3750d5f70fdb7e3bf05e5bbd161a4c073ff69fd466745c0324822d5be03be99094455ba9cf36942fc4d9ca399842a213bce1d70
|
@@ -89,6 +89,15 @@ module Lorj
|
|
89
89
|
# - :validate: Regular expression to validate end user input
|
90
90
|
# during setup.
|
91
91
|
# - :list_values: Additional options to get a list of possible values.
|
92
|
+
# - :post_step_function Function to call after data asked to the user.
|
93
|
+
# This function must return a boolean:
|
94
|
+
# - true : The data is accepted and setup will go further.
|
95
|
+
# - false: The data is NOT accepted and setup will ask the data again.
|
96
|
+
# setup will loop until the function is happy with (return true)
|
97
|
+
# - :pre_step_function Function to call before data is asked to the user.
|
98
|
+
# This function must return a boolean:
|
99
|
+
# - true : setup will ask the data.
|
100
|
+
# - false: setup will skip asking the data.
|
92
101
|
#
|
93
102
|
# For details or more options, see core_model.rb
|
94
103
|
#
|
data/lib/core/core_setup_ask.rb
CHANGED
@@ -159,7 +159,7 @@ module Lorj
|
|
159
159
|
default = result[:default_value] unless result[:default_value].nil?
|
160
160
|
|
161
161
|
begin
|
162
|
-
default = erb(default)
|
162
|
+
default = erb(default) unless default.nil?
|
163
163
|
rescue => e
|
164
164
|
PrcLib.warning("ERB error with :%s/:default_value '%s'.\n%s",
|
165
165
|
data, result[:default_value], e.message)
|
data/lib/core/core_setup_init.rb
CHANGED
@@ -217,13 +217,13 @@ module Lorj
|
|
217
217
|
options = _get_meta_data(data)
|
218
218
|
options = {} if options.nil?
|
219
219
|
|
220
|
-
data_desc = _setup_display_data(data, options)
|
221
|
-
|
222
220
|
if options[:pre_step_function]
|
223
221
|
proc = options[:pre_step_function]
|
224
222
|
next unless @process.method(proc).call(data)
|
225
223
|
end
|
226
224
|
|
225
|
+
data_desc = _setup_display_data(data, options)
|
226
|
+
|
227
227
|
_setup_ask_data(data_desc, data, options)
|
228
228
|
end
|
229
229
|
end
|
@@ -22,7 +22,7 @@
|
|
22
22
|
class CloudProcess
|
23
23
|
# KeyPair Create Process Handler
|
24
24
|
# The process implemented is:
|
25
|
-
# * Check local SSH keypairs
|
25
|
+
# * Check local SSH keypairs with given ':keypair_name'
|
26
26
|
# * Check remote keypair existence
|
27
27
|
# * Compare and warn if needed.
|
28
28
|
# * Import public key found if missing remotely and name it.
|
@@ -40,56 +40,120 @@ class CloudProcess
|
|
40
40
|
#
|
41
41
|
def forj_get_or_create_keypair(sCloudObj, hParams)
|
42
42
|
keypair_name = hParams[:keypair_name]
|
43
|
-
# setup has configured and copied the appropriate key to forj keypairs.
|
44
|
-
|
45
|
-
loc_kpair = keypair_detect(keypair_name,
|
46
|
-
File.expand_path(hParams[:keypair_path]))
|
47
|
-
|
48
|
-
private_key_file = File.join(loc_kpair[:keypair_path],
|
49
|
-
loc_kpair[:private_key_name])
|
50
|
-
public_key_file = File.join(loc_kpair[:keypair_path],
|
51
|
-
loc_kpair[:public_key_name])
|
52
|
-
|
53
|
-
PrcLib.info("Found openssh private key file '%s'.",
|
54
|
-
private_key_file) if loc_kpair[:private_key_exist?]
|
55
|
-
PrcLib.info("Found openssh public key file '%s'.",
|
56
|
-
public_key_file) if loc_kpair[:public_key_exist?]
|
57
|
-
|
58
43
|
PrcLib.state("Searching for keypair '%s'", keypair_name)
|
59
44
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
45
|
+
keypair = forj_get_keypair(sCloudObj, keypair_name, hParams)
|
46
|
+
if keypair.empty?
|
47
|
+
loc_kpair = keypair_detect(keypair_name, hParams[:keypair_path],
|
48
|
+
hParams[:keypair_base])
|
64
49
|
keypair = keypair_import(hParams, loc_kpair)
|
65
50
|
else
|
66
|
-
keypair
|
67
|
-
keypair[:coherent] = coherent_keypair?(loc_kpair, keypair)
|
68
|
-
# Adding information about key files.
|
69
|
-
end
|
70
|
-
if keypair[:coherent]
|
71
|
-
keypair[:private_key_name] = loc_kpair[:private_key_name]
|
72
|
-
keypair[:public_key_name] = loc_kpair[:public_key_name]
|
73
|
-
keypair[:keypair_path] = loc_kpair[:keypair_path]
|
51
|
+
keypair_display(keypair)
|
74
52
|
end
|
75
53
|
keypair
|
76
54
|
end
|
77
55
|
|
78
|
-
|
79
|
-
|
56
|
+
# Query cloud keypairs and check coherence with local files
|
57
|
+
# of same name in forj files located by :keypair_path
|
58
|
+
def forj_query_keypairs(sCloudObj, sQuery, hParams)
|
59
|
+
keypair_path = File.expand_path(hParams[:keypair_path])
|
60
|
+
keypair_base = File.expand_path(hParams[:keypair_base])
|
61
|
+
|
80
62
|
ssl_error_obj = SSLErrorMgt.new
|
81
63
|
begin
|
82
|
-
|
83
|
-
# query_single(sCloudObj, list, sQuery, key_name)
|
84
|
-
query_single(sCloudObj, sQuery, key_name)
|
64
|
+
keypairs = controller_query(sCloudObj, sQuery)
|
85
65
|
rescue => e
|
86
66
|
retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
|
87
67
|
end
|
68
|
+
# Looping on keypairs to identify if they have a valid local ssh key.
|
69
|
+
keypairs.each do |keypair|
|
70
|
+
loc_kpair = keypair_detect(keypair_name, keypair_path, keypair_base)
|
71
|
+
keypair_files_detected(keypair, loc_kpair)
|
72
|
+
end
|
73
|
+
keypairs
|
74
|
+
end
|
75
|
+
|
76
|
+
# Get cloud keypair and check coherence with local files
|
77
|
+
# of same name in forj files
|
78
|
+
def forj_get_keypair(sCloudObj, keypair_name, hParams)
|
79
|
+
ssl_error_obj = SSLErrorMgt.new
|
80
|
+
begin
|
81
|
+
keypair = controller_get(sCloudObj, keypair_name)
|
82
|
+
rescue => e
|
83
|
+
retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
|
84
|
+
end
|
85
|
+
|
86
|
+
keypair_path = File.expand_path(hParams[:keypair_path])
|
87
|
+
loc_kpair = keypair_detect(keypair_name, keypair_path, keypair_name)
|
88
|
+
keypair_files_detected(keypair, loc_kpair) unless keypair.empty?
|
89
|
+
keypair
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
93
|
+
# ************************************ keypairs Object
|
94
|
+
# Identify keypairs
|
95
|
+
class Lorj::BaseDefinition
|
96
|
+
define_obj(:keypairs,
|
97
|
+
|
98
|
+
:create_e => :forj_get_or_create_keypair,
|
99
|
+
:query_e => :forj_query_keypairs,
|
100
|
+
:get_e => :forj_get_keypair
|
101
|
+
# :delete_e => :forj_delete_keypair
|
102
|
+
)
|
103
|
+
|
104
|
+
obj_needs :CloudObject, :compute_connection
|
105
|
+
obj_needs :data, :keypair_name, :for => [:create_e]
|
106
|
+
obj_needs :data, :keypair_path
|
107
|
+
obj_needs :data, :keypair_base
|
108
|
+
|
109
|
+
# By default optional. But required by the import case if needed.
|
110
|
+
obj_needs_optional
|
111
|
+
obj_needs :data, :public_key, :for => [:create_e]
|
112
|
+
|
113
|
+
def_attribute :public_key
|
114
|
+
end
|
115
|
+
|
91
116
|
# Keypair management: Internal process functions
|
92
117
|
class CloudProcess
|
118
|
+
# Function to display information about keypair object found.
|
119
|
+
#
|
120
|
+
def keypair_display(keypair)
|
121
|
+
PrcLib.info("Found keypair '%s'.", keypair[:name])
|
122
|
+
|
123
|
+
private_key_file = File.join(keypair[:keypair_path],
|
124
|
+
keypair[:private_key_name])
|
125
|
+
public_key_file = File.join(keypair[:keypair_path],
|
126
|
+
keypair[:public_key_name])
|
127
|
+
|
128
|
+
PrcLib.info("Found openssh private key file '%s'.",
|
129
|
+
private_key_file) if keypair[:private_key_exist?]
|
130
|
+
PrcLib.info("Found openssh public key file '%s'.",
|
131
|
+
public_key_file) if keypair[:public_key_exist?]
|
132
|
+
if keypair[:coherent]
|
133
|
+
PrcLib.info("keypair '%s' local files are coherent with keypair in "\
|
134
|
+
'your cloud service. You will be able to use your local '\
|
135
|
+
'keys to connect to any box configured with this keypair '\
|
136
|
+
'name, over SSH.', keypair[:name])
|
137
|
+
else
|
138
|
+
PrcLib.warning("Your local public key file '%s' is incoherent with "\
|
139
|
+
"public key attached to the keypair '%s' in your cloud."\
|
140
|
+
" You won't be able to access your box with this keypair."\
|
141
|
+
"\nPublic key found in the cloud:\n%s",
|
142
|
+
public_key_file, keypair[:name], keypair[:public_key])
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Function to update a keypair object with ssh files found in :keypair_path
|
147
|
+
#
|
148
|
+
def keypair_files_detected(keypair, loc_kpair)
|
149
|
+
keypair[:private_key_exist?] = loc_kpair[:private_key_exist?]
|
150
|
+
keypair[:public_key_exist?] = loc_kpair[:public_key_exist?]
|
151
|
+
keypair[:private_key_name] = loc_kpair[:private_key_name]
|
152
|
+
keypair[:public_key_name] = loc_kpair[:public_key_name]
|
153
|
+
keypair[:keypair_path] = loc_kpair[:keypair_path]
|
154
|
+
keypair[:coherent] = coherent_keypair?(loc_kpair, keypair)
|
155
|
+
end
|
156
|
+
|
93
157
|
def keypair_import(hParams, loc_kpair)
|
94
158
|
PrcLib.fatal(1, "Unable to import keypair '%s'. "\
|
95
159
|
'Public key file is not found. '\
|
@@ -100,22 +164,20 @@ class CloudProcess
|
|
100
164
|
loc_kpair[:public_key_name])
|
101
165
|
|
102
166
|
begin
|
103
|
-
|
167
|
+
public_key = File.read(public_key_file)
|
104
168
|
rescue => e
|
105
169
|
PrcLib.fatal(1, "Unable to import keypair '%s'. '%s' is "\
|
106
170
|
"unreadable.\n%s", hParams[:keypair_name],
|
107
171
|
loc_kpair[:public_key_file],
|
108
172
|
e.message)
|
109
173
|
end
|
110
|
-
keypair = create_keypair(:keypairs,
|
174
|
+
keypair = create_keypair(:keypairs, :public_key => public_key)
|
111
175
|
|
112
176
|
return nil if keypair.nil?
|
113
177
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
keypair[:coherent] = true
|
118
|
-
end
|
178
|
+
# Adding information about SSH key files.
|
179
|
+
keypair_files_detected(keypair, loc_kpair)
|
180
|
+
|
119
181
|
keypair
|
120
182
|
end
|
121
183
|
|
@@ -124,7 +186,7 @@ class CloudProcess
|
|
124
186
|
PrcLib.state("Importing keypair '%s'", key_name)
|
125
187
|
ssl_error_obj = SSLErrorMgt.new
|
126
188
|
begin
|
127
|
-
keypair = controller_create(sCloudObj)
|
189
|
+
keypair = controller_create(sCloudObj, hParams)
|
128
190
|
PrcLib.info("Keypair '%s' imported.", keypair[:name])
|
129
191
|
rescue StandardError => e
|
130
192
|
retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
|
@@ -136,9 +198,18 @@ class CloudProcess
|
|
136
198
|
# Build keypair data information structure with files found in
|
137
199
|
# local filesystem. Take care of priv with or without .pem
|
138
200
|
# and pubkey with pub.
|
139
|
-
|
140
|
-
|
141
|
-
|
201
|
+
# :keypair_path data settings is changing to become just a path to
|
202
|
+
# the keypair files, the base keypair.
|
203
|
+
# Which will introduce a :keypair_base in the setup.
|
204
|
+
def keypair_detect(keypair_name, key_fullpath, key_basename = nil)
|
205
|
+
# When uses key_basename, we switch to the new model
|
206
|
+
# using :keypair_path and :keypair_base in setup
|
207
|
+
if key_basename.nil?
|
208
|
+
key_basename = File.basename(key_fullpath)
|
209
|
+
key_path = File.expand_path(File.dirname(key_fullpath))
|
210
|
+
else
|
211
|
+
key_path = File.expand_path(key_fullpath)
|
212
|
+
end
|
142
213
|
|
143
214
|
obj_match = key_basename.match(/^(.*?)(\.pem|\.pub)?$/)
|
144
215
|
key_basename = obj_match[1]
|
@@ -184,15 +255,6 @@ class CloudProcess
|
|
184
255
|
[found_ext, files]
|
185
256
|
end
|
186
257
|
|
187
|
-
def forj_get_keypair(sCloudObj, sName, _hParams)
|
188
|
-
ssl_error_obj = SSLErrorMgt.new
|
189
|
-
begin
|
190
|
-
controller_get(sCloudObj, sName)
|
191
|
-
rescue => e
|
192
|
-
retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
258
|
def get_keypairs_path(hParams, hKeys)
|
197
259
|
keypair_name = hParams[:keypair_name]
|
198
260
|
|
@@ -225,8 +287,6 @@ class CloudProcess
|
|
225
287
|
# - coherent : Boolean. True if same public key.
|
226
288
|
def coherent_keypair?(loc_kpair, keypair)
|
227
289
|
# send keypairs by parameter
|
228
|
-
|
229
|
-
keypair_name = loc_kpair[:keypair_name]
|
230
290
|
is_coherent = false
|
231
291
|
|
232
292
|
pub_keypair = keypair[:public_key]
|
@@ -241,17 +301,7 @@ class CloudProcess
|
|
241
301
|
loc_kpair[:public_key_file], e.message)
|
242
302
|
else
|
243
303
|
if loc_pubkey.split(' ')[1].strip == pub_keypair.split(' ')[1].strip
|
244
|
-
PrcLib.info("keypair '%s' local files are coherent with keypair in "\
|
245
|
-
'your cloud service. You will be able to connect to '\
|
246
|
-
'your box over SSH.', keypair_name)
|
247
304
|
is_coherent = true
|
248
|
-
else
|
249
|
-
PrcLib.warning("Your local keypair file '%s' are incoherent with "\
|
250
|
-
"public key '%s' found in your cloud. You won't be "\
|
251
|
-
"able to access your box with this keypair.\nPublic "\
|
252
|
-
"key found in the cloud:\n%s",
|
253
|
-
loc_kpair[:public_key_file], keypair_name,
|
254
|
-
keypair[:public_key])
|
255
305
|
end
|
256
306
|
end
|
257
307
|
else
|
@@ -261,24 +311,3 @@ class CloudProcess
|
|
261
311
|
is_coherent
|
262
312
|
end
|
263
313
|
end
|
264
|
-
|
265
|
-
# ************************************ keypairs Object
|
266
|
-
# Identify keypairs
|
267
|
-
class Lorj::BaseDefinition
|
268
|
-
define_obj(:keypairs,
|
269
|
-
|
270
|
-
:create_e => :forj_get_or_create_keypair,
|
271
|
-
:query_e => :forj_query_keypair,
|
272
|
-
:get_e => :forj_get_keypair
|
273
|
-
# :delete_e => :forj_delete_keypair
|
274
|
-
)
|
275
|
-
|
276
|
-
obj_needs :CloudObject, :compute_connection
|
277
|
-
obj_needs :data, :keypair_name, :for => [:create_e]
|
278
|
-
obj_needs :data, :keypair_path, :for => [:create_e]
|
279
|
-
|
280
|
-
obj_needs_optional
|
281
|
-
obj_needs :data, :public_key, :for => [:create_e]
|
282
|
-
|
283
|
-
def_attribute :public_key
|
284
|
-
end
|
@@ -34,6 +34,7 @@ class CloudProcess
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
# Function to query the list of addresses for one server
|
37
38
|
def forj_query_public_address(sCloudObj, sQuery, hParams)
|
38
39
|
server_name = hParams[:server, :name]
|
39
40
|
ssl_error_obj = SSLErrorMgt.new
|
@@ -54,6 +55,7 @@ class CloudProcess
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
58
|
+
# Function to get the IP address
|
57
59
|
def forj_get_public_address(sCloudObj, sId, _hParams)
|
58
60
|
ssl_error_obj = SSLErrorMgt.new
|
59
61
|
begin
|
data/lib/lorj/version.rb
CHANGED
data/lib/lorj_account.rb
CHANGED
@@ -161,7 +161,9 @@ module Lorj
|
|
161
161
|
# - +options+ : Options for get:
|
162
162
|
# - +:section+ : Get will use this section name instead of searching it.
|
163
163
|
# - +:names+ : array of layers name to exclusively get data.
|
164
|
+
# - +:name+ : layer name to exclusively get data.
|
164
165
|
# - +:indexes+ : array of layers index to exclusively get data.
|
166
|
+
# - +:index+ : layer index to exclusively get data.
|
165
167
|
# If neither :name or :index is set, get will search
|
166
168
|
# data on all predefined layers, first found.
|
167
169
|
# * *Returns* :
|
@@ -175,9 +177,9 @@ module Lorj
|
|
175
177
|
section = options[:section]
|
176
178
|
section = Lorj.data.first_section(key) if section.nil?
|
177
179
|
|
178
|
-
options =
|
180
|
+
options = options.merge(:keys => [key], :section => section)
|
179
181
|
|
180
|
-
indexes =
|
182
|
+
indexes = _identify_indexes(options, exclusive?(key, section))
|
181
183
|
names = []
|
182
184
|
indexes.each { |index| names << @config_layers[index][:name] }
|
183
185
|
|
@@ -205,11 +207,13 @@ module Lorj
|
|
205
207
|
# - +options+ : possible options:
|
206
208
|
# - +:section+ : Force to use a specific section name.
|
207
209
|
# - +:names+ : array of layers name to exclusively get data.
|
210
|
+
# - +:name+ : layer name to exclusively get data.
|
208
211
|
# - +:indexes+ : array of layers index to exclusively get data.
|
212
|
+
# - +:index+ : layer index to exclusively get data.
|
209
213
|
# If neither :name or :index is set, get will search data on all
|
210
214
|
# predefined layers, first found, first listed.
|
211
215
|
# * *Returns* :
|
212
|
-
# -
|
216
|
+
# - config name found.
|
213
217
|
# * *Raises* :
|
214
218
|
# Nothing
|
215
219
|
def where?(key, options = {})
|
@@ -217,9 +221,9 @@ module Lorj
|
|
217
221
|
options = {} unless options.is_a?(Hash)
|
218
222
|
|
219
223
|
section = options[:section]
|
220
|
-
section = Lorj.
|
224
|
+
section = Lorj.data.first_section(key) if section.nil?
|
221
225
|
|
222
|
-
indexes =
|
226
|
+
indexes = _identify_indexes(options, exclusive?(key, section))
|
223
227
|
|
224
228
|
names = []
|
225
229
|
indexes.each { |index| names << @config_layers[index][:name] }
|
@@ -242,17 +246,20 @@ module Lorj
|
|
242
246
|
# - +options+ : possible options:
|
243
247
|
# - +:section+ : Force to use a specific section name.
|
244
248
|
# - +:names+ : array of layers name to exclusively get data.
|
249
|
+
# - +:name+ : layer name to exclusively get data.
|
245
250
|
# - +:indexes+ : array of layers index to exclusively get data.
|
251
|
+
# - +:index+ : layer index to exclusively get data.
|
246
252
|
# If neither :name or :index is set, get will search data on all
|
247
253
|
# predefined layers, first found.
|
248
254
|
#
|
249
255
|
# * *Returns* :
|
250
|
-
# -
|
251
|
-
# -
|
252
|
-
# -
|
253
|
-
#
|
254
|
-
# -
|
255
|
-
#
|
256
|
+
# - true : if found in runtime.
|
257
|
+
# - true : if found in the Account data structure.
|
258
|
+
# - true : if found in the local configuration file.
|
259
|
+
# Usually ~/.forj/config.yaml
|
260
|
+
# - true : if found in the Application default
|
261
|
+
# (File 'defaults.yaml') (class Default)
|
262
|
+
# - false otherwise.
|
256
263
|
# * *Raises* :
|
257
264
|
# Nothing
|
258
265
|
def exist?(key, options = nil)
|
@@ -261,9 +268,9 @@ module Lorj
|
|
261
268
|
|
262
269
|
section = options[:section]
|
263
270
|
section = Lorj.data.first_section(key) if section.nil?
|
264
|
-
options =
|
271
|
+
options = options.merge(:keys => [key], :section => section)
|
265
272
|
|
266
|
-
indexes =
|
273
|
+
indexes = _identify_indexes(options, exclusive?(key, section))
|
267
274
|
|
268
275
|
names = []
|
269
276
|
indexes.each { |index| names << @config_layers[index][:name] }
|
@@ -550,6 +557,8 @@ module Lorj
|
|
550
557
|
indexes = exclusive_indexes(account_exclusive)
|
551
558
|
indexes = [index] if !index.nil? && indexes.include?(index)
|
552
559
|
|
560
|
+
return _identify_array_indexes(options, account_exclusive) if index.nil?
|
561
|
+
|
553
562
|
options[:indexes] = indexes
|
554
563
|
indexes
|
555
564
|
end
|
data/lib/prc_core_config.rb
CHANGED
@@ -424,7 +424,7 @@ module PRC
|
|
424
424
|
return nil if keys.length == 0 || keys[0].nil? || config_layers[0].nil?
|
425
425
|
|
426
426
|
config_layers.each_index do |index|
|
427
|
-
config =
|
427
|
+
config = config_layers[index][:config]
|
428
428
|
|
429
429
|
data_options = options.clone
|
430
430
|
data_options.delete_if do |key|
|
@@ -57,6 +57,10 @@ describe 'class: PRC::CoreConfig,' do
|
|
57
57
|
initialize_layers(layers)
|
58
58
|
end
|
59
59
|
|
60
|
+
def iexist?(options)
|
61
|
+
p_exist?(options)
|
62
|
+
end
|
63
|
+
|
60
64
|
def set(options)
|
61
65
|
p_set(options)
|
62
66
|
end
|
@@ -77,6 +81,26 @@ describe 'class: PRC::CoreConfig,' do
|
|
77
81
|
expect(@config.exist?(:test)).to equal(true)
|
78
82
|
end
|
79
83
|
|
84
|
+
it 'config.p_exist?(:keys => [:test]) returns true' do
|
85
|
+
expect(@config.iexist?(:keys => [:test])).to equal(true)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'config.p_exist?(:keys => [:test], :name => "runtime") returns false' do
|
89
|
+
expect(@config.iexist?(:keys => [:test],
|
90
|
+
:name => 'runtime')).to equal(false)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'config.p_exist?(:keys => [:test], :names => ["runtime"])'\
|
94
|
+
' returns false' do
|
95
|
+
expect(@config.iexist?(:keys => [:test],
|
96
|
+
:names => ['runtime'])).to equal(false)
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'config.p_exist?(:keys => [:test], :names => ["local"]) returns true' do
|
100
|
+
expect(@config.iexist?(:keys => [:test],
|
101
|
+
:names => ['local'])).to equal(true)
|
102
|
+
end
|
103
|
+
|
80
104
|
it 'config.exist?(:test2, :test) returns true' do
|
81
105
|
expect(@config.exist?(:test2, :test)).to equal(true)
|
82
106
|
end
|
@@ -172,11 +172,35 @@ describe 'class: Lorj::Account,' do
|
|
172
172
|
expect(@account.where?(:keypair_name)).to eq(%w(account local default))
|
173
173
|
end
|
174
174
|
|
175
|
+
it "account.set(:keypair_name, 'nova_test3') return "\
|
176
|
+
" 'nova_test3'" do
|
177
|
+
expect(@account.set(:keypair_name, 'nova_test3')).to eq('nova_test3')
|
178
|
+
expect(@account.where?(:keypair_name)).to eq(%w(runtime account
|
179
|
+
local default))
|
180
|
+
end
|
181
|
+
|
175
182
|
it "account.get(:keypair_name, :name => 'account') return 'nova_test2'" do
|
176
|
-
expect(@account.get(:keypair_name,
|
183
|
+
expect(@account.get(:keypair_name, nil,
|
177
184
|
:name => 'account')).to eq('nova_test2')
|
178
185
|
end
|
179
186
|
|
187
|
+
it "account.get(:keypair_name, :names => ['account']) return "\
|
188
|
+
"'nova_test2'" do
|
189
|
+
expect(@account.get(:keypair_name, nil,
|
190
|
+
:names => ['account'])).to eq('nova_test2')
|
191
|
+
end
|
192
|
+
|
193
|
+
it "account.get(:keypair_name, :name => 'runtime') return 'nova_test3'" do
|
194
|
+
expect(@account.get(:keypair_name, nil,
|
195
|
+
:name => 'runtime')).to eq('nova_test3')
|
196
|
+
end
|
197
|
+
|
198
|
+
it "account.get(:keypair_name, :names => ['runtime']) return "\
|
199
|
+
"'nova_test3'" do
|
200
|
+
expect(@account.get(:keypair_name, nil,
|
201
|
+
:names => ['runtime'])).to eq('nova_test3')
|
202
|
+
end
|
203
|
+
|
180
204
|
it 'account.ac_save return true' do
|
181
205
|
expect(@account.ac_save).to equal(true)
|
182
206
|
end
|
@@ -193,7 +217,7 @@ describe 'class: Lorj::Account,' do
|
|
193
217
|
|
194
218
|
it "account.get(:keypair_name, :name => 'account') return "\
|
195
219
|
"saved 'nova_test2'" do
|
196
|
-
expect(@account.get(:keypair_name,
|
220
|
+
expect(@account.get(:keypair_name, nil,
|
197
221
|
:name => 'account')).to eq('nova_test2')
|
198
222
|
end
|
199
223
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lorj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- forj team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|