forj 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 107e066d39b5e872886f29e3cf357d762770f52d
4
- data.tar.gz: c72b3a154b661f05bac54dd38d3bb4207fb48004
3
+ metadata.gz: 104016c81c311f9a0f4454a0f50aadeb9e2810a2
4
+ data.tar.gz: 07452ff472445eed9d882d1d8e153c75b7b27182
5
5
  SHA512:
6
- metadata.gz: 963e240a9957f4b5ae872ea3fa046a7cdd70169d6006eea9cb32e7aca2dc29b9e10c8befb473d36d64abc8a281f815766ce319efc310eb5ea78adb819287803e
7
- data.tar.gz: c75c3cb8fd8e175d40f00e24120f20a93b1566d3fedb05b3487ba448d1ba466d972d84d2e5193e5a8f14414c5d8e3d9ea736774cdd4966896c5922353290e368
6
+ metadata.gz: dc95fd28f3de676003c62a1804725ca4225199391c78096a200a048c92d02207324d19ffd6a127b9a446baafe6b16a28ca3a49c90d676e2a6db33fbf35dd75a0
7
+ data.tar.gz: f1f431e9d6ebb546d1f524b921db1098ce537ec5a263ea310a87f2b6ff36fc35261d37552f8b4e0fe8568d551ee5beb9daf115b8042f689a4ca26ea0c508688f
data/README.md CHANGED
@@ -176,6 +176,23 @@ To ssh into a server
176
176
  forj ssh <name> <node>
177
177
  e.g. forj ssh maestro_01 [maestro, ci, util, review] # the nodes from your blueprint
178
178
 
179
+ Excon and SSL Issue
180
+ ===================
181
+
182
+ If you are connecting to a private cloud, you may need to provide some additional certificate data:
183
+
184
+ Excon env variables:
185
+ * SSL_CERT_DIR : path_to_certs
186
+ * SSL_CERT_FILE: path_to_file
187
+
188
+ Ex:
189
+
190
+ export SSL_CERT_FILE=~/ca.crt
191
+ forj setup myAccount openstack
192
+
193
+ or
194
+
195
+ SSL_CERT_FILE=~/ca.crt forj setup myAccount openstack
179
196
 
180
197
  Contributing to Forj
181
198
  =====================
data/bin/forj CHANGED
@@ -34,6 +34,7 @@ PrcLib.pdata_path = File.expand_path(File.join('~', '.cache', PrcLib.app_name))
34
34
  require 'appinit.rb' # Load Application settings features
35
35
  Forj.keypairs_path = File.join(PrcLib.data_path, 'keypairs')
36
36
  Forj.build_path = File.join(PrcLib.data_path, '.build')
37
+ Forj.file_version = '1.0.0'
37
38
 
38
39
  require 'forj-settings.rb' # Settings features
39
40
 
@@ -57,27 +58,43 @@ Quick steps: How to create a forj?
57
58
  ----------------------------------
58
59
 
59
60
  To test a forj blueprint, you will need an account on a cloud solution.
