forj 0.0.39 → 0.0.40

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: 34b917ad8fea682fd2f00aeb9dfddd87e27622cc
4
- data.tar.gz: 6fb1f8bf1b18491b9f73dc4134b3b7f3b69bd295
3
+ metadata.gz: bf55692c422122d563704df71be87e18427bcdf2
4
+ data.tar.gz: ffc9da6135f46720256dbabb3f8a9bf277a3d848
5
5
  SHA512:
6
- metadata.gz: be0dcbadd3c1582763998fc3d847b15245ea7b922d6d00c7845e2bab06cc1ac22d65780edcbf28d7ab09cc6e22907f76cd2337431d21e8d69b9c5f43d2b4ddd9
7
- data.tar.gz: ff78c34bb6d96b0b49ba9dbc5742f96565ae28912b18b03fdc39423baf2db4fa5ffc38728afda0ee7d69fa0c3e042fd4380ae87323da03b0a282d60ac56e10d5
6
+ metadata.gz: 29d4e63ea42e92a8b2225a550146e692afd76b95911a1d74ae257e1c5823483473774b3e5d1e3049f02bb2f189dac8a35a1f8ec32d8a2d52f55aa7f99b19730d
7
+ data.tar.gz: 3a39d5dd6bed1d7cc75607e726625979a37dda94b59f337105b9479cf37228efff4bac5cd15442b1686b2e45fb5e815c18da326e82e7deaa4841f173fffc4dac
data/Gemfile CHANGED
@@ -16,10 +16,15 @@
16
16
  # limitations under the License.
17
17
 
18
18
  source 'https://rubygems.org'
19
+ group(:development, :test) do
20
+ gem 'rake'
21
+ gem 'debugger'
22
+ gem 'rspec', "~> 2.10.0", :require => false
23
+ end
19
24
 
20
25
  gem 'mime-types','1.25.1'
21
- gem 'excon','0.33.0'
22
- gem 'json'
26
+ gem 'excon','0.31.0'
27
+ gem 'json','~>1.7.5'
23
28
  gem 'nokogiri','1.5.11'
24
29
  gem 'fog', '1.19.0'
25
30
  gem 'git', '>=1.2.7'
@@ -27,3 +32,7 @@ gem 'rainbow'
27
32
  gem 'rbx-require-relative', '~> 0.0.7'
28
33
  gem 'thor', '>=0.16.0'
29
34
  gem 'hpcloud', '~>2.0.8'
35
+ gem 'highline','>=1.6.21'
36
+ gem 'ansi','>=1.4.3'
37
+ gem 'encryptor','>=1.3.0'
38
+
data/README.md CHANGED
@@ -16,13 +16,14 @@ Installation
16
16
 
17
17
  **For ruby 1.9**
18
18
 
19
- $ sudo apt-get install ruby-dev build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev libxml2-dev libxslt-dev git -y
19
+ $ apt-get -y update
20
+ $ sudo 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
20
21
  $ sudo gem install forj
21
22
 
22
23
 
23
24
  **For ruby 1.8**
24
25
 
25
- $ sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 -y
26
+ $ sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 rubygems -y
26
27
  $ sudo apt-get install libreadline-ruby1.8 libruby1.8 libopenssl-ruby -y
27
28
  $ sudo apt-get install libxslt-dev libxml2-dev -y
28
29
  $ sudo gem install nokogiri
@@ -31,6 +32,18 @@ Installation
31
32
  $ sudo gem install hpcloud
32
33
  $ sudo gem install forj
33
34
 
35
+ **Installation from source**
36
+ Perform one of the ruby installation steps without `gem install forj`.
37
+
38
+ $ sudo apt-get -y install build-essential make libxslt-dev libxml2-dev
39
+ $ sudo mkdir -p /opt/config/production/git
40
+ $ cd /opt/config/production/git
41
+ $ git clone https://review.forj.io/forj-oss/cli
42
+ $ cd cli
43
+ $ gem install bundler --no-rdoc --no-ri
44
+ $ gem install rake --no-rdoc --no-ri
45
+ $ bundle install --gemfile Gemfile
46
+ $ rake install
34
47
 
35
48
  Quick steps: How to create a forj?
