forj 1.0.5 → 1.0.6

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: bce94bcc25e62cfda68553083ab01c6f9dddd210
4
- data.tar.gz: 6f98bdd389ac9e930225075145e2aeac9680b280
3
+ metadata.gz: 109aaca45df11251c58c7dc0a609e70b8f00464c
4
+ data.tar.gz: b1e2012cbc1e679e2aa3d15a009090ddb6082b7e
5
5
  SHA512:
6
- metadata.gz: 10cf1c72bc894a6db47de88fbeead1f64a5d429f26fc8e6f69f382e5ffc4377d2d7c86976768a4dfb9262a04c5c7861a87c2078c43c4b2222fbf7af32e312406
7
- data.tar.gz: 40272628a7797e2eccaa90daba1b57e81049db3f1381ce1bd7dc84395d6d460d06d23f0f4d1861fe98fbb40781c932137226840cb78f3dff90f46e79b89530fb
6
+ metadata.gz: 184323727e5d66392e42d3f9a350e2dee1aad85949e0261cb6fc8e4f211209193fd61674dafcda7d12573cd93b27de76ef68ad8c0075e7726049c7120033c3ba
7
+ data.tar.gz: 75236938deada281404745ca1bda29cd5c19f432f2c20dba20851837864b0d453bee63b968d410fa294685f6143653ad0efa643e23c50d267fb3e9a2bc081ae4
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ Gemfile.lock
5
5
  pkg/
6
6
  *.swp
7
7
  .geanyprj
8
+ .vagrant
data/README.md CHANGED
@@ -45,6 +45,14 @@ Perform one of the ruby installation steps without `gem install forj`.
45
45
  $ bundle install --gemfile Gemfile
46
46
  $ rake install
47
47
 
48
+ **For all OS including Linux/windows/mac
49
+ 2 vagrant images has been written.
50
+ Read [vagrant/README.md] for details.
51
+
52
+ This solution helps to develop and test on forj and lorj
53
+
54
+ For more information about lorj, a process/controller library, see https://github.com/forj-oss/lorj
55
+
48
56
  Quick steps: How to create a forj?
49
57
  ----------------------------------
50
58
 
@@ -52,11 +60,31 @@ Quick steps: How to create a forj?
52
60
 
53
61
  1. Setup your first forj account.
54
62
 
55
- `$ forj setup [AccountName]`
63
+ `$ forj setup [AccountName [provider]]`
56
64
 
57
65
  Ex: `forj setup MyAccount`. In this example, your account will be named 'MyAccount'.
58
66
  The first time you setup your account, it will become the default one.
