-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
171 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "optparse" | ||
require 'omf_rc' | ||
require 'omf_rc/resource_factory' | ||
$stdout.sync = true | ||
|
||
options = { | ||
uid: `hostname`.chomp | ||
} | ||
|
||
executable_name = File.basename($PROGRAM_NAME) | ||
oml_enabled = false | ||
|
||
begin | ||
oml_enabled = OML4R::init(ARGV, :appName => executable_name) do |opts| | ||
opts.banner = "usage: #{executable_name} [options]" | ||
|
||
opts.on("-u USER", "Username") do |user| | ||
options[:user] = user | ||
end | ||
|
||
opts.on("-p PASSWORD", "Password") do |password| | ||
options[:password] = password | ||
end | ||
|
||
opts.on("-s SERVER", "PubSub server") do |server| | ||
options[:server] = server | ||
end | ||
|
||
opts.on("-t TOPIC", "PubSub topic to create, also becomes the uid of the resource, default to hostname") do |topic| | ||
options[:uid] = topic | ||
end | ||
|
||
opts.on("-d", "--debug", "Debug mode") do | ||
options[:debug] = true | ||
end | ||
|
||
opts.on("-l LOG_FILE_DIR", "Write log file to this folder") do |file_dir| | ||
options[:log_file_dir] = file_dir | ||
end | ||
end | ||
rescue => e | ||
# Right now OML4R does not raise proper exceptions :( | ||
# OML4R requires --oml-noop to be set if we want to run without doing any | ||
# measurements... this is too restrictive here, we want to run without OML | ||
# if no OML parameters were set and this even if --oml-noop is not set. | ||
if e.message.include?('OML4R: Missing values for parameters :expID ') | ||
puts "Warning: Missing some OML options to instrument this RC, so it will "+ | ||
"run without instrumentation. (see --oml-help)" | ||
else | ||
puts e.message | ||
exit(1) | ||
end | ||
end | ||
|
||
OmfCommon::Measure.enable if oml_enabled | ||
|
||
unless options[:server] && options[:user] && options[:password] | ||
puts "Error: Missing parameters to connect to a PubSub Server (see --help)" | ||
exit(1) | ||
end | ||
|
||
Logging.logger.root.level = :debug if options[:debug] | ||
Blather.logger = logger | ||
|
||
if options[:log_file_dir] && File.exist?(options[:log_file_dir]) | ||
Logging.logger.root.add_appenders( | ||
Logging.appenders.file( | ||
"#{options[:log_file_dir]}/omf_rc.log", | ||
:layout => Logging.layouts.pattern(:date_pattern => '%F %T %z', | ||
:pattern => '[%d] %-5l %c: %m\n'))) | ||
end | ||
|
||
#OmfRc::ResourceFactory.load_default_resource_proxies | ||
OmfRc::ResourceFactory.load_addtional_resource_proxies("../lib/omf_rc/resource_proxy") | ||
|
||
EM.run do | ||
openflow_slice_factory = OmfRc::ResourceFactory.new(:openflow_slice_factory, options) | ||
openflow_slice_factory.connect | ||
|
||
trap(:INT) { openflow_slice_factory.disconnect } | ||
trap(:TERM) { openflow_slice_factory.disconnect } | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'omf_rc' | ||
require 'omf_rc/resource_factory' | ||
$stdout.sync = true | ||
|
||
Blather.logger = logger | ||
|
||
opts = { | ||
# XMPP server domain | ||
server: 'srv.mytestbed.net', # 'localhost', | ||
# Debug mode of not | ||
debug: false | ||
} | ||
|
||
Logging.logger.root.level = :debug if opts[:debug] | ||
|
||
OmfRc::ResourceFactory.load_addtional_resource_proxies("../lib/omf_rc/resource_proxy") | ||
|
||
EM.run do | ||
# Use resource factory method to initialise a new instance of garage | ||
g = "flowvisor" | ||
info "Starting #{g}" | ||
flowvisor = OmfRc::ResourceFactory.new( | ||
:openflow_slice_factory, | ||
opts.merge(user: g, password: 'pw', uid: g) | ||
) | ||
flowvisor.connect | ||
|
||
# Disconnect garage from XMPP server, when these two signals received | ||
trap(:INT) { flowvisor.disconnect } | ||
trap(:TERM) { flowvisor.disconnect } | ||
end |
Oops, something went wrong.