forj 1.0.14 → 1.0.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 613daa28b3ba9524c23beed49420d1893e909c24
4
- data.tar.gz: da633b67dda381136608a689d9c47c484d5618c7
3
+ metadata.gz: 312576a6319c822544600e056e1c8cf131d6b14e
4
+ data.tar.gz: 7cb0109cb4327892975a9e80d1dd9a67dd69c939
5
5
  SHA512:
6
- metadata.gz: dbddb2c23bf804063c3106a646d08985c685dfc0b30363825bcda8b645534b7f09fec7a08c528bc0879bd9f8f38950cf054bab790fb069d6c1424a37411881eb
7
- data.tar.gz: 5e8fcd27a45a2ce4153e699c5b70522637749f0fdb41460ed6f2d86bd98f33120869ec8b336cff7936ae8e822bb5f8deed187f5eb9beddab775c2f4a534a9f80
6
+ metadata.gz: dbae1414fa3b0417da43eb8b19945ba249aa62f348ae7cf3285a21d1ac9f64ac138a4f89b57373a82d0106a042e94e9f158be24ff10359fb8073381e42212bb0
7
+ data.tar.gz: e7fbb5342219e1b81b6e7dcecb98b113b200419aa2e6b4825bcb6ae90fe63316df267c2d518e566337339c8fcfaf139e1583b98c666e764eadb6949b6dc56d0a
data/Gemfile CHANGED
@@ -18,23 +18,3 @@
18
18
  source 'https://rubygems.org'
19
19
 
20
20
  gemspec
21
- # group(:development, :test) do
22
- # gem 'rake'
23
- # gem 'debugger'
24
- # gem 'byebug'
25
- # gem 'rspec', "~> 3.1.0", :require => false
26
- # end
27
-
28
- # if updating here, update forj.gemspec as well, to be coherent.
29
- # gem 'mime-types','1.25.1'
30
- # gem 'excon','0.31.0'
31
- # gem 'json','1.7.5'
32
- # gem 'nokogiri','1.5.11'
33
- # gem 'fog', '1.19.0'
34
- # gem 'git', '>=1.2.7'
35
- # gem 'rainbow'
36
- # gem 'thor', '>=0.16.0'
37
- # gem 'highline','>=1.6.21'
38
- # gem 'ansi','>=1.4.3'
39
- # gem 'encryptor','>=1.3.0'
40
- # gem 'bundler', '1.7.3'
data/bin/forj CHANGED
@@ -16,8 +16,6 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require 'rubygems'
19
- # require 'debugger' # Use to debug with Ruby < 2.0
20
- # require 'byebug' # Use to debug with Ruby >= 2.0
21
19
  require 'bundler/setup'
22
20
  require 'thor'
23
21
  require 'ansi'
@@ -45,6 +43,8 @@ require 'forj-settings.rb' # Settings features
45
43
  class ForjThor < Thor
46
44
  class_option :debug, :aliases => '-d', :desc => 'Set debug mode'
47
45
  class_option :verbose, :aliases => '-v', :desc => 'Set verbose mode'
46
+ class_option :quiet, :aliases => '-q', :desc => 'Set quiet mode'
47
+ class_option :real_quiet, :desc => 'Set REAL quiet mode (errors/fatal only)'
48
48
  class_option :config, :aliases => '-c', :desc => 'Path to a different forj'\
49
49
  ' config file. By default, use ~/.forj/config.yaml'
50
50
  class_option :lorj_debug, :desc => 'Set lorj debug level verbosity. 1 to 5.'\
@@ -178,6 +178,10 @@ If you want to check/updated them, use `forj get [-a account]`
178
178
  ' your cloud'
179
179
  method_option :ca_root_cert, :desc => 'Certificate Authorities file used by'\
180
180
  ' your compagny to authenticate your intranet servers.'
181
+ method_option :disable_lorj, :type => :boolean,
182
+ :desc => 'If set, Maestro - gardener (Cloud'\
183
+ ' management) will use internal FOG cloud implementation to build your '\
184
+ 'forge. By default, Maestro gardener delegate this task to Lorj_cloud.'
181
185
 
