bin/forj in forj-1.0.13 vs bin/forj in forj-1.0.14

- old
+ new

@@ -14,12 +14,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require 'rubygems' -# require 'debugger' # Use to debug with Ruby < 2.0 -# require 'byebug' # Use to debug with Ruby >= 2.0 +# require 'debugger' # Use to debug with Ruby < 2.0 +# require 'byebug' # Use to debug with Ruby >= 2.0 require 'bundler/setup' require 'thor' require 'ansi' require 'forj' @@ -164,28 +164,31 @@ 'wait for your local repository to be sent out to the new box. '\ 'For more details on test-box, call it to get help.' method_option :tb_path, :aliases => '-t', :desc => 'Define the path to the test-box script. '\ 'This option superseeds the TEST_BOX '\ - 'environment variable.' + 'environment variable.' method_option :test_box, :aliases => '-T', :type => :array, :desc => "Use a local repository for test-box\n\n"\ 'Other options:' method_option :extra_metadata, :aliases => '-e', :desc => 'Custom' \ ' server metadata format key1=value1,key2=value2...,keyN=valueN' + method_option :webproxy, :aliases => '-x', + :desc => 'Set HTTP/HTTPS proxy setting from'\ + ' your cloud' method_option :ca_root_cert, :desc => 'Certificate Authorities file used by'\ ' your compagny to authenticate your intranet servers.' def boot(blueprint, on_or_name, old_accountname = nil, as = nil, old_name = nil) - Forj::Settings.common_options(options) + opts = Forj::Settings.common_options(options) require 'boot.rb' deprecated_name = [old_accountname, as, old_name] - Forj::Boot.boot(blueprint, on_or_name, deprecated_name, options) + Forj::Boot.boot(blueprint, on_or_name, deprecated_name, opts) end ################################# Show defaults long_desc <<-LONGDESC This command helps to show values used by 'forj' to boot a blueprint @@ -199,11 +202,11 @@ Otherwise print 'name' account data. LONGDESC desc 'show <Object> [name]', 'Show Object (default valuesr, account data,' \ ' etc...) values.' def show(object, name = nil) - Forj::Settings.common_options(options) + opts = Forj::Settings.common_options(options) case object when 'defaults' o_config = Lorj::Account.new @@ -238,11 +241,11 @@ puts format("Account value for '%s':", name) puts o_config.config_dump([%(account)]).to_yaml puts '---' puts format("To change those values, execute 'forj setup -a %s'.", - options[:account_name]) + opts[:account_name]) else PrcLib.error("object '%s' unknown.", name) end end @@ -263,12 +266,12 @@ ' account name to use. By default, uses the default account set in' \ ' your local config file.' + "\n\n" + 'Following options superseed your' \ ' Account, config file or forj defaults.' def destroy(name) require 'destroy.rb' - Forj::Settings.common_options(options) - Forj::Destroy.destroy(name, options) + opts = Forj::Settings.common_options(options) + Forj::Destroy.destroy(name, opts) end ################################# SET desc 'set [key=value] [...] [options]', 'Set one or more variables in' \ ' defaults or a forj account.' @@ -308,17 +311,16 @@ 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 set(*p) - PrcLib.level = Logger::INFO if options[:verbose] - PrcLib.level = Logger::DEBUG if options[:debug] + opts = Forj::Settings.common_options(options) if p.length == 0 - Forj::Settings.show_settings(options) + Forj::Settings.show_settings(opts) else - Forj::Settings.set_settings(options, p) + Forj::Settings.set_settings(opts, p) end end ################################# GET desc 'get', 'Get data from defaults or account values.' @@ -347,15 +349,13 @@ 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 get(key = nil) - PrcLib.level = Logger::INFO if options[:verbose] - PrcLib.level = Logger::DEBUG if options[:debug] - + opts = Forj::Settings.common_options(options) require 'get.rb' - Forj::Get.get(options, key) + Forj::Get.get(opts, key) end ################################# SSH desc 'ssh <Instance> [options]', 'connect to your forge thru ssh' long_desc <<-LONGDESC @@ -371,27 +371,27 @@ 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) + opts = Forj::Settings.common_options(options) require 'ssh.rb' - account = Lorj::Account.new(options[:config]) + account = Lorj::Account.new(opts[:config]) # Setting account at runtime layer - account[:account_name] = options[:account_name] if options[:account_name] + account[:account_name] = opts[:account_name] if opts[:account_name] # Setting account at account layer 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] + account.set(:box_ssh, opts[:box_name]) if opts[:box_name] + account.set(:identity, opts[:identity]) if opts[:identity] Forj::Ssh.connect(oInstanceName, account) end ################################# SETUP @@ -415,13 +415,13 @@ \x5- user/password (password is encrypted) \x5- DNS settings if you want Maestro to manage it. \x5- domain name to add to each boxes hostname LONGDESC def setup(sAccountName = 'hpcloud', sProvider = 'hpcloud') - Forj::Settings.common_options(options) + opts = Forj::Settings.common_options(options) require 'cloud_connection.rb' - account = Lorj::Account.new(options[:config], Forj.file_version) + account = Lorj::Account.new(opts[:config], Forj.file_version) account.ac_new(sAccountName, sProvider) unless account.ac_load(sAccountName) o_cloud = Forj::CloudConnection.connect(account) PrcLib.high_level_msg("Setting up '%s' with provider '%s'\n",