60
- Currently forj cli supports only HPHelion (https://horizon.hp.com) but will
61
- be expanded to support most of known clouds supported by FOG. (http://fog.io)
61
+ Currently forj cli supports folowing providers:
62
+
63
+ - openstack: openstack cloud and hp helion cloud (Fog)
64
+ - hpcloud : HP Public cloud (Fog)
65
+
66
+ This list can be expanded to more clouds.
67
+
68
+ If you want to contribute to support your cloud, check out:
69
+ http://github.com/forj-oss/lorj_cloud
62
70
 
63
71
  1. Setup your FORJ account.
64
- `$ forj setup [AccountName] [--provider Provider]`
65
72
 
66
- Ex: `forj setup MyForjAccount`. In this example:
67
- You will setup 'MyForjAccount' with your HPHelion account.
68
- The first time, this account will become the default one.
73
+ `$ forj setup`
74
+
75
+ This will create an account 'hpcloud' configured with 'hpcloud' provider
76
+
77
+ If you want another provider:
78
+
79
+ `$ forj setup MyAccountName openstack`
69
80
 
70
- **IMPORTANT NOTE** By default, forj setup will propose you to create your forge
71
- on HPHelion (provider 'hpcloud').
72
- If AccountName is not set, the account name will be proposed to be name
73
- 'hpcloud' as well!
81
+ The first time you setup an account, it will become the default one.
74
82
 
75
83
  2. Create your forge on your default account
76
84
  `$ forj boot <blueprint> <InstanceName>`
77
85
 
78
86
  Ex: `forj boot redstone MyForge`. In this example:
79
87
  Forj will create a `redstone` blueprint forge named `MyForge`,
80
- using the default `MyForjAccount`.
88
+ using the default account.
89
+
90
+ If you want to create your forge on another cloud account, do the following:
91
+
92
+ `$ forj boot <blueprint> <InstanceName> [-a account]`
93
+
94
+ Ex: `forj boot redstone MyForge -a MyAccountName`. In this example:
95
+ Forj will create a `redstone` blueprint forge named `MyForge`,
96
+ using the 'MyAccountName' account.
97
+
81
98
 
82
99
  forj command line details:
83
100
  --------------------------
@@ -130,16 +147,15 @@ If you want to check/updated them, use `forj get [-a account]`
130
147
  method_option :maestro_flavor, :aliases => '-f', :desc => 'config:' \
131
148
  ' flavor : Maestro flavor to use.'
132
149
  method_option :bp_flavor, :aliases => '-b', :desc => 'config:' \
133
- ' bp_flavor : Blueprint nodes default flavor to use.' \
134
- + "\n\n" + ' Build system options:'
150
+ ' bp_flavor : Blueprint nodes default flavor to use.'\
151
+ "\n\n Build system options:"
135
152
  method_option :boothook, :aliases => '-H', :desc => 'By default, ' \
136
153
  ' boothook file used is build/bin/build-tools/boothook.sh. ' \
137
154
  ' Use this option to set another one.'
138
155
  method_option :build, :aliases => '-B', :desc => 'Replace' \
139
156
  ' the default build.sh'
140
157
  method_option :branch, :aliases => '-R', :desc => 'Branch' \
141
- 'name to clone for maestro.' \
142
- + "\n\n" + 'Maestro/infra bootstrap debugging:'
158
+ "name to clone for maestro.\n\nMaestro/infra bootstrap debugging:"
143
159
  method_option :test_box, :aliases => '-T', :desc => 'Identify a' \
144
160
  ' path to become your test-box repository.' \
145
161
  "\n " \
@@ -192,10 +208,16 @@ queriable Objects:
192
208
  " and update with 'forj set'"
193
209
  when 'account'
194
210
  unless name
195
- puts "List of FORJ accounts: Use 'forj account YourAccount' " \
196
- ' to see one account details.'
197
211
  o_accounts = Lorj::Accounts.new
198
- puts o_accounts.dump.to_yaml
212
+ accounts = o_accounts.dump
213
+ if accounts.length == 0
214
+ PrcLib.message 'No accounts found. Use forj setup [Account '\
215
+ '[provider]] to create your first account.'
216
+ return
217
+ end
218
+ PrcLib.message "List of FORJ accounts: Use 'forj account YourAccount'" \
219
+ ' to see one account details.'
220
+ puts accounts.to_yaml
199
221
  return
200
222
  end
201
223
  o_config = Lorj::Account.new
@@ -336,6 +358,9 @@ ex: forj ssh myforge -n review
336
358
  ' create ssh connection'
337
359
  method_option :identity, :aliases => '-i', :desc => 'Private key' \
338
360
  ' file name.'
361
+ method_option :account_name, :aliases => '-a', :desc => 'Set the forj' \
362
+ ' account name to use. By default, uses the default account set in your' \
363
+ ' local config file.'
339
364
 
340
365
  def ssh(oInstanceName)
341
366
  Forj::Settings.common_options(options)
@@ -345,8 +370,13 @@ ex: forj ssh myforge -n review
345
370
 
346
371
  # Setting account at runtime layer
347
372
  account[:account_name] = options[:account_name] if options[:account_name]
373
+
348
374
  # Setting account at account layer
349
- account.ac_load account[:account_name]
375
+ unless account.ac_load account[:account_name]
376
+ PrcLib.fatal(1, "Invalid account '%s'. Use `forj show account` "\
377
+ 'to get the list of valid accounts.',
378
+ account[:account_name])
379
+ end
350
380
 
351
381
  account.set(:box_ssh, options[:box_name]) if options[:box_name]
352
382
  account.set(:identity, options[:identity]) if options[:identity]
@@ -380,13 +410,23 @@ Several data will be requested like:
380
410
  Forj::Settings.common_options(options)
381
411
  require 'cloud_connection.rb'
382
412
 
383
- account = Lorj::Account.new(options[:config])
384
- account.set(:provider_name, sProvider)
385
- account.set(:account_name, sAccountName)
413
+ account = Lorj::Account.new(options[:config], Forj.file_version)
414
+ account.ac_new(sAccountName, sProvider) unless account.ac_load(sAccountName)
386
415
 
387
416
  o_cloud = Forj::CloudConnection.connect(account)
388
- o_cloud.setup(:forge, sAccountName)
417
+
418
+ PrcLib.high_level_msg("Setting up '%s' with provider '%s'\n",
419
+ sAccountName, account[:provider])
420
+
421
+ o_cloud.setup(:forge)
422
+
389
423
  o_cloud.config.ac_save
424
+ unless o_cloud.config.local_exist?(:account_name)
425
+ PrcLib.info("Setting account '%s' as default. You can change it with "\
426
+ '`forj set account_name=<new account>`', sAccountName)
427
+ o_cloud.config.local_set(:account_name, sAccountName)
428
+ end
429
+ o_cloud.config.save_local_config
390
430
  PrcLib.high_level_msg("\nAccount %s '%s' saved.\n", sProvider, sAccountName)
391
431
  end
392
432
  end
data/forj/defaults.yaml CHANGED
@@ -135,6 +135,7 @@
135
135
  :default_value: "<%= Forj.keypairs_path %>"
136
136
  :keypair_base:
137
137
  :desc: "Contains the key file base name without .pem/.pub."
138
+ :default_value: "<%= config[:keypair_name] %>"
138
139
  :keypair_name:
139
140
  :desc: "keypair name defined in your cloud to access your server. By default we named it 'forj'. If it doesn't exist, it will be created."
140
141
  :required: true
@@ -208,7 +209,7 @@
208
209
  :tenant_name:
209
210
  :desc: "Tenant name required by fog/openstack on gardener"
210
211
  :account: true
211
- :validate: !ruby/regexp /^\w?[\w_-]*$/
212
+ :validate: !ruby/regexp /^\w?[\w_:-]*$/
212
213
  :ask_step: 1
213
214
  :ask_sort: 0
214
215
  :default_value: "<%= (config[:provider_name] == 'openstack')?config[:tenant]:nil %>"
data/forj.gemspec CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.name = 'forj'
20
20
  s.homepage = 'https://www.forj.io'
21
21
 
22
- s.version = '1.0.9'
23
- s.date = '2015-03-27'
22
+ s.version = '1.0.10'
23
+ s.date = '2015-04-17'
24
24
  s.summary = 'forj command line'
25
25
  s.description = 'forj cli - See https://www.forj.io for documentation/information'
26
26
 
@@ -44,7 +44,6 @@ Gem::Specification.new do |s|
44
44
  s.require_paths = %w[lib]
45
45
 
46
46
  s.add_runtime_dependency 'thor', '>=0.16.0'
47
- s.add_runtime_dependency 'fog', '~>1.26.0'
48
47
  s.add_runtime_dependency 'git', '>=1.2.7'
49
48
  s.add_runtime_dependency 'highline', '>= 1.6.21'
50
49
  s.add_runtime_dependency 'ansi', '>= 1.4.3'
@@ -52,11 +51,11 @@ Gem::Specification.new do |s|
52
51
  s.add_runtime_dependency 'json', '1.7.5'
53
52
  s.add_runtime_dependency 'bundler'
54
53
  s.add_runtime_dependency 'nokogiri','1.5.11'
55
- s.add_runtime_dependency 'lorj', '~> 1.0.8'
54
+ s.add_runtime_dependency 'lorj_cloud', '~> 0.1.0'
56
55
 
57
56
  s.add_development_dependency "rake", "~> 10.0"
58
57
  s.add_development_dependency "rspec", "~> 3.1.0"
59
- s.add_development_dependency "rubocop", ">=0.29.0"
58
+ s.add_development_dependency "rubocop", ">=0.30.0"
60
59
  s.rdoc_options << '--title' << 'Lorj - The Process Controllers framework system' <<
61
60
  '--main' << 'README.md'
62
61
  end
data/lib/appinit.rb CHANGED
@@ -19,7 +19,7 @@
19
19
  # or other kind of setting.
20
20
  module Forj
21
21
  class << self
22
- attr_accessor :build_path, :keypairs_path
22
+ attr_accessor :build_path, :keypairs_path, :file_version
23
23
  end
24
24
 
25
25
  module_function
@@ -38,4 +38,8 @@ module Forj
38
38
  @build_path = File.expand_path(v) unless @build_path
39
39
  PrcLib.ensure_dir_exists(@build_path)
40
40
  end
41
+
42
+ def file_version=(v)
43
+ @file_version = v unless @file_version
44
+ end
41
45
  end
data/lib/boot.rb CHANGED
@@ -29,7 +29,7 @@ module Forj
29
29
  def self.deprecated_name?(blueprint, on_or_name,
30
30
  old_accountname, as,
31
31
  old_name
32
- )
32
+ )
33
33
  # depreciated: <BluePrint> on <AccountName> as <InstanceName>
34
34
  if old_accountname && as && old_name
35
35
  msg = format(
@@ -100,6 +100,10 @@ module Forj
100
100
  end
101
101
  end
102
102
 
103
+ # rubocop: disable Metrics/CyclomaticComplexity
104
+ # rubocop: disable Metrics/MethodLength
105
+
106
+ # Boot process
103
107
  def self.boot(blueprint, on_or_name, deprecated_name, options)
104
108
  @account = Lorj::Account.new(options[:config])
105
109
 
@@ -115,14 +119,22 @@ module Forj
115
119
 
116
120
  @account[:account_name] = options[:account_name] if options[:account_name]
117
121
 
118
- @account.ac_load @account[:account_name]
122
+ unless @account.ac_load @account[:account_name]
123
+ PrcLib.fatal(1, "Account '%s' not loaded. You need to call "\
124
+ '`forj setup %s [provider]` to use this account.',
125
+ @account[:account_name], @account[:account_name])
126
+ end
119
127
 
120
- options_map = { :infra => :infra_repo, :key_name => :keypair_name,
121
- :key_path => :keypair_path,
128
+ options_map = { :infra => :infra_repo,
129
+ :key_name => :keypair_name,
130
+ :key_path => :keypair_path,
122
131
  :security_group => :security_group,
123
- :image_name => :image_name, :maestro_flavor => :flavor,
124
- :bp_flavor => :bp_flavor, :maestro_repo => :maestro_repo,
125
- :branch => :branch, :test_box => :test_box,
132
+ :image_name => :image_name,
133
+ :maestro_flavor => :flavor,
134
+ :bp_flavor => :bp_flavor,
135
+ :maestro_repo => :maestro_repo,
136
+ :branch => :branch,
137
+ :test_box => :test_box,
126
138
  :extra_metadata => :extra_metadata }
127
139
 
128
140
  load_options(options, options_map) do |key, value|
@@ -15,26 +15,32 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
+ require 'lorj_cloud'
19
+
18
20
  module Forj
19
21
  # Provide cloud object
20
22
  module CloudConnection
21
23
  def self.connect(account)
22
24
  a_processes = []
23
25
 
26
+ provider = account[:provider]
27
+
24
28
  # Defines how to manage Maestro and forges
29
+ # Uses 'cloud' module process provided by 'lorj_cloud'
30
+ a_processes << { :process_module => :cloud,
31
+ :controller_name => provider }
32
+
25
33
  # create a maestro box. Identify a forge instance, delete it,...
26
- a_processes << File.join(LIB_PATH, 'forj', 'ForjCore.rb')
34
+ a_processes << { :process_path => File.join(LIB_PATH, 'forj',
35
+ 'ForjCore.rb') }
27
36
 
28
37
  # Defines how cli will control FORJ features
29
38
  # boot/down/ssh/...
30
- a_processes << File.join(LIB_PATH, 'forj', 'ForjCli.rb')
39
+ a_processes << { :process_path => File.join(LIB_PATH, 'forj',
40
+ 'ForjCli.rb') }
31
41
 
32
42
  # Loading CloudCore embedding provider controller + its process.
33
- o_cloud = Lorj::CloudCore.new(
34
- account,
35
- account[:account_name],
36
- a_processes
37
- )
43
+ o_cloud = Lorj::Core.new(account, a_processes)
38
44
 
39
45
  o_cloud
40
46
  end
data/lib/cloud_test.rb CHANGED
@@ -56,7 +56,7 @@ If you already have an existing infra workspace,
56
56
  Otherwise, we will build a new one with some predefined data,
57
57
  you can review and update later.
58
58
  END
59
- )
59
+ )
60
60
  s_ask = format(
61
61
  'Do you want to create a new one from Maestro (yes/no)?',
62
62
  infra_dir
@@ -90,11 +90,9 @@ server_id_length = 0
90
90
  server_name_length = 0
91
91
 
92
92
  o_forge[:server].each do |server|
93
- if server[:id].length > server_id_length
94
- server_id_length = server[:id].length
95
- end
93
+ server_id_length = server[:id].length if server[:id].length > server_id_length
96
94
 
97
- if server[:name].length > server_name_length
95
+ if server[:name].length > server_name_length
98
96
  server_name_length = server[:name].length
99
97
  end
100
98
  end
@@ -106,7 +104,7 @@ puts format(
106
104
  'Index '.ljust(6),
107
105
  'Name'.ljust(server_name_length),
108
106
  'ID'.ljust(server_id_length)
109
- )
107
+ )
110
108
  # Display Forge servers detail
111
109
  o_forge[:server].each do |server|
112
110
  puts format(
@@ -114,7 +112,7 @@ o_forge[:server].each do |server|
114
112
  server_index.to_s.ljust(6),
115
113
  server[:name].to_s.ljust(server_name_length),
116
114
  server[:id].to_s.ljust(server_id_length)
117
- )
115
+ )
118
116
  server_index += 1