182
186
  def boot(blueprint, on_or_name, old_accountname = nil, as = nil,
183
187
  old_name = 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.14'
23
- s.date = '2015-06-05'
22
+ s.version = '1.0.15'
23
+ s.date = '2015-06-24'
24
24
  s.summary = 'forj command line'
25
25
  s.description = 'forj cli - See https://www.forj.io for documentation/information'
26
26
 
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.homepage = 'https://forj.io'
36
36
  s.license = 'Apache License, Version 2.0.'
37
37
  s.post_install_message = 'Go to docs.forj.io for more information on how to use forj cli'
38
- s.required_ruby_version = '>= 1.8.5'
38
+ s.required_ruby_version = '>= 1.9.3'
39
39
 
40
40
  s.bindir = 'bin'
41
41
 
@@ -51,11 +51,19 @@ Gem::Specification.new do |s|
51
51
  s.add_runtime_dependency 'json', '1.7.5'
52
52
  s.add_runtime_dependency 'bundler'
53
53
  s.add_runtime_dependency 'nokogiri','1.5.11'
54
- s.add_runtime_dependency 'lorj_cloud', '~> 0.1.1'
54
+ s.add_runtime_dependency 'lorj_cloud', '>= 0.1.4'
55
55
 
56
56
  s.add_development_dependency "rake", "~> 10.0"
57
57
  s.add_development_dependency "rspec", "~> 3.1.0"
58
- s.add_development_dependency "rubocop", ">=0.30.0"
58
+ if RUBY_VERSION.match(/1\.8/)
59
+ s.add_development_dependency "ruby-debug"
60
+ elsif RUBY_VERSION.match(/1\.9/)
61
+ s.add_development_dependency "debugger"
62
+ s.add_development_dependency "rubocop", ">= 0.30.0"
63
+ else
64
+ s.add_development_dependency "byebug"
65
+ s.add_development_dependency "rubocop", ">= 0.30.0"
66
+ end
59
67
  s.rdoc_options << '--title' << 'Lorj - The Process Controllers framework system' <<
60
68
  '--main' << 'README.md'
61
69
  end
data/lib/appinit.rb CHANGED
@@ -43,3 +43,20 @@ module Forj
43
43
  @file_version = v unless @file_version
44
44
  end
45
45
  end
46
+
47
+ if ENV['RUBY_DEBUG'] == 'true'
48
+ if /1\.8/ =~ RUBY_VERSION
49
+ require 'ruby-debug'
50
+ Debugger.start
51
+ alias stop debugger # rubocop: disable Style/Alias
52
+ elsif /1\.9/ =~ RUBY_VERSION
53
+ require 'debugger'
54
+ alias stop debugger # rubocop: disable Style/Alias
55
+ else
56
+ require 'byebug'
57
+ alias stop byebug # rubocop: disable Style/Alias
58
+ end
59
+ else
60
+ def stop
61
+ end
62
+ end
data/lib/boot.rb CHANGED
@@ -53,8 +53,8 @@ module Forj
53
53
 
54
54
  def self.load_options(options, options_map)
55
55
  options_map.each do |opt_key, ac_key|
56
- if options.key?(opt_key.to_s)
57
- value = yield(opt_key, options[opt_key.to_s])
56
+ if options.key?(opt_key)
57
+ value = yield(opt_key, options[opt_key])
58
58
  @account.set(ac_key, value) unless value.nil?
59
59
  end
60
60
  end
@@ -100,8 +100,6 @@ module Forj
100
100
  end
101
101
  end
102
102
  end
103
- # rubocop: disable Metrics/CyclomaticComplexity
104
- # rubocop: disable Metrics/MethodLength
105
103
 
106
104
  #
107
105
  module Boot
@@ -127,8 +125,8 @@ module Forj
127
125
  @account[:account_name], @account[:account_name])
128
126
  end
129
127
 
130
- options['tb_path'] = nil if options.key?('test_box') &&
131
- !options.key?('tb_path')
128
+ options[:tb_path] = nil if options.key?(:test_box) &&
129
+ !options.key?(:tb_path)
132
130
  options_map = { :infra => :infra_repo,
133
131
  :key_name => :keypair_name,
134
132
  :key_path => :keypair_path,
@@ -142,7 +140,9 @@ module Forj
142
140
  :tb_path => :test_box_path,
143
141
  :ca_root_cert => :ca_root_cert,
144
142
  :extra_metadata => :extra_metadata,
145
- :webproxy => :webproxy }
143
+ :webproxy => :webproxy,
144
+ :disable_lorj => :lorj_disabled
145
+ }
146
146
 
147
147
  load_options(options, options_map) { |k, v| complete_boot_options(k, v) }
148
148
 
@@ -157,7 +157,13 @@ module Forj
157
157
  @account[:instance_name],
158
158
  PrcLib.log_file)
159
159
 
160
- o_cloud.create(:forge)
160
+ o_cloud.create(:forge,
161
+ :server_name => "maestro.#{@account[:instance_name]}",
162
+ :image_name => @account['maestro#image_name'],
163
+ :flavor_name => @account['maestro#flavor_name'],
164
+ :network_name => @account['maestro#network_name'],
165
+ :security_group => @account['maestro#security_group'],
166
+ :ports => @account[:ports])
161
167
  end
