-
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
0 parents
commit 80fa5f4
Showing
14 changed files
with
619 additions
and
0 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,18 @@ | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
coverage | ||
InstalledFiles | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp | ||
|
||
# YARD artifacts | ||
.yardoc | ||
_yardoc | ||
doc/ |
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,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in omf_rc_foo.gemspec | ||
gemspec |
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,22 @@ | ||
Copyright (c) 2012 Jack C Hong | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,29 @@ | ||
# OmfRcOpenflow | ||
|
||
OMF Resource Controllers related to Openflow | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
gem 'omf_rc_openflow' | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install omf_rc_openflow | ||
|
||
## Usage | ||
|
||
TODO: Write usage instructions here | ||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Added some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request |
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,2 @@ | ||
#!/usr/bin/env rake | ||
require "bundler/gem_tasks" |
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,142 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'omf_common' | ||
$stdout.sync = true | ||
|
||
include OmfCommon | ||
|
||
options = { | ||
user: 'user', | ||
password: 'pw', | ||
server: 'srv.mytestbed.net', # XMPP pubsub server domain | ||
uid: 'flowvisor', | ||
debug: false | ||
} | ||
|
||
flowvisor_id = options[:uid] | ||
|
||
Logging.logger.root.level = options[:debug] ? :debug : :info | ||
Blather.logger = logger | ||
|
||
# We will use Comm directly, with default DSL implementaion :xmpp | ||
comm = Comm.new(:xmpp) | ||
|
||
flowvisor_topic = comm.get_topic(flowvisor_id) | ||
|
||
port2ip = { | ||
16 => '10.0.1.18', | ||
21 => '10.0.1.19', | ||
23 => '10.0.1.20', | ||
15 => '10.0.1.21' | ||
} | ||
|
||
port2eth = { | ||
16 => '00:03:2d:0d:30:c0', | ||
21 => '00:03:2d:0d:30:d4', | ||
23 => '00:03:2d:0d:30:cc', | ||
15 => '00:03:2d:0d:30:ce' | ||
} | ||
|
||
#flowvisor_topic.on_message proc { |m| m.operation != :inform } do |message| | ||
# logger.warn message | ||
#end | ||
|
||
# messages { key: Topic } | ||
msgs = { | ||
create_1: comm.create_message([type: 'openflow_slice', name: 'test1']), | ||
create_2: comm.create_message([type: 'openflow_slice', name: 'test2', controller_port: '9934']), | ||
|
||
config_1a: comm.configure_message([{flows: {operation: 'add', device: 'all', eth_src: port2eth[16]}}]), | ||
config_1b: comm.configure_message([{flows: {operation: 'add', device: 'all', eth_src: port2eth[21]}}]), | ||
config_1c: comm.configure_message([{flows: {operation: 'add', device: '00:00:00:00:00:00:00:02', in_port: '1', eth_src: port2eth[16]}}]), | ||
config_1d: comm.configure_message([{flows: {operation: 'add', device: '00:00:00:00:00:00:00:01', in_port: '1', eth_src: port2eth[21]}}]), | ||
|
||
config_2a: comm.configure_message([{flows: {operation: 'add', device: '00:00:00:00:00:00:00:01', in_port: '15'}}]), | ||
config_2b: comm.configure_message([{flows: {operation: 'add', device: '00:00:00:00:00:00:00:02', in_port: '23'}}]), | ||
config_2c: comm.configure_message([{flows: {operation: 'add', device: '00:00:00:00:00:00:00:02', in_port: '1', eth_src: port2eth[15]}}]), | ||
config_2d: comm.configure_message([{flows: {operation: 'add', device: '00:00:00:00:00:00:00:01', in_port: '1', eth_src: port2eth[23]}}]), | ||
} | ||
|
||
%w{create_1 create_2}.each do |s| | ||
msgs[s.to_sym].on_inform_failed do |message| | ||
logger.error "Resource creation failed ---" | ||
logger.error message.read_content("reason") | ||
end | ||
end | ||
|
||
%w{config_1a config_1b config_1c config_1d config_2a config_2b config_2c config_2d}.each do |s| | ||
msgs[s.to_sym].on_inform_status do |message| | ||
message.each_property do |p| | ||
logger.info "#{p.attr('key')} => #{p.content.strip}" | ||
end | ||
end | ||
end | ||
|
||
msgs[:create_1].on_inform_created do |message| | ||
slice_topic = comm.get_topic(message.resource_id) | ||
slice_id = slice_topic.id | ||
|
||
msgs[:release_1] ||= comm.release_message { |m| m.element('resource_id', slice_id) } | ||
|
||
msgs[:release_1].on_inform_released do |message| | ||
logger.info "Slice (#{message.resource_id}) deleted (resource released)" | ||
end | ||
|
||
logger.info "Slice #{slice_id} ready for testing" | ||
|
||
slice_topic.subscribe do | ||
msgs[:config_1a].publish slice_id | ||
# msgs[:config_1b].publish slice_id | ||
# msgs[:config_1c].publish slice_id | ||
# msgs[:config_1d].publish slice_id | ||
end | ||
end | ||
|
||
msgs[:create_2].on_inform_created do |message| | ||
slice_topic = comm.get_topic(message.resource_id) | ||
slice_id = slice_topic.id | ||
|
||
msgs[:release_2] ||= comm.release_message { |m| m.element('resource_id', slice_id) } | ||
|
||
msgs[:release_2].on_inform_released do |message| | ||
logger.info "Slice (#{message.resource_id}) deleted (resource released)" | ||
end | ||
|
||
logger.info "Slice #{slice_id} ready for testing" | ||
|
||
slice_topic.subscribe do | ||
msgs[:config_2a].publish slice_id | ||
# msgs[:config_2b].publish slice_id | ||
# msgs[:config_2c].publish slice_id | ||
# msgs[:config_2d].publish slice_id | ||
end | ||
end | ||
|
||
# Then we can register event handlers to the communicator | ||
# | ||
# Event triggered when connection is ready | ||
comm.when_ready do | ||
logger.info "CONNECTED: #{comm.jid.inspect}" | ||
|
||
# We assume that a openflow_slice_factory (flowvisor) resource proxy instance is up already, so we subscribe to its pubsub topic | ||
flowvisor_topic.subscribe do | ||
# If subscribed, we publish a 'create' message, 'create' a new openflow slice for testing | ||
msgs[:create_1].publish flowvisor_id | ||
msgs[:create_2].publish flowvisor_id | ||
end | ||
end | ||
|
||
EM.run do | ||
comm.connect(options[:user], options[:password], options[:server]) | ||
|
||
trap(:INT) do | ||
msgs[:release_1].publish flowvisor_id | ||
msgs[:release_2].publish flowvisor_id | ||
comm.disconnect | ||
end | ||
trap(:TERM) do | ||
msgs[:release_1].publish flowvisor_id | ||
msgs[:release_2].publish flowvisor_id | ||
comm.disconnect | ||
end | ||
end |
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,22 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'omf_rc' | ||
require 'omf_rc/resource_factory' | ||
require 'omf_rc/resource_proxy/openflow_slice_factory' | ||
require 'omf_rc/resource_proxy/openflow_slice' | ||
$stdout.sync = true | ||
|
||
options = { | ||
user: 'testbed', | ||
password: 'pw', | ||
server: 'srv.mytestbed.net', # XMPP pubsub server domain | ||
uid: 'flowvisor', | ||
} | ||
|
||
EM.run do | ||
openflowslicefactory = OmfRc::ResourceFactory.new(:openflow_slice_factory, options) | ||
openflowslicefactory.connect | ||
|
||
trap(:INT) { openflowslicefactory.disconnect } | ||
trap(:TERM) { openflowslicefactory.disconnect } | ||
end |
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,101 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'omf_common' | ||
$stdout.sync = true | ||
|
||
include OmfCommon | ||
|
||
options = { | ||
user: 'user', | ||
password: 'pw', | ||
server: 'srv.mytestbed.net', # XMPP pubsub server domain | ||
uid: 'flowvisor', | ||
debug: false | ||
} | ||
|
||
flowvisor_id = options[:uid] | ||
|
||
Logging.logger.root.level = options[:debug] ? :debug : :info | ||
Blather.logger = logger | ||
|
||
# We will use Comm directly, with default DSL implementaion :xmpp | ||
comm = Comm.new(:xmpp) | ||
|
||
flowvisor_topic = comm.get_topic(flowvisor_id) | ||
|
||
#flowvisor_topic.on_message proc { |m| m.operation != :inform } do |message| | ||
# logger.warn message | ||
#end | ||
|
||
# messages { key: Topic } | ||
msgs = { | ||
create: comm.create_message([type: 'openflow_slice', name: 'test1']), | ||
config_a: comm.configure_message([flows: {operation: 'add', device: '00:00:00:00:00:00:00:01', in_port: '16'}]), | ||
# config_b: comm.configure_message([flows: {operation: 'add', device: '00:00:00:00:00:00:00:02', in_port: '21'}]), | ||
# config_c: comm.configure_message([flows: {operation: 'add', device: '00:00:00:00:00:00:00:02', in_port: '23'}]), | ||
# config_d: comm.configure_message([flows: {operation: 'add', device: '00:00:00:00:00:00:00:01', in_port: '15'}]), | ||
# config_e: comm.configure_message([flows: {operation: 'add', device: '00:00:00:00:00:00:00:01', in_port: '1', eth_src: '00:03:2d:0d:30:d4'}]), | ||
# config_f: comm.configure_message([flows: {operation: 'add', device: '00:00:00:00:00:00:00:02', in_port: '1', eth_src: '00:03:2d:0d:30:c0'}]), | ||
} | ||
|
||
msgs[:create].on_inform_failed do |message| | ||
logger.error "Resource creation failed ---" | ||
logger.error message.read_content("reason") | ||
end | ||
|
||
%w{config_a}.each do |s| | ||
#config_b config_c config_d config_e config_f}.each do |s| | ||
msgs[s.to_sym].on_inform_status do |message| | ||
message.each_property do |p| | ||
logger.info "#{p.attr('key')} => #{p.content.strip}" | ||
end | ||
end | ||
end | ||
|
||
msgs[:create].on_inform_created do |message| | ||
slice_topic = comm.get_topic(message.resource_id) | ||
slice_id = slice_topic.id | ||
|
||
msgs[:release] ||= comm.release_message { |m| m.element('resource_id', slice_id) } | ||
|
||
msgs[:release].on_inform_released do |message| | ||
logger.info "Slice (#{message.resource_id}) deleted (resource released)" | ||
end | ||
|
||
logger.info "Slice #{slice_id} ready for testing" | ||
|
||
slice_topic.subscribe do | ||
msgs[:config_a].publish slice_id | ||
# msgs[:config_b].publish slice_id | ||
# msgs[:config_c].publish slice_id | ||
# msgs[:config_d].publish slice_id | ||
# msgs[:config_e].publish slice_id | ||
# msgs[:config_f].publish slice_id | ||
end | ||
end | ||
|
||
# Then we can register event handlers to the communicator | ||
# | ||
# Event triggered when connection is ready | ||
comm.when_ready do | ||
logger.info "CONNECTED: #{comm.jid.inspect}" | ||
|
||
# We assume that a openflow_slice_factory (flowvisor) resource proxy instance is up already, so we subscribe to its pubsub topic | ||
flowvisor_topic.subscribe do | ||
# If subscribed, we publish a 'create' message, 'create' a new openflow slice for testing | ||
msgs[:create].publish flowvisor_id | ||
end | ||
end | ||
|
||
EM.run do | ||
comm.connect(options[:user], options[:password], options[:server]) | ||
|
||
trap(:INT) do | ||
msgs[:release].publish flowvisor_id | ||
comm.disconnect | ||
end | ||
trap(:TERM) do | ||
msgs[:release].publish flowvisor_id | ||
comm.disconnect | ||
end | ||
end |
Oops, something went wrong.