Skip to content

Commit

Permalink
Compatibility with newest version
Browse files Browse the repository at this point in the history
  • Loading branch information
kohoumas committed Jan 17, 2013
1 parent cea20b8 commit 056209d
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 266 deletions.
84 changes: 84 additions & 0 deletions bin/omf_rc_openflow_slice_factory
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
142 changes: 0 additions & 142 deletions bin/openflow_scenario

This file was deleted.

22 changes: 0 additions & 22 deletions bin/openflow_slice_factory_controller

This file was deleted.

101 changes: 0 additions & 101 deletions bin/openflow_test

This file was deleted.

33 changes: 33 additions & 0 deletions example/openflow_slice_factory_controller.rb
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
Loading

0 comments on commit 056209d

Please sign in to comment.