36
49
  ----------------------------------
@@ -39,16 +52,17 @@ Quick steps: How to create a forj?
39
52
 
40
53
  1. Setup your first forj account.
41
54
 
42
- `$ forj setup [Provider]`
55
+ `$ forj setup [AccountName]`
43
56
 
44
- Ex: `forj setup hpcloud`. In this example, your account will be named 'hpcloud'.
57
+ Ex: `forj setup MyAccount`. In this example, your account will be named 'MyAccount'.
58
+ The first time you setup your account, it will become the default one.
45
59
  **WARNING!!!** [Provider] is currently not supported. By default, it is using hpcloud as default provider.
46
60
 
47
61
  2. Create your forge on your default account
48
62
 
49
- `$ forj boot <blueprint> on hpcloud as <InstanceName>`
63
+ `$ forj boot <blueprint> <InstanceName>`
50
64
 
51
- Ex: `forj boot redstone on hpcloud as MyForge`
65
+ 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.
52
66
 
53
67
 
54
68
  ###Forj options:
@@ -64,11 +78,11 @@ To get help on specific action, just type:
64
78
  Examples of possible actions:
65
79
 
66
80
  Commands:
67
- forj boot <Blueprint> on <Provider> as <InstanceName> [options] # boot a Maestro box and instruct it to provision the blueprint
68
- forj down # delete the Maestro box and all systems installed by the blueprint
69
- forj help [action] # Describe available FORJ actions or one specific action
70
- forj setup # set the credentials for forj cli
71
- forj show defaults # Show list of predefined value you can update in your ~/.forj/config.yaml
81
+ forj boot <Blueprint> <InstanceName> [options] # boot a Maestro box and instruct it to provision the blueprint
82
+ forj down # delete the Maestro box and all systems installed by the blueprint
83
+ forj help [action] # Describe available FORJ actions or one specific action
84
+ forj setup # set the credentials for forj cli
85
+ forj show defaults # Show list of predefined value you can update in your ~/.forj/config.yaml
72
86
  forj ssh
73
87
 
74
88
 
@@ -84,12 +98,12 @@ Here are the variables list you can set:
84
98
  account_name: name # Default forj account used to connect to your cloud. This setting is automatically set to the first account created with forj setup <CloudProvider>
85
99
  maestro_url: url # Maestro GIT repository for clone.
86
100
  infra_repo: path # Path to the default Infra repository used to store your specific bootstrap/build environment. By default: ~/.forj/infra
87
- image: imageName # NOT CURRENTLY USED. Still under development.
88
- # 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)'
101
+ image: imageName # 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)'
89
102
  # If you have created the generic proto2b image, you can set it here.
90
- flavor: flavorName # NOT CURRENTLY USED. Still under development.
91
- # Maestro Flavor name. This flavor is for Maestro only. Your blueprint layout defines each node flavors on needs.
92
- # By default: standard.xsmall
103
+ flavor: flavorName # Maestro Flavor name. This flavor is for Maestro only. Your blueprint layout defines each node flavors on needs.
104
+ # By default: standard.medium
105
+ bp_flavor: flavorName # Blueprint nodes default flavor. Usually, blueprint node are smaller than Maestro.
106
+ # By default: standard.small
93
107
  ports: [Port1,Port2,...] # list of additional ports to add in your cloud security group.
94
108
  # This list is added to the default one in defaults.yaml
95
109
  keypair_path: path # Define the file path to your OpenSSH private key. Useful to access your box with ssh command line.
data/Rakefile CHANGED
@@ -15,9 +15,14 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
-
18
+ require 'rubygems'
19
+ require 'bundler/setup'
19
20
  require 'rspec/core/rake_task'
20
21
 
22
+ $stdout.sync = true
23
+ $stderr.sync = true
24
+ Bundler::GemHelper.install_task
25
+
21
26
  task :default => [:spec]
22
27
 
23
28
  desc 'Run the specs.'
data/bin/forj CHANGED
@@ -36,6 +36,7 @@ include Setup
36
36
  include Ssh
37
37
 
38
38
  require 'forj-config.rb' # Load class ForjConfig