162
168
  end
163
169
  # rubocop: enable Metrics/CyclomaticComplexity
@@ -182,8 +188,13 @@ module Forj
182
188
  def self.tb_repo_detect(paths)
183
189
  res = {}
184
190
  paths.each do |path|
191
+ PrcLib.debug("tb_repo_detect: checking #{path}")
185
192
  cmd = <<-CMD
186
193
  cd "#{path}"
194
+ if [ $? -ne 0 ]
195
+ then
196
+ exit 1
197
+ fi
187
198
  git rev-parse --show-toplevel 2>/dev/null 1>&2
188
199
  if [ $? -ne 0 ]
189
200
  then
@@ -203,11 +214,22 @@ pwd
203
214
  # Ruby bug. tested with:
204
215
  # ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
205
216
  # rubocop: disable Style/SpecialGlobalVars
206
- next unless $?.exitstatus == 0
217
+ unless $?.exitstatus == 0
218
+ PrcLib.warning("tb_repo_detect: #{path} seems not to be a GIT "\
219
+ "repo.\n"\
220
+ "#{cmd_res.join("\n")}")
221
+ next
222
+ end
207
223
  # rubocop: enable Style/SpecialGlobalVars
208
224
  repo_found = cmd_res[0].match(%r{.*/(.*)(.git)?})
209
- next unless repo_found
225
+ unless repo_found
226
+ PrcLib.warning("tb_repo_detect: Unable to find the repo path.\n"\
227
+ "#{cmd_res.join("\n")}")
228
+
229
+ next
230
+ end
210
231
  res[repo_found[1]] = cmd_res[1]
232
+ PrcLib.debug("tb_repo_detect: FOUND #{cmd_res[1]}")
211
233
  end
212
234
  res
213
235
  end
@@ -228,6 +250,7 @@ pwd
228
250
  'test-box is disabled.', script)
229
251
  return nil
230
252
  end
253
+ PrcLib.debug("tb_repo_detect: FOUND #{script_found}")
231
254
  return script_found
232
255
  end
233
256
 
@@ -237,6 +260,7 @@ pwd
237
260
  script_found = tb_check_bin(path)
238
261
  break unless script_found.nil?
239
262
  end
263
+ PrcLib.debug("tb_repo_detect: FOUND #{script_found}")
240
264
 
241
265
  script_found
242
266
  end
data/lib/cloud_test.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # require 'byebug'
4
-
5
3
  APP_PATH = File.dirname(__FILE__)
6
4
  LIB_PATH = File.expand_path(File.join(File.dirname(APP_PATH), 'lib'))
7
5
 
data/lib/forj-settings.rb CHANGED
@@ -26,6 +26,9 @@ module Forj
26
26
  PrcLib.debug('Thor options converted to use Symbol instead of String '\
27
27
  'in keys')
28
28
  end
29
+ PrcLib.level = Logger::INFO
30
+ PrcLib.level = Logger::ERROR if opts[:real_quiet]
31
+ PrcLib.level = Logger::WARN if opts[:quiet]
29
32
  PrcLib.level = Logger::INFO if opts[:verbose]
30
33
  PrcLib.level = Logger::DEBUG if opts[:debug]
31
34
  unless opts[:lorj_debug].nil?
@@ -33,6 +36,7 @@ module Forj
33
36
  PrcLib.level = Logger::DEBUG
34
37
  end
35
38
  latest_version?(opts[:account_name]) if opts[:account_name]
39
+
36
40
  opts
37
41
  end
38
42
 
@@ -47,7 +51,10 @@ module Forj
47
51
  account_name) \
48
52
  unless config.latest_version?('account')
49
53
  end
54
+ end
50
55
 
56
+ # This module helps you to setup your forge's account
57
+ module Settings
51
58
  def self.account_show_all(account_name)
52
59
  config = Lorj::Account.new
53
60
 
@@ -27,10 +27,22 @@
27
27
  :gardener_config:
28
28
  :desc: "Maestro gardener Cloud configuration:"
29
29
  :explanation: |-
30
- Maestro gardener is currently configured to access your cloud Compute service with fog openstack.
31
- Fog openstack is compatible with hpcloud services
30
+ Maestro gardener is currently the layer used by Maestro to access your cloud.
32
31
 
