forj 0.0.43 → 0.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/bin/forj +49 -120
- data/lib/appinit.rb +50 -0
- data/lib/boot.rb +30 -43
- data/lib/connection.rb +28 -5
- data/lib/defaults.yaml +115 -61
- data/lib/forj-account.rb +168 -50
- data/lib/forj-config.rb +204 -148
- data/lib/forj-settings.rb +209 -0
- data/lib/helpers.rb +1 -5
- data/lib/log.rb +1 -25
- data/lib/repositories.rb +5 -4
- data/spec/connection_spec.rb +9 -10
- data/spec/forj-config_spec.rb +21 -20
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a1aeb1a399ecfab67138cf2cb50b12deff71212
|
4
|
+
data.tar.gz: 9c46f0ccaeaaca2775b4d897065b10f1d4aea93e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd00c4f1f397736bf1f3b6cb0fce7c65a1545c927544afafb42cad52271632dcbded52531d643e5a674d3fe39f106e5e1139eae43cd082124555e5da0c9b7ccd
|
7
|
+
data.tar.gz: b840b30588d58ed512bb1890688aeb50596675d3376cbcaf9bbeb51ab2677723d1c0cef819b2cd5a18ce97755a7cb29d19dced034a8c38e66e8b8a702454583c
|
data/Rakefile
CHANGED
data/bin/forj
CHANGED
@@ -25,6 +25,18 @@ $LIB_PATH = File.expand_path(File.join(File.dirname($APP_PATH),'lib'))
|
|
25
25
|
|
26
26
|
$LOAD_PATH << $LIB_PATH
|
27
27
|
|
28
|
+
require 'appinit.rb' # Load generic Application level function
|
29
|
+
|
30
|
+
# Initialize forj paths
|
31
|
+
AppInit::forj_initialize()
|
32
|
+
|
33
|
+
# Initialize global Log object
|
34
|
+
$FORJ_LOGGER=ForjLog.new()
|
35
|
+
|
36
|
+
require 'forj-config.rb' # Load class ForjConfig and Meta data class variables. Requires Logging to be fully set.
|
37
|
+
require 'forj-account.rb' # Load class ForjAccount
|
38
|
+
require 'connection.rb' # Load class ForjConnection
|
39
|
+
|
28
40
|
require 'boot.rb'
|
29
41
|
require 'down.rb'
|
30
42
|
require 'setup.rb'
|
@@ -34,25 +46,14 @@ include Boot
|
|
34
46
|
include Down
|
35
47
|
include Setup
|
36
48
|
include Ssh
|
37
|
-
|
38
|
-
require 'forj-config.rb' # Load class ForjConfig
|
39
|
-
require 'forj-account.rb' # Load class ForjAccount
|
40
|
-
require 'log.rb' # Load default loggers
|
41
|
-
require 'connection.rb' # Load class ForjConnection
|
49
|
+
require 'forj-settings.rb' # Settings features
|
42
50
|
|
43
51
|
#require 'debugger' # Use to debug with Ruby < 2.0
|
44
52
|
#require 'byebug' # Use to debug with Ruby >= 2.0
|
45
53
|
|
46
|
-
include Logging
|
47
54
|
|
48
|
-
# Initialize forj paths
|
49
|
-
ensure_forj_dirs_exists()
|
50
|
-
|
51
|
-
# Initialize global Log object
|
52
|
-
$FORJ_LOGGER=ForjLog.new()
|
53
55
|
|
54
|
-
|
55
|
-
class Forj < Thor
|
56
|
+
class ForjThor < Thor
|
56
57
|
|
57
58
|
class_option :debug, :aliases => '-d', :desc => 'Set debug mode'
|
58
59
|
class_option :verbose, :aliases => '-v', :desc => 'Set verbose mode'
|
@@ -163,6 +164,9 @@ Maestro/infra bootstrap debugging:"
|
|
163
164
|
|
164
165
|
# Options are added if they are set. Otherwise, get will retrieve the default value.
|
165
166
|
oConfig.set(:account_name, options[:account_name]) if options[:account_name]
|
167
|
+
oForjAccount = ForjAccount.new(oConfig)
|
168
|
+
oForjAccount.ac_load()
|
169
|
+
|
166
170
|
oConfig.set(:infra_repo, options[:infra])
|
167
171
|
oConfig.set(:keypair_name, options[:key_name])
|
168
172
|
oConfig.set(:keypair_path, options[:key_path])
|
@@ -171,6 +175,7 @@ Maestro/infra bootstrap debugging:"
|
|
171
175
|
oConfig.set(:flavor, options[:maestro_flavor])
|
172
176
|
oConfig.set(:bp_flavor, options[:bp_flavor])
|
173
177
|
oConfig.set(:maestro_repo , options[:maestro_repo])
|
178
|
+
oConfig.set(:branch , options[:branch])
|
174
179
|
oConfig.set(:test_box, File.expand_path(options[:test_box])) if options[:test_box] and File.directory?(File.expand_path(options[:test_box]))
|
175
180
|
|
176
181
|
|
@@ -187,8 +192,7 @@ Maestro/infra bootstrap debugging:"
|
|
187
192
|
end
|
188
193
|
end
|
189
194
|
|
190
|
-
Boot.boot(blueprint, name, options[:build],options[:
|
191
|
-
options[:boothook], options[:box_name], oConfig)
|
195
|
+
Boot.boot(blueprint, name, options[:build], options[:boothook], options[:box_name], oForjAccount)
|
192
196
|
end
|
193
197
|
|
194
198
|
################################# Show defaults
|
@@ -244,16 +248,19 @@ Warning! This action don't removed any network/security groups cloud object.
|
|
244
248
|
def down(name)
|
245
249
|
Logging.set_level(Logger::INFO) if options[:verbose]
|
246
250
|
Logging.set_level(Logger::DEBUG) if options[:debug]
|
251
|
+
|
247
252
|
oConfig = ForjConfig.new(options[:config])
|
248
253
|
oConfig.set(:account_name, options[:account_name]) if options[:account_name]
|
254
|
+
oForjAccount = ForjAccount.new(oConfig)
|
255
|
+
oForjAccount.ac_load()
|
249
256
|
|
250
|
-
Down.down(
|
257
|
+
Down.down(oForjAccount, name)
|
251
258
|
end
|
252
259
|
|
253
260
|
################################# SET
|
254
|
-
desc 'set [key=value] [options]', 'Set
|
261
|
+
desc 'set [key=value] [...] [options]', 'Set one or more variables in defaults or a forj account.'
|
255
262
|
long_desc <<-LONGDESC
|
256
|
-
You can set some variables to change 'forj' defaults or specifically
|
263
|
+
You can set some variables to change 'forj' defaults or specifically some account data.
|
257
264
|
|
258
265
|
Ex: By default, forj use ~/.ssh/forj-id_rsa as keypair for all forge instance. During setup, if this keypair doesn't exist, it proposes to create it for you, with ssh-keygen.
|
259
266
|
If you want to use a keypair that already exists, you can set it as your default, with:
|
@@ -280,65 +287,23 @@ Ex: By default, forj use ~/.ssh/forj-id_rsa as keypair for all forge instance. D
|
|
280
287
|
|
281
288
|
method_option :account_name, :aliases => '-a', :desc => "Set the forj account name to use. By default, uses the default account set in your local config file."
|
282
289
|
|
283
|
-
def set(
|
290
|
+
def set(*p)
|
284
291
|
Logging.set_level(Logger::INFO) if options[:verbose]
|
285
292
|
Logging.set_level(Logger::DEBUG) if options[:debug]
|
286
293
|
|
287
294
|
oConfig=ForjConfig.new()
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
+
|
296
|
+
if p.length == 0 and not options[:account_name]
|
297
|
+
Forj::Settings::config_show_all(oConfig)
|
298
|
+
|
299
|
+
elsif p.length == 0 and options[:account_name]
|
300
|
+
Forj::Settings::account_show_all(oConfig, options[:account_name])
|
301
|
+
|
302
|
+
elsif p.length != 0 and options[:account_name]
|
303
|
+
Forj::Settings::account_set(oConfig, options[:account_name], p)
|
304
|
+
|
295
305
|
else
|
296
|
-
|
297
|
-
if mkey_val
|
298
|
-
if not options[:account_name]
|
299
|
-
if oConfig.exist?(mkey_val[1])
|
300
|
-
sBef = "%s: '%s'" % [oConfig.exist?(mkey_val[1]), oConfig.get(mkey_val[1])]
|
301
|
-
else
|
302
|
-
sBef = "unset"
|
303
|
-
end
|
304
|
-
if mkey_val[2] != ""
|
305
|
-
oConfig.LocalSet(mkey_val[1], mkey_val[2])
|
306
|
-
else
|
307
|
-
oConfig.LocalDel(mkey_val[1])
|
308
|
-
end
|
309
|
-
oConfig.SaveConfig()
|
310
|
-
if oConfig.exist?(mkey_val[1])
|
311
|
-
sAft = "%s: '%s'" % [oConfig.exist?(mkey_val[1]), oConfig.get(mkey_val[1])]
|
312
|
-
else
|
313
|
-
sAft = "unset"
|
314
|
-
end
|
315
|
-
puts "Updated:\n%s: %s => %s" % [mkey_val[1], sBef, sAft]
|
316
|
-
else
|
317
|
-
account_name = options[:account_name]
|
318
|
-
oConfig.set(:account_name, account_name)
|
319
|
-
oForjAccount = ForjAccount.new(oConfig)
|
320
|
-
oForjAccount.ac_load()
|
321
|
-
if oForjAccount.exist?(mkey_val[1])
|
322
|
-
sBef = "%s: '%s'" % [oForjAccount.exist?(mkey_val[1]).sub("hash", account_name), oForjAccount.get(mkey_val[1])]
|
323
|
-
else
|
324
|
-
sBef = "unset"
|
325
|
-
end
|
326
|
-
if mkey_val[2] == ""
|
327
|
-
oForjAccount.del(mkey_val[1])
|
328
|
-
else
|
329
|
-
oForjAccount.set(mkey_val[1], mkey_val[2])
|
330
|
-
end
|
331
|
-
oForjAccount.ac_save()
|
332
|
-
if oForjAccount.exist?(mkey_val[1])
|
333
|
-
sAft = "%s: '%s'" % [oForjAccount.exist?(mkey_val[1]).sub("hash", account_name), oForjAccount.get(mkey_val[1])]
|
334
|
-
else
|
335
|
-
sAft = "unset"
|
336
|
-
end
|
337
|
-
puts "Updated:\n%s: %s => %s" % [mkey_val[1], sBef, sAft]
|
338
|
-
end
|
339
|
-
else
|
340
|
-
Logging.fatal(1 ,"Syntax error. Please set your value like: 'key=value' and retry.")
|
341
|
-
end
|
306
|
+
Forj::Settings::config_set(oConfig, p)
|
342
307
|
end
|
343
308
|
end
|
344
309
|
|
@@ -369,54 +334,18 @@ Ex: To get the keypair_name defined from the account, or from your ~/.forj/confi
|
|
369
334
|
Logging.set_level(Logger::INFO) if options[:verbose]
|
370
335
|
Logging.set_level(Logger::DEBUG) if options[:debug]
|
371
336
|
|
372
|
-
oConfig=ForjConfig.new()
|
373
|
-
if
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
puts "%-15s(%-7s) %-12s:\n--------------------------------------" % ['key', 'origin', 'section name']
|
383
|
-
hMaps = oConfig.getAppDefault(:account_section_mapping)
|
384
|
-
hMaps.each { |map_key, value|
|
385
|
-
if oConfig.exist?(map_key)
|
386
|
-
puts "%-15s(%-7s) %-12s: '%s'" % [map_key, oConfig.exist?(map_key), value[:section], oConfig.get(map_key)]
|
387
|
-
else
|
388
|
-
puts "%-15s( ) %-12s: unset" % [map_key, value[:section]]
|
389
|
-
end
|
390
|
-
|
391
|
-
}
|
392
|
-
end
|
393
|
-
puts "\nUse 'forj set <key>=<value>' to update defaults"
|
337
|
+
oConfig = ForjConfig.new()
|
338
|
+
if not options[:account_name] and not key
|
339
|
+
Forj::Settings::config_get_all(oConfig)
|
340
|
+
|
341
|
+
elsif options[:account_name] and key
|
342
|
+
Forj::Settings::account_get(oConfig, options[:account_name], key)
|
343
|
+
|
344
|
+
elsif not options[:account_name] and key
|
345
|
+
Forj::Settings::config_get(oConfig, key)
|
346
|
+
|
394
347
|
else
|
395
|
-
oConfig
|
396
|
-
oForjAccount = ForjAccount.new(oConfig)
|
397
|
-
Logging.fatal(1, "Unable to load account '%s'. Not found." % options[:account_name]) if not oForjAccount.ac_load
|
398
|
-
if key
|
399
|
-
if oForjAccount.exist?(key)
|
400
|
-
puts "%s: '%s'" % [oForjAccount.exist?(key).sub("hash", options[:account_name]), oForjAccount.get(key)]
|
401
|
-
elsif oForjAccount.exist?(key.parameterize.underscore.to_sym)
|
402
|
-
key_symb = key.parameterize.underscore.to_sym
|
403
|
-
puts "%s: '%s'" % [oForjAccount.exist?(key_symb).sub("hash", options[:account_name]), oForjAccount.get(key_symb)]
|
404
|
-
else
|
405
|
-
Logging.message("key '%s' not found"% [key])
|
406
|
-
end
|
407
|
-
else
|
408
|
-
puts "legend: default = Application defaults, local = Local default config, %s = '%s' account config\n\n" % [options[:account_name], options[:account_name]]
|
409
|
-
puts "%-15s(%-7s) %-12s:\n--------------------------------------" % ['key', 'origin', 'section name']
|
410
|
-
hMaps = oConfig.getAppDefault(:account_section_mapping)
|
411
|
-
hMaps.each { |map_key, value|
|
412
|
-
if oForjAccount.exist?(map_key)
|
413
|
-
puts "%-15s(%-7s) %-12s: '%s'" % [map_key, oForjAccount.exist?(map_key).sub("hash", options[:account_name]), value[:section], oForjAccount.get(map_key)]
|
414
|
-
else
|
415
|
-
puts "%-15s( ) %12s: unset" % [map_key, value[:section]]
|
416
|
-
end
|
417
|
-
}
|
418
|
-
end
|
419
|
-
puts "\nUse 'forj set <key>=<value> -a %s' to update account data.\nOr 'forj set <key>= -a %s' to restore key default value." % [options[:account_name], options[:account_name]]
|
348
|
+
Forj::Settings::account_get_all(oConfig, options[:account_name])
|
420
349
|
end
|
421
350
|
end
|
422
351
|
|
@@ -472,4 +401,4 @@ Several data will be requested like:
|
|
472
401
|
end
|
473
402
|
|
474
403
|
|
475
|
-
|
404
|
+
ForjThor.start
|
data/lib/appinit.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
# Base Logging system started and loaded.
|
20
|
+
require 'log.rb' # Load default loggers
|
21
|
+
include Logging
|
22
|
+
|
23
|
+
module AppInit
|
24
|
+
|
25
|
+
def AppInit.forj_initialize()
|
26
|
+
# Function to create FORJ paths if missing.
|
27
|
+
|
28
|
+
# Defining Global variables
|
29
|
+
$FORJ_DATA_PATH = File.expand_path(File.join('~', '.forj'))
|
30
|
+
$FORJ_ACCOUNTS_PATH = File.join($FORJ_DATA_PATH, 'accounts')
|
31
|
+
$FORJ_KEYPAIRS_PATH = File.join($FORJ_DATA_PATH, 'keypairs')
|
32
|
+
$FORJ_CREDS_PATH = File.expand_path(File.join('~', '.cache', 'forj'))
|
33
|
+
|
34
|
+
# TODO: To move to an hpcloud object.
|
35
|
+
$HPC_KEYPAIRS = File.expand_path(File.join('~', '.hpcloud', 'keypairs'))
|
36
|
+
$HPC_ACCOUNTS = File.expand_path(File.join('~', '.hpcloud', 'accounts'))
|
37
|
+
|
38
|
+
AppInit.ensure_dir_exists($FORJ_DATA_PATH)
|
39
|
+
AppInit.ensure_dir_exists($FORJ_ACCOUNTS_PATH)
|
40
|
+
AppInit.ensure_dir_exists($FORJ_KEYPAIRS_PATH)
|
41
|
+
FileUtils.chmod(0700, $FORJ_KEYPAIRS_PATH)
|
42
|
+
AppInit.ensure_dir_exists($FORJ_CREDS_PATH)
|
43
|
+
end
|
44
|
+
|
45
|
+
def AppInit.ensure_dir_exists(path)
|
46
|
+
if not dir_exists?(path)
|
47
|
+
FileUtils.mkpath(path) if not File.directory?(path)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/boot.rb
CHANGED
@@ -34,22 +34,13 @@ include Helpers
|
|
34
34
|
# Boot module
|
35
35
|
#
|
36
36
|
module Boot
|
37
|
-
def boot(blueprint, name, build,
|
37
|
+
def boot(blueprint, name, build, boothook, box_name, oConfig)
|
38
38
|
begin
|
39
39
|
|
40
40
|
Logging.fatal(1, 'FORJ account not specified. Did you used `forj setup`, before?') if not oConfig.get(:account_name)
|
41
41
|
|
42
|
-
oForjAccount = ForjAccount.new(oConfig)
|
43
|
-
|
44
|
-
oForjAccount.ac_load()
|
45
|
-
|
46
|
-
|
47
|
-
# Load Forj account data
|
48
|
-
forjAccountFile = File.join($FORJ_ACCOUNTS_PATH, oConfig.get(:account_name))
|
49
|
-
oConfig.ExtraLoad(forjAccountFile, :forj_accounts, oConfig.get(:account_name))
|
50
|
-
|
51
42
|
# Check options and set data
|
52
|
-
cloud_provider =
|
43
|
+
cloud_provider = oConfig.get(:provider_name, 'hpcloud')
|
53
44
|
|
54
45
|
if cloud_provider != 'hpcloud'
|
55
46
|
Logging.fatal(1, "forj setup support only hpcloud. '%s' is currently not supported." % cloud_provider)
|
@@ -61,7 +52,7 @@ module Boot
|
|
61
52
|
# Initialize defaults
|
62
53
|
maestro_url = oConfig.get(:maestro_url)
|
63
54
|
|
64
|
-
infra_dir = File.expand_path(
|
55
|
+
infra_dir = File.expand_path(oConfig.get(:infra_repo))
|
65
56
|
|
66
57
|
|
67
58
|
# Check about infra repo compatibility with forj cli
|
@@ -80,47 +71,47 @@ module Boot
|
|
80
71
|
end
|
81
72
|
|
82
73
|
# Get FORJ DNS setting
|
83
|
-
yDNS = rhGet(
|
84
|
-
Logging.fatal(1, "DNS or domain name are missing. Please execute forj setup %s" %
|
74
|
+
yDNS = rhGet(oConfig.hAccountData, :dns)
|
75
|
+
Logging.fatal(1, "DNS or domain name are missing. Please execute forj setup %s" % oConfig.getAccountData(:account, 'name')) if not yDNS
|
85
76
|
|
86
|
-
branch = oConfig.get(:branch)
|
77
|
+
branch = oConfig.get(:branch, 'master')
|
87
78
|
|
88
79
|
# Step Maestro Clone
|
89
|
-
if not
|
80
|
+
if not oConfig.get(:maestro_repo)
|
90
81
|
Logging.info('cloning maestro repo from \'%s\'...' % maestro_url)
|
91
82
|
Repositories.clone_repo(maestro_url)
|
92
83
|
maestro_repo=File.expand_path('~/.forj/maestro')
|
93
84
|
else
|
94
|
-
maestro_repo=File.expand_path(
|
85
|
+
maestro_repo=File.expand_path(oConfig.get(:maestro_repo))
|
95
86
|
if not File.exists?('%s/templates/infra/maestro.box.%s.env' % [maestro_repo, branch])
|
96
|
-
Logging.fatal(1, "'%s' is not a recognized Maestro repository. forj cli searched for templates/infra
|
87
|
+
Logging.fatal(1, "'%s' is not a recognized Maestro repository. forj cli searched for templates/infra/maestro.box.%s.env" % [maestro_repo, branch])
|
97
88
|
end
|
98
89
|
Logging.info('Using your maestro cloned repo \'%s\'...' % maestro_repo)
|
99
90
|
end
|
100
91
|
|
101
92
|
if bBuildInfra
|
102
93
|
Logging.info('Building your infra... in \'%s\'' % [infra_dir])
|
103
|
-
Repositories.create_infra(maestro_repo)
|
94
|
+
Repositories.create_infra(maestro_repo, branch)
|
104
95
|
end
|
105
96
|
|
106
97
|
# Connect to services
|
107
98
|
oFC=ForjConnection.new(oConfig)
|
108
99
|
|
109
|
-
Logging.info('Configuring network \'%s\'' % [
|
100
|
+
Logging.info('Configuring network \'%s\'' % [oConfig.get('network_name')])
|
110
101
|
begin
|
111
|
-
network = Network.get_or_create_network(oFC,
|
102
|
+
network = Network.get_or_create_network(oFC, oConfig.get('network_name'))
|
112
103
|
subnet = Network.get_or_create_subnet(oFC, network.id, network.name)
|
113
104
|
Network.get_or_create_router(oFC, network, subnet)
|
114
105
|
rescue => e
|
115
106
|
Logging.fatal(1, "Network properly configured is required.", e)
|
116
107
|
end
|
117
108
|
|
118
|
-
Logging.info('Configuring keypair \'%s\'' % [
|
119
|
-
SecurityGroup.hpc_import_key(
|
109
|
+
Logging.info('Configuring keypair \'%s\'' % [oConfig.get('keypair_name')])
|
110
|
+
SecurityGroup.hpc_import_key(oConfig)
|
120
111
|
|
121
112
|
|
122
|
-
Logging.info('Configuring Security Group \'%s\'' % [
|
123
|
-
security_group = SecurityGroup.get_or_create_security_group(oFC,
|
113
|
+
Logging.info('Configuring Security Group \'%s\'' % [oConfig.get('security_group')])
|
114
|
+
security_group = SecurityGroup.get_or_create_security_group(oFC, oConfig.get('security_group'))
|
124
115
|
ports = oConfig.get(:ports)
|
125
116
|
|
126
117
|
ports.each do |port|
|
@@ -135,24 +126,20 @@ module Boot
|
|
135
126
|
end
|
136
127
|
end
|
137
128
|
|
138
|
-
# oForjAccount data get are retrieved from the account file under section described in defaults.yaml, as soon as this mapping exist.
|
139
|
-
# If not found, get the data from the local configuration file. Usually ~/.forj/config.yaml
|
140
|
-
# If not found, get the data from defaults.yaml
|
141
|
-
# otherwise, use the get default parameter as value. Default is nil.
|
142
129
|
|
143
130
|
|
144
131
|
oBuildEnv = BuildEnv.new(oConfig)
|
145
132
|
ENV['FORJ_CLI_ENV'] = oBuildEnv.sBuildEnvFile
|
146
133
|
oBuildEnv.set('FORJ_HPC', oFC.sAccountName)
|
147
134
|
oBuildEnv.set('FORJ_HPC_NET', network.name)
|
148
|
-
oBuildEnv.set('FORJ_SECURITY_GROUP',
|
149
|
-
oBuildEnv.set('FORJ_KEYPAIR',
|
150
|
-
oBuildEnv.set('FORJ_HPC_NOVA_KEYPUB',
|
151
|
-
oBuildEnv.set('FORJ_BASE_IMG',
|
152
|
-
oBuildEnv.set('FORJ_FLAVOR',
|
153
|
-
oBuildEnv.set('FORJ_BP_FLAVOR',
|
154
|
-
oBuildEnv.set('FORJ_TENANT_NAME',
|
155
|
-
oBuildEnv.set('FORJ_HPC_COMPUTE', rhGet(oConfig.ExtraGet(:hpc_accounts, oFC.sAccountName, :regions), :compute))
|
135
|
+
oBuildEnv.set('FORJ_SECURITY_GROUP', oConfig.get('security_group'))
|
136
|
+
oBuildEnv.set('FORJ_KEYPAIR', oConfig.get('keypair_name'))
|
137
|
+
oBuildEnv.set('FORJ_HPC_NOVA_KEYPUB', oConfig.get('keypair_path') + '.pub')
|
138
|
+
oBuildEnv.set('FORJ_BASE_IMG', oConfig.get('image'))
|
139
|
+
oBuildEnv.set('FORJ_FLAVOR', oConfig.get('flavor'))
|
140
|
+
oBuildEnv.set('FORJ_BP_FLAVOR', oConfig.get('bp_flavor'))
|
141
|
+
oBuildEnv.set('FORJ_TENANT_NAME', oConfig.get(:tenant_name))
|
142
|
+
oBuildEnv.set('FORJ_HPC_COMPUTE', rhGet(oConfig.oConfig.ExtraGet(:hpc_accounts, oFC.sAccountName, :regions), :compute))
|
156
143
|
|
157
144
|
|
158
145
|
oBuildEnv.set('FORJ_DOMAIN', yDNS[:domain_name])
|
@@ -168,8 +155,8 @@ module Boot
|
|
168
155
|
|
169
156
|
build = 'bin/build.sh' unless build
|
170
157
|
|
171
|
-
build_config =
|
172
|
-
box_name =
|
158
|
+
build_config = oConfig.get('build_config')
|
159
|
+
box_name = oConfig.get('box_name')
|
173
160
|
|
174
161
|
arg = '--meta blueprint=%s ' % [blueprint]
|
175
162
|
arg += "--test-box '%s' " % oConfig.get(:test_box) if oConfig.exist?(:test_box)
|
@@ -209,12 +196,12 @@ class BuildEnv
|
|
209
196
|
|
210
197
|
def initialize(oConfig)
|
211
198
|
|
212
|
-
oConfig.fatal_if_inexistent(:infra_repo)
|
213
|
-
oConfig.fatal_if_inexistent(:account_name)
|
199
|
+
oConfig.oConfig.fatal_if_inexistent(:infra_repo)
|
200
|
+
oConfig.oConfig.fatal_if_inexistent(:account_name)
|
214
201
|
|
215
202
|
sBuildDir = File.expand_path(File.join(oConfig.get(:infra_repo),'build'))
|
216
203
|
@sBuildEnvFile = File.join(sBuildDir, oConfig.get(:account_name)+'.build.env')
|
217
|
-
|
204
|
+
AppInit.ensure_dir_exists(sBuildDir)
|
218
205
|
@yBuildEnvVar = {}
|
219
206
|
@oConfig = oConfig
|
220
207
|
end
|
@@ -234,7 +221,7 @@ class BuildEnv
|
|
234
221
|
begin
|
235
222
|
File.open(@sBuildEnvFile, 'w') do |out|
|
236
223
|
@yBuildEnvVar.each do | key, value |
|
237
|
-
desc = @oConfig.getAppDefault(:description, key)
|
224
|
+
desc = @oConfig.oConfig.getAppDefault(:description, key)
|
238
225
|
out.write("# %s - %s\n" % [key, desc]) if desc
|
239
226
|
value = "" if not value
|
240
227
|
out.write("%s='%s'\n\n" % [key, value])
|
data/lib/connection.rb
CHANGED
@@ -17,15 +17,38 @@
|
|
17
17
|
|
18
18
|
require 'rubygems'
|
19
19
|
require 'fog'
|
20
|
-
require '
|
21
|
-
|
22
|
-
require_relative 'yaml_parse.rb'
|
20
|
+
require 'yaml_parse.rb'
|
23
21
|
include YamlParse
|
24
22
|
|
25
23
|
#
|
26
24
|
# Connection module
|
27
25
|
#
|
28
26
|
|
27
|
+
class SSLErrorMgt
|
28
|
+
|
29
|
+
def initialize()
|
30
|
+
@iRetry=0
|
31
|
+
end
|
32
|
+
|
33
|
+
def ErrorDetected(message,backtrace)
|
34
|
+
if message.match('SSLv2/v3 read server hello A: unknown protocol')
|
35
|
+
if @iRetry <5
|
36
|
+
sleep(2)
|
37
|
+
@iRetry+=1
|
38
|
+
print "%s/5 try...\r" % @iRetry if $FORJ_LOGGER.level == 0
|
39
|
+
return false
|
40
|
+
else
|
41
|
+
Logging.error('Too many retry. %s' % message)
|
42
|
+
return true
|
43
|
+
end
|
44
|
+
else
|
45
|
+
Logging.error("%s\n%s" % [message,backtrace.join("\n")])
|
46
|
+
return true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
29
52
|
class ForjConnection
|
30
53
|
|
31
54
|
attr_accessor :oCompute
|
@@ -103,9 +126,9 @@ class ForjConnection
|
|
103
126
|
if not File.exists?(creds)
|
104
127
|
Logging.fatal(1, "'%s' was not configured. Did you executed 'forj setup %s'? Please do it and retry." % [@sAccountName, @sAccountName])
|
105
128
|
end
|
106
|
-
@oConfig.ExtraLoad(creds, :hpc_accounts, @sAccountName)
|
129
|
+
@oConfig.oConfig.ExtraLoad(creds, :hpc_accounts, @sAccountName)
|
107
130
|
|
108
|
-
template = @oConfig.ExtraGet(:hpc_accounts, @sAccountName)
|
131
|
+
template = @oConfig.oConfig.ExtraGet(:hpc_accounts, @sAccountName)
|
109
132
|
credentials = {}
|
110
133
|
begin
|
111
134
|
credentials['access_key'] = template[:credentials][:account_id]
|