39
+ require 'forj-account.rb' # Load class ForjAccount
39
40
  require 'log.rb' # Load default loggers
40
41
  require 'connection.rb' # Load class ForjConnection
41
42
 
@@ -67,18 +68,21 @@ class Forj < Thor
67
68
  Quick steps: How to create a forj?
68
69
  ----------------------------------
69
70
 
70
- 1. Setup your first forj account.
71
- `$ forj setup [Provider]`
71
+ To test a forj blueprint, you will need an account on a cloud solution.
72
+ Currently forj cli supports only HPHelion (https://horizon.hp.com) but will be expanded to support most of known clouds supported by FOG. (http://fog.io)
72
73
 
73
- Ex: `forj setup hpcloud`. In this example, your account will be named 'hpcloud'.
74
+ 1. Setup your FORJ account.
75
+ `$ forj setup [AccountName] [--provider Provider]`
74
76
 
75
- IMPORTANT NOTE: Without any provider, forj setup will choose 'hpcloud' as provider.
76
- Currently, forj supports only hpcloud. Openstack will be available soon.
77
+ Ex: `forj setup MyForjAccount`. In this example, you will setup 'MyForjAccount' with your HPHelion account. The first time, this account will become the default one.
78
+
79
+ **IMPORTANT NOTE** By default, forj setup will propose you to create your forge on HPHelion (provider 'hpcloud').
80
+ If AccountName is not set, the account name will be proposed to be name 'hpcloud' as well!
77
81
 
78
82
  2. Create your forge on your default account
79
- `$ forj boot <blueprint> on <Provider> as <InstanceName> `
83
+ `$ forj boot <blueprint> <InstanceName>`
80
84
 
81
- Ex: `forj boot redstone on hpcloud as MyForge`
85
+ Ex: `forj boot redstone MyForge`. In this example, forj will create a `redstone` blueprint forge named `MyForge`, using the default `MyForjAccount`
82
86
 
83
87
  forj command line details:
84
88
  --------------------------
@@ -87,44 +91,81 @@ forj command line details:
87
91
  end
88
92
  end
89
93
 
90
- # BOOT
94
+ ################################# BOOT
91
95
  desc 'boot <Blueprint> on <Provider> as <InstanceName> [options]', 'boot a Maestro box and instruct it to provision the blueprint'
92
96
 
93
97
  long_desc <<-LONGDESC
94
98
  This task boot a new forge with the following options
95
99
  \x5- blueprint : Is the name of the blueprint (currently cli only supports redstone)
96
- \x5- Provider : in which cloud provider to deploy the forge
97
100
  \x5- InstanceName : name of the forge
98
101
 
99
102
  Ex: forj boot redstone on hpcloud as maestro_test
100
103
 
101
- `forj boot` load predefine valued from `lib/defaults.yaml`. If you need to change one of them, add this value in your ~/.forj/config.yaml.
104
+ `forj boot` load predefined forj values from `lib/defaults.yaml`. If you need to change one of them, add the key/value in your local config (-c or `~/.forj/config.yaml`).
102
105
  The list of predefined values can be retrieved with forj show defaults
103
106
 
104
107
  LONGDESC
105
108
 
106
- method_option :account_name, :aliases => '-a', :desc => 'Set the forj account name to use. By default, it takes the provider name.'
107
- method_option :infra, :aliases => '-i', :desc => 'Defines your Infra directory to use while booting. You can also set FORJ_INFRA_DIR.'
108
- method_option :maestro_repo, :aliases => '-m', :desc => 'To use a different Maestro repository already cloned. By default, Maestro is cloned to ~/.forj/maestro from github.'
109
- method_option :key_name, :aliases => '-k', :desc => "Keypair name to use."
110
- method_option :key_path, :aliases => '-p', :desc => "Private or Public key file. forj will determine if you provide a public key or a private, if respectively the extension '.pub' exist or not."
111
-
109
+ method_option :account_name, :aliases => '-a', :desc => "Set the forj account name to use. By default, uses the default account set in your local config file."
110
+ method_option :maestro_repo, :aliases => '-m', :desc => "To use a different Maestro repository already cloned.
111
+ By default, Maestro is systematically cloned to ~/.forj/maestro from github.
112
+
113
+ Following options superseed your config file or forj defaults."
114
+ method_option :infra, :aliases => '-r', :desc => 'config: infra_repo : Defines your Infra directory to use while booting. You can also set FORJ_INFRA_DIR.'
115
+ method_option :key_name, :aliases => '-k', :desc => "config: keypair_name : Keypair name to use."
116
+ method_option :key_path, :aliases => '-p', :desc => "config: keypair_path : Private or Public key file to use."
117
+ method_option :security_group, :aliases => '-s', :desc => "config: security_group: Security group name to use and configure."
118
+ method_option :image, :aliases => '-i', :desc => "config: image : Image name to use to build Maestro and blueprint nodes."
119
+ method_option :maestro_flavor, :aliases => '-f', :desc => "config: flavor : Maestro flavor to use."
120
+ method_option :bp_flavor, :aliases => '-b', :desc => "config: bp_flavor : Blueprint nodes default flavor to use.
121
+
122
+ Build system options:"
112
123
  method_option :boothook, :aliases => '-H', :desc => 'By default, boothook file used is build/bin/build-tools/boothook.sh. Use this option to set another one.'
113
124
  method_option :build, :aliases => '-B', :desc => 'Replace the default build.sh'
114
- method_option :branch, :aliases => '-B', :desc => 'The build will extract from git branch name. It sets the configuration build <config> to the branch name <branch>.'
115
- method_option :test_box, :aliases => '-T', :desc => 'Create test.rb-box meta from the repository path provided.'
125
+ method_option :branch, :aliases => '-R', :desc => "Branch name to clone for maestro.
116
126
 
117
- def boot(blueprint, on, cloud_provider, as, name)
127
+ Maestro/infra bootstrap debugging:"
128
+ method_option :test_box, :aliases => '-T', :desc => "Identify a path to become your test-box repository.
129
+ Ex: if your maestro is in ~/src/forj-oss, --test_box ~/src/forj-oss/maestro build.sh and
130
+ test-box will send your local maestro repo to your box, for boot."
131
+
132
+ def boot(blueprint, on_or_name, old_accountname = nil, as = nil, old_name = nil)
133
+
118
134
  Logging.set_level(Logger::INFO) if options[:verbose]
119
135
  Logging.set_level(Logger::DEBUG) if options[:debug]
120
- oConfig=ForjConfig.new(options[:config])
136
+
137
+ oConfig = ForjConfig.new(options[:config])
138
+
139
+
140
+ # depreciated: <BluePrint> on <AccountName> as <InstanceName>
141
+ if old_accountname and as and old_name
142
+ msg = "The syntax `forj boot '%s' on '%s' as '%s'` is depreciated.\nUse `forj boot '%s' '%s'" % [blueprint, old_accountname, old_name, blueprint, old_name]
143
+ if oConfig.get('account_name') == old_accountname
144
+ Logging.warning("%s` instead." % msg)
145
+ else
146
+ Logging.warning("%s -a '%s'` instead." % [msg, old_accountname])
147
+ end
148
+ name = old_name
149
+ oConfig.set('account_name', old_accountname)
150
+ else
151
+ name = on_or_name
152
+ end
121
153
 
122
154
  Logging.fatal(1, "instance name '%s' not supported. Support only lower case, numeric and dash caracters." % [name]) if not /^[\d[[:lower:]]-]+$/ =~ name
123
155
 
124
156
  # Options are added if they are set. Otherwise, get will retrieve the default value.
125
- oConfig.set('account_name', options[:account_name])
126
- oConfig.set('infra_repo', options[:infra])
127
- oConfig.set('keypair_name', options[:key_name])
157
+ oConfig.set('account_name', options[:account_name]) if options[:account_name]
158
+ oConfig.set('infra_repo', options[:infra])
159
+ oConfig.set('keypair_name', options[:key_name])
160
+ oConfig.set('keypair_path', options[:key_path])
161
+ oConfig.set('security_group', options[:security_group])
162
+ oConfig.set('image', options[:image])
163
+ oConfig.set('flavor', options[:maestro_flavor])
164
+ oConfig.set('bp_flavor', options[:bp_flavor])
165
+ oConfig.set(:maestro_repo , options[:maestro_repo])
166
+ oConfig.set(:test_box, File.expand_path(options[:test_box])) if options[:test_box] and File.directory?(File.expand_path(options[:test_box]))
167
+
168
+
128
169
  if options[:key_path]
129
170
  mFound = options[:key_path].match(/^(.*)(\.pub)?$/)
130
171
  if mFound
@@ -138,27 +179,34 @@ The list of predefined values can be retrieved with forj show defaults
138
179
  end
139
180
  end
140
181
 
141
- # TODO: Be able to support the default provider from config.yaml
142
- oConfig.set('provider', cloud_provider)
143
- Boot.boot(blueprint, name,
144
- options[:build],
182
+ Boot.boot(blueprint, name, options[:build],
145
183
  options[:build_config], options[:branch],
146
- options[:maestro_repo], options[:boothook],
147
- options[:box_name], oConfig)
184
+ options[:boothook], options[:box_name], oConfig)
148
185
  end
149
186
 
150
- desc 'show defaults', 'Show list of predefined value you can update in your ~/.forj/config.yaml'
151
-
152
- def show(name)
153
- oConfig=ForjConfig.new()
187
+ ################################# Show defaults
188
+ desc 'show defaults', 'Show list of predefined value you can update in your ~/.forj/config.yaml'
189
+ method_option :account_name, :aliases => '-a', :desc => "Set the forj account name to use. By default, uses the default account set in your local config file."
190
+
191
+ def show(name)
192
+ case name
193
+ when 'defaults'
194
+ oConfig=ForjConfig.new()
195
+ oConfig.set('account_name', options[:account_name])
196
+ oForjAccount = ForjAccount.new(oConfig)
197
+ oForjAccount.ac_load()
198
+
199
+ puts 'List of default values: (local refer to your config file. hash refer to your FORJ account data)'
200
+ puts '-----------------------'
201
+ puts oConfig.default_dump([oForjAccount.hAccountData]).to_yaml
202
+ puts '-----------------------'
203
+ puts "To change default values, update your ~/.forj/config.yaml and add the key/value entry under 'default' section."
204
+ else
205
+ Logging.error("object '%s' unknown." % name)
206
+ end
207
+ end
154
208
 
155
- puts 'List of default values:
156
- --------------------------'
157
- puts rhGet(oConfig.yConfig,'default').to_yaml()
158
- puts '--------------------------'
159
- puts "You can change any of those variables by editing/adding them in your ~/.forj/config.yaml, under section 'default:'"
160
- end
161
- # DOWN
209
+ ################################# DOWN
162
210
  desc 'down', 'delete the Maestro box and all systems installed by the blueprint'
163
211
  long_desc <<-LONGDESC
164
212
  Not yet implemented
@@ -166,11 +214,11 @@ The list of predefined values can be retrieved with forj show defaults
166
214
 
167
215
  def down(name)
168
216
  Logging.set_level(Logger::INFO) if options[:verbose]
169
- Logging.set_level(Logger::DEBUG) if options[:debug]
170
- Down.down(name)
217
+ Logging.set_level(Logger::DEBUG) if options[:debug]
218
+ Down.down(name)
171
219
  end
172
220
 
173
- # SSH
221
+ ################################# SSH
174
222
  desc 'ssh', 'connect to your forge thru ssh'
175
223
  long_desc <<-LONGDESC
176
224
  Connect through ssh to an existing instance
@@ -184,26 +232,37 @@ Connect through ssh to an existing instance
184
232
  Ssh.connect(name, server)
185
233
  end
186
234
 
187
- # SETUP
188
- method_option :account_name, :aliases => '-a', :desc => 'Set the forj account name to use. By default, it takes the provider name.'
235
+ ################################# SETUP
236
+ method_option :keypair_name, :aliases => '-k', :desc => "config keypair_name : Keypair name attached as default to your FORJ account."
237
+ method_option :keypair_path, :aliases => '-p', :desc => "config keypair_path : SSH key file (private or public) to attach as default to your FORJ account.
238
+ It will attach any detected private/public key thanks to the file name
239
+ (without extension/.pem = private, .pub = public)"
189
240
 
190
- desc 'setup [Provider] [options]', 'set the hpcloud credentials for forj cli'
241
+ desc 'setup [AccountName [Provider]] [options]', "Setup FORJ cloud account credentials and information."
191
242
  long_desc <<-LONGDESC
192
- Set the cloud credentials and services for forj. Currently supports only hpcloud provider.
243
+ This setup will configure a FORJ account used to connect to your cloud system.
244
+ \x5It will ask for your cloud provider credentials and services.
245
+
246
+ If AccountName is not set, 'hpcloud' will be used for AccountName and provider name, by default.
247
+ \x5If AccountName is not set without provider, 'hpcloud' provider will be used, by default.
248
+
249
+ WARNING! Currently supports only hpcloud provider.
193
250
 
194
251
  Several data will be requested like:
195
- \x5- access_key: access key from hpcloud
196
- \x5- secret_key: secret key from hpcloud
197
- \x5- auth_uri: identity endpoint
198
- \x5- tenant_id: id for the tenant you want to use
199
- \x5- availability_zone: which availability zone will be deployed
252
+ \x5- Cloud provider credentials and services.
253
+ \x5- user/password (password is encrypted)
254
+ \x5- DNS settings if you want Maestro to manage it.
255
+ \x5- domain name to add to each boxes hostname
200
256
  LONGDESC
201
- def setup(sProvider = 'hpcloud')
257
+ def setup(sAccountName = 'hpcloud', sProvider = "hpcloud")
202
258
  Logging.set_level(Logger::INFO) if options[:verbose]
203
259
  Logging.set_level(Logger::DEBUG) if options[:debug]
204
260
  oConfig=ForjConfig.new(options[:config])
205
261
  oConfig.set('provider', sProvider)
206
- Setup.setup(oConfig, options)
262
+ oConfig.set('account_name', sAccountName)
263
+ oConfig.set('keypair_path', options[:keypair_path]) if options[:keypair_path]
264
+ oConfig.set('keypair_name', options[:keypair_name]) if options[:keypair_name]
265
+ Setup.setup(oConfig)
207
266
  end
208
267
 
209
268
  end
data/lib/boot.rb CHANGED
@@ -35,21 +35,28 @@ include Helpers
35
35
  #
36
36
  module Boot
37
37
  def boot(blueprint, name, build, build_config,
38
- branch, maestro_repo, boothook, box_name,
39
- oConfig)
38
+ branch, boothook, box_name, oConfig)
40
39
  begin