33
- It requires the openstack uri, project name, user and password.
32
+ First versions of gardener call directly the Openstack API from FOG for compute/network
33
+ and call directly hpcloud FOG API to manage DNS records.
34
+
35
+ The new gardener version, now implements an agnostic cloud library called 'Lorj_cloud'
36
+ and replace the Openstack FOG API with compute/network.
37
+
38
+ The DNS management will be replaced as well in next version of gardener.
39
+
40
+ 'Lorj_cloud' is used as the default compute/network cloud management.
41
+ As those changes are in transition, the old gardener behavior has been kept and can be re-enabled.
42
+ See 'lorj_disabled' paramater in 'forj get/set' or --disable-lorj from cli.
43
+
44
+ In order to switch easily on Maestro between FOG <=> LORJ_CLOUD, setup
45
+ will still requires the openstack uri, project name, user and password.
34
46
  :bp_config:
35
47
  :desc: "Maestro and blueprint configuration:"
36
48
  :maestro_access_config:
@@ -202,6 +214,9 @@
202
214
  :validate: !ruby/regexp /^\w?\w*$/
203
215
  :default_value: "forj"
204
216
  :ask_step: :maestro_config
217
+ :ports:
218
+ :desc: "Ports open in the security groups given."
219
+ :default_value: [22, 80, 443, 3000, 3131-3135, 4505-4506, 5000, 5666, 8000, 8080-8081, 8083, 8125, 8139-8140, 8773-8776, 9292, 29418, 35357]
205
220
  :maestro_repo:
206
221
  :desc: "To use a different Maestro repository already cloned."
207
222
  :infra_repo:
@@ -274,7 +289,9 @@
274
289
  :desc: "Additional bootstrap directories (separated by space) to add in the bootstrap loop."
275
290
  :bootstrap_extra_dir:
276
291
  :desc: "Additional bootstrap directory to add in the bootstrap loop, before :bootstrap_dirs and after maestro default bootstrap directory."
277
-
292
+ :lorj_disabled:
293
+ :desc: "True if maestro gardener by default will use FOG to access the cloud. Otherwise, it will use LORJ_CLOUD."
294
+ :default_value: false
278
295
 
279
296
  # Defines certificates
280
297
 
@@ -41,9 +41,14 @@ class Lorj::BaseDefinition # rubocop: disable Style/ClassAndModuleChildren
41
41
  obj_needs :data, :infra_repo
42
42
  obj_needs :data, :branch
43
43
 
44
+ # ******************* Lorj_cloud account
45
+ define_obj :lorj_account,
46
+ :create_e => :build_lorj_account
47
+
48
+ obj_needs :data, 'maestro#lorj_disabled'
49
+
44
50
  # ******************* metadata object
45
51
  define_obj :metadata,
46
-
47
52
  :create_e => :build_metadata
48
53
 
49
54
  obj_needs :data, :instance_name
@@ -63,6 +68,8 @@ class Lorj::BaseDefinition # rubocop: disable Style/ClassAndModuleChildren
63
68
  obj_needs :data, 'credentials#account_id'
64
69
  obj_needs :data, 'credentials#account_key'
65
70
  obj_needs :data, 'credentials#auth_uri'
71
+ obj_needs :data, :server_name
72
+ obj_needs :CloudObject, :lorj_account
66
73
  obj_needs_optional
67
74
 
68
75
  obj_needs :data, 'network#webproxy'
@@ -105,6 +112,8 @@ class Lorj::BaseDefinition # rubocop: disable Style/ClassAndModuleChildren
105
112
  obj_needs :data, 'maestro#flavor_name', :for => [:create_e]
106
113
  obj_needs :data, 'maestro#network_name', :for => [:create_e]
107
114
  obj_needs :data, 'maestro#security_group', :for => [:create_e]
115
+ obj_needs :data, :ports, :for => [:create_e]
116
+ obj_needs :CloudObject, :lorj_account, :for => [:create_e]
108
117
 
109
118
  obj_needs_optional
110
119
  obj_needs :CloudObject, :server
@@ -121,6 +130,9 @@ class Lorj::BaseDefinition # rubocop: disable Style/ClassAndModuleChildren
121
130
  # Adding support of ca-root-cert file to send out.
122
131
  obj_needs :data, 'certs#ca_root_cert', :for => [:create_e]
123
132
 
133
+ # Lorj_disabled support
134
+ obj_needs :data, 'maestro#lorj_disabled', :for => [:create_e]
135
+
124
136
  # Defines how cli will control FORJ features
125
137
  # boot/down/ssh/...
126
138
 
@@ -53,6 +53,7 @@ class ForjCoreProcess
53
53
  maestro_create_status(s_status)
54
54
 
55
55
  o_address = hParams.refresh[:public_ip, :ObjectData]
56
+ o_address = Lorj::Data.new if o_address.nil?
56
57
 
57
58
  s_status = active_server?(server, o_address, boot_options[:keys],
58
59
  boot_options[:coherent], s_status)
