bin/omf_ec in omf_ec-6.0.3 vs bin/omf_ec in omf_ec-6.0.4.pre.1

- old
+ new

@@ -38,10 +38,14 @@ desc "Log file directory" arg_name "directory" default_value "/tmp" flag [:log_file_dir] +desc "Logging config file" +arg_name "file" +flag [:log_config] + # the path given here is relative to the user's home directory config_file(".config/omf_ec.yml") desc "Execute an experiment script" arg_name "path_to_script_file [-- --experiment_property value]" @@ -57,11 +61,11 @@ c.desc "Check script version (you need to define OMF_VERSIONS in your script" c.switch "version_check" c.action do |global_options, options, args| help_now! "Missing experiment script" if args[0].nil? - help_now! "Experiment script not found" unless File.exist?(args[0]) + help_now! "Experiment script not found" unless File.exist?(File.expand_path(args[0])) # User-provided command line values for Experiment Properties cannot be # set here as the propertties have not been defined yet by the experiment. # Thus just pass them to the experiment, which will be responsible # for setting them later @@ -77,11 +81,11 @@ end OmfEc.experiment.cmdline_properties = properties end # FIXME this loading script is way too simple - load_exp(args[0], global_options, options, properties) + load_exp(File.expand_path(args[0]), global_options, options, properties) end end desc "Load an image onto the nodes" command :load do |c| @@ -229,30 +233,32 @@ require 'blather' Blather.logger = logger end unless global_options[:debug] - Logging.consolidate 'OmfCommon', 'OmfEc', 'OmfRc' + Logging.consolidate 'OmfCommon', 'OmfRc' end # FIXME this should go to common setup - if global_options[:log_file_dir] && File.exist?(global_options[:log_file_dir]) + if global_options[:log_file_dir] && File.exist?(File.expand_path(global_options[:log_file_dir])) Logging.logger.root.add_appenders( Logging.appenders.file( - "#{global_options[:log_file_dir]}/#{OmfEc.experiment.id}.log", + "#{File.expand_path(global_options[:log_file_dir])}/#{OmfEc.experiment.id}.log", :layout => Logging.layouts.pattern(:date_pattern => '%F %T %z', :pattern => '[%d] %-5l %c: %m\n'))) end + + OmfCommon.load_logging_config(global_options[:log_config]) end def load_exp(exp_path, global_options = {} , options = {}, properties = {}) begin - if global_options[:cert] && File.exist?(global_options[:cert]) && - global_options[:key] && File.exist?(global_options[:key]) + if global_options[:cert] && File.exist?(File.expand_path(global_options[:cert])) && + global_options[:key] && File.exist?(File.expand_path(global_options[:key])) - entity = OmfCommon::Auth::Certificate.create_from_x509(File.read(global_options[:cert]), - File.read(global_options[:key])) + entity = OmfCommon::Auth::Certificate.create_from_x509(File.read(File.expand_path(global_options[:cert])), + File.read(File.expand_path(global_options[:key]))) end opts = { communication: { url: global_options[:uri] }, eventloop: { type: :em }, @@ -269,21 +275,25 @@ } opts[:communication][:auth] = {} if entity OmfCommon.init(:development, opts) do |el| + setup_logging(global_options) OmfCommon.comm.on_connected do |comm| + info "OMF Experiment Controller #{OmfEc::VERSION}" info "Connected using #{comm.conn_info}" - info "Start experiment: #{OmfEc.experiment.id}" + info "Execute: #{exp_path}" + info "Properties: #{OmfEc.experiment.cmdline_properties}" - OmfCommon::Auth::CertificateStore.instance.register_default_certs(global_options[:root_cert_dir]) if global_options[:root_cert_dir] + OmfCommon::Auth::CertificateStore.instance.register_default_certs(File.expand_path(global_options[:root_cert_dir])) if global_options[:root_cert_dir] OmfCommon::Auth::CertificateStore.instance.register(entity, OmfCommon.comm.local_address) if entity begin include OmfEc::Backward::DefaultEvents load exp_path + OmfEc::Experiment.start rescue => e error e.message error e.backtrace.join("\n") end