119
117
  end
120
118
 
data/lib/destroy.rb CHANGED
@@ -28,8 +28,13 @@ module Forj
28
28
 
29
29
  # Setting account at runtime layer
30
30
  account[:account_name] = options[:account_name] if options[:account_name]
31
- # Setting account at account layer
32
- account.ac_load account[:account_name]
31
+
32
+ # Loading account at account layer
33
+ unless account.ac_load account[:account_name]
34
+ PrcLib.fatal(1, "Invalid account '%s'. Use `forj show account` "\
35
+ 'to get the list of valid accounts.',
36
+ account[:account_name])
37
+ end
33
38
 
34
39
  o_cloud = Forj::CloudConnection.connect(account)
35
40
 
data/lib/forj/ForjCli.rb CHANGED
@@ -25,7 +25,7 @@ class Lorj::BaseDefinition
25
25
  define_obj(:ssh,
26
26
 
27
27
  :create_e => :ssh_connection
28
- )
28
+ )
29
29
  obj_needs :CloudObject, :forge
30
30
  obj_needs :data, :instance_name
31
31
  obj_needs :data, :keypair_name
@@ -57,7 +57,7 @@ class ForjCoreProcess
57
57
  s_status = active_server?(server, o_address, boot_options[:keys],
58
58
  boot_options[:coherent], s_status)