@@ -69,11 +70,7 @@ class ForjCoreProcess
69
70
  o_forge = process_get(sObjectType, config[:instance_name])
70
71
  if o_forge.empty? || o_forge[:servers].length == 0
71
72
  PrcLib.high_level_msg("\nBuilding your forge...\n")
72
- process_create(:internet_server,
73
- :image_name => hParams['maestro#image_name'],
74
- :flavor_name => hParams['maestro#flavor_name'],
75
- :network_name => hParams['maestro#network_name'],
76
- :security_group => hParams['maestro#security_group'])
73
+ process_create(:internet_server)
77
74
  o_forge[:servers, 'maestro'] = hParams.refresh[:server]
78
75
  else
79
76
  o_forge = load_existing_forge(o_forge, hParams)
@@ -88,7 +85,8 @@ class ForjCoreProcess
88
85
  if o_server
89
86
  query = { :server_id => o_server[:id] }
90
87
  register(o_server)
91
- o_ip = process_query(:public_ip, query)
88
+ o_ip = process_query(:public_ip, query,
89
+ :network_name => hParams['maestro#network_name'])
92
90
  register(o_ip[0]) if o_ip.length > 0
93
91
  else
94
92
  PrcLib.high_level_msg("\nYour forge exist, without maestro." \
@@ -160,6 +158,8 @@ class ForjCoreProcess
160
158
  keypair_coherent, s_status
161
159
  )
162
160
  if o_server[:attrs][:status] == :active
161
+ return :assign_ip if o_address[:public_ip].nil?
162
+
163
163
  image = server_get_image o_server
164
164
 
165
165
  s_msg = format('Your forj Maestro server is up and running and is '\
@@ -195,8 +195,6 @@ class ForjCoreProcess
195
195
  end
196
196
  end
197
197
 
198
- # rubocop:disable Metrics/ClassLength
199
-
200
198
  # Functions for boot - build_forge
201
199
  class ForjCoreProcess
202
200
  # TODO: Rewrite this function to break it for rubocop.
@@ -285,12 +283,13 @@ class ForjCoreProcess
285
283
  if s_status == :starting
286
284
  s_status = :assign_ip if o_server[:status] == :active
287
285
  elsif s_status == :assign_ip
288
- s_status = assign_ip_boot(o_address, boot_options, s_status, o_server)
286
+ s_status = assign_ip_boot(o_address, boot_options, s_status, o_server,
287
+ hParams)
289
288
  else # analyze the log output
290
289
  output_options = { :status => s_status, :error => m_cloud_init_error,
291
290
  :old_log => o_old_log, :cur_act => i_cur_act
292
291
  }
293
- output_options = analyze_log_output(output_options, s_status)
292
+ output_options = analyze_log_output(output_options, s_status, hParams)
294
293
  s_status = output_options[:status]
295
294
  m_cloud_init_error = output_options[:error]
296
295
  o_old_log = output_options[:old_log]
@@ -298,6 +297,7 @@ class ForjCoreProcess
298
297
 
299
298
  tb_detect(hParams, o_old_log)
300
299
  ca_root_detect(hParams, o_old_log)
300
+ lorj_detect(hParams, o_old_log, boot_options)
301
301
 
302
302
  if pending_count == 60
303
303
  image = server_get_image o_server
@@ -356,7 +356,7 @@ end
356
356
 
357
357
  # Functions for boot - build_forge
358
358
  class ForjCoreProcess
359
- def assign_ip_boot(o_address, boot_options, s_status, o_server)
359
+ def assign_ip_boot(o_address, boot_options, s_status, o_server, hParams)
360
360
  if o_address.empty?
361
361
  # To be able to ask for server IP assigned
362
362
  query_cache_cleanup(:public_ip)
@@ -368,8 +368,7 @@ class ForjCoreProcess
368
368
  o_address = o_addresses[0]
369
369
  end
370
370
  end
371
-
372
- image = data_objects(:image, :ObjectData)
371
+ image = hParams.refresh[:image]
373
372
  s_msg = <<-END
374
373
  Public IP for server '%s' is assigned.
375
374
  Now, as soon as the server respond to the ssh port,
@@ -394,7 +393,7 @@ done
394
393
  s_status
395
394
  end
396
395
 
397
- def analyze_log_output(output_options, s_status)
396
+ def analyze_log_output(output_options, s_status, hParams)
398
397
  o_log = process_get(:server_log, 25)
399
398
  return output_options if o_log.nil? || o_log.empty?
400
399
 
@@ -414,7 +413,8 @@ done
414
413
  )
415
414
  else
416
415
  # validate server status
417
- output_options = analyze_server_status(s_status, log, output_options)
416
+ output_options = analyze_server_status(s_status, log,
417
+ output_options, hParams)
418
418
  end
