forj 0.0.44 → 0.0.47
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/bin/forj +11 -10
- data/lib/boot.rb +46 -18
- data/lib/defaults.yaml +6 -5
- data/lib/forj-account.rb +8 -0
- data/lib/forj-config.rb +8 -0
- data/lib/log.rb +19 -19
- data/lib/repositories.rb +115 -56
- data/spec/connection_spec.rb +1 -0
- data/spec/forj-config_spec.rb +3 -0
- data/spec/repositories_spec.rb +14 -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: a158eb6d8db91610bf6d6b64ccf3454fc5ad4c8a
|
4
|
+
data.tar.gz: 86f77c9bac06ba4e14a8e8040fe48da673b428e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 961aaf4d7e623dc4a2f6ce7077c9067345d024fce67937bf570e09c5418b1d347ed38b190f526e776a6687f7bec4fe2fecbaf60826d7bdf5f111373b316840d1
|
7
|
+
data.tar.gz: 3ee7247de4d5483777eb07f972dac20cd81f1796f37cdfa3fe48700ccf8ef958ee353e6beed692c28d90e7d35057d5300568fd98494804d5e919b7a23c60aa0e
|
data/Gemfile
CHANGED
data/bin/forj
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
18
|
require 'rubygems'
|
19
|
+
require 'bundler/setup'
|
19
20
|
require 'require_relative'
|
20
21
|
require 'thor'
|
21
22
|
require 'ansi'
|
@@ -93,7 +94,7 @@ forj command line details:
|
|
93
94
|
end
|
94
95
|
|
95
96
|
desc 'version', 'get GEM version of forj.'
|
96
|
-
|
97
|
+
|
97
98
|
def version()
|
98
99
|
if Gem.loaded_specs['forj']
|
99
100
|
puts Gem.loaded_specs['forj'].version.to_s
|
@@ -111,7 +112,7 @@ This task boot a new forge with the following options
|
|
111
112
|
|
112
113
|
Ex: forj boot redstone maestro_test -a dev
|
113
114
|
|
114
|
-
When `forj boot` starts, some variables are loaded. If you want to check/updated them, use `forj get [-a account]`
|
115
|
+
When `forj boot` starts, some variables are loaded. If you want to check/updated them, use `forj get [-a account]`
|
115
116
|
|
116
117
|
LONGDESC
|
117
118
|
|
@@ -124,7 +125,7 @@ Following options superseed your Account, config file or forj defaults."
|
|
124
125
|
method_option :key_name, :aliases => '-k', :desc => "config: keypair_name : Keypair name to use."
|
125
126
|
method_option :key_path, :aliases => '-p', :desc => "config: keypair_path : Private or Public key file to use."
|
126
127
|
method_option :security_group, :aliases => '-s', :desc => "config: security_group: Security group name to use and configure."
|
127
|
-
method_option :
|
128
|
+
method_option :image_name, :aliases => '-i', :desc => "config: image_name : Image name to use to build Maestro and blueprint nodes."
|
128
129
|
method_option :maestro_flavor, :aliases => '-f', :desc => "config: flavor : Maestro flavor to use."
|
129
130
|
method_option :bp_flavor, :aliases => '-b', :desc => "config: bp_flavor : Blueprint nodes default flavor to use.
|
130
131
|
|
@@ -166,12 +167,12 @@ Maestro/infra bootstrap debugging:"
|
|
166
167
|
oConfig.set(:account_name, options[:account_name]) if options[:account_name]
|
167
168
|
oForjAccount = ForjAccount.new(oConfig)
|
168
169
|
oForjAccount.ac_load()
|
169
|
-
|
170
|
+
|
170
171
|
oConfig.set(:infra_repo, options[:infra])
|
171
172
|
oConfig.set(:keypair_name, options[:key_name])
|
172
173
|
oConfig.set(:keypair_path, options[:key_path])
|
173
174
|
oConfig.set(:security_group, options[:security_group])
|
174
|
-
oConfig.set(:
|
175
|
+
oConfig.set(:image_name, options[:image])
|
175
176
|
oConfig.set(:flavor, options[:maestro_flavor])
|
176
177
|
oConfig.set(:bp_flavor, options[:bp_flavor])
|
177
178
|
oConfig.set(:maestro_repo , options[:maestro_repo])
|
@@ -252,7 +253,7 @@ Warning! This action don't removed any network/security groups cloud object.
|
|
252
253
|
oConfig = ForjConfig.new(options[:config])
|
253
254
|
oConfig.set(:account_name, options[:account_name]) if options[:account_name]
|
254
255
|
oForjAccount = ForjAccount.new(oConfig)
|
255
|
-
oForjAccount.ac_load()
|
256
|
+
oForjAccount.ac_load()
|
256
257
|
|
257
258
|
Down.down(oForjAccount, name)
|
258
259
|
end
|
@@ -297,7 +298,7 @@ Ex: By default, forj use ~/.ssh/forj-id_rsa as keypair for all forge instance. D
|
|
297
298
|
Forj::Settings::config_show_all(oConfig)
|
298
299
|
|
299
300
|
elsif p.length == 0 and options[:account_name]
|
300
|
-
Forj::Settings::account_show_all(oConfig, options[:account_name])
|
301
|
+
Forj::Settings::account_show_all(oConfig, options[:account_name])
|
301
302
|
|
302
303
|
elsif p.length != 0 and options[:account_name]
|
303
304
|
Forj::Settings::account_set(oConfig, options[:account_name], p)
|
@@ -337,13 +338,13 @@ Ex: To get the keypair_name defined from the account, or from your ~/.forj/confi
|
|
337
338
|
oConfig = ForjConfig.new()
|
338
339
|
if not options[:account_name] and not key
|
339
340
|
Forj::Settings::config_get_all(oConfig)
|
340
|
-
|
341
|
+
|
341
342
|
elsif options[:account_name] and key
|
342
343
|
Forj::Settings::account_get(oConfig, options[:account_name], key)
|
343
|
-
|
344
|
+
|
344
345
|
elsif not options[:account_name] and key
|
345
346
|
Forj::Settings::config_get(oConfig, key)
|
346
|
-
|
347
|
+
|
347
348
|
else
|
348
349
|
Forj::Settings::account_get_all(oConfig, options[:account_name])
|
349
350
|
end
|
data/lib/boot.rb
CHANGED
@@ -54,20 +54,29 @@ module Boot
|
|
54
54
|
|
55
55
|
infra_dir = File.expand_path(oConfig.get(:infra_repo))
|
56
56
|
|
57
|
-
|
58
|
-
# Check about infra repo compatibility with forj cli
|
59
|
-
bBuildInfra = Repositories.infra_rebuild_required?(oConfig, infra_dir)
|
60
|
-
|
61
57
|
# Ask information if needed.
|
62
58
|
if not Dir.exist?(File.expand_path(infra_dir))
|
63
|
-
|
59
|
+
Logging.warning(<<-END
|
60
|
+
Your infra workspace directory is missing.
|
61
|
+
|
62
|
+
Forj uses an infra workspace directory to store any kind of data that are private to you.
|
63
|
+
We provides ways to send those data securily to your new Forge instance, as metadata.
|
64
|
+
In production case, we suggest you to keep it safe in your SCM preferred database.
|
65
|
+
|
66
|
+
If you already have an existing infra workspace, use 'forj set infra_repo=<PathToYourRepo>' to set it and restart.
|
67
|
+
|
68
|
+
Otherwise, we will build a new one with some predefined data, you can review and update later.
|
69
|
+
END
|
70
|
+
)
|
71
|
+
sAsk = "Do you want to create a new one from Maestro (yes/no)?" % [infra_dir]
|
64
72
|
bBuildInfra=agree(sAsk)
|
73
|
+
if not bBuildInfra
|
74
|
+
puts 'Process aborted on your demand.'
|
75
|
+
exit 0
|
76
|
+
end
|
65
77
|
else
|
66
|
-
|
67
|
-
|
68
|
-
if not Dir.exist?(File.expand_path(infra_dir)) and not bBuildInfra
|
69
|
-
Logging.info('Exiting.')
|
70
|
-
return
|
78
|
+
# Check about infra repo compatibility with forj cli
|
79
|
+
bBuildInfra = Repositories.infra_rebuild_required?(oConfig, infra_dir)
|
71
80
|
end
|
72
81
|
|
73
82
|
# Get FORJ DNS setting
|
@@ -78,22 +87,41 @@ module Boot
|
|
78
87
|
|
79
88
|
# Step Maestro Clone
|
80
89
|
if not oConfig.get(:maestro_repo)
|
81
|
-
Logging.
|
82
|
-
Repositories.clone_repo(maestro_url)
|
90
|
+
Logging.state("cloning maestro repo from '%s' - branch '%s'" % [maestro_url, branch])
|
91
|
+
Repositories.clone_repo(maestro_url, oConfig)
|
83
92
|
maestro_repo=File.expand_path('~/.forj/maestro')
|
84
93
|
else
|
85
94
|
maestro_repo=File.expand_path(oConfig.get(:maestro_repo))
|
86
|
-
if not File.exists?('%s/templates/infra/maestro.box
|
87
|
-
|
95
|
+
if not File.exists?('%s/templates/infra/maestro.box.master.env' % [maestro_repo])
|
96
|
+
msg = <<-END
|
97
|
+
'#{maestro_repo}' is not a recognized Maestro repository or is too old. forj cli searched for templates/infra/maestro.box.master.env
|
98
|
+
|
99
|
+
Suggestion:
|
100
|
+
1. Clone #{maestro_url} to a different location.
|
101
|
+
$ mkdir -p ~/src/forj-oss
|
102
|
+
$ cd ~/src/forj-oss
|
103
|
+
$ git clone #{maestro_url}
|
104
|
+
2. Use this master branch of maestro repository with forj
|
105
|
+
$ forj set maestro_repo=~/src/forj-oss/maestro
|
106
|
+
|
107
|
+
then retry your boot.
|
108
|
+
END
|
109
|
+
Logging.fatal(1, msg)
|
88
110
|
end
|
89
|
-
Logging.info(
|
111
|
+
Logging.info("Using your maestro cloned repo '%s'" % maestro_repo)
|
90
112
|
end
|
91
113
|
|
114
|
+
bBuildInfra = Repositories.infra_rebuild(oConfig, infra_dir) unless bBuildInfra
|
115
|
+
|
92
116
|
if bBuildInfra
|
93
|
-
Logging.info(
|
117
|
+
Logging.info("Building your infra... in '%s'" % [infra_dir])
|
94
118
|
Repositories.create_infra(maestro_repo, branch)
|
119
|
+
else
|
120
|
+
Logging.info("Re-using your infra... in '%s'" % [infra_dir]) if not bBuildInfra
|
95
121
|
end
|
96
122
|
|
123
|
+
Repositories.ensure_build_env_file(maestro_url, maestro_repo, branch)
|
124
|
+
|
97
125
|
# Connect to services
|
98
126
|
oFC=ForjConnection.new(oConfig)
|
99
127
|
|
@@ -135,8 +163,8 @@ module Boot
|
|
135
163
|
oBuildEnv.set('FORJ_SECURITY_GROUP', oConfig.get('security_group'))
|
136
164
|
oBuildEnv.set('FORJ_KEYPAIR', oConfig.get('keypair_name'))
|
137
165
|
oBuildEnv.set('FORJ_HPC_NOVA_KEYPUB', oConfig.get('keypair_path') + '.pub')
|
138
|
-
oBuildEnv.set('FORJ_BASE_IMG', oConfig.get('
|
139
|
-
oBuildEnv.set('FORJ_FLAVOR', oConfig.get('
|
166
|
+
oBuildEnv.set('FORJ_BASE_IMG', oConfig.get('image_name'))
|
167
|
+
oBuildEnv.set('FORJ_FLAVOR', oConfig.get('flavor_name'))
|
140
168
|
oBuildEnv.set('FORJ_BP_FLAVOR', oConfig.get('bp_flavor'))
|
141
169
|
oBuildEnv.set('FORJ_TENANT_NAME', oConfig.get(:tenant_name))
|
142
170
|
oBuildEnv.set('FORJ_HPC_COMPUTE', rhGet(oConfig.oConfig.ExtraGet(:hpc_accounts, oFC.sAccountName, :regions), :compute))
|
data/lib/defaults.yaml
CHANGED
@@ -19,12 +19,12 @@
|
|
19
19
|
:infra_repo: ~/.forj/infra
|
20
20
|
|
21
21
|
# You can set proto2b in your ~/.forj/config.yaml if you built it from maestro/build. Read the maestro/README.md to create it.
|
22
|
-
:
|
22
|
+
:image_name: Ubuntu Precise 12.04.4 LTS Server 64-bit 20140414 (Rescue Image)
|
23
23
|
|
24
24
|
# Flavor to use for Maestro
|
25
|
-
:flavor:
|
25
|
+
:flavor: medium
|
26
26
|
# Default flavor to use for all Blueprint nodes.
|
27
|
-
:bp_flavor:
|
27
|
+
:bp_flavor: small
|
28
28
|
|
29
29
|
# Ports to open for Maestro, added to the security group
|
30
30
|
:security_group: forj
|
@@ -164,9 +164,10 @@
|
|
164
164
|
:desc: "forj cli use 'build.sh' to create Maestro. See build_config option on build.sh to get more information. By default 'box'"
|
165
165
|
:bp_flavor:
|
166
166
|
:desc: "Blueprint nodes default flavor. Usually, blueprint node are smaller than Maestro."
|
167
|
-
:
|
167
|
+
:flavor_name:
|
168
168
|
:desc: "Maestro Flavor name. This flavor is for Maestro only. Your blueprint layout defines each node flavors on needs."
|
169
|
-
:
|
169
|
+
:default: :flavor
|
170
|
+
:image_name:
|
170
171
|
:desc: "Image used to create Maestro and all forge boxes. By default, it is 'Ubuntu Precise 12.04.4 LTS Server 64-bit 20140414 (Rescue Image)'"
|
171
172
|
:ports:
|
172
173
|
:desc: "List of security group rules (1 port or range of ports) to open to the external network."
|
data/lib/forj-account.rb
CHANGED
@@ -132,6 +132,10 @@ class ForjAccount
|
|
132
132
|
@oConfig.get(default_key , default )
|
133
133
|
end
|
134
134
|
|
135
|
+
def [](key, default = nil)
|
136
|
+
get(key, default)
|
137
|
+
end
|
138
|
+
|
135
139
|
def exist?(key)
|
136
140
|
return nil if not key
|
137
141
|
|
@@ -232,6 +236,10 @@ class ForjAccount
|
|
232
236
|
_set(section, key, value)
|
233
237
|
end
|
234
238
|
|
239
|
+
def []=(key, value)
|
240
|
+
set(key, value)
|
241
|
+
end
|
242
|
+
|
235
243
|
def del(key)
|
236
244
|
return nil if not key
|
237
245
|
|
data/lib/forj-config.rb
CHANGED
@@ -372,6 +372,10 @@ class ForjConfig
|
|
372
372
|
true
|
373
373
|
end
|
374
374
|
|
375
|
+
def []=(key, value)
|
376
|
+
set(key, value)
|
377
|
+
end
|
378
|
+
|
375
379
|
def runtimeExist?(key)
|
376
380
|
(rhExist?(@yRuntime, key) == 1)
|
377
381
|
end
|
@@ -419,6 +423,10 @@ class ForjConfig
|
|
419
423
|
default
|
420
424
|
end
|
421
425
|
|
426
|
+
def [](key, default = nil)
|
427
|
+
get(key, default)
|
428
|
+
end
|
429
|
+
|
422
430
|
def getAppDefault(section, key = nil)
|
423
431
|
|
424
432
|
key = key.to_sym if key.class == String
|
data/lib/log.rb
CHANGED
@@ -35,12 +35,12 @@ module Logging
|
|
35
35
|
|
36
36
|
class ForjLog
|
37
37
|
# Class used to create 2 log object, in order to keep track of error in a log file and change log output to OUTPUT on needs (option flags).
|
38
|
-
|
38
|
+
|
39
39
|
attr_reader :level
|
40
40
|
|
41
41
|
def initialize(sLogFile = 'forj.log', level = Logger::WARN)
|
42
|
-
|
43
|
-
if not $FORJ_DATA_PATH
|
42
|
+
|
43
|
+
if not $FORJ_DATA_PATH
|
44
44
|
raise "Internal Error: Unable to initialize ForjLog - global FORJ_DATA_PATH not set"
|
45
45
|
end
|
46
46
|
|
@@ -50,16 +50,16 @@ module Logging
|
|
50
50
|
|
51
51
|
@oFileLogger = Logger.new(File.join($FORJ_DATA_PATH, sLogFile), 'weekly')
|
52
52
|
@oFileLogger.level = Logger::DEBUG
|
53
|
-
@oFileLogger.formatter = proc do |severity, datetime, progname, msg|
|
53
|
+
@oFileLogger.formatter = proc do |severity, datetime, progname, msg|
|
54
54
|
"#{progname} : #{datetime}: #{severity}: #{msg} \n"
|
55
|
-
end
|
56
|
-
|
55
|
+
end
|
56
|
+
|
57
57
|
@oOutLogger = Logger.new(STDOUT)
|
58
58
|
@level = level
|
59
59
|
@oOutLogger.level = @level
|
60
|
-
@oOutLogger.formatter = proc do |severity, datetime, progname, msg|
|
60
|
+
@oOutLogger.formatter = proc do |severity, datetime, progname, msg|
|
61
61
|
severity == 'ANY'?"#{msg} \n":"#{severity}: #{msg} \n"
|
62
|
-
end
|
62
|
+
end
|
63
63
|
end
|
64
64
|
|
65
65
|
def info?
|
@@ -74,7 +74,7 @@ module Logging
|
|
74
74
|
def fatal?
|
75
75
|
return(@oOutLogger.fatal?)
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def info(message)
|
79
79
|
@oOutLogger.info(message + ANSI.clear_line)
|
80
80
|
@oFileLogger.info(message)
|
@@ -90,7 +90,7 @@ module Logging
|
|
90
90
|
def fatal(message, e)
|
91
91
|
@oOutLogger.fatal(message + ANSI.clear_line)
|
92
92
|
@oFileLogger.fatal("%s\n%s\n%s" % [message, e.message, e.backtrace.join("\n")]) if e
|
93
|
-
|
93
|
+
@oFileLogger.fatal(message)
|
94
94
|
end
|
95
95
|
|
96
96
|
def warn(message)
|
@@ -106,21 +106,21 @@ module Logging
|
|
106
106
|
def unknown(message)
|
107
107
|
@oOutLogger.unknown(message + ANSI.clear_line)
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
def message(message)
|
113
113
|
$FORJ_LOGGER.unknown(message)
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
def info(message)
|
117
117
|
$FORJ_LOGGER.info(message)
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
def debug(message)
|
121
121
|
$FORJ_LOGGER.debug(message)
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
def warning(message)
|
125
125
|
$FORJ_LOGGER.warn(message)
|
126
126
|
end
|
@@ -128,7 +128,7 @@ module Logging
|
|
128
128
|
def error(message)
|
129
129
|
$FORJ_LOGGER.error(message)
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
132
|
def fatal(rc, message, e = nil)
|
133
133
|
$FORJ_LOGGER.fatal(message, e)
|
134
134
|
puts 'Issues found. Please fix it and retry. Process aborted.'
|
@@ -138,11 +138,11 @@ module Logging
|
|
138
138
|
def set_level(level)
|
139
139
|
$FORJ_LOGGER.set_level(level)
|
140
140
|
end
|
141
|
-
|
141
|
+
|
142
142
|
def state(message)
|
143
|
-
print("%s ...%s\r" % [message, ANSI.clear_line]) if $FORJ_LOGGER.level
|
143
|
+
print("%s ...%s\r" % [message, ANSI.clear_line]) if $FORJ_LOGGER.level <= Logger::INFO
|
144
144
|
end
|
145
|
-
|
145
|
+
|
146
146
|
def high_level_msg(message)
|
147
147
|
# Not DEBUG and not INFO. Just printed to the output.
|
148
148
|
puts ("%s" % [message]) if $FORJ_LOGGER.level > 1
|
data/lib/repositories.rb
CHANGED
@@ -30,10 +30,10 @@ include YamlParse
|
|
30
30
|
#
|
31
31
|
|
32
32
|
# Current version of the infra. Compatible with forj version or higher.
|
33
|
-
INFRA_VERSION = "37"
|
33
|
+
$INFRA_VERSION = "0.0.37"
|
34
34
|
|
35
35
|
module Repositories
|
36
|
-
def clone_repo(maestro_url)
|
36
|
+
def clone_repo(maestro_url, oConfig)
|
37
37
|
current_dir = Dir.pwd
|
38
38
|
|
39
39
|
home = File.expand_path('~')
|
@@ -44,7 +44,9 @@ module Repositories
|
|
44
44
|
if File.directory?(path + 'maestro')
|
45
45
|
FileUtils.rm_r path + 'maestro'
|
46
46
|
end
|
47
|
-
Git.clone(maestro_url, 'maestro', :path => path)
|
47
|
+
git = Git.clone(maestro_url, 'maestro', :path => path)
|
48
|
+
git.checkout(oConfig[:branch]) if oConfig[:branch] != 'master'
|
49
|
+
Logging.info("Maestro repo '%s' cloned on branch '%s'" % [path, oConfig[:branch]])
|
48
50
|
end
|
49
51
|
rescue => e
|
50
52
|
Logging.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
@@ -54,7 +56,35 @@ module Repositories
|
|
54
56
|
Dir.chdir(current_dir)
|
55
57
|
end
|
56
58
|
|
59
|
+
def ensure_build_env_file(maestro_url, maestro_repo, branch)
|
60
|
+
infra = File.join($FORJ_DATA_PATH, 'infra')
|
61
|
+
template = File.join(maestro_repo, 'templates', 'infra')
|
62
|
+
|
63
|
+
template_file = 'maestro.box.master.env'
|
64
|
+
env_file = 'maestro.box.' + branch + '.env'
|
65
|
+
|
66
|
+
source_build_env = File.join(template, template_file)
|
67
|
+
dest_build_env = File.join(infra, env_file)
|
68
|
+
|
69
|
+
if not File.exist?(source_build_env)
|
70
|
+
raise <<-END
|
71
|
+
Your Maestro repository branch is too old.
|
72
|
+
Suggestion:
|
73
|
+
1. Clone #{maestro_url} to a different location.
|
74
|
+
$ mkdir -p ~/src/forj-oss
|
75
|
+
$ cd ~/src/forj-oss
|
76
|
+
$ git clone #{maestro_url}
|
77
|
+
2. Use this master branch of maestro repository with forj
|
78
|
+
$ forj set maestro_repo=~/src/forj-oss/maestro
|
79
|
+
|
80
|
+
then retry your boot.
|
81
|
+
END
|
82
|
+
end
|
83
|
+
return if File.exist?(dest_build_env)
|
57
84
|
|
85
|
+
Logging.info("Creating '%s' to '%s'" % [source_build_env, dest_build_env])
|
86
|
+
FileUtils.copy(source_build_env, dest_build_env)
|
87
|
+
end
|
58
88
|
|
59
89
|
def create_infra(maestro_repo, branch)
|
60
90
|
# Build our own infra from maestro infra templates.
|
@@ -68,26 +98,39 @@ module Repositories
|
|
68
98
|
FileUtils.rm_r(infra)
|
69
99
|
end
|
70
100
|
AppInit.ensure_dir_exists(dest_cloud_init)
|
101
|
+
if not File.exist?(cloud_init)
|
102
|
+
raise <<-END
|
103
|
+
Your Maestro repository branch is too old.
|
104
|
+
Suggestion:
|
105
|
+
1. Clone %s to a different location.
|
106
|
+
$ mkdir -p ~/src/forj-oss
|
107
|
+
$ cd ~/src/forj-oss
|
108
|
+
$ git clone %s
|
109
|
+
2. Use this master branch of maestro repository with forj
|
110
|
+
$ forj set maestro_repo=~/src/forj-oss/maestro
|
111
|
+
|
112
|
+
then retry your boot.
|
113
|
+
END
|
114
|
+
end
|
71
115
|
Logging.debug("Copying recursively '%s' to '%s'" % [cloud_init, infra])
|
72
116
|
FileUtils.copy_entry(cloud_init, dest_cloud_init)
|
73
117
|
|
74
|
-
template_file = 'maestro.box.' + branch + '.env'
|
75
|
-
build_env = File.join(template,template_file)
|
76
|
-
Logging.debug("Copying '%s' to '%s'" % [build_env, infra])
|
77
|
-
FileUtils.copy(build_env, infra)
|
78
|
-
|
79
118
|
file_ver = File.join(infra, 'forj-cli.ver')
|
80
119
|
File.write(file_ver, $INFRA_VERSION)
|
81
120
|
end
|
82
|
-
|
121
|
+
|
122
|
+
# Infra repository compatibility
|
123
|
+
# < 0.0.37 - Use a template file of build env file.
|
124
|
+
# => Migration required.
|
125
|
+
# >= 0.0.37 - Using a generic version of build env file, fully managed by forj cli.
|
126
|
+
# => No migration
|
127
|
+
|
83
128
|
def infra_rebuild_required?(oConfig, infra_dir)
|
84
129
|
# This function check if the current infra is compatible with current gem version.
|
85
|
-
|
86
|
-
# prior 0.0.37 - Use a template file of build env file.
|
87
|
-
# 0.0.37 - Using a generic version of build env file, fully managed by forj cli.
|
130
|
+
|
88
131
|
return false if not File.exists?(infra_dir)
|
89
|
-
|
90
|
-
if infra_dir != File.join($FORJ_DATA_PATH, 'infra')
|
132
|
+
|
133
|
+
if infra_dir != File.join($FORJ_DATA_PATH, 'infra')
|
91
134
|
# Do not take care. We do not manage it, ourself.
|
92
135
|
return false
|
93
136
|
end
|
@@ -97,23 +140,33 @@ module Repositories
|
|
97
140
|
forj_infra_version = File.read(file_ver) if File.exist?(file_ver)
|
98
141
|
|
99
142
|
if forj_infra_version
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
old_infra_data_update(oConfig, forj_infra_version, infra_dir)
|
105
|
-
end
|
106
|
-
else # Prior version 37
|
107
|
-
old_infra_data_update(oConfig, 36, infra_dir)
|
108
|
-
end
|
143
|
+
return false if Gem::Version.new(forj_infra_version) == Gem::Version.new($INFRA_VERSION)
|
144
|
+
return true if Gem::Version.new(forj_infra_version) < Gem::Version.new($INFRA_VERSION)
|
145
|
+
end
|
146
|
+
# Before version 0.0.37, version file did not exist. So return true
|
109
147
|
true
|
110
148
|
end
|
111
|
-
|
149
|
+
|
150
|
+
def infra_rebuild(oConfig, infra_dir)
|
151
|
+
return false if not File.exists?(infra_dir)
|
152
|
+
|
153
|
+
file_ver = File.join(infra_dir, 'forj-cli.ver')
|
154
|
+
forj_infra_version = nil
|
155
|
+
forj_infra_version = File.read(file_ver) if File.exist?(file_ver)
|
156
|
+
|
157
|
+
if forj_infra_version.nil? or forj_infra_version == ""
|
158
|
+
# Prior version 37
|
159
|
+
return(old_infra_data_update(oConfig, '0.0.36', infra_dir))
|
160
|
+
elsif Gem::Version.new(forj_infra_version) < Gem::Version.new($INFRA_VERSION)
|
161
|
+
return(old_infra_data_update(oConfig, forj_infra_version, infra_dir))
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
112
165
|
def old_infra_data_update(oConfig, version, infra_dir)
|
113
|
-
Logging.info("Migrating your local infra repo to the latest version.")
|
114
|
-
|
166
|
+
Logging.info("Migrating your local infra repo (%s) to the latest version." % version)
|
167
|
+
bRebuild = false # Be default migration is successful. No need to rebuild it.
|
115
168
|
case version
|
116
|
-
when 36
|
169
|
+
when '0.0.36'
|
117
170
|
# Moving from 0.0.36 or less to 0.0.37 or higher.
|
118
171
|
# SET_COMPUTE="{SET_COMPUTE!}" => Setting for Compute. ignored. Coming from HPC
|
119
172
|
# SET_TENANT_NAME="{SET_TENANT_NAME!}" => Setting for Compute. ignored. Need to query HPC from current Tenant ID
|
@@ -124,46 +177,52 @@ module Repositories
|
|
124
177
|
# SET_DNS_ZONE="{SET_DNS_ZONE!}" => Setting for DNS. meta = dns_zone
|
125
178
|
# ==> :forj_accounts, sAccountName, :dns, :service
|
126
179
|
|
127
|
-
# SET_DOMAIN="{SET_DOMAIN!}" => Setting for Maestro (required) and DNS if enabled.
|
180
|
+
# SET_DOMAIN="{SET_DOMAIN!}" => Setting for Maestro (required) and DNS if enabled.
|
128
181
|
# ==> :forj_accounts, sAccountName, :dns, :domain_name
|
129
182
|
sAccountName = oConfig.get(:account_name)
|
130
183
|
|
131
184
|
yDns = {}
|
132
185
|
yDns = oConfig.oConfig.ExtraGet(:forj_accounts, sAccountName, :dns) if oConfig.oConfig.ExtraExist?(:forj_accounts, sAccountName, :dns)
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
186
|
+
Dir.foreach(infra_dir) do | file |
|
187
|
+
next if not /^maestro\.box\..*\.env$/ =~ file
|
188
|
+
build_env = File.join(infra_dir, file)
|
189
|
+
Logging.debug("Reading data from '%s'" % build_env)
|
190
|
+
tags = {'SET_DNS_TENANTID' => :tenant_id,
|
191
|
+
'SET_DNS_ZONE' => :service,
|
192
|
+
'SET_DOMAIN' => :domain_name
|
193
|
+
}
|
194
|
+
begin
|
195
|
+
bUpdate = nil
|
196
|
+
|
197
|
+
File.open(build_env) do |f|
|
198
|
+
f.each_line do |line|
|
199
|
+
mObj = line.match(/^(SET_[A-Z_]+)=["'](.*)["'].*$/)
|
200
|
+
if mObj
|
201
|
+
Logging.debug("Reviewing detected '%s' tag" % [mObj[1]])
|
202
|
+
tag = (tags[mObj[1]]? tags[mObj[1]] : nil)
|
203
|
+
if tag and mObj[2]
|
204
|
+
if bUpdate == nil and rhGet(yDns, tag) and rhGet(yDns, tag) != mObj[2]
|
205
|
+
Logging.message("Your account setup is different than build env.")
|
206
|
+
Logging.message("We suggest you to update your account setup with data from your build env.")
|
207
|
+
bUpdate = agree("Do you want to update your setup with those build environment data?")
|
208
|
+
end
|
209
|
+
if bUpdate != nil and bUpdate
|
210
|
+
Logging.debug("Saved: '%s' = '%s'" % [mObj[1],mObj[2]])
|
211
|
+
rhSet(yDns, mObj[2], tag)
|
212
|
+
end
|
157
213
|
end
|
158
214
|
end
|
159
215
|
end
|
160
216
|
end
|
217
|
+
rescue => e
|
218
|
+
Logging.fatal(1, "Failed to open the build environment file '%s'" % build_env, e)
|
161
219
|
end
|
162
|
-
rescue => e
|
163
|
-
Logging.fatal(1, "Unable to open the build environment file to migrate it", e)
|
164
220
|
end
|
165
|
-
|
166
|
-
|
221
|
+
file_ver = File.join(infra_dir, 'forj-cli.ver')
|
222
|
+
File.write(file_ver, $INFRA_VERSION)
|
223
|
+
oConfig.oConfig.ExtraSet(:forj_accounts, sAccountName, :dns, yDns)
|
224
|
+
oConfig.oConfig.ExtraSave(File.join($FORJ_ACCOUNTS_PATH, sAccountName), :forj_accounts, sAccountName)
|
225
|
+
return bRebuild
|
167
226
|
end
|
168
227
|
end
|
169
228
|
end
|
data/spec/connection_spec.rb
CHANGED
data/spec/forj-config_spec.rb
CHANGED
@@ -15,6 +15,9 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
+
require 'rubygems'
|
19
|
+
require 'bundler/setup'
|
20
|
+
|
18
21
|
$APP_PATH = File.dirname(__FILE__)
|
19
22
|
$LIB_PATH = File.expand_path(File.join(File.dirname($APP_PATH),'lib'))
|
20
23
|
$FORJ_DATA_PATH= File.expand_path('~/.forj')
|
data/spec/repositories_spec.rb
CHANGED
@@ -16,11 +16,23 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
18
|
require 'rubygems'
|
19
|
+
require 'bundler/setup'
|
19
20
|
require 'spec_helper'
|
20
21
|
|
21
22
|
require 'ansi'
|
22
23
|
require 'fog'
|
23
24
|
|
25
|
+
$APP_PATH = File.dirname(__FILE__)
|
26
|
+
$LIB_PATH = File.expand_path(File.join(File.dirname($APP_PATH),'lib'))
|
27
|
+
$FORJ_DATA_PATH= File.expand_path('~/.forj')
|
28
|
+
|
29
|
+
$LOAD_PATH << './lib'
|
30
|
+
|
31
|
+
require 'forj-config.rb' # Load class ForjConfig
|
32
|
+
require 'log.rb' # Load default loggers
|
33
|
+
include Logging
|
34
|
+
$FORJ_LOGGER=ForjLog.new('forj-rspec.log', Logger::FATAL)
|
35
|
+
|
24
36
|
require_relative '../lib/repositories.rb'
|
25
37
|
include Repositories
|
26
38
|
|
@@ -31,8 +43,8 @@ describe 'repositories' do
|
|
31
43
|
it 'should clone the repo' do
|
32
44
|
@test_class = TestClass.new
|
33
45
|
@test_class.extend(Repositories)
|
34
|
-
|
35
|
-
repo = @test_class.clone_repo('https://github.com/forj-oss/cli')
|
46
|
+
oConfig = ForjConfig.new
|
47
|
+
repo = @test_class.clone_repo('https://github.com/forj-oss/cli', oConfig)
|
36
48
|
expect(repo).to be
|
37
49
|
end
|
38
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.47
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- forj team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|