59
59
 
60
- till_server_active(s_status, server, o_address, boot_options)
60
+ till_server_active(s_status, hParams, o_address, boot_options)
61
61
 
62
62
  o_forge = get_forge(sObjectType, config[:instance_name], hParams)
63
63
 
@@ -154,7 +154,7 @@ class ForjCoreProcess
154
154
 
155
155
  def active_server?(o_server, o_address, private_key_file,
156
156
  keypair_coherent, s_status
157
- )
157
+ )
158
158
  if o_server[:attrs][:status] == :active
159
159
  image = server_get_image o_server
160
160
 
@@ -191,10 +191,14 @@ class ForjCoreProcess
191
191
  end
192
192
  end
193
193
 
194
+ # rubocop:disable Metrics/ClassLength
195
+
194
196
  # Functions for boot - build_forge
195
197
  class ForjCoreProcess
198
+ # TODO: Rewrite this function to break it for rubocop.
196
199
  # rubocop:disable CyclomaticComplexity
197
200
 
201
+ # Function displaying the server status
198
202
  def maestro_create_status(sStatus, iCurAct = 4, pending_count = 0)
199
203
  s_activity = '/-\\|?'
200
204
  if iCurAct < 4
@@ -228,12 +232,16 @@ class ForjCoreProcess
228
232
  # TODO: Rewrite this function to break it for rubocop.
229
233
  # rubocop: disable PerceivedComplexity
230
234
  # rubocop: disable Metrics/MethodLength
235
+ # rubocop: disable Metrics/AbcSize
231
236
 
232
- def till_server_active(s_status, o_server, o_address, boot_options)
237
+ # Loop until server is active
238
+ def till_server_active(s_status, hParams, o_address, boot_options)
233
239
  m_cloud_init_error = []
234
240
  i_cur_act = 0
235
241
  o_old_log = ''
236
242
  pending_count = 0
243
+ server_error = 0
244
+ o_server = hParams.refresh[:server, :ObjectData]
237
245
 
238
246
  while s_status != :active
239
247
  if i_cur_act == 4
@@ -244,10 +252,34 @@ class ForjCoreProcess
244
252
  maestro_create_status(s_status, i_cur_act, pending_count)
245
253
  i_cur_act += 1
246
254
  i_cur_act = i_cur_act % 4
255
+
256
+ if s_status == :restart
257
+ process_delete(:server)
258
+ PrcLib.message("Bad server '%s' removed. Creating a new one...",
259
+ o_server[:name])
260
+ sleep(5)
261
+ process_create(:internet_server)
262
+ s_status = :starting
263
+ o_server = hParams.refresh[:server, :ObjectData]
264
+ next
265
+ end
266
+
247
267
  o_server = load_server(o_server)
248
- # s_status = o_server[:attrs][:status]
268
+
269
+ if o_server[:status] == :error
270
+ if server_error == 1
271
+ PrcLib.fatal(1, 'Server tried to be rebuilt but failed again.')
272
+ end
273
+ server_error = 1
274
+ PrcLib.warning("The creation of server '%s' has currently failed. "\
275
+ 'Trying to rebuild it, once before give up.',
276
+ o_server[:name])
277
+ s_status = :restart
278
+ next
279
+ end
280
+
249
281
  if s_status == :starting