419
419
  output_options
420
420
  end
@@ -446,7 +446,7 @@ end
446
446
 
447
447
  # Functions for boot - build_forge
448
448
  class ForjCoreProcess
449
- def analyze_server_status(s_status, o_log, output_options)
449
+ def analyze_server_status(s_status, o_log, output_options, _hParams)
450
450
  if s_status == :cloud_init &&
451
451
  /cloud-init-nonet gave up waiting for a network device/ =~ o_log
452
452
  # Valid for ubuntu image 12.04
@@ -584,10 +584,10 @@ DNS_SECRET='#{hParams['credentials#account_key']}'
584
584
  def load_h_meta(hParams, hpcloud_priv)
585
585
  h_meta = {
586
586
  'flavor_name' => hParams['maestro#bp_flavor'],
587
- 'cdksite' => config.get(:server_name),
587
+ 'cdksite' => hParams[:server_name],
588
588
  'cdkdomain' => hParams['dns#domain_name'],
589
589
  'eroip' => '127.0.0.1',
590
- 'erosite' => config.get(:server_name),
590
+ 'erosite' => hParams[:server_name],
591
591
  'erodomain' => hParams['dns#domain_name'],
592
592
  'gitbranch' => hParams['maestro#branch'],
593
593
  'security_groups' => hParams['maestro#security_group'],
@@ -626,6 +626,7 @@ DNS_SECRET='#{hParams['credentials#account_key']}'
626
626
  tb_metadata(hParams, h_meta)
627
627
  ca_root_metadata(hParams, h_meta)
628
628
  proxy_metadata(hParams, h_meta)
629
+ lorj_metadata(hParams, h_meta)
629
630
 
630
631
  h_meta
631
632
  end
@@ -639,18 +640,20 @@ DNS_SECRET='#{hParams['credentials#account_key']}'
639
640
 
640
641
  hpcloud_priv = load_hpcloud(hParams, os_key)
641
642
 
642
- config.set(
643
- :server_name,
644
- format('maestro.%s', hParams[:instance_name])
645
- ) # Used by :server object
646
-
647
643
  h_meta = load_h_meta(hParams, hpcloud_priv)
648
644
 
649
645
  config.set(:meta_data, h_meta) # Used by :server object
650
646
 
651
647
  h_meta_printable = h_meta.clone
652
648
  h_meta_printable['hpcloud_priv'] = 'XXX - data hidden - XXX'
653
- PrcLib.info("Metadata set:\n%s", h_meta_printable)
649
+ m_print = ''
650
+ max_key = 0
651
+ h_meta_printable.keys.each { |k| max_key = [max_key, k.length].max }
652
+ h_meta_printable.keys.sort.each do |k|
653
+ m_print += format("%-#{max_key}s : %s\n",
654
+ k, ANSI.bold(h_meta_printable[k]))
655
+ end
656
+ PrcLib.info("Metadata set:\n%s", m_print)
654
657
 
655
658
  o_meta_data = register(h_meta, sObjectType)
656
659
  o_meta_data[:meta_data] = h_meta
@@ -945,7 +948,7 @@ class ForjCoreProcess
945
948
  ) unless File.exist?(mime)
946
949
  end
947
950
 
948
- def build_userdata(sObjectType, hParams) # rubocop: disable Metrics/AbcSize
951
+ def build_userdata(sObjectType, hParams)
949
952
  # get the paths for maestro and infra repositories
950
953
  # maestro_path = hParams[:maestro_repository].values
951
954
  # infra_path = hParams[:infra_repository].values
@@ -1404,22 +1407,18 @@ class ForjCoreProcess
1404
1407
  def get_forge(sCloudObj, sForgeId, _hParams)
1405
1408
  s_query = {}
1406
1409
  servers = {}
1407
- s_query[:name] = sForgeId
1410
+ s_query[:name] = Regexp.new("\\.#{sForgeId}$")
1408
1411
 
1409
- o_servers = process_query(:server, s_query)
1410
-
1411
- regex = Regexp.new(format('\.%s$', sForgeId))
1412
+ o_servers = process_query(:server, s_query,
1413
+ :search_for => "for instance #{sForgeId}")
1412
1414
 
1413
1415
  o_servers.each do |o_server|
1414
- name = o_server[:name]
1415
- next unless regex =~ name
1416
-
1417
- type = name.clone
1416
+ type = o_server[:name].clone
1418
1417
  type['.' + sForgeId] = ''
1419
1418
  servers[type] = o_server
1420
1419
  end
1421
1420
  PrcLib.info('%s server(s) were found under instance name %s ',
1422
- servers.count, s_query[:name])
1421
+ servers.count, sForgeId)
1423
1422
 