41
40
 
41
+ Logging.fatal(1, 'FORJ account not specified. Did you used `forj setup`, before?') if not oConfig.get('account_name')
42
+
43
+ oForjAccount = ForjAccount.new(oConfig)
44
+
45
+ oForjAccount.ac_load()
46
+
47
+
48
+ # Load Forj account data
49
+ forjAccountFile = File.join($FORJ_ACCOUNTS_PATH, oConfig.get('account_name'))
50
+ oConfig.ExtraLoad(forjAccountFile, :forj_accounts, oConfig.get('account_name'))
51
+
42
52
  # Check options and set data
43
- cloud_provider=oConfig.get('provider')
44
- Logging.fatal(1, 'No provider specified.') if not cloud_provider
53
+ cloud_provider = oForjAccount.get(:account, :provider, 'hpcloud')
45
54
 
46
55
  if cloud_provider != 'hpcloud'
47
56
  Logging.fatal(1, "forj setup support only hpcloud. '%s' is currently not supported." % cloud_provider)
48
57
  end
49
58
 
50
- oConfig.set('account_name', cloud_provider)
51
-
52
- initial_msg = 'booting %s on %s (~/.forj/forj.log)' % [blueprint , cloud_provider]
59
+ initial_msg = "booting %s on %s\nCheck log with `tail -f ~/.forj/forj.log`.\nUse --verbose or --debug for more boot status on screen" % [blueprint , cloud_provider]
53
60
  Logging.high_level_msg(initial_msg) #################