250
- s_status = :assign_ip if o_server[:attrs][:status] == :active
282
+ s_status = :assign_ip if o_server[:status] == :active
251
283
  elsif s_status == :assign_ip
252
284
  s_status = assign_ip_boot(o_address, boot_options, s_status, o_server)
253
285
  else # analyze the log output
@@ -342,7 +374,7 @@ done
342
374
  END
343
375
  s_msg = format(s_msg, o_server[:name], image[:ssh_user],
344
376
  o_address[:public_ip], boot_options[:keys]
345
- )
377
+ )
346
378
  unless boot_options[:coherent]
347
379
  s_msg += ANSI.bold("\nUnfortunatelly") + " your current keypair' \
348
380
  ' is not usable to connect to your server.\nYou need to fix' \
@@ -496,7 +528,7 @@ class ForjCoreProcess
496
528
  :salt => Time.now.to_i.to_s,
497
529
  :iv => Base64.strict_encode64(
498
530
  OpenSSL::Cipher::Cipher.new('aes-256-cbc').random_iv
499
- )
531
+ )
500
532
  }
501
533
 
502
534
  PrcLib.debug("Writing '%s' key file", key_file)
@@ -644,14 +676,15 @@ class ForjCoreProcess
644
676
  clone_maestro_repo(maestro_url, path_maestro, config)
645
677
  end
646
678
  rescue => e
647
- PrcLib.error('Error while cloning the repo from %s\n%s\n%s',
648
- maestro_url, e.message, e.backtrace.join("\n"))
649
- PrcLib.info(
650
- 'If this error persist you could clone the repo manually in ~/.forj/'
651
- )
679
+ PrcLib.error("Error while cloning the repo from %s\n%s\n%s"\
680
+ "\nIf this error persist you could clone the repo manually"\
681
+ " in '%s'",
682
+ maestro_url, e.message, e.backtrace.join("\n"),
683
+ h_result[:maestro_repo])
652
684
  end
653
685
  o_maestro = register(h_result, sObjectType)
654
686
  o_maestro[:maestro_repo] = h_result[:maestro_repo]
687
+ o_maestro[:maestro_repo_exist?] = File.directory?(h_result[:maestro_repo])
655
688
  o_maestro
656
689
  end
657
690
  end
@@ -896,7 +929,7 @@ class ForjCoreProcess
896
929
  ) unless File.exist?(mime)
897
930
  end
898
931
 
899
- def build_userdata(sObjectType, hParams)
932
+ def build_userdata(sObjectType, hParams) # rubocop: disable Metrics/AbcSize
900
933
  # get the paths for maestro and infra repositories
901
934
  # maestro_path = hParams[:maestro_repository].values
902
935
  # infra_path = hParams[:infra_repository].values
@@ -911,6 +944,13 @@ class ForjCoreProcess
911
944
  format('userdata.mime.%s', rand(36**5).to_s(36))
912
945
  )
913
946
 
947
+ unless hParams[:maestro_repository, :maestro_repo_exist?]
948
+ PrcLib.fatal(1, "Maestro repository doesn't exist. This is required for "\
949
+ "cloud_init user_data build. Check why '%s' "\
950
+ "doesn't exist.",
951
+ hParams[:maestro_repository, :maestro_repo])
952
+ end
953
+
914
954
  meta_data = JSON.generate(hParams[:metadata, :meta_data])
915
955
 
916
956
  build_tmpl_dir = File.expand_path(File.join(LIB_PATH, 'build_tmpl'))
@@ -1091,7 +1131,7 @@ class ForjCoreProcess
1091
1131
  # forj keypair storage. Otherwise this update is ignored.
1092
1132
  def save_sequences(private_key_file, forj_private_key_file,
1093
1133
  public_key_file, forj_public_key_file, key_name
1094
- )
1134
+ )
1095
1135
  PrcLib.info('Importing key pair to FORJ keypairs list.')
1096
1136
 
1097
1137
  FileUtils.copy(private_key_file, forj_private_key_file)
@@ -1107,7 +1147,7 @@ class ForjCoreProcess
1107
1147
  # forj keypair storage. Otherwise this update is ignored.
1108
1148
  def save_md5(private_key_file, forj_private_key_file,
1109
1149
  public_key_file, forj_public_key_file
1110
- )
1150
+ )
1111
1151
  # Checking source/dest files content
1112
1152
  if Digest::MD5.file(private_key_file).hexdigest !=
1113
1153
  Digest::MD5.file(forj_private_key_file).hexdigest
@@ -1138,7 +1178,7 @@ class ForjCoreProcess
1138
1178
  PrcLib.info("Configured forj keypair '%s' with '%s'",
1139
1179
  keys[:keypair_name],
1140
1180
  File.join(keys[:keypair_path], keys[:key_basename])
1141
- )
1181
+ )
1142
1182
  end
1143
1183
 
1144
1184
  # keypair_files post setup
@@ -1214,16 +1254,16 @@ class ForjCoreProcess
1214
1254
  #
1215
1255
  def update_keypair_config(_ = nil)
1216
1256
  %w(local account).each do |config_name|
1217
- next if config.exist?(:keypair_base, :names => [config_name])
1218
-
1257
+ next if config.latest_version?(config_name)
1219
1258
  keypair_path = config.get(:keypair_path, nil, :name => config_name)
1220
1259
 