1424
1423
  o_forge = register({}, sCloudObj)
1425
1424
  o_forge[:servers] = servers
@@ -0,0 +1,130 @@
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
+ # Process to call lorj_export
18
+
19
+ require 'lorj'
20
+
21
+ # lorj_account process functions
22
+ class ForjCoreProcess
23
+ def build_lorj_account(sObjectType, hParams)
24
+ data = {}
25
+
26
+ map = {
27
+ 'credentials#auth_uri' => {},
28
+ 'credentials#account_id' => {},
29
+ 'credentials#account_key' => {},
30
+ 'credentials#tenant' => {},
31
+ 'credentials#keypair_name' => {},
32
+ 'services#compute' => {},
33
+ 'services#network' => {},
34
+ 'maestro#image_name' => { :keys => [:server, :image_name] },
35
+ 'maestro#ssh_user' => { :keys => [:server, :ssh_user] },
36
+ 'maestro#flavor_name' => { :keys => [:server, :flavor_name] },
37
+ 'maestro#network_name' => { :keys => [:server, :network_name] },
38
+ 'maestro#security_group' => { :keys => [:server, :security_group] },
39
+ 'dns#domain_name' => {},
40
+ 'network#webproxy' => {}
41
+ }
42
+
43
+ data[:key], data[:data] = account_export(map)
44
+ data_registered = register(data, sObjectType)
45
+ data_registered[:key] = Base64.strict_encode64(data[:key].to_yaml)
46
+ data_registered[:data] = data[:data]
47
+ enabled = !hParams['maestro#lorj_disabled'].is_a?(TrueClass)
48
+ data_registered[:enabled] = enabled
49
+ data_registered
50
+ end
51
+
52
+ def lorj_metadata(hParams, h_meta)
53
+ h_meta['lorj_enabled'] = hParams[:lorj_account, :enabled].to_s
54
+ end
55
+
56
+ def lorj_detect(hParams, log_output, keypair)
57
+ return unless hParams.exist?(:lorj_account, :data)
58
+
59
+ # the server must wait with 4 last lines in server log:
60
+ # [...] - forj-cli: lorj_tmp_file=[...] lorj_tmp_key=[...] flag_file=[...]
61
+ # [...] - build.sh: [...]
62
+ # [...] - forj-cli: Waiting for [...]
63
+ # [...] - On your workstation, [...]
64
+
65
+ re = /forj-cli: lorj_tmp_file=(.*) lorj_tmp_key=(.*) flag_file=(.*)/
66
+ res = log_output.split("\n")[-4].match(re)
67
+
68
+ return unless res
69
+ PrcLib.info('lorj: your box is waiting for your cloud data. '\
70
+ 'One moment.')
71
+
72
+ # TODO : Add tb_ensure_ssh_config task to set this server in ~/.ssh/config.
73
+ # unless tb_ensure_ssh_config(hParams)
74
+ # PrcLib.info('test-box: Unable to configure ssh config with this server.'\
75
+ # ' You needs to do it yourself manually. Remote box boot '\
76
+ # "process is waiting for #{test_box_dir}")
77
+ # return
78
+ # end
79
+ PrcLib.warning('lorj: ssh config is currently not managed. You may '\
80
+ "need to configure it yourself, otherwise forj won't "\
81
+ 'connect and transfert the data to the box.')
82
+
83
+ pubip = hParams[:public_ip, :public_ip]
84
+ user = hParams[:image, :ssh_user]
85
+ identity = File.join(keypair[:keypair_path], keypair[:private_key_name])
86
+ if keypair[:coherent]
87
+ ssh_options = '-o StrictHostKeyChecking=no -o ServerAliveInterval=180'
88
+ ssh_options += " -i #{identity}"
89
+ ssh_options += " #{user}@#{pubip}"
90
+ ssh_cmd = "echo \"#{hParams[:lorj_account, :data]}\" > #{res[1]}"
91
+ ssh_cmd += "; echo \"#{hParams[:lorj_account, :key]}\" > #{res[2]}"
92
+ ssh_cmd += "; touch \"#{res[3]}\""
93
+
94
+ # TODO: Implement testing branch warning. See build.sh lines 618 -> 632
95
+ cmd = "ssh #{ssh_options} '#{ssh_cmd}'"
96
+
97
+ PrcLib.info "Running following shell instructions:\n#{cmd}"
98
+
99
+ return if system(cmd)
100
+ end
101
+
102
+ msg <<-EOF
103
+ Unable to copy Lorj data to the server '#{pubip}'. You need to do it yourself
104
+ manually, now. To do it, execute following instructions:
105
+ 1. Connect to server #{pubip} as #{user}.
106
+ You need to find the proper way to connect to '#{pubip}' as the cloud keypair
107
+ found is not coherent with some local SSH keys in
108
+ #{PrcLib.data_path}/keypairs
109
+
110
+ Ex: ssh #{ssh_options}
111
+
112
+ 2. Create 2 files with the following data:
113
+ $ echo '#{hParams[:lorj_account, :data]}' > '#{res[1]}'
114
+ $ echo '#{hParams[:lorj_account, :key]}' > '#{res[2]}'
115
+
116
+ 3. touch the flag file
117
+ $ touch '#{res[3]}'
118
+
119
+ 4. Disconnect.
120
+ $ exit
121
+
122
+ As soon as those instructions are done, Maestro should go on.
123
+ EOF
124
+
125
+ PrcLib.error msg
126
+ loop do
127
+ break if ask("When you are done, type 'DONE'") == 'DONE'
128
+ end
129
+ end
130
+ end
@@ -19,7 +19,7 @@ FORJCORE_PATH = File.expand_path(File.dirname(__FILE__))
19
19
 
