bin/forj in forj-1.0.9 vs bin/forj in forj-1.0.10
- old
+ new
@@ -32,10 +32,11 @@
# Initialize forj paths
require 'appinit.rb' # Load Application settings features
Forj.keypairs_path = File.join(PrcLib.data_path, 'keypairs')
Forj.build_path = File.join(PrcLib.data_path, '.build')
+Forj.file_version = '1.0.0'
require 'forj-settings.rb' # Settings features
# This is the main Forj class
# it helps you to create and support your forge.
@@ -55,32 +56,48 @@
puts <<-LONGDESC
Quick steps: How to create a forj?
----------------------------------
To test a forj blueprint, you will need an account on a cloud solution.
-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)
+Currently forj cli supports folowing providers:
+- openstack: openstack cloud and hp helion cloud (Fog)
+- hpcloud : HP Public cloud (Fog)
+
+This list can be expanded to more clouds.
+
+If you want to contribute to support your cloud, check out:
+http://github.com/forj-oss/lorj_cloud
+
1. Setup your FORJ account.
- `$ forj setup [AccountName] [--provider Provider]`
- 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.
+ `$ forj setup`
-**IMPORTANT NOTE** By default, forj setup will propose you to create your forge
- on HPHelion (provider 'hpcloud').
-If AccountName is not set, the account name will be proposed to be name
- 'hpcloud' as well!
+ This will create an account 'hpcloud' configured with 'hpcloud' provider
+ If you want another provider:
+
+ `$ forj setup MyAccountName openstack`
+
+ The first time you setup an account, it will become the default one.
+
2. Create your forge on your default account
`$ forj boot <blueprint> <InstanceName>`
Ex: `forj boot redstone MyForge`. In this example:
Forj will create a `redstone` blueprint forge named `MyForge`,
- using the default `MyForjAccount`.
+ using the default account.
+ If you want to create your forge on another cloud account, do the following:
+
+ `$ forj boot <blueprint> <InstanceName> [-a account]`
+
+ Ex: `forj boot redstone MyForge -a MyAccountName`. In this example:
+ Forj will create a `redstone` blueprint forge named `MyForge`,
+ using the 'MyAccountName' account.
+
+
forj command line details:
--------------------------
LONGDESC
self.class.help(shell, subcommand)
end
@@ -128,20 +145,19 @@
method_option :image_name, :aliases => '-i', :desc => 'config:' \
' image_name : Image name to use to build Maestro and blueprint nodes.'
method_option :maestro_flavor, :aliases => '-f', :desc => 'config:' \
' flavor : Maestro flavor to use.'
method_option :bp_flavor, :aliases => '-b', :desc => 'config:' \
- ' bp_flavor : Blueprint nodes default flavor to use.' \
- + "\n\n" + ' Build system options:'
+ ' bp_flavor : Blueprint nodes default flavor to use.'\
+ "\n\n Build system options:"
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.'
method_option :build, :aliases => '-B', :desc => 'Replace' \
' the default build.sh'
method_option :branch, :aliases => '-R', :desc => 'Branch' \
- 'name to clone for maestro.' \
- + "\n\n" + 'Maestro/infra bootstrap debugging:'
+ "name to clone for maestro.\n\nMaestro/infra bootstrap debugging:"
method_option :test_box, :aliases => '-T', :desc => 'Identify a' \
' path to become your test-box repository.' \
"\n " \
'Ex: if your maestro is in ~/src/forj-oss, --test_box' \
' ~/src/forj-oss/maestro build.sh and' \
@@ -190,14 +206,20 @@
puts '---'
puts "To change default values, use 'forj get' to check valid keys," \
" and update with 'forj set'"
when 'account'
unless name
- puts "List of FORJ accounts: Use 'forj account YourAccount' " \
- ' to see one account details.'
o_accounts = Lorj::Accounts.new
- puts o_accounts.dump.to_yaml
+ accounts = o_accounts.dump
+ if accounts.length == 0
+ PrcLib.message 'No accounts found. Use forj setup [Account '\
+ '[provider]] to create your first account.'
+ return
+ end
+ PrcLib.message "List of FORJ accounts: Use 'forj account YourAccount'" \
+ ' to see one account details.'
+ puts accounts.to_yaml
return
end
o_config = Lorj::Account.new
o_config[:account_name] = name
@@ -334,21 +356,29 @@
method_option :box_name, :aliases => '-n', :desc => 'box name to' \
' create ssh connection'
method_option :identity, :aliases => '-i', :desc => 'Private key' \
' file name.'
+ 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.'
def ssh(oInstanceName)
Forj::Settings.common_options(options)
require 'ssh.rb'
account = Lorj::Account.new(options[:config])
# Setting account at runtime layer
account[:account_name] = options[:account_name] if options[:account_name]
+
# Setting account at account layer
- account.ac_load account[:account_name]
+ unless account.ac_load account[:account_name]
+ PrcLib.fatal(1, "Invalid account '%s'. Use `forj show account` "\
+ 'to get the list of valid accounts.',
+ account[:account_name])
+ end
account.set(:box_ssh, options[:box_name]) if options[:box_name]
account.set(:identity, options[:identity]) if options[:identity]
Forj::Ssh.connect(oInstanceName, account)
@@ -378,16 +408,26 @@
LONGDESC
def setup(sAccountName = 'hpcloud', sProvider = 'hpcloud')
Forj::Settings.common_options(options)
require 'cloud_connection.rb'
- account = Lorj::Account.new(options[:config])
- account.set(:provider_name, sProvider)
- account.set(:account_name, sAccountName)
+ account = Lorj::Account.new(options[:config], Forj.file_version)
+ account.ac_new(sAccountName, sProvider) unless account.ac_load(sAccountName)
o_cloud = Forj::CloudConnection.connect(account)
- o_cloud.setup(:forge, sAccountName)
+
+ PrcLib.high_level_msg("Setting up '%s' with provider '%s'\n",
+ sAccountName, account[:provider])
+
+ o_cloud.setup(:forge)
+
o_cloud.config.ac_save
+ unless o_cloud.config.local_exist?(:account_name)
+ PrcLib.info("Setting account '%s' as default. You can change it with "\
+ '`forj set account_name=<new account>`', sAccountName)
+ o_cloud.config.local_set(:account_name, sAccountName)
+ end
+ o_cloud.config.save_local_config
PrcLib.high_level_msg("\nAccount %s '%s' saved.\n", sProvider, sAccountName)
end
end
ForjThor.start