1221
- next if keypair_path.nil?
1222
-
1223
- options = { :name => config_name }
1224
- options.merge!(:section => :default) if config_name == 'local'
1225
- config.set(:keypair_base, File.basename(keypair_path), options)
1226
- config.set(:keypair_path, File.dirname(keypair_path), options)
1260
+ unless keypair_path.nil?
1261
+ options = { :name => config_name }
1262
+ options.merge!(:section => :default) if config_name == 'local'
1263
+ config.set(:keypair_base, File.basename(keypair_path), options)
1264
+ config.set(:keypair_path, File.dirname(keypair_path), options)
1265
+ end
1266
+ config.version_set(config_name, Forj.file_version)
1227
1267
  end
1228
1268
  true
1229
1269
  end
@@ -1296,6 +1336,7 @@ class ForjCoreProcess
1296
1336
  return true if key_name.nil?
1297
1337
  config[:key_cloud_coherence] = false
1298
1338
  cloud_key = process_get(:keypairs, key_name)
1339
+ register(cloud_key)
1299
1340
  if !cloud_key.empty?
1300
1341
  if cloud_key[:coherent]
1301
1342
  config[:key_cloud_coherence] = true
@@ -1305,10 +1346,15 @@ class ForjCoreProcess
1305
1346
  return true
1306
1347
  end
1307
1348
  keypair_display(cloud_key)
1308
- s_ask = 'Do you still want to create new key?'
1309
- PrcLib.fatal(1, 'This keypair name cannot be used. ' \
1310
- 'You may check keypair_path setting ' \
1311
- 'in your account.') unless agree(s_ask)
1349
+
1350
+ return true unless cloud_key[:public_key_exist?]
1351
+
1352
+ PrcLib.message("You need to create a new keypair instead of '%s'"\
1353
+ 'or quit the setup to get the original key and retry.',
1354
+ key_name)
1355
+ s_ask = 'Do you want to create new keypair?'
1356
+
1357
+ PrcLib.fatal(1, 'Quitting setup per your request.') unless agree(s_ask)
1312
1358
  false
1313
1359
  end
1314
1360
 
@@ -1316,11 +1362,24 @@ class ForjCoreProcess
1316
1362
  # return true continue to ask keypair files
1317
1363
  # return false skip asking keypair files
1318
1364
  def forj_cloud_keypair_coherent?(_keypair_files)
1365
+ return true unless config.exist?(:key_cloud_coherence)
1366
+
1367
+ keypair = data_objects(:keypairs)
1368
+
1369
+ return true unless keypair.nil? || keypair[:private_key_exist?]
1370
+
1319
1371
  if config[:key_cloud_coherence]
1320
1372
  PrcLib.message('Your local ssh keypair is detected ' \
1321
1373
  'and valid to access the box.')
1322
1374
  return false
1323
1375
  end
1376
+ match = ANSI.bold(format('matching %s keypair name previously set',
1377
+ ANSI.red(config[:keypair_name])))
1378
+ desc = 'the base keypair file name (with absolute path) ' + match
1379
+
1380
+ Lorj.data.set(:sections, :credentials, :keypair_files,
1381
+ { :desc => desc }, 'setup')
1382
+
1324
1383
  true
1325
1384
  end
1326
1385
  end
data/lib/forj-settings.rb CHANGED
@@ -24,6 +24,19 @@ module Forj
24
24
  PrcLib.core_level = options[:lorj_debug].to_i
25
25
  PrcLib.level = Logger::DEBUG
26
26
  end
27
+ latest_version?(options[:account_name]) if options[:account_name]
28
+ end
29
+
30
+ def self.latest_version?(account_name)
31
+ config = Lorj::Account.new(nil, Forj.file_version)
32
+
33
+ config.ac_load account_name
34
+
35
+ PrcLib.fatal(1,
36
+ "Your account '%s' is obsolete, use `forj setup`," \
37
+ ' to update it.',
38
+ account_name) \
39
+ unless config.latest_version?('account')
27
40
  end
28
41
 
29
42
  def self.account_show_all(account_name)
@@ -35,12 +48,12 @@ module Forj
35
48
  puts format(
36
49
  "List of account settings for provider '%s': ",
37
50
  config.get(:provider)
38
- )
51
+ )
39
52
  puts format(
40
53
  "%-15s %-12s :\n------------------------------",
41
54
  'key',
42
55
  'section name'
43
- )
56
+ )
44
57
 
45
58
  config.meta_each do |section, found_key, hValue|
46
59
  next if hValue.rh_get(:readonly)
@@ -50,11 +63,11 @@ module Forj
50
63
  puts format(
51
64
  "\nUse `forj set KeyName=Value -a %s` to set one.",
52
65
  [account_name]
53
- )
66
+ )
54
67
  puts format(
55
68
  'Use `forj get -a %s` to check current values.',
56
69
  account_name
57
- )
70
+ )
58
71
  end
59
72
 
60
73
  def self.config_show_all
@@ -64,7 +77,7 @@ module Forj
64
77
  "%-15s %-12s :\n------------------------------",
65
78
  'key',
66
79
  'section name'
67
- )
80
+ )
68
81
  config.meta_each do |section, found_key, hValue|
69
82
  next if hValue.rh_get(:readonly)
70
83
  s_desc = hValue.rh_get(:desc)
@@ -157,7 +170,7 @@ module Forj
157
170
  full_key,
158
171
  s_bef,
159
172
  ANSI.bold + s_aft + ANSI.clear
160
- )
173
+ )
161
174
  end
162
175
  config.ac_save if b_dirty
163
176
  end
@@ -271,7 +284,7 @@ module Forj
271
284
  s_upd_msg,
272
285
  mykey,
273
286
  section
274
- )
287
+ )
275
288
  end
276
289
  end
277
290
  end
@@ -293,7 +306,7 @@ module Forj
293
306
  '--------------', 'U',
294
307
  'key', 'origin',
295
308
  'section name'
296
- )
309
+ )
297
310
 
298
311
  get_account_values(oConfig, account_name)
