bin/omf_ec in omf_ec-6.0.1 vs bin/omf_ec in omf_ec-6.0.2.pre.1
- old
+ new
@@ -21,13 +21,21 @@
flag [:u, :uri]
desc "Debug XMPP traffic mode (include XMPP debug logging messages under debug mode)."
switch [:x, :xmpp]
-desc "Private key file"
+desc "Root certificate file"
+arg_name "cert", :optional
+flag [:root_cert]
+
+desc "Your certificate"
+arg_name "cert", :optional
+flag [:cert]
+
+desc "Your private key"
arg_name "key", :optional
-flag [:private_key]
+flag [:key]
desc "Log file directory"
arg_name "directory"
default_value "/tmp"
flag [:log_file_dir]
@@ -50,12 +58,12 @@
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])
- # User-provided command line values for Experiment Properties cannot be
- # set here as the propertties have not been defined yet by the experiment.
+ # 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
properties = {}
if args.size > 1
exp_properties = args[1..-1]
@@ -237,40 +245,55 @@
end
end
def load_exp(exp_path, global_options = {} , options = {}, properties = {})
begin
+ if global_options[:root_cert] && File.exist?(global_options[:root_cert])
+ root = OmfCommon::Auth::Certificate.create_from_x509(File.read(global_options[:root_cert]))
+ end
+
+ if global_options[:cert] && File.exist?(global_options[:cert]) &&
+ global_options[:key] && File.exist?(global_options[:key])
+
+ entity = OmfCommon::Auth::Certificate.create_from_x509(File.read(global_options[:cert]),
+ File.read(global_options[:key]))
+ end
+
opts = {
communication: { url: global_options[:uri] },
eventloop: { type: :em },
logging: {
- level: global_options[:debug] ? 'debug' : 'info',
+ level: { default: global_options[:debug] ? 'debug' : 'info' },
appenders: {
stdout: {
date_pattern: '%H:%M:%S',
pattern: '%d %-5l %c{2}: %m\n',
color_scheme: 'default'
}
}
}
}
+ opts[:communication][:auth] = { certs: [ root.to_pem_compact ] } if root
+
OmfCommon.init(:development, opts) do |el|
setup_logging(global_options)
OmfCommon.comm.on_connected do |comm|
- info "Connected"
+ info "Connected using #{comm.conn_info}"
info "Start experiment: #{OmfEc.experiment.id}"
+ OmfCommon::Auth::CertificateStore.instance.register(root) if root
+ OmfCommon::Auth::CertificateStore.instance.register(entity, OmfCommon.comm.local_address) if entity
+
begin
include OmfEc::Backward::DefaultEvents
load exp_path
rescue => e
error e.message
error e.backtrace.join("\n")
end
- #comm.on_interrupted { Experiment.done }
comm.on_interrupted { comm.disconnect }
end
end
rescue => e
logger.fatal e.message