54
61
 
55
62
  # Initialize defaults
@@ -57,9 +64,6 @@ module Boot
57
64
 
58
65
  infra_dir = File.expand_path(oConfig.get('infra_repo'))
59
66
 
60
- # Load Forj account data
61
- forjAccountFile = File.join($FORJ_ACCOUNTS_PATH, oConfig.get('account_name'))
62
- oConfig.ExtraLoad(forjAccountFile, :forj_accounts, oConfig.get('account_name'))
63
67
 
64
68
  # Check about infra repo compatibility with forj cli
65
69
  bBuildInfra = Repositories.infra_rebuild_required?(oConfig, infra_dir)
@@ -77,18 +81,19 @@ module Boot
77
81
  end
78
82
 
79
83
  # Get FORJ DNS setting
80
- yDNS = oConfig.ExtraGet(:forj_accounts, oConfig.get('account_name'), :dns)
81
- Logging.fatal(1, "DNS or domain name are missing. Please execute forj setup %s" % oConfig.get('account_name')) if not yDNS
84
+ yDNS = rhGet(oForjAccount.hAccountData, :dns)
85
+ Logging.fatal(1, "DNS or domain name are missing. Please execute forj setup %s" % oForjAccount.get(:account, 'name')) if not yDNS
86
+
87
+ branch = oConfig.get('branch') unless branch
82
88
 
83
89
  # Step Maestro Clone
84
- if not maestro_repo
85
- Logging.high_level_msg('cloning maestro repo ...' ) #################
90
+ if not oConfig.get(:maestro_repo)
86
91
  Logging.info('cloning maestro repo from \'%s\'...' % maestro_url)
87
92
  Repositories.clone_repo(maestro_url)
88
93
  maestro_repo=File.expand_path('~/.forj/maestro')
89
94
  else
90
- maestro_repo=File.expand_path(maestro_repo)
91
- if not File.exists?('%s/templates/infra/%s-maestro.box.GITBRANCH.env.tmpl' % [maestro_repo, cloud_provider])
95
+ maestro_repo=File.expand_path(oConfig.get(:maestro_repo))
96
+ if not File.exists?('%s/templates/infra/maestro.box.%s.env' % [maestro_repo, branch])
92
97
  Logging.fatal(1, "'%s' is not a recognized Maestro repository. forj cli searched for templates/infra/%s-maestro.box.GITBRANCH.env.tmpl" % [maestro_repo, cloud_provider])
93
98
  end
94
99
  Logging.info('Using your maestro cloned repo \'%s\'...' % maestro_repo)
@@ -102,27 +107,23 @@ module Boot
102
107
  # Connect to services
103
108
  oFC=ForjConnection.new(oConfig)
104
109
 
105
- Logging.high_level_msg('Configuring network...') #################
106
110
  Logging.info('Configuring network \'%s\'' % [oConfig.get('network')])
107
111
  begin
108
112
  network = Network.get_or_create_network(oFC, oConfig.get('network'))
109
113
  subnet = Network.get_or_create_subnet(oFC, network.id, network.name)
110
114
  router = Network.get_or_create_router(oFC, network, subnet)
111
115
  rescue => e
112
- Logging.fatal(1, "Network properly configured is required.\n%s\n%s" % [e.message, e.backtrace.join("\n")])
116
+ Logging.fatal(1, "Network properly configured is required.", e)
113
117
  end
114
118
 
115
- Logging.state('Configuring keypair...') #################
116
- Logging.info('Configuring keypair \'%s\'' % [oConfig.get('keypair_name')])
117
- SecurityGroup.hpc_import_key(oConfig, oFC.sAccountName)
119
+ Logging.info('Configuring keypair \'%s\'' % [oForjAccount.get(:credentials, 'keypair_name')])
120
+ SecurityGroup.hpc_import_key(oForjAccount)
118
121
 
119
- Logging.state('Configuring security group...') #################
120
122
 
121
123
  Logging.info('Configuring Security Group \'%s\'' % [oConfig.get('security_group')])
122
124
  security_group = SecurityGroup.get_or_create_security_group(oFC, oConfig.get('security_group'))
123
125
  ports = oConfig.get('ports')
124
126
 
125
- Logging.state('Configuring security group ports...') #################
126
127
  ports.each do |port|
127
128
  port = port.to_s if port.class != String
128
129
  if not /^\d+(-\d+)?$/ =~ port
@@ -139,13 +140,14 @@ module Boot
139
140
  ENV['FORJ_CLI_ENV'] = oBuildEnv.sBuildEnvFile
140
141
  oBuildEnv.set('FORJ_HPC', oFC.sAccountName)
141
142
  oBuildEnv.set('FORJ_HPC_NET', network.name)
142
- oBuildEnv.set('FORJ_SECURITY_GROUP', oConfig.get('security_group'))
143
- oBuildEnv.set('FORJ_KEYPAIR', oConfig.get('keypair_name'))
144
- oBuildEnv.set('FORJ_HPC_NOVA_KEYPUB', oConfig.get('keypair_path') + '.pub')
145
- oBuildEnv.set('FORJ_BASE_IMG', oConfig.get('image'))
146
- oBuildEnv.set('FORJ_FLAVOR', oConfig.get('flavor'))
147
- oBuildEnv.set('FORJ_TENANT_NAME', rhGet(oConfig.ExtraGet(:forj_accounts, oFC.sAccountName, :compute), :tenant_name))
148
- oBuildEnv.set('FORJ_HPC_COMPUTE', rhGet(oConfig.ExtraGet(:hpc_accounts, oFC.sAccountName, :regions), :compute))
143
+ oBuildEnv.set('FORJ_SECURITY_GROUP', oForjAccount.get(:maestro, 'security_group'))
144
+ oBuildEnv.set('FORJ_KEYPAIR', oForjAccount.get(:credentials,'keypair_name'))
145
+ oBuildEnv.set('FORJ_HPC_NOVA_KEYPUB', oForjAccount.get(:credentials,'keypair_path') + '.pub')
146
+ oBuildEnv.set('FORJ_BASE_IMG', oForjAccount.get(:maestro, 'image'))
147
+ oBuildEnv.set('FORJ_FLAVOR', oForjAccount.get(:maestro, 'flavor'))
148
+ oBuildEnv.set('FORJ_BP_FLAVOR', oForjAccount.get(:maestro, 'bp_flavor'))
149
+ oBuildEnv.set('FORJ_TENANT_NAME', oForjAccount.get(:compute, :tenant_name))
150
+ oBuildEnv.set('FORJ_HPC_COMPUTE', rhGet(oConfig.ExtraGet(:hpc_accounts, oFC.sAccountName, :regions), :compute))
149
151
 
150
152
 
151
153
  oBuildEnv.set('FORJ_DOMAIN', yDNS[:domain_name])
@@ -162,12 +164,12 @@ module Boot
162
164
  build = 'bin/build.sh' unless build
163
165
 
164
166
  build_config = oConfig.get('build_config')
165
- branch = oConfig.get('branch') unless branch
166
167
  box_name = oConfig.get('box_name')
167
168
 
168
- meta = '--meta blueprint=%s ' % [blueprint]
169
+ arg = '--meta blueprint=%s ' % [blueprint]
170
+ arg += "--test-box '%s' " % oConfig.get(:test_box) if oConfig.exist?(:test_box)
169
171
 
170
- command = '%s --build_ID %s --box-name %s --build-conf-dir %s --build-config %s --gitBranch %s --debug-box %s' % [build, name, box_name, infra_dir, build_config, branch, meta]
172
+ command = '%s --build_ID %s --box-name %s --build-conf-dir %s --build-config %s --gitBranch %s --debug-box %s' % [build, name, box_name, infra_dir, build_config, branch, arg]
171
173
 
172
174
  maestro_build_path = File.join(maestro_repo, 'build')
173
175
 
@@ -227,9 +229,8 @@ class BuildEnv
227
229
  begin
228
230
  File.open(@sBuildEnvFile, 'w') do |out|
229
231
  @yBuildEnvVar.each do | key, value |
230
- if rhExist?(@oConfig.yConfig, 'description', key)
231
- out.write("# %s - %s\n" % [key, rhGet(@oConfig.yConfig, 'description', key)])
232
- end
232
+ desc = @oConfig.getAppDefault(:description, key)
233
+ out.write("# %s - %s\n" % [key, desc]) if desc
233
234
  value = "" if not value
234
235
  out.write("%s='%s'\n\n" % [key, value])
235
236
  end