299
312
 
@@ -302,12 +315,12 @@ module Forj
302
315
  puts format(
303
316
  'Use `forj set <key>=<value> -a %s` to update account data.',
304
317
  account_name
305
- )
318
+ )
306
319
  puts format(
307
320
  'Or `forj set <key>= -a %s` '\
308
321
  'to restore key default value.',
309
322
  account_name
310
- )
323
+ )
311
324
  end
312
325
 
313
326
  def self.config_get_all(oConfig)
@@ -318,7 +331,7 @@ module Forj
318
331
  '-----', 'U',
319
332
  '''key', 'origin',
320
333
  'section name'
321
- )
334
+ )
322
335
 
323
336
  oConfig.meta_each do |section, found_key, hValue|
324
337
  s_upd_msg = '+'
@@ -339,14 +352,14 @@ module Forj
339
352
  ANSI.clear,
340
353
  section,
341
354
  oConfig.get(found_key)
342
- )
355
+ )
343
356
  else
344
357
  puts format(
345
358
  '%s %-19s( ) %-12s: unset',
346
359
  s_upd_msg,
347
360
  found_key,
348
361
  section
349
- )
362
+ )
350
363
  end
351
364
  end
352
365
  puts "\nUse 'forj set <key>=<value>' to update defaults on values" \
@@ -364,14 +377,14 @@ module Forj
364
377
  "%s: '%s'",
365
378
  oConfig.where?(key)[0],
366
379
  oConfig.get(key)
367
- )
380
+ )
368
381
  elsif oConfig.where?(key.parameterize.underscore.to_sym)
369
382
  key_symb = key.parameterize.underscore.to_sym
370
383
  puts format(
371
384
  "%s: '%s'",
372
385
  oConfig.where?(key_symb)[0],
373
386
  oConfig.get(key_symb)
374
- )
387
+ )
375
388
  else
376
389
  PrcLib.message("key '%s' not found", key)
377
390
  end
data/lib/ssh.rb CHANGED
@@ -80,8 +80,8 @@ module Forj
80
80
  ((s_default.nil?) ? '' : format(
81
81
  'Default: ' + "|%s|\n", s_default
82
82
  ))
83
- )
84
83
  )
84
+ )
85
85
  value = choose do |q|
86
86
  q.choices(*server_list)
87
87
  q.default = s_default unless s_default.nil?
data/vagrant/README.md CHANGED
@@ -49,3 +49,43 @@ Example use cases:
49
49
  1. update your code under your host, on in vagrant, /srv/forj/...
50
50
  2. update the installation with sources. This will execute rubocop and rspec, before any install.
51
51
  sudo /srv/forj/vagrant/configure/install.sh
52
+
53
+ # fog openstack V3 auth
54
+
55
+ To use the latest openstack authentication v3 (including domain), you need to get fog 1.30 or get it from source. hphelion 1.1 uses openstack authentication V3.
56
+
57
+ Currently, gem fog 1.30 doesn't exist. So, this section will explain what needs to be done to get the latest patch from github
58
+
59
+ We assume vagrant is installed and working perfectly.
60
+
61
+ 1. clone fog, cli and lorj patches from source.
62
+
63
+ $ mkdir -p ~/tmp/src
64
+ $ cd ~/tmp/src
65
+ $ git clone https://github.com/clarsonneur/fog.git
66
+ $ cd fog
67
+ $ sed -i 's/1.29/1.30/g' fog.gemspec
68
+ $ cd -
69
+ $ git clone https://github.com/forj-oss/lorj.git
70
+ $ cd lorj
71
+ $ git fetch https://review.forj.io/forj-oss/lorj refs/changes/55/2555/4 && git cherry-pick FETCH_HEAD
72
+ $ cd -
73
+ $ git clone https://github.com/forj-oss/cli.git
74
+ $ cd cli
75
+ $ git fetch https://review.forj.io/forj-oss/cli refs/changes/47/2547/6 && git cherry-pick FETCH_HEAD
76
+ $ cd -
77
+
78
+ 2. set some tasks to execute before install forj cli
79
+
80
+ $ src="~/tmp/src/fog:bundler install ;gem build fog.gemspec ;gem install fog-1.30.0.gem"
81
+ $ src="$src;|~/tmp/src/lorj/:bundler install ;rake install"
82
+ $ export src
83
+ $ cd ~/tmp/src/cli/vagrant/fedora # You can try ubuntu as well in ../ubuntu
84
+ $ vagrant up # The box is going to be created and provisionned.
85
+ $ vagrant ssh # You are in!
86
+
87
+ 3. if needed, you can set the SSL_CERT_FILE, or SSL_CERT_PATH if you having trouble with https certificates.
88
+ We assume you are still in your vagrant box.
89
+ $ export
90
+
91
+ 4. Do any forj task, like forj setup, boot or destroy...
@@ -52,6 +52,17 @@ Vagrant.configure(2) do |config|
52
52
  end
53
53
  end
54
54
 
55
+ src_data = {}
56
+ if ENV.key?('src')
57
+ # Support '<path1>:cmd1[;cmd2[;...]];|[path2:cmd3...]'
58
+ src_list = ENV['src'].split(';|')
59
+ src_list.each do |src|
60
+ src_name, cmd = src.split(':')
61
+ src_data[src_name] = cmd
62
+ config.vm.synced_folder src_name, File.join('/srv', File.basename(src_name))
63
+ end
64
+ end
65
+
55
66
  # Provider-specific configuration so you can fine-tune various
56
67
  # backing providers for Vagrant. These expose provider-specific options.
57
68
  # Example for VirtualBox:
@@ -86,10 +97,15 @@ Vagrant.configure(2) do |config|
86
97
  config.proxy.no_proxy = ENV['no_proxy'] if ENV.key?('no_proxy')
87
98
  end
88
99
  priv = { privileged: true }
89
- config.vm.provision "shell", priv.merge(inline: "yum install ruby-devel libxml2-devel libxslt-devel python-yaml gcc git -y")
100
+ config.vm.provision "shell", priv.merge(inline: "yum install ruby-devel libxml2-devel libxslt-devel python-yaml gcc git tar patch gcc-c++ -y")
90
101
  config.vm.provision "shell", inline: "gem install bundler --no-rdoc --no-ri"
91
102
  config.vm.provision "shell", inline: "gem install rake --no-rdoc --no-ri"
92
103
  config.vm.provision "shell", inline: "echo 'PATH=$PATH:/usr/local/bin' >> /etc/profile.d/local.sh"
104
+ src_data.each do |key, value|
105
+ path = File.join('/srv', File.basename(key))
106
+ value = "echo 'Nothing more to do in #{path}'" if value.nil?
107
+ config.vm.provision "shell", inline: "cd #{path} ; #{value}"
108
+ end
93
109
  config.vm.provision "shell", inline: "/srv/forj/vagrant/configure/install.sh"
94
110
  config.vm.provision "shell", inline: "echo \"echo 'Call sudo /srv/forj/vagrant/configure/install.sh to reinstall forj/lorj from source'\" >> ~vagrant/.bash_profile"
95
111
  end
@@ -5,6 +5,8 @@
5
5
  # configures the configuration version (we support older styles for
6
6
  # backwards compatibility). Please don't change it unless you know what
7
7
  # you're doing.
8
+
9
+
8
10
  Vagrant.configure(2) do |config|
9
11
  # The most common configuration options are documented and commented below.
10
12
  # For a complete reference, please see the online documentation at
@@ -40,11 +42,24 @@ Vagrant.configure(2) do |config|
40
42
  # config.vm.synced_folder "../data", "/vagrant_data"
41
43
  config.vm.synced_folder "../../", "/srv/forj"
42
44
 
45
+ lorj = false
43
46
  if ENV.key?('lorj_src')
44
47
  lorj_src = File.expand_path(ENV['lorj_src'])
45
48
  git_data = File.join(lorj_src, '.git', 'config')
46
49
  if File.exist?(git_data) && open(git_data) { |f| f.grep(/forj-oss\/lorj/) }
47
50
  config.vm.synced_folder ENV['lorj_src'], "/srv/lorj"
51
+ lorj=true
52
+ end
53
+ end
54
+
55
+ src_data = {}
56
+ if ENV.key?('src')
57
+ # Support '<path1>:cmd1[;cmd2[;...]];|[path2:cmd3...]'
58
+ src_list = ENV['src'].split(';|')
59
+ src_list.each do |src|
60
+ src_name, cmd = src.split(':')
61
+ src_data[src_name] = cmd
62
+ config.vm.synced_folder src_name, File.join('/srv', File.basename(src_name))
48
63
  end
49
64
  end
50
65
 
@@ -86,6 +101,12 @@ Vagrant.configure(2) do |config|
86
101
  config.vm.provision "shell", priv.merge(inline: "apt-get install ruby1.9.1 ruby1.9.1-dev rubygems1.9.1 build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev libxml2-dev libxslt-dev git -y")
87
102
  config.vm.provision "shell", priv.merge(inline: "gem install bundler --no-rdoc --no-ri")
88
103
  config.vm.provision "shell", priv.merge(inline: "gem install rake --no-rdoc --no-ri")
104
+ config.vm.provision "shell", inline: "echo 'PATH=$PATH:/usr/local/bin' >> /etc/profile.d/local.sh"
105
+ src_data.each do |key, value|
106
+ path = File.join('/srv', File.basename(key))
107
+ value = "echo 'Nothing more to do in #{path}'" if value.nil?
108
+ config.vm.provision "shell", inline: "cd #{path} ; #{value}"
109
+ end
89
110
  config.vm.provision "shell", inline: "/srv/forj/vagrant/configure/install.sh"
90
- config.vm.provision "shell", inline: "echo 'echo \"Call /srv/forj/vagrant/configure/install.sh to reinstall forj/lorj from source\"' >> ~vagrant/.bash_profile"
111
+ config.vm.provision "shell", inline: "echo \"echo 'Call sudo /srv/forj/vagrant/configure/install.sh to reinstall forj/lorj from source'\" >> ~vagrant/.bash_profile"
91
112
  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: 1.0.9
4
+ version: 1.0.10
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-27 00:00:00.000000000 Z
11
+ date: 2015-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.16.0
27
- - !ruby/object:Gem::Dependency
28
- name: fog
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: 1.26.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: 1.26.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: git
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -137,19 +123,19 @@ dependencies:
137
123
  - !ruby/object:Gem::Version
138
124
  version: 1.5.11
139
125
  - !ruby/object:Gem::Dependency
140
- name: lorj
126
+ name: lorj_cloud
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - ~>
144
130
  - !ruby/object:Gem::Version
145
- version: 1.0.8
131
+ version: 0.1.0
146
132
  type: :runtime
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - ~>
151
137
  - !ruby/object:Gem::Version
152
- version: 1.0.8
138
+ version: 0.1.0
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: rake
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +170,14 @@ dependencies:
184
170
  requirements:
185
171
  - - '>='
186
172
  - !ruby/object:Gem::Version
187
- version: 0.29.0
173
+ version: 0.30.0
188
174
  type: :development
189
175
  prerelease: false
190
176
  version_requirements: !ruby/object:Gem::Requirement
191
177
  requirements:
192
178
  - - '>='
193
179
  - !ruby/object:Gem::Version
194
- version: 0.29.0
180
+ version: 0.30.0
195
181
  description: forj cli - See https://www.forj.io for documentation/information
196
182
  email:
197
183
  - forj@forj.io