20
20
  # Define model
21
21
 
22
- lorj_objects = %w(forj_process test_box ca_root_cert proxy declare)
22
+ lorj_objects = %w(lorj_account forj_process test_box ca_root_cert proxy declare)
23
23
 
24
24
  lorj_objects.each do |name|
25
25
  load File.join(FORJCORE_PATH, 'forj_core', 'process', name + '.rb')
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.15
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-06-05 00:00:00.000000000 Z
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.16.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.16.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: git
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.2.7
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.2.7
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: highline
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.6.21
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.6.21
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: ansi
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.4.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.4.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: encryptor
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.3.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.3.0
83
83
  - !ruby/object:Gem::Dependency
@@ -98,14 +98,14 @@ dependencies:
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
@@ -126,56 +126,70 @@ dependencies:
126
126
  name: lorj_cloud
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 0.1.1
131
+ version: 0.1.4
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: 0.1.1
138
+ version: 0.1.4
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '10.0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '10.0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rspec
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ~>
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
159
  version: 3.1.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ~>
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: 3.1.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: byebug
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: rubocop
169
183
  requirement: !ruby/object:Gem::Requirement
170
184
  requirements:
171
- - - '>='
185
+ - - ">="
172
186
  - !ruby/object:Gem::Version
173
187
  version: 0.30.0
174
188
  type: :development
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
- - - '>='
192
+ - - ">="
179
193
  - !ruby/object:Gem::Version
180
194
  version: 0.30.0
181
195
  description: forj cli - See https://www.forj.io for documentation/information
@@ -186,9 +200,9 @@ executables:
186
200
  extensions: []
187
201
  extra_rdoc_files: []
188
202
  files:
189
- - .gitignore
190
- - .gitreview
191
- - .rubocop.yml
203
+ - ".gitignore"
204
+ - ".gitreview"
205
+ - ".rubocop.yml"
192
206
  - Gemfile
193
207
  - README.md
194
208
  - Rakefile
@@ -211,6 +225,7 @@ files:
211
225
  - lib/process/forj_core/process/ca_root_cert.rb
212
226
  - lib/process/forj_core/process/declare.rb
213
227
  - lib/process/forj_core/process/forj_process.rb
228
+ - lib/process/forj_core/process/lorj_account.rb
214
229
  - lib/process/forj_core/process/proxy.rb
215
230
  - lib/process/forj_core/process/test_box.rb
216
231
  - lib/process/forj_core_process.rb
@@ -231,25 +246,25 @@ licenses:
231
246
  metadata: {}
232
247
  post_install_message: Go to docs.forj.io for more information on how to use forj cli
233
248
  rdoc_options:
234
- - --title
249
+ - "--title"
235
250
  - Lorj - The Process Controllers framework system
236
- - --main
251
+ - "--main"
237
252
  - README.md
238
253
  require_paths:
239
254
  - lib
240
255
  required_ruby_version: !ruby/object:Gem::Requirement
241
256
  requirements:
242
- - - '>='
257
+ - - ">="
243
258
  - !ruby/object:Gem::Version
244
- version: 1.8.5
259
+ version: 1.9.3
245
260
  required_rubygems_version: !ruby/object:Gem::Requirement
246
261
  requirements:
247
- - - '>='
262
+ - - ">="
248
263
  - !ruby/object:Gem::Version
249
264
  version: '0'
250
265
  requirements: []
251
266
  rubyforge_project:
252
- rubygems_version: 2.1.11
267
+ rubygems_version: 2.2.3
253
268
  signing_key:
254
269
  specification_version: 4
255
270
  summary: forj command line