59
- **WARNING!!!** [Provider] is currently not supported. By default, it is using hpcloud as default provider.
67
+
68
+ Supported provider: **hpcloud**, **openstack**. hpcloud is the default.
69
+
70
+ If you uses hphelion as a provider, check the API authentication system to select hpcloud or openstack.
71
+
72
+ - *hpcloud* : Use this provider for http://www.hpcloud.com/, or hphelion.
73
+ Uses Access key and secret key authentication mechanism.
74
+
75
+ - [hp public cloud|http://www.hpcloud.com/] from HP. Tested successfully.
76
+
77
+ - *openstack*: Use this provider to access any openstack installation (public or private) or Hphelion (public or private)
78
+ Uses login and password authentication system
79
+
80
+ If you want to test against a new local openstack cloud, you can consider :
81
+
82
+ - [packstack|https://wiki.openstack.org/wiki/Packstack] from RedHat. Can be used for a notebook local installation. tested successfully.
83
+ - [hphelion|http://www8.hp.com/fr/fr/cloud/helion-overview.html] from HP. Tested successfully
84
+ - [Ubuntu OpenStack|http://www.ubuntu.com/cloud] from Canonical. Not tested.
85
+
86
+ For any other cloud, you need a provider in lorj library. Contribute to create a new provider!
87
+ See
60
88
 
61
89
  2. Create your forge on your default account
62
90
 
@@ -64,6 +92,12 @@ Quick steps: How to create a forj?
64
92
 
65
93
  Ex: `forj boot redstone myforge` - This command will start a Redstone forge named 'myforge' with the default FORJ account. Previous, we set it to be MyAccount.
66
94
 
95
+ NOTE: If you are creating a Forge in a corporate network, a proxy may be required for Maestro to access internet.
96
+ You can ask `forj` cli to send the proxy to use with -e
97
+
98
+ Ex: Thanks to a CorporateAccount setup with forj setup, the following will use it and set the webproxy metadata.
99
+
100
+ `forj boot redstone myforge -a CorporateAccount -e webproxy=$http_proxy`
67
101
 
68
102
  ###Forj options:
69
103
 
data/bin/forj CHANGED
@@ -227,6 +227,10 @@ Warning! This action do not remove any network/security groups cloud object.
227
227
 
228
228
  method_option :force, :aliases => '-f', :desc => 'force deletion of all' \
229
229
  ' servers for the given InstanceName'
230
+ method_option :account_name, :aliases => '-a', :desc => 'Set the forj' \
231
+ ' account name to use. By default, uses the default account set in' \
232
+ ' your local config file.' + "\n\n" + 'Following options superseed your' \
233
+ ' Account, config file or forj defaults.'
230
234
  def destroy(name)
231
235
  require 'destroy.rb'
232
236
  Forj::Settings.common_options(options)
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.5'
23
- s.date = '2015-02-11'
22
+ s.version = '1.0.6'
23
+ s.date = '2015-03-18'
24
24
  s.summary = 'forj command line'
25
25
  s.description = 'forj cli - See https://www.forj.io for documentation/information'
26
26
 
@@ -52,10 +52,11 @@ Gem::Specification.new do |s|
52
52
  s.add_runtime_dependency 'json', '1.7.5'
53
53
  s.add_runtime_dependency 'bundler'
54
54
  s.add_runtime_dependency 'nokogiri','1.5.11'
55
- s.add_runtime_dependency 'lorj', '~> 1.0.2'
55
+ s.add_runtime_dependency 'lorj', '~> 1.0.6'
56
56
 
57
57
  s.add_development_dependency "rake", "~> 10.0"
58
58
  s.add_development_dependency "rspec", "~> 3.1.0"
59
+ s.add_development_dependency "rubocop", ">=0.29.0"
59
60
  s.rdoc_options << '--title' << 'Lorj - The Process Controllers framework system' <<
60
61
  '--main' << 'README.md'
61
62
  end
data/forj/defaults.yaml CHANGED
@@ -30,10 +30,6 @@
30
30
  :security_group: forj
31
31
  :ports: [22, 80, 443, 3000, 3131-3135, 4505-4506, 5000, 5666, 8000, 8080-8081, 8083, 8125, 8139-8140, 8773-8776, 9292, 29418, 35357]
32
32
 
33
- # Private key file path. Those files (private/public key) will be added to ~/.forj/keypairs/ as respectively 'keypair_name' and 'keypair_name'.pub
34
- :keypair_files: ~/.ssh/forj-id_rsa
35
- :keypair_name: forj
36
-
37
33
  # Network: If network doesn't exist, forj cli will try to create it, and attach it a router.
38
34
  :network: forj
39
35
 
@@ -127,7 +123,7 @@
127
123
 
128
124
  If the keypair doesn't exist locally, it will be created for you.
129
125
  :desc: "Base keypair file name"
130
- :default_value: "~/.ssh/id_rsa-forj"
126
+ :default_value: "~/.ssh/<%= config[:keypair_name] %>-id_rsa"
131
127
  :validate_function: :forj_check_keypairs_files
132
128
  :account: true
133
129
  :ask_step: 2
@@ -137,7 +133,7 @@
137
133
  :desc: "Forj internal copy of private and public key pair files "
138
134
  :keypair_name:
139
135
  :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
- :validate: !ruby/regexp /^\w?\w*$/
136
+ :required: true
141
137
  :default_value: "forj"
142
138
  :account: true
143
139
  :ask_step: 2
@@ -157,8 +153,9 @@
157
153
  :account_exclusive: true
158
154
  :account: true
159
155
  :required: true
156
+ :encrypted: true
160
157
  :tenant:
161
- :desc: "Openstack Tenant ID"
158
+ :desc: "Openstack Tenant Name (Project name)"
162
159
  :account_exclusive: true
163
160
  :account: true
164
161
  :required: true
@@ -170,6 +167,7 @@
170
167
  :required: true
171
168
  :validate: !ruby/regexp /\w+/
172
169
  :ask_step: 1
170
+ :default_value: "<%= (config[:provider_name] == 'openstack')?config[:account_id]:nil %>"
173
171
  :os_enckey:
174
172
  :desc: "Openstack compute cloud password"
175
173
  :account_exclusive: true
@@ -177,6 +175,7 @@
177
175
  :account: true
178
176
  :required: true
179
177
  :ask_step: 1
178
+ :default_value: "<%= (config[:provider_name] == 'openstack')?config[:account_key]:nil %>"
180
179
 
181
180
  # Defines DNS services for maestro
182
181
  :dns:
@@ -206,11 +205,12 @@
206
205
  :validate: !ruby/regexp /^\w?[\w_-]*$/
207
206
  :ask_step: 1
208
207
  :ask_sort: 0
208
+ :default_value: "<%= (config[:provider_name] == 'openstack')?config[:tenant]:nil %>"
209
209
  :network_name:
210
210
  :desc: "Network name to attach to each forge boxes. By default we use 'forj'. If it doesn't exist, it will be created."
211
211
  :default: network
212
212
  :account: true
213
- :validate: !ruby/regexp /^\w?\w*$/
213
+ :required: true
214
214
  :default_value: "forj"
215
215
  :ask_step: 2
216
216
  :security_group:
@@ -228,7 +228,10 @@
228
228
  :build_config:
229
229
  :desc: "forj cli use 'build.sh' to create Maestro. See build_config option on build.sh to get more information. By default 'box'"
230
230
  :bp_flavor:
231
- :desc: "Blueprint nodes default flavor. Usually, blueprint node are smaller than Maestro."
231
+ :desc: "Blueprint nodes default flavor"
232
+ :explanation: |-
233
+ Blueprint usually defines the required flavor for their nodes. If not, it will use this flavor as default.
234
+ Usually, blueprint nodes are smaller than Maestro.
232
235
  :account: true
233
236
  :list_values:
234
237
  :query_type: :query_call # Will execute a query on flavor, query_params is empty for all.
@@ -237,7 +240,8 @@
237
240
  :validate: :list_strict
238
241
  :ask_step: 2
239
242
  :flavor_name:
240
- :desc: "Maestro Flavor name. This flavor is for Maestro only. Your blueprint layout defines each node flavors on needs."
243
+ :explanation: 'This flavor is for Maestro only.'
244
+ :desc: "Maestro Flavor name"
241
245
  :default: :flavor
242
246
  :account: true
243
247
  :list_values:
@@ -247,7 +251,10 @@
247
251
  :validate: :list_strict
248
252
  :ask_step: 2
249
253
  :image_name:
250
- :desc: "Ubuntu 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)'"
254
+ :desc: "Image name"
255
+ :explanation: |-
256
+ Ubuntu image used to create Maestro and all forge boxes. Originally, Maestro uses 'Ubuntu Precise 12.04.4 LTS Server 64-bit'.
257
+ You need to choose the appropriate image to make Maestro & boxes to boot normally.
251
258
  :account: true
252
259
  :ask_step: 2
253
260
  :list_values:
@@ -267,13 +274,12 @@
267
274
  Checking image '<%= config[:image_name] %>'...
268
275
  :account: true
269
276
  :ask_step: 2
277
+ :after: :image_name
270
278
  :list_values:
271
- :query_type: :process_call # Will execute a query on image and return the list of images.
272
- :query_call: :setup_ssh_user
273
- :query_params:
274
- :image_name: lorj::config[:image_name]
275
- :object: :image
276
- :value: :name
279
+ :query_type: :process_call # Will execute a process to query on image
280
+ :query_call: :setup_ssh_user # and return the list of images and a default value.
281
+ :query_params: # Transmitted as hParams
282
+ :image_name: '<%= config[:image_name] %>'
277
283
  :ports:
278
284
  :desc: "List of security group rules (1 port or range of ports) to open to the external network."
279
285
  :branch:
data/lib/forj-settings.rb CHANGED
@@ -93,19 +93,19 @@ module Forj
93
93
  s_bef = format(
94
94
  "'%s' (%s)",
95
95
  old_value,
96
- account.exist?(key_to_set)
96
+ account.where?(key_to_set)[0]
97
97
  ) if account.exist?(key_to_set)
98
98
 
99
99
  s_bef
100
100
  end
101
101
 
102
- def self.format_new_key(_o_forj_account, key_to_set)
102
+ def self.format_new_key(account, key_to_set)
103
103
  s_aft = 'unset'
104
104
 
105
105
  s_aft = format(
106
106
  "'%s' (%s)",
107
107
  account.get(key_to_set),
108
- account.exist?(key_to_set)
108
+ account.where?(key_to_set)[0]
109
109
  ) if account.exist?(key_to_set)
110
110
 
111
111
  s_aft
@@ -131,7 +131,7 @@ module Forj
131
131
 
132
132
  full_key = format(
133
133
  '%s/%s',
134
- Lorj::Default.get_meta_auto(key_to_set),
134
+ Lorj.data.first_section(key_to_set),
135
135
  key_to_set
136
136
  )
137
137
 
@@ -145,9 +145,9 @@ module Forj
145
145
  b_dirty = true
146
146
 
147
147
  if key_value == ''
148
- config.del(key_to_set)
148
+ config.del(key_to_set, :name => 'account')
149
149
  else
150
- config.set(key_to_set, key_value)
150
+ config.set(key_to_set, key_value, :name => 'account')
151
151
  end
152
152
 
153
153
  s_aft = format_new_key(config, key_to_set)
data/lib/forj/ForjCore.rb CHANGED
@@ -104,5 +104,7 @@ class Lorj::BaseDefinition
104
104
 
105
105
  obj_needs_optional
106
106
  obj_needs :CloudObject, :server
107
+ obj_needs :CloudObject, :public_ip, :for => [:create_e]
108
+ obj_needs :CloudObject, :keypairs, :for => [:create_e]
107
109
  obj_needs :data, :blueprint
108
110
  end
@@ -33,9 +33,9 @@ class ForjCoreProcess
33
33
  def build_forge(sObjectType, hParams)
34
34
  forge_exist?(sObjectType)
35
35
 
36
- o_server = data_objects(:server, :ObjectData)
36
+ o_server = hParams.refresh[:server, :ObjectData]
37
37
 
38
- boot_options = boot_keypairs(o_server)
38
+ boot_options = boot_keypairs(hParams)
39
39
 
40
40
  # Define the log lines to get and test.
41
41
  config.set(:log_lines, 5)
@@ -47,7 +47,7 @@ class ForjCoreProcess
47
47
  s_status = :checking
48
48
  maestro_create_status(s_status)
49
49
 
50
- o_address = data_objects(:public_ip, :ObjectData)
50
+ o_address = hParams.refresh[:public_ip, :ObjectData]
51
51
 
52
52
  s_status = active_server?(o_server, o_address, boot_options[:keys],
53
53
  boot_options[:coherent], s_status
@@ -57,7 +57,7 @@ class ForjCoreProcess
57
57
 
58
58
  o_forge = get_forge(sObjectType, config[:instance_name], hParams)
59
59
 
60
- read_blueprint_implemented(o_forge, o_address)
60
+ read_blueprint_implemented(o_forge, hParams)
61
61
  o_forge
62
62
  end
63
63
 
@@ -93,27 +93,17 @@ class ForjCoreProcess
93
93
  end
94
94
  end
95
95
 
96
- def boot_keypairs(o_server)
97
- # Get keypairs
98
- h_keys = keypair_detect(
99
- o_server[:key_name],
100
- File.join(Forj.keypairs_path, o_server[:key_name])
101
- )
102
-
103
- private_key_file = File.join(
104
- h_keys[:keypair_path],
105
- h_keys[:private_key_name]
106
- )
107
- # public_key_file = File.join(
108
- # h_keys[:keypair_path],
109
- # h_keys[:public_key_name]
110
- # )
96
+ def boot_keypairs(params)
97
+ o_server = params[:server, :ObjectData]
98
+ h_keys = params[:keypairs]
111
99
 
112
- o_server_key = process_get(:keypairs, o_server[:key_name])
100
+ if h_keys.nil? || o_server[:key_name] != h_keys[:name]
101
+ h_keys = process_get(:keypairs, o_server[:key_name])
102
+ end
103
+ private_key_file = File.join(h_keys[:keypair_path],
104
+ h_keys[:private_key_name])
113
105
 
114
- keypair_coherent = coherent_keypair?(h_keys, o_server_key)
115
- boot_options = { :keys => private_key_file, :coherent => keypair_coherent }
116
- boot_options
106
+ { :keys => private_key_file, :coherent => h_keys[:coherent] }
117
107
  end
118
108
 
119
109
  def active_server?(o_server, o_address, private_key_file,
@@ -158,12 +148,14 @@ end
158
148
  # Functions for boot - build_forge
159
149
  class ForjCoreProcess
160
150
  # rubocop:disable CyclomaticComplexity
161
- def maestro_create_status(sStatus, iCurAct = 4)
151
+
152
+ def maestro_create_status(sStatus, iCurAct = 4, pending_count = 0)
162
153
  s_activity = '/-\\|?'
163
154
  if iCurAct < 4
164
155
  s_cur_act = 'ACTIVE'
165
156
  else
166
- s_cur_act = ANSI.bold('PENDING')
157
+ s_cur_act = format('%s - %d s', ANSI.bold('PENDING'),
158
+ (pending_count + 1) * 5)
167
159
  end
168
160
 
169
161
  case sStatus
@@ -186,15 +178,24 @@ class ForjCoreProcess
186
178
  PrcLib.info('Server is active')
187
179
  end
188
180
  end
189
- # rubocop:enable CyclomaticComplexity
181
+
182
+ # TODO: Rewrite this function to break it for rubocop.
183
+ # rubocop: disable PerceivedComplexity
184
+ # rubocop: disable Metrics/MethodLength
190
185
 
191
186
  def till_server_active(s_status, o_server, o_address, boot_options)
192
187
  m_cloud_init_error = []
193
188
  i_cur_act = 0
194
189
  o_old_log = ''
190
+ pending_count = 0
195
191
 
196
192
  while s_status != :active
197
- maestro_create_status(s_status, i_cur_act)
193
+ if i_cur_act == 4
194
+ pending_count += 1
195
+ else
196
+ pending_count = 0
197
+ end
198
+ maestro_create_status(s_status, i_cur_act, pending_count)
198
199
  i_cur_act += 1
199
200
  i_cur_act = i_cur_act % 4
200
201
  o_server = load_server(o_server)
@@ -212,11 +213,44 @@ class ForjCoreProcess
212
213
  m_cloud_init_error = output_options[:error]
213
214
  o_old_log = output_options[:old_log]
214
215
  i_cur_act = output_options[:cur_act]
216
+ if pending_count == 60
217
+ image = server_get_image o_server
218
+ highlight = ANSI.yellow('-' * 40)
219
+ PrcLib.warning("No more server activity detected.\n"\
220
+ "#{highlight}\n"\
221
+ "%s\n"\
222
+ "#{highlight}\n"\
223
+ "The server '%s' is not providing any output log for"\
224
+ " more than 5 minutes.\nPlease review the current"\
225
+ 'output show below to determine if this a normal '\
226
+ "situation.\nYou can connect to the server if you "\
227
+ "want to.\nTo connect, use:\n"\
228
+ 'ssh %s@%s -o StrictHostKeyChecking=no -i %s',
229
+ o_old_log, o_server[:name], image[:ssh_user],
230
+ o_address[:public_ip], boot_options[:keys])
231
+ end
215
232
  end
216
233
  sleep(5) if s_status != :active
217
234
  end
218
235
  end
219
236
 
237
+ # Function to get the image data from the server
238
+ #
239
+
240
+ def server_get_image(server)
241
+ image = data_objects(:image, :ObjectData)
242
+ return image unless image.nil?
243
+
244
+ image = process_get(:image, server[:image_id])
245
+
246
+ return Lorj::Data.new if image.nil?
247
+
248
+ register(image)
249
+ end
250
+
251
+ # rubocop:enable CyclomaticComplexity
252
+ # rubocop:enable PerceivedComplexity
253
+
220
254
  # Function to get the server, tracking errors
221
255
  #
222
256
  # *return*
@@ -227,8 +261,10 @@ class ForjCoreProcess
227
261
  found_server = process_get(:server, server[:attrs][:id])
228
262
  rescue => e
229
263
  PrcLib.error(e.message)
264
+ else
265
+ return found_server
230
266
  end
231
- (found_server.nil? ? server : found_server)
267
+ server
232
268
  end
233
269
  end
234
270
 
@@ -246,17 +282,19 @@ class ForjCoreProcess
246
282
  o_address = o_addresses[0]
247
283
  end
248
284
  end
285
+
286
+ image = data_objects[:image, :ObjectData]
249
287
  s_msg = <<-END
250
288
  Public IP for server '%s' is assigned.
251
289
  Now, as soon as the server respond to the ssh port,
252
290
  you will be able to get a tail of the build with:
253
291
  while [ 1 = 1 ]
254
292
  do
255
- ssh ubuntu@%s -o StrictHostKeyChecking=no -i %s tail -f /var/log/cloud-init.log
293
+ ssh %s@%s -o StrictHostKeyChecking=no -i %s tail -f /var/log/cloud-init.log
256
294
  sleep 5
257
295
  done
258
296
  END
259
- s_msg = format(s_msg, o_server[:name],
297
+ s_msg = format(s_msg, o_server[:name], image[:user],
260
298
  o_address[:public_ip], boot_options[:keys]
261
299
  )
262
300
  unless boot_options[:coherent]
@@ -271,28 +309,26 @@ done
271
309
  end
272
310
 
273
311
  def analyze_log_output(output_options, s_status)
274
- # m_cloud_init_error = []
275
- # o_old_log = ''
276
- o_log = process_get(:server_log, 25)[:attrs][:output]
277
- # i_cur_act = 4 if o_log == o_old_log
278
- output_options[:cur_act] = 4 if o_log == output_options[:old_log]
279
- # o_old_log = o_log
280
- output_options[:old_log] = o_log
281
- if /cloud-init boot finished/ =~ o_log
282
- # s_status = :active
312
+ o_log = process_get(:server_log, 25)
313
+ return output_options if o_log.nil? || o_log.empty?
314
+
315
+ log = o_log[:attrs][:output]
316
+ output_options[:cur_act] = 4 if log == output_options[:old_log]
317
+ output_options[:old_log] = log
318
+ if /cloud-init boot finished/ =~ log
283
319
  output_options[:status] = :active
284
320
  output_options[:error] = display_boot_moving_error(
285
321
  output_options[:error]
286
322
  )
287
- elsif /\[CRITICAL\]/ =~ o_log
288
- m_critical = o_log.scan(/.*\[CRITICAL\].*\n/)
323
+ elsif /\[CRITICAL\]/ =~ log
324
+ m_critical = log.scan(/.*\[CRITICAL\].*\n/)
289
325
  output_options[:error] = display_boot_critical_error(
290
326
  output_options[:error],
291
327
  m_critical
292
328
  )
293
329
  else
294
330
  # validate server status
295
- output_options = analyze_server_status(s_status, o_log, output_options)
331
+ output_options = analyze_server_status(s_status, log, output_options)
296
332
  end
297
333
  output_options
298
334
  end
@@ -348,19 +384,22 @@ class ForjCoreProcess
348
384
  output_options
349
385
  end
350
386
 
351
- def read_blueprint_implemented(o_forge, o_address)
387
+ def read_blueprint_implemented(o_forge, params)
388
+ o_address = params[:public_ip, :ObjectData]
389
+ blueprint = params[:blueprint]
390
+ instance_name = params[:instance_name]
352
391
  s_msg = format(
353
392
  "Your Forge '%s' is ready and accessible from" \
354
393
  " IP #{o_address[:public_ip]}.",
355
- config[:instance_name]
394
+ instance_name
356
395
  )
357
396
  # TODO: read the blueprint/layout to identify which services
358
397
  # are implemented and can be accessible.
359
- if config[:blueprint]
398
+ if blueprint
360
399
  s_msg += format(
361
400
  "\n" + 'Maestro has implemented the following server(s) for your' \
362
401
  " blueprint '%s':",
363
- config[:blueprint]
402
+ blueprint
364
403
  )
365
404
  server_options = display_servers_with_ip(o_forge, s_msg)
366
405
  s_msg += server_options[:message]
@@ -369,13 +408,8 @@ class ForjCoreProcess
369
408
  s_msg += format("\n%d server(s) identified.\n", i_count)
370
409
  else
371
410
  s_msg = 'No servers found except maestro'
372
- PrcLib.warning(
373
- format(
374
- 'Something went wrong, while creating nodes for blueprint' \
375
- " '%s'. check maestro logs.",
376
- config[:blueprint]
377
- )
378
- )
411
+ PrcLib.warning('Something went wrong, while creating nodes for '\
412
+ "blueprint '%s'. check maestro logs.", blueprint)
379
413
  end
380
414
  else
381
415
  s_msg += "\nMaestro has NOT implemented any servers, because you did" \
@@ -861,7 +895,7 @@ class ForjCoreProcess
861
895
  if PrcLib.core_level < 5
862
896
  File.delete(mime)
863
897
  else
864
- ForjLib.debug(5, "user_data temp file '%s' kept", mime)
898
+ Lorj.debug(5, "user_data temp file '%s' kept", mime)
865
899
  end
866
900
 
867
901
  config[:user_data] = user_data
@@ -935,45 +969,24 @@ class ForjCoreProcess
935
969
 
936
970
  def create_keys_automatically(keys, private_key_file)
937
971
  return if keys[:private_key_exist?]
938
- # Need to create a key. ask if we need so.
939
- PrcLib.message("The private key file attached to keypair named '%s' is not"\
940
- ' found. Running ssh-keygen to create it.',
941
- keys[:keypair_name])
942
972
  unless File.exist?(private_key_file)
973
+ # Need to create a key. ask if we need so.
974
+ PrcLib.message("The private key file attached to keypair named '%s' is "\
975
+ 'not found. Running ssh-keygen to create it.',
976
+ keys[:keypair_name])
943
977
  PrcLib.ensure_dir_exists(File.dirname(private_key_file))
944
978
  command = format('ssh-keygen -t rsa -f %s', private_key_file)
945
979
  PrcLib.debug(format("Executing '%s'", command))
946
980
  system(command)
947
981
  end
948
- if !File.exist?(private_key_file)
949
- PrcLib.fatal(1, "'%s' not found. Unable to add your keypair to hpcloud."\
950
- ' Create it yourself and provide it with -p option. '\
951
- 'Then retry.', private_key_file)
952
- else
953
- PrcLib.fatal(1, 'ssh-keygen did not created your key pairs. Aborting.'\
982
+ return if File.exist?(private_key_file)
983
+ PrcLib.fatal(1, 'ssh-keygen did not created your key pairs. Aborting.'\
954
984
  ' Please review errors in ~/.forj/forj.log')
955
- end
956
985
  end
957
986
  end
958
987
 
959
988
  # Functions for setup
960
989
  class ForjCoreProcess
961
- def load_key_with_passphrase(keys, public_key_file, private_key_file)
962
- # unless keys[:public_key_exist?]
963
- return if keys[:private_key_exist?]
964
- PrcLib.message("Your public key '%s' was not found. Getting it from the" \
965
- ' private one. It may require your passphrase.',
966
- public_key_file)
967
- command = format(
968
- 'ssh-keygen -y -f %s > %s',
969
- private_key_file,
970
- public_key_file
971
- )
972
- PrcLib.debug("Executing '%s'", command)
973
- system(command)
974
- # end
975
- end
976
-
977
990
  def save_sequences(private_key_file, forj_private_key_file,
978
991
  public_key_file, forj_public_key_file, key_name
979
992
  )
@@ -981,8 +994,8 @@ class ForjCoreProcess
981
994
  FileUtils.copy(private_key_file, forj_private_key_file)
982
995
  FileUtils.copy(public_key_file, forj_public_key_file)
983
996
  # Attaching this keypair to the account
984
- @hAccountData.rh_set(key_name, :credentials, 'keypair_name')
985
- @hAccountData.rh_set(forj_private_key_file, :credentials, 'keypair_path')
997
+ config.set(:keypair_name, key_name, :name => 'account')
998
+ config.set(:keypair_path, forj_private_key_file, :name => 'account')
986
999
  config.local_set(key_name.to_s, private_key_file, :imported_keys)
987
1000
  end
988
1001
 
@@ -1015,7 +1028,7 @@ end
1015
1028
  class ForjCoreProcess
1016
1029
  def save_internal_key(forj_private_key_file, keys)
1017
1030
  # Saving internal copy of private key file for forj use.
1018
- config.set(:keypair_path, forj_private_key_file)
1031
+ config.set(:keypair_path, forj_private_key_file, :name => 'account')
1019
1032
  PrcLib.info("Configured forj keypair '%s' with '%s'",
1020
1033
  keys[:keypair_name],
1021
1034
  File.join(keys[:keypair_path], keys[:key_basename])
@@ -1043,10 +1056,8 @@ class ForjCoreProcess
1043
1056
  # Creation sequences
1044
1057
  create_keys_automatically(keys, private_key_file)
1045
1058
 
1046
- load_key_with_passphrase(keys, public_key_file, private_key_file)
1047
-
1048
1059
  forj_private_key_file = File.join(Forj.keypairs_path, key_name)
1049
- # forj_public_key_file = File.join($FORJ_KEYPAIRS_PATH, key_name + '.pub')
1060
+ forj_public_key_file = File.join(Forj.keypairs_path, key_name + '.pub')
1050
1061
 
1051
1062
  # Saving sequences
1052
1063
  if keys[:keypair_path] != Forj.keypairs_path
@@ -1068,7 +1079,7 @@ class ForjCoreProcess
1068
1079
 
1069
1080
  def forj_dns_settings
1070
1081
  s_ask = 'Optionally, you can ask Maestro to use/manage a domain name on' \
1071
- " your cloud. It requires your DNS cloud service to be enabled.\nDo " \
1082
+ " your cloud. It requires your DNS cloud service to be enabled.\nDo" \
1072
1083
  ' you want to configure it?'
1073
1084
  config.set(:dns_settings, agree(s_ask))
1074
1085
  true
@@ -1077,7 +1088,8 @@ class ForjCoreProcess
1077
1088
  def forj_dns_settings?(sKey)
1078
1089
  # Return true to ask the question. false otherwise
1079
1090
  unless config.get(:dns_settings)
1080
- config.set(sKey, nil)
1091
+ section = Lorj.data.first_section(sKey)
1092
+ config.del(sKey, :name => 'account', :section => section)
1081
1093
  return false # Do not ask
1082
1094
  end
1083
1095
  true
@@ -1272,17 +1284,11 @@ end
1272
1284
  class ForjCoreProcess
1273
1285
  def setup_ssh_user(_sCloudObj, hParams)
1274
1286
  images = process_query(:image, :name => hParams[:image_name])
1275
- case images.length
1276
- when 0
1277
- s_default = hParams[:default_value]
1278
- else
1279
- if images[0, :ssh_user].nil?
1280
- s_default = hParams[:default_value]
1281
- else
1282
- s_default = images[0, :ssh_user]
1283
- end
1287
+ result = { :list => config[:users] }
1288
+ if images.length >= 1 && !images[0, :ssh_user].nil?
1289
+ result[:default_value] = images[0, :ssh_user]
1284
1290
  end
1285
- { :default_value => s_default, :list => config[:users] }
1291
+ result
1286
1292
  end
1287
1293
 
1288
1294
  def ssh_login(options, user, public_ip)
data/vagrant/README.md ADDED
@@ -0,0 +1,51 @@
1
+ You can test forj cli (and lorj as well) from any OS, like linux/windows or mac thanks to vagrant.
2
+
3
+ There is 2 differents implementations of forj cli working on fedora or ubuntu.
4
+
5
+ Choose the one you want.
6
+
7
+ To test forj cli, do the following:
8
+
9
+ 1. install [virtualbox | https://www.virtualbox.org/wiki/Downloads] or vmware workstation
10
+
11
+ 2. install [vagrant|https://www.vagrantup.com/]
12
+
13
+ 3. clone the forj repository.
14
+
15
+ $ `git clone https://review.forj.io/forj-oss/forj`
16
+
17
+ 4. run vagrant up
18
+
19
+ $ `cd forj/vagrant/fedora`
20
+
21
+ $ `vagrant up`
22
+
23
+ If you want to test both forj and lorj from source, use this different way:
24
+ For more information about lorj, a process/controller library, see https://github.com/forj-oss/lorj
25
+
26
+ 3. clone the forj and lorj repository.
27
+
28
+ $ `git clone https://review.forj.io/forj-oss/forj`
29
+ $ `git clone https://review.forj.io/forj-oss/lorj`
30
+
31
+ 4. run vagrant up
32
+
33
+ $ `cd forj/vagrant/fedora`
34
+ $ `lorj_src=../lorj vagrant up`
35
+
36
+ Now you are in, under fedora in this example, and forj cli installed from source.
37
+ You are in a linux environment, where you can do anything you need.
38
+
39
+
40
+ Example use cases:
41
+
42
+ - you want to install the latest forj cli package
43
+
44
+ sudo gem uninstall forj
45
+ sudo gem install forj
46
+
47
+ - You want to test an update in forj
48
+
49
+ 1. update your code under your host, on in vagrant, /srv/forj/...
50
+ 2. update the installation with sources. This will execute rubocop and rspec, before any install.
51
+ sudo /srv/forj/vagrant/configure/install.sh
@@ -0,0 +1,31 @@
1
+ #!/bin/bash
2
+ #
3
+ # (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ #
18
+ echo export GIT_SSL_NO_VERIFY=1 >> ~/.bashrc
19
+ . ~/.bashrc
20
+
21
+ for PRJ in lorj forj
22
+ do
23
+ if [ -d /srv/$PRJ ]
24
+ then
25
+ cd /srv/$PRJ
26
+ bundle install --gemfile Gemfile
27
+ rake install
28
+ cd -
29
+ fi
30
+ done
31
+
@@ -0,0 +1,95 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # All Vagrant configuration is done below. The "2" in Vagrant.configure
5
+ # configures the configuration version (we support older styles for
6
+ # backwards compatibility). Please don't change it unless you know what
7
+ # you're doing.
8
+
9
+
10
+ Vagrant.configure(2) do |config|
11
+ # The most common configuration options are documented and commented below.
12
+ # For a complete reference, please see the online documentation at
13
+ # https://docs.vagrantup.com.
14
+
15
+ # Every Vagrant development environment requires a box. You can search for
16
+ # boxes at https://atlas.hashicorp.com/search.
17
+ config.vm.box = "hansode/fedora-21-server-x86_64"
18
+
19
+ # Disable automatic box update checking. If you disable this, then
20
+ # boxes will only be checked for updates when the user runs
21
+ # `vagrant box outdated`. This is not recommended.
22
+ # config.vm.box_check_update = false
23
+
24
+ # Create a forwarded port mapping which allows access to a specific port
25
+ # within the machine from a port on the host machine. In the example below,
26
+ # accessing "localhost:8080" will access port 80 on the guest machine.
27
+ # config.vm.network "forwarded_port", guest: 80, host: 8080
28
+
29
+ # Create a private network, which allows host-only access to the machine
30
+ # using a specific IP.
31
+ # config.vm.network "private_network", ip: "192.168.33.10"
32
+
33
+ # Create a public network, which generally matched to bridged network.
34
+ # Bridged networks make the machine appear as another physical device on
35
+ # your network.
36
+ # config.vm.network "public_network"
37
+
38
+ # Share an additional folder to the guest VM. The first argument is
39
+ # the path on the host to the actual folder. The second argument is
40
+ # the path on the guest to mount the folder. And the optional third
41
+ # argument is a set of non-required options.
42
+ # config.vm.synced_folder "../data", "/vagrant_data"
43
+ config.vm.synced_folder "../../", "/srv/forj"
44
+
45
+ lorj = false
46
+ if ENV.key?('lorj_src')
47
+ lorj_src = File.expand_path(ENV['lorj_src'])
48
+ git_data = File.join(lorj_src, '.git', 'config')
49
+ if File.exist?(git_data) && open(git_data) { |f| f.grep(/forj-oss\/lorj/) }
50
+ config.vm.synced_folder ENV['lorj_src'], "/srv/lorj"
51
+ lorj=true
52
+ end
53
+ end
54
+
55
+ # Provider-specific configuration so you can fine-tune various
56
+ # backing providers for Vagrant. These expose provider-specific options.
57
+ # Example for VirtualBox:
58
+ #
59
+ # config.vm.provider "virtualbox" do |vb|
60
+ # # Display the VirtualBox GUI when booting the machine
61
+ # vb.gui = true
62
+ #
63
+ # # Customize the amount of memory on the VM:
64
+ # vb.memory = "1024"
65
+ # end
66
+ #
67
+ # View the documentation for the provider you are using for more
68
+ # information on available options.
69
+
70
+ # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
71
+ # such as FTP and Heroku are also available. See the documentation at
72
+ # https://docs.vagrantup.com/v2/push/atlas.html for more information.
73
+ # config.push.define "atlas" do |push|
74
+ # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
75
+ # end
76
+
77
+ # Enable provisioning with a shell script. Additional provisioners such as
78
+ # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
79
+ # documentation for more information about their specific syntax and use.
80
+ # config.vm.provision "shell", inline <<-SHELL
81
+ # sudo apt-get install apache2
82
+ # SHELL
83
+ if Vagrant.has_plugin?("vagrant-proxyconf")
84
+ config.proxy.http = ENV['http_proxy'] if ENV.key?('http_proxy')
85
+ config.proxy.https = ENV['https_proxy'] if ENV.key?('https_proxy')
86
+ config.proxy.no_proxy = ENV['no_proxy'] if ENV.key?('no_proxy')
87
+ end
88
+ priv = { privileged: true }
89
+ config.vm.provision "shell", priv.merge(inline: "yum install ruby-devel libxml2-devel libxslt-devel python-yaml gcc git -y")
90
+ config.vm.provision "shell", inline: "gem install bundler --no-rdoc --no-ri"
91
+ config.vm.provision "shell", inline: "gem install rake --no-rdoc --no-ri"
92
+ config.vm.provision "shell", inline: "echo 'PATH=$PATH:/usr/local/bin' >> /etc/profile.d/local.sh"
93
+ config.vm.provision "shell", inline: "/srv/forj/vagrant/configure/install.sh"
94
+ 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
+ end
@@ -0,0 +1,90 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # All Vagrant configuration is done below. The "2" in Vagrant.configure
5
+ # configures the configuration version (we support older styles for
6
+ # backwards compatibility). Please don't change it unless you know what
7
+ # you're doing.
8
+ Vagrant.configure(2) do |config|
9
+ # The most common configuration options are documented and commented below.
10
+ # For a complete reference, please see the online documentation at
11
+ # https://docs.vagrantup.com.
12
+
13
+ # Every Vagrant development environment requires a box. You can search for
14
+ # boxes at https://atlas.hashicorp.com/search.
15
+ config.vm.box = "ubuntu/trusty64"
16
+
17
+ # Disable automatic box update checking. If you disable this, then
18
+ # boxes will only be checked for updates when the user runs
19
+ # `vagrant box outdated`. This is not recommended.
20
+ # config.vm.box_check_update = false
21
+
22
+ # Create a forwarded port mapping which allows access to a specific port
23
+ # within the machine from a port on the host machine. In the example below,
24
+ # accessing "localhost:8080" will access port 80 on the guest machine.
25
+ # config.vm.network "forwarded_port", guest: 80, host: 8080
26
+
27
+ # Create a private network, which allows host-only access to the machine
28
+ # using a specific IP.
29
+ # config.vm.network "private_network", ip: "192.168.33.10"
30
+
31
+ # Create a public network, which generally matched to bridged network.
32
+ # Bridged networks make the machine appear as another physical device on
33
+ # your network.
34
+ # config.vm.network "public_network"
35
+
36
+ # Share an additional folder to the guest VM. The first argument is
37
+ # the path on the host to the actual folder. The second argument is
38
+ # the path on the guest to mount the folder. And the optional third
39
+ # argument is a set of non-required options.
40
+ # config.vm.synced_folder "../data", "/vagrant_data"
41
+ config.vm.synced_folder "../../", "/srv/forj"
42
+
43
+ if ENV.key?('lorj_src')
44
+ lorj_src = File.expand_path(ENV['lorj_src'])
45
+ git_data = File.join(lorj_src, '.git', 'config')
46
+ if File.exist?(git_data) && open(git_data) { |f| f.grep(/forj-oss\/lorj/) }
47
+ config.vm.synced_folder ENV['lorj_src'], "/srv/lorj"
48
+ end
49
+ end
50
+
51
+ # Provider-specific configuration so you can fine-tune various
52
+ # backing providers for Vagrant. These expose provider-specific options.
53
+ # Example for VirtualBox:
54
+ #
55
+ # config.vm.provider "virtualbox" do |vb|
56
+ # # Display the VirtualBox GUI when booting the machine
57
+ # vb.gui = true
58
+ #
59
+ # # Customize the amount of memory on the VM:
60
+ # vb.memory = "1024"
61
+ # end
62
+ #
63
+ # View the documentation for the provider you are using for more
64
+ # information on available options.
65
+
66
+ # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
67
+ # such as FTP and Heroku are also available. See the documentation at
68
+ # https://docs.vagrantup.com/v2/push/atlas.html for more information.
69
+ # config.push.define "atlas" do |push|
70
+ # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
71
+ # end
72
+
73
+ # Enable provisioning with a shell script. Additional provisioners such as
74
+ # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
75
+ # documentation for more information about their specific syntax and use.
76
+ # config.vm.provision "shell", inline <<-SHELL
77
+ # sudo apt-get install apache2
78
+ # SHELL
79
+ if Vagrant.has_plugin?("vagrant-proxyconf")
80
+ config.proxy.http = ENV['http_proxy'] if ENV.key?('http_proxy')
81
+ config.proxy.https = ENV['https_proxy'] if ENV.key?('https_proxy')
82
+ config.proxy.no_proxy = ENV['no_proxy'] if ENV.key?('no_proxy')
83
+ end
84
+ priv = { privileged: true }
85
+ 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")
86
+ config.vm.provision "shell", priv.merge(inline: "gem install bundler --no-rdoc --no-ri")
87
+ config.vm.provision "shell", priv.merge(inline: "gem install rake --no-rdoc --no-ri")
88
+ config.vm.provision "shell", inline: "/srv/forj/vagrant/configure/install.sh"
89
+ config.vm.provision "shell", inline: "echo 'echo \"Call /srv/forj/vagrant/configure/install.sh to reinstall forj/lorj from source\"' >> ~vagrant/.bash_profile"
90
+ 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.5
4
+ version: 1.0.6
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-02-11 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - ~>
144
144
  - !ruby/object:Gem::Version
145
- version: 1.0.2
145
+ version: 1.0.6
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ~>
151
151
  - !ruby/object:Gem::Version
152
- version: 1.0.2
152
+ version: 1.0.6
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rake
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ~>
179
179
  - !ruby/object:Gem::Version
180
180
  version: 3.1.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '>='
186
+ - !ruby/object:Gem::Version
187
+ version: 0.29.0
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '>='
193
+ - !ruby/object:Gem::Version
194
+ version: 0.29.0
181
195
  description: forj cli - See https://www.forj.io for documentation/information
182
196
  email:
183
197
  - forj@forj.io
@@ -215,6 +229,10 @@ files:
215
229
  - spec/setup_spec.rb
216
230
  - spec/spec_helper.rb
217
231
  - spec/ssh_spec.rb
232
+ - vagrant/README.md
233
+ - vagrant/configure/install.sh
234
+ - vagrant/fedora/Vagrantfile
235
+ - vagrant/ubuntu/Vagrantfile
218
236
  homepage: https://forj.io
219
237
  licenses:
220
238
  - Apache License, Version 2.0.