omf_rc_openflow 6.0.0.pre.1 → 6.0.0.pre.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -2
- data/bin/omf_rc_openflow_slice_factory +49 -35
- data/bin/omf_rc_virtual_openflow_switch_factory +49 -35
- data/example/openflow_slice_factory_controller.rb +24 -18
- data/example/openflow_slice_factory_test.rb +48 -52
- data/example/virtual_openflow_switch_factory_controller.rb +25 -18
- data/example/virtual_openflow_switch_factory_test.rb +48 -62
- data/lib/omf_rc/resource_proxy/openflow_slice.rb +1 -27
- data/lib/omf_rc/resource_proxy/openflow_slice_factory.rb +12 -6
- data/lib/omf_rc/resource_proxy/virtual_openflow_switch.rb +1 -40
- data/lib/omf_rc/resource_proxy/virtual_openflow_switch_factory.rb +33 -13
- data/lib/omf_rc_openflow/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -25,11 +25,11 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
In a Linux machine that runs FlowVisor or OpenvSwitch software, execute:
|
27
27
|
|
28
|
-
$ omf_rc_openflow_slice_factory
|
28
|
+
$ omf_rc_openflow_slice_factory -u xmpp://user:password@domain -i topic
|
29
29
|
|
30
30
|
Or execute:
|
31
31
|
|
32
|
-
$ omf_rc_virtual_openflow_slice_factory
|
32
|
+
$ omf_rc_virtual_openflow_slice_factory -u xmpp://user:password@domain -i topic
|
33
33
|
|
34
34
|
to control the FlowVisor or OpenvSwitch resource in a OMF6 Experiment Controller (EC).
|
35
35
|
|
@@ -1,45 +1,40 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'optparse'
|
4
|
+
require 'erb'
|
5
|
+
|
4
6
|
require 'omf_rc'
|
5
7
|
require 'omf_rc/resource_factory'
|
6
8
|
require 'omf_rc_openflow'
|
7
9
|
|
8
10
|
$stdout.sync = true
|
9
|
-
|
10
|
-
options = {
|
11
|
-
uid: `hostname`.chomp
|
12
|
-
}
|
13
|
-
|
11
|
+
options = {}
|
14
12
|
executable_name = File.basename($PROGRAM_NAME)
|
15
13
|
oml_enabled = false
|
14
|
+
gem_version = Gem::Specification.find_by_name('omf_rc_openflow').version.to_s
|
16
15
|
|
17
16
|
begin
|
18
17
|
oml_enabled = OML4R::init(ARGV, :appName => executable_name) do |opts|
|
19
18
|
opts.banner = "usage: #{executable_name} [options]"
|
20
19
|
|
21
|
-
opts.on("-
|
22
|
-
options[:
|
20
|
+
opts.on("-c CONFIGFILE", "Configuration File") do |file|
|
21
|
+
options[:configfile] = file
|
23
22
|
end
|
24
23
|
|
25
|
-
opts.on("-
|
26
|
-
options[:
|
24
|
+
opts.on("-a ADVANCED_CONFIGFILE", "Advanced Configuration File") do |file|
|
25
|
+
options[:advanced_configfile] = file
|
27
26
|
end
|
28
27
|
|
29
|
-
opts.on("-
|
30
|
-
options[:
|
28
|
+
opts.on("-u URI", "Communication URI (xmpp://user:password@domain)") do |uri|
|
29
|
+
options[:uri] = uri
|
31
30
|
end
|
32
31
|
|
33
|
-
opts.on("-
|
34
|
-
options[:
|
32
|
+
opts.on("-e ENVIRONMENT", "Environment (development, production ...)") do |environment|
|
33
|
+
options[:environment] = environment
|
35
34
|
end
|
36
35
|
|
37
|
-
opts.on("-
|
38
|
-
options[:
|
39
|
-
end
|
40
|
-
|
41
|
-
opts.on("-l LOG_FILE_DIR", "Write log file to this folder") do |file_dir|
|
42
|
-
options[:log_file_dir] = file_dir
|
36
|
+
opts.on("-i UID", "UID of the resource, also becomes the pubsub topic of the resource, default to hostname") do |uid|
|
37
|
+
options[:uid] = uid
|
43
38
|
end
|
44
39
|
end
|
45
40
|
rescue => e
|
@@ -56,28 +51,47 @@ rescue => e
|
|
56
51
|
end
|
57
52
|
end
|
58
53
|
|
54
|
+
if !options[:configfile].nil?
|
55
|
+
cfg_options = YAML.load(ERB.new(File.read(options[:configfile])).result)
|
56
|
+
options = cfg_options.merge(options)
|
57
|
+
end
|
58
|
+
|
59
|
+
options[:uid] ||=`hostname`.chomp
|
60
|
+
|
59
61
|
OmfCommon::Measure.enable if oml_enabled
|
60
62
|
|
61
|
-
|
63
|
+
options[:environment] ||= :development
|
64
|
+
|
65
|
+
if options[:uri]
|
66
|
+
common_options = { communication: { url: options[:uri] } }
|
67
|
+
else
|
68
|
+
common_options = {}
|
69
|
+
end
|
70
|
+
|
71
|
+
if !options[:advanced_configfile].nil?
|
72
|
+
a_cfg_options = (YAML.load_file(options[:advanced_configfile]))
|
73
|
+
common_options = a_cfg_options.merge(common_options)
|
74
|
+
end
|
75
|
+
|
76
|
+
unless common_options[:communication] && common_options[:communication][:url]
|
62
77
|
puts "Error: Missing parameters to connect to a PubSub Server (see --help)"
|
63
78
|
exit(1)
|
64
79
|
end
|
65
80
|
|
66
|
-
|
67
|
-
|
81
|
+
resource_options = {
|
82
|
+
uid: options[:uid]
|
83
|
+
}
|
68
84
|
|
69
|
-
|
70
|
-
Logging.logger.root.add_appenders(
|
71
|
-
Logging.appenders.file(
|
72
|
-
"#{options[:log_file_dir]}/omf_rc.log",
|
73
|
-
:layout => Logging.layouts.pattern(:date_pattern => '%F %T %z',
|
74
|
-
:pattern => '[%d] %-5l %c: %m\n')))
|
75
|
-
end
|
85
|
+
#OmfRc::ResourceFactory.load_default_resource_proxies
|
76
86
|
|
77
|
-
|
78
|
-
|
79
|
-
openflow_slice_factory.connect
|
87
|
+
OmfCommon.init(options[:environment].to_sym, common_options) do |el|
|
88
|
+
info "Starting OMF Resource Controller for OpenFlow Slice factory (FlowVisor) version '#{gem_version}'"
|
80
89
|
|
81
|
-
|
82
|
-
|
90
|
+
OmfCommon.comm.on_connected do |comm|
|
91
|
+
info "Connected as #{comm.jid}" if comm.jid
|
92
|
+
res = OmfRc::ResourceFactory.create(:openflow_slice_factory, resource_options)
|
93
|
+
|
94
|
+
comm.on_interrupted { res.disconnect }
|
95
|
+
end
|
83
96
|
end
|
97
|
+
info "Stopping OMF Resource Controller for OpenFlow slice factory version '#{gem_version}'"
|
@@ -1,45 +1,40 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'optparse'
|
4
|
+
require 'erb'
|
5
|
+
|
4
6
|
require 'omf_rc'
|
5
7
|
require 'omf_rc/resource_factory'
|
6
8
|
require 'omf_rc_openflow'
|
7
9
|
|
8
10
|
$stdout.sync = true
|
9
|
-
|
10
|
-
options = {
|
11
|
-
uid: `hostname`.chomp
|
12
|
-
}
|
13
|
-
|
11
|
+
options = {}
|
14
12
|
executable_name = File.basename($PROGRAM_NAME)
|
15
13
|
oml_enabled = false
|
14
|
+
gem_version = Gem::Specification.find_by_name('omf_rc_openflow').version.to_s
|
16
15
|
|
17
16
|
begin
|
18
17
|
oml_enabled = OML4R::init(ARGV, :appName => executable_name) do |opts|
|
19
18
|
opts.banner = "usage: #{executable_name} [options]"
|
20
19
|
|
21
|
-
opts.on("-
|
22
|
-
options[:
|
20
|
+
opts.on("-c CONFIGFILE", "Configuration File") do |file|
|
21
|
+
options[:configfile] = file
|
23
22
|
end
|
24
23
|
|
25
|
-
opts.on("-
|
26
|
-
options[:
|
24
|
+
opts.on("-a ADVANCED_CONFIGFILE", "Advanced Configuration File") do |file|
|
25
|
+
options[:advanced_configfile] = file
|
27
26
|
end
|
28
27
|
|
29
|
-
opts.on("-
|
30
|
-
options[:
|
28
|
+
opts.on("-u URI", "Communication URI (xmpp://user:password@domain)") do |uri|
|
29
|
+
options[:uri] = uri
|
31
30
|
end
|
32
31
|
|
33
|
-
opts.on("-
|
34
|
-
options[:
|
32
|
+
opts.on("-e ENVIRONMENT", "Environment (development, production ...)") do |environment|
|
33
|
+
options[:environment] = environment
|
35
34
|
end
|
36
35
|
|
37
|
-
opts.on("-
|
38
|
-
options[:
|
39
|
-
end
|
40
|
-
|
41
|
-
opts.on("-l LOG_FILE_DIR", "Write log file to this folder") do |file_dir|
|
42
|
-
options[:log_file_dir] = file_dir
|
36
|
+
opts.on("-i UID", "UID of the resource, also becomes the pubsub topic of the resource, default to hostname") do |uid|
|
37
|
+
options[:uid] = uid
|
43
38
|
end
|
44
39
|
end
|
45
40
|
rescue => e
|
@@ -56,28 +51,47 @@ rescue => e
|
|
56
51
|
end
|
57
52
|
end
|
58
53
|
|
54
|
+
if !options[:configfile].nil?
|
55
|
+
cfg_options = YAML.load(ERB.new(File.read(options[:configfile])).result)
|
56
|
+
options = cfg_options.merge(options)
|
57
|
+
end
|
58
|
+
|
59
|
+
options[:uid] ||=`hostname`.chomp
|
60
|
+
|
59
61
|
OmfCommon::Measure.enable if oml_enabled
|
60
62
|
|
61
|
-
|
63
|
+
options[:environment] ||= :development
|
64
|
+
|
65
|
+
if options[:uri]
|
66
|
+
common_options = { communication: { url: options[:uri] } }
|
67
|
+
else
|
68
|
+
common_options = {}
|
69
|
+
end
|
70
|
+
|
71
|
+
if !options[:advanced_configfile].nil?
|
72
|
+
a_cfg_options = (YAML.load_file(options[:advanced_configfile]))
|
73
|
+
common_options = a_cfg_options.merge(common_options)
|
74
|
+
end
|
75
|
+
|
76
|
+
unless common_options[:communication] && common_options[:communication][:url]
|
62
77
|
puts "Error: Missing parameters to connect to a PubSub Server (see --help)"
|
63
78
|
exit(1)
|
64
79
|
end
|
65
80
|
|
66
|
-
|
67
|
-
|
81
|
+
resource_options = {
|
82
|
+
uid: options[:uid]
|
83
|
+
}
|
68
84
|
|
69
|
-
|
70
|
-
Logging.logger.root.add_appenders(
|
71
|
-
Logging.appenders.file(
|
72
|
-
"#{options[:log_file_dir]}/omf_rc.log",
|
73
|
-
:layout => Logging.layouts.pattern(:date_pattern => '%F %T %z',
|
74
|
-
:pattern => '[%d] %-5l %c: %m\n')))
|
75
|
-
end
|
85
|
+
#OmfRc::ResourceFactory.load_default_resource_proxies
|
76
86
|
|
77
|
-
|
78
|
-
|
79
|
-
virtual_openflow_switch_factory.connect
|
87
|
+
OmfCommon.init(options[:environment].to_sym, common_options) do |el|
|
88
|
+
info "Starting OMF Resource Controller for virtual OpenFlow Switch factory (OpenVSwitch) version '#{gem_version}'"
|
80
89
|
|
81
|
-
|
82
|
-
|
90
|
+
OmfCommon.comm.on_connected do |comm|
|
91
|
+
info "Connected as #{comm.jid}" if comm.jid
|
92
|
+
res = OmfRc::ResourceFactory.create(:virtual_openflow_switch_factory, resource_options)
|
93
|
+
|
94
|
+
comm.on_interrupted { res.disconnect }
|
95
|
+
end
|
83
96
|
end
|
97
|
+
info "Stopping OMF Resource Controller for virtual OpenFlow Switch factory version '#{gem_version}'"
|
@@ -3,32 +3,38 @@
|
|
3
3
|
require 'omf_rc'
|
4
4
|
require 'omf_rc/resource_factory'
|
5
5
|
#require 'omf_rc_openflow'
|
6
|
+
|
6
7
|
$stdout.sync = true
|
7
8
|
|
8
|
-
|
9
|
+
|
10
|
+
op_mode = :development
|
9
11
|
|
10
12
|
opts = {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
|
13
|
+
communication: { url: 'xmpp://flowvisor:pw@srv.mytestbed.net' },
|
14
|
+
eventloop: { type: :em },
|
15
|
+
logging: {
|
16
|
+
level: 'info'
|
17
|
+
# level: 'debug',
|
18
|
+
# appenders: {
|
19
|
+
# stdout: {
|
20
|
+
# date_pattern: '%H:%M:%S',
|
21
|
+
# pattern: '%d %-5l %c{2}: %m\n',
|
22
|
+
# color_scheme: 'default'
|
23
|
+
# }
|
24
|
+
# }
|
25
|
+
}
|
18
26
|
}
|
19
27
|
|
20
|
-
Logging.logger.root.level = :debug if opts[:debug]
|
21
|
-
|
22
28
|
OmfRc::ResourceFactory.load_addtional_resource_proxies(File.dirname(__FILE__)+"/../lib/omf_rc/util")
|
23
29
|
OmfRc::ResourceFactory.load_addtional_resource_proxies(File.dirname(__FILE__)+"/../lib/omf_rc/resource_proxy")
|
24
30
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
OmfCommon.init(op_mode, opts) do |el|
|
32
|
+
OmfCommon.comm.on_connected do |comm|
|
33
|
+
info ">>> Starting flowvisor"
|
34
|
+
|
35
|
+
flowvisor = OmfRc::ResourceFactory.new(:openflow_slice_factory, opts.merge(uid: 'flowvisor'))
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
# Disconnect garage from XMPP server, when INT or TERM signals received
|
38
|
+
comm.on_interrupted { flowvisor.disconnect }
|
39
|
+
end
|
34
40
|
end
|
@@ -1,64 +1,60 @@
|
|
1
1
|
# OMF_VERSIONS = 6.0
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
}
|
3
|
+
def create_slice(flowvisor)
|
4
|
+
flowvisor.create(:openflow_slice, {name: "test"}) do |reply_msg|
|
5
|
+
if !reply_msg.itype.start_with? "ERROR" #success?
|
6
|
+
slice = reply_msg.resource
|
7
|
+
|
8
|
+
slice.on_subscribed do
|
9
|
+
info ">>> Connected to newly created slice #{reply_msg[:res_id]} with name #{reply_msg[:name]}"
|
10
|
+
on_slice_created(slice)
|
11
|
+
end
|
12
|
+
|
13
|
+
after(10) do
|
14
|
+
flowvisor.release(slice) do |reply_msg|
|
15
|
+
info ">>> Released slice #{reply_msg[:res_id]}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
else
|
19
|
+
error ">>> Slice creation failed - #{reply_msg[:reason]}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
20
23
|
|
21
|
-
|
24
|
+
def on_slice_created(slice)
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
done!
|
27
|
-
end
|
26
|
+
slice.request([:name]) do |reply_msg|
|
27
|
+
info "> Slice requested name: #{reply_msg[:name]}"
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
msgs[:release_slice].on_inform_released do |message|
|
35
|
-
logger.info "Slice (#{@slice_id}) released"
|
36
|
-
m = @comm.request_message([:slices])
|
37
|
-
m.on_inform_status do |message|
|
38
|
-
logger.info "Flowvisor (#{message.read_property('uid')}) requested slices: #{message.read_property('slices').join(', ')}"
|
39
|
-
done!
|
30
|
+
slice.configure(flows: [{operation: 'add', device: '00:00:00:00:00:00:00:01', eth_dst: '11:22:33:44:55:66'},
|
31
|
+
{operation: 'add', device: '00:00:00:00:00:00:00:01', eth_dst: '11:22:33:44:55:77'}]) do |reply_msg|
|
32
|
+
info "> Slice configured flows:"
|
33
|
+
reply_msg.read_property('flows').each do |flow|
|
34
|
+
logger.info " #{flow}"
|
40
35
|
end
|
41
|
-
m.publish @flowvisor_id
|
42
36
|
end
|
43
|
-
|
44
|
-
logger.info "Slice (#{@slice_id}) created"
|
45
|
-
@slice_topic.subscribe {msgs[:config_slice].publish @slice_id}
|
46
|
-
end
|
47
|
-
|
48
|
-
msgs[:config_slice].on_inform_status do |message|
|
49
|
-
logger.info "Slice (#{message.read_property('uid')}) configured name: #{message.read_property('name')} & contact_email: #{message.read_property('contact_email')}"
|
50
|
-
msgs[:slices].publish @flowvisor_id
|
51
|
-
end
|
52
37
|
|
53
|
-
|
54
|
-
|
55
|
-
|
38
|
+
# Monitor all status, error or warn information from the slice
|
39
|
+
#slice.on_status do |msg|
|
40
|
+
# msg.each_property do |name, value|
|
41
|
+
# info "#{name} => #{value}"
|
42
|
+
# end
|
43
|
+
#end
|
44
|
+
slice.on_error do |msg|
|
45
|
+
error msg[:reason]
|
46
|
+
end
|
47
|
+
slice.on_warn do |msg|
|
48
|
+
warn msg[:reason]
|
49
|
+
end
|
56
50
|
end
|
57
51
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
52
|
+
OmfCommon.comm.subscribe('flowvisor') do |flowvisor|
|
53
|
+
unless flowvisor.error?
|
54
|
+
create_slice(flowvisor)
|
55
|
+
else
|
56
|
+
error flowvisor.inspect
|
62
57
|
end
|
63
|
-
|
58
|
+
|
59
|
+
after(20) { info 'Disconnecting ...'; OmfCommon.comm.disconnect }
|
64
60
|
end
|
@@ -2,32 +2,39 @@
|
|
2
2
|
|
3
3
|
require 'omf_rc'
|
4
4
|
require 'omf_rc/resource_factory'
|
5
|
+
#require 'omf_rc_openflow'
|
6
|
+
|
5
7
|
$stdout.sync = true
|
6
8
|
|
7
|
-
|
9
|
+
|
10
|
+
op_mode = :development
|
8
11
|
|
9
12
|
opts = {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
|
13
|
+
communication: { url: 'xmpp://ovs:pw@srv.mytestbed.net' },
|
14
|
+
eventloop: { type: :em },
|
15
|
+
logging: {
|
16
|
+
level: 'info'
|
17
|
+
# level: 'debug',
|
18
|
+
# appenders: {
|
19
|
+
# stdout: {
|
20
|
+
# date_pattern: '%H:%M:%S',
|
21
|
+
# pattern: '%d %-5l %c{2}: %m\n',
|
22
|
+
# color_scheme: 'default'
|
23
|
+
# }
|
24
|
+
# }
|
25
|
+
}
|
17
26
|
}
|
18
27
|
|
19
|
-
Logging.logger.root.level = :debug if opts[:debug]
|
20
|
-
|
21
28
|
OmfRc::ResourceFactory.load_addtional_resource_proxies(File.dirname(__FILE__)+"/../lib/omf_rc/util")
|
22
29
|
OmfRc::ResourceFactory.load_addtional_resource_proxies(File.dirname(__FILE__)+"/../lib/omf_rc/resource_proxy")
|
23
30
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
OmfCommon.init(op_mode, opts) do |el|
|
32
|
+
OmfCommon.comm.on_connected do |comm|
|
33
|
+
info ">>> Starting ovs"
|
34
|
+
|
35
|
+
ovs = OmfRc::ResourceFactory.new(:virtual_openflow_switch_factory, opts.merge(uid: 'ovs'))
|
29
36
|
|
30
|
-
|
31
|
-
|
32
|
-
|
37
|
+
# Disconnect garage from XMPP server, when INT or TERM signals received
|
38
|
+
comm.on_interrupted { ovs.disconnect }
|
39
|
+
end
|
33
40
|
end
|
@@ -1,74 +1,60 @@
|
|
1
1
|
# OMF_VERSIONS = 6.0
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
# @comm
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
logger.error message.read_content('reason')
|
28
|
-
done!
|
3
|
+
#msgs = {
|
4
|
+
# request_port: @comm.request_message([port: {name: 'tun0', information: 'netdev-tunnel/get-port'}]),
|
5
|
+
# configure_port: @comm.configure_message([port: {name: 'tun0', remote_ip: '138.48.3.201', remote_port: '39505'}]),
|
6
|
+
#}
|
7
|
+
|
8
|
+
def create_switch(ovs)
|
9
|
+
ovs.create(:virtual_openflow_switch, {name: "test"}) do |reply_msg|
|
10
|
+
if !reply_msg.itype.start_with? "ERROR" #success?
|
11
|
+
switch = reply_msg.resource
|
12
|
+
|
13
|
+
switch.on_subscribed do
|
14
|
+
info ">>> Connected to newly created switch #{reply_msg[:res_id]} with name #{reply_msg[:name]}"
|
15
|
+
on_switch_created(switch)
|
16
|
+
end
|
17
|
+
|
18
|
+
after(10) do
|
19
|
+
ovs.release(switch) do |reply_msg|
|
20
|
+
info ">>> Released switch #{reply_msg[:res_id]}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
else
|
24
|
+
error ">>> Switch creation failed - #{reply_msg[:reason]}"
|
25
|
+
end
|
26
|
+
end
|
29
27
|
end
|
30
28
|
|
31
|
-
|
32
|
-
logger.info "OVS (#{message.read_property('uid')}) requested switches: #{message.read_property('switches')}"
|
33
|
-
msgs[:create_switch].publish @ovs_id
|
34
|
-
end
|
29
|
+
def on_switch_created(switch)
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
msgs[:release_switch] ||= @comm.release_message {|m| m.element('resource_id', @switch_id)}
|
41
|
-
msgs[:release_switch].on_inform_released do |message|
|
42
|
-
logger.info "Switch (#{@switch_id}) released"
|
43
|
-
m = @comm.request_message([:switches])
|
44
|
-
m.on_inform_status do |message|
|
45
|
-
logger.info "OVS (#{message.read_property('uid')}) requested switches: #{message.read_property('switches')}"
|
46
|
-
done!
|
31
|
+
switch.configure(ports: {operation: 'add', name: 'tun0', type: 'tunnel'}) do |reply_msg|
|
32
|
+
info "> Switch configured ports: #{reply_msg[:ports]}"
|
33
|
+
switch.configure(port: {name: 'tun0', remote_ip: '138.48.3.201', remote_port: '39505'}) do |reply_msg|
|
34
|
+
info "> Switch configured port: #{reply_msg[:port]}"
|
47
35
|
end
|
48
|
-
m.publish @ovs_id
|
49
36
|
end
|
50
|
-
|
51
|
-
logger.info "Switch (#{@switch_id}) created"
|
52
|
-
@switch_topic.subscribe {msgs[:config_switch_name].publish @switch_id}
|
53
|
-
end
|
54
|
-
|
55
|
-
msgs[:config_switch_name].on_inform_status do |message|
|
56
|
-
logger.info "Switch (#{message.read_property('uid')}) configured name: #{message.read_property('name')}"
|
57
|
-
msgs[:config_add_port].publish @switch_id
|
58
|
-
end
|
59
37
|
|
60
|
-
|
61
|
-
|
62
|
-
|
38
|
+
# Monitor all status, error or warn information from the switch
|
39
|
+
#switch.on_status do |msg|
|
40
|
+
# msg.each_property do |name, value|
|
41
|
+
# info "#{name} => #{value}"
|
42
|
+
# end
|
43
|
+
#end
|
44
|
+
switch.on_error do |msg|
|
45
|
+
error msg[:reason]
|
46
|
+
end
|
47
|
+
switch.on_warn do |msg|
|
48
|
+
warn msg[:reason]
|
49
|
+
end
|
63
50
|
end
|
64
51
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
52
|
+
OmfCommon.comm.subscribe('ovs') do |ovs|
|
53
|
+
unless ovs.error?
|
54
|
+
create_switch(ovs)
|
55
|
+
else
|
56
|
+
error ovs.inspect
|
57
|
+
end
|
69
58
|
|
70
|
-
|
71
|
-
logger.info "Switch (#{message.read_property('uid')}) configured port: #{message.read_property('port')}"
|
72
|
-
msgs[:release_switch].publish @ovs_id
|
59
|
+
after(20) { info 'Disconnecting ...'; OmfCommon.comm.disconnect }
|
73
60
|
end
|
74
|
-
|
@@ -4,23 +4,13 @@
|
|
4
4
|
module OmfRc::ResourceProxy::OpenflowSlice
|
5
5
|
include OmfRc::ResourceProxyDSL
|
6
6
|
|
7
|
-
# The default parameters of a new slice. The openflow controller is assumed to be in the same working station with flowvisor instance
|
8
|
-
SLICE_DEFAULTS = {
|
9
|
-
passwd: "1234",
|
10
|
-
url: "tcp:127.0.0.1:9933",
|
11
|
-
email: "nothing@nowhere"
|
12
|
-
}
|
13
|
-
|
14
7
|
|
15
8
|
register_proxy :openflow_slice, :create_by => :openflow_slice_factory
|
16
9
|
|
17
10
|
utility :openflow_slice_tools
|
18
11
|
|
12
|
+
property :name, :default => nil
|
19
13
|
|
20
|
-
# Slice's name is initiated with value "nil"
|
21
|
-
hook :before_ready do |resource|
|
22
|
-
resource.property.name = nil
|
23
|
-
end
|
24
14
|
|
25
15
|
# Before release, the related flowvisor instance should also remove the corresponding slice
|
26
16
|
hook :before_release do |resource|
|
@@ -28,22 +18,6 @@ module OmfRc::ResourceProxy::OpenflowSlice
|
|
28
18
|
end
|
29
19
|
|
30
20
|
|
31
|
-
# The name is one-time configured
|
32
|
-
configure :name do |resource, name|
|
33
|
-
raise "The name cannot be changed" if resource.property.name
|
34
|
-
resource.property.name = name.to_s
|
35
|
-
begin
|
36
|
-
resource.flowvisor_connection.call("api.createSlice", name.to_s, *SLICE_DEFAULTS.values)
|
37
|
-
rescue Exception => e
|
38
|
-
if e.message["Cannot create slice with existing name"]
|
39
|
-
logger.warn message = "The requested slice already existed in Flowvisor"
|
40
|
-
else
|
41
|
-
raise e
|
42
|
-
end
|
43
|
-
end
|
44
|
-
resource.property.name
|
45
|
-
end
|
46
|
-
|
47
21
|
# Configures the slice password
|
48
22
|
configure :passwd do |resource, passwd|
|
49
23
|
resource.flowvisor_connection.call("api.changePasswd", resource.property.name, passwd.to_s)
|
@@ -16,6 +16,13 @@ module OmfRc::ResourceProxy::OpenflowSliceFactory
|
|
16
16
|
timeout: nil
|
17
17
|
}
|
18
18
|
|
19
|
+
# The default parameters of a new slice. The openflow controller is assumed to be in the same working station with flowvisor instance
|
20
|
+
SLICE_DEFAULTS = {
|
21
|
+
passwd: "1234",
|
22
|
+
url: "tcp:127.0.0.1:9933",
|
23
|
+
email: "nothing@nowhere"
|
24
|
+
}
|
25
|
+
|
19
26
|
|
20
27
|
register_proxy :openflow_slice_factory
|
21
28
|
|
@@ -23,15 +30,14 @@ module OmfRc::ResourceProxy::OpenflowSliceFactory
|
|
23
30
|
|
24
31
|
|
25
32
|
# Checks if the created child is an :openflow_slice resource and passes the connection arguments that are essential for the connection with flowvisor instance
|
26
|
-
hook :before_create do |resource, type, opts
|
33
|
+
hook :before_create do |resource, type, opts|
|
27
34
|
if type.to_sym != :openflow_slice
|
28
35
|
raise "This resource doesn't create resources of type "+type
|
36
|
+
elsif opts.name == nil
|
37
|
+
raise "The created slice must be configured with a name"
|
29
38
|
end
|
30
|
-
|
31
|
-
|
32
|
-
rescue
|
33
|
-
raise "This resource is not connected with a flowvisor instance, so it cannot create openflow slices"
|
34
|
-
end
|
39
|
+
#opts = Hashie::Mash.new(opts)
|
40
|
+
resource.flowvisor_connection.call("api.createSlice", opts.name.to_s, *SLICE_DEFAULTS.values)
|
35
41
|
opts.property ||= Hashie::Mash.new
|
36
42
|
opts.property.provider = ">> #{resource.uid}"
|
37
43
|
opts.property.flowvisor_connection_args = resource.property.flowvisor_connection_args
|
@@ -8,11 +8,8 @@ module OmfRc::ResourceProxy::VirtualOpenflowSwitch
|
|
8
8
|
|
9
9
|
utility :virtual_openflow_switch_tools
|
10
10
|
|
11
|
+
property :name, :default => nil
|
11
12
|
|
12
|
-
# Switch name is initiated with value "nil"
|
13
|
-
hook :before_ready do |resource|
|
14
|
-
resource.property.name = nil
|
15
|
-
end
|
16
13
|
|
17
14
|
# Before release, the related ovsdb-server instance should also remove the corresponding switch
|
18
15
|
hook :before_release do |resource|
|
@@ -43,42 +40,6 @@ module OmfRc::ResourceProxy::VirtualOpenflowSwitch
|
|
43
40
|
end
|
44
41
|
|
45
42
|
|
46
|
-
# Switch name is one-time configured
|
47
|
-
configure :name do |resource, name|
|
48
|
-
raise "The name cannot be changed" if resource.property.name
|
49
|
-
resource.property.name = name.to_s
|
50
|
-
arguments = {
|
51
|
-
"method" => "transact",
|
52
|
-
"params" => [ "Open_vSwitch",
|
53
|
-
{ "op" => "insert",
|
54
|
-
"table" => "Interface",
|
55
|
-
"row" => {"name" => resource.property.name, "type" => "internal"},
|
56
|
-
"uuid-name" => "new_interface"
|
57
|
-
},
|
58
|
-
{ "op" => "insert",
|
59
|
-
"table" => "Port",
|
60
|
-
"row" => {"name" => resource.property.name, "interfaces" => ["named-uuid", "new_interface"]},
|
61
|
-
"uuid-name" => "new_port"
|
62
|
-
},
|
63
|
-
{ "op" => "insert",
|
64
|
-
"table" => "Bridge",
|
65
|
-
"row" => {"name" => resource.property.name, "ports" => ["named-uuid", "new_port"], "datapath_type" => "netdev"},
|
66
|
-
"uuid-name" => "new_bridge"
|
67
|
-
},
|
68
|
-
{ "op" => "mutate",
|
69
|
-
"table" => "Open_vSwitch",
|
70
|
-
"where" => [],
|
71
|
-
"mutations" => [["bridges", "insert", ["set", [["named-uuid", "new_bridge"]]]]]
|
72
|
-
}
|
73
|
-
],
|
74
|
-
"id" => "add-switch"
|
75
|
-
}
|
76
|
-
result = resource.ovs_connection("ovsdb-server", arguments)["result"]
|
77
|
-
raise "The requested switch already existed in ovsdb-server or there is another problem" if result[4]
|
78
|
-
resource.property.uuid = result[2]["uuid"][1]
|
79
|
-
resource.property.name
|
80
|
-
end
|
81
|
-
|
82
43
|
# Add/remove port
|
83
44
|
configure :ports do |resource, array_parameters|
|
84
45
|
array_parameters = [array_parameters] if !array_parameters.kind_of?(Array)
|
@@ -8,10 +8,10 @@ module OmfRc::ResourceProxy::VirtualOpenflowSwitchFactory
|
|
8
8
|
ovsdb_server_host: "localhost",
|
9
9
|
ovsdb_server_port: "6635",
|
10
10
|
ovsdb_server_socket: "/usr/local/var/run/openvswitch/db.sock",
|
11
|
-
ovsdb_server_conn: "unix", # default "unix" between "tcp" and "unix"
|
11
|
+
ovsdb_server_conn: "unix", # default "unix", between "tcp" and "unix"
|
12
12
|
ovs_vswitchd_pid: "/usr/local/var/run/openvswitch/ovs-vswitchd.pid",
|
13
13
|
ovs_vswitchd_socket: "/usr/local/var/run/openvswitch/ovs-vswitchd.%s.ctl",
|
14
|
-
ovs_vswitchd_conn: "unix" #default "unix"
|
14
|
+
ovs_vswitchd_conn: "unix" #default "unix", between "tcp" and "unix"
|
15
15
|
}
|
16
16
|
|
17
17
|
|
@@ -21,23 +21,43 @@ module OmfRc::ResourceProxy::VirtualOpenflowSwitchFactory
|
|
21
21
|
|
22
22
|
|
23
23
|
# Checks if the created child is an :virtual_openflow_switch resource and passes the connection arguments
|
24
|
-
hook :before_create do |resource, type, opts
|
24
|
+
hook :before_create do |resource, type, opts|
|
25
25
|
if type.to_sym != :virtual_openflow_switch
|
26
26
|
raise "This resource doesn't create resources of type "+type
|
27
27
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
#opts = Hashie::Mash.new(opts)
|
29
|
+
arguments = {
|
30
|
+
"method" => "transact",
|
31
|
+
"params" => [ "Open_vSwitch",
|
32
|
+
{ "op" => "insert",
|
33
|
+
"table" => "Interface",
|
34
|
+
"row" => {"name" => opts.name.to_s, "type" => "internal"},
|
35
|
+
"uuid-name" => "new_interface"
|
36
|
+
},
|
37
|
+
{ "op" => "insert",
|
38
|
+
"table" => "Port",
|
39
|
+
"row" => {"name" => opts.name.to_s, "interfaces" => ["named-uuid", "new_interface"]},
|
40
|
+
"uuid-name" => "new_port"
|
41
|
+
},
|
42
|
+
{ "op" => "insert",
|
43
|
+
"table" => "Bridge",
|
44
|
+
"row" => {"name" => opts.name.to_s, "ports" => ["named-uuid", "new_port"], "datapath_type" => "netdev"},
|
45
|
+
"uuid-name" => "new_bridge"
|
46
|
+
},
|
47
|
+
{ "op" => "mutate",
|
48
|
+
"table" => "Open_vSwitch",
|
49
|
+
"where" => [],
|
50
|
+
"mutations" => [["bridges", "insert", ["set", [["named-uuid", "new_bridge"]]]]]
|
51
|
+
}
|
52
|
+
],
|
53
|
+
"id" => "add-switch"
|
54
|
+
}
|
55
|
+
result = resource.ovs_connection("ovsdb-server", arguments)["result"]
|
56
|
+
raise "The requested switch already existed in ovsdb-server or other problem" if result[4]
|
38
57
|
opts.property ||= Hashie::Mash.new
|
39
58
|
opts.property.provider = ">> #{resource.uid}"
|
40
59
|
opts.property.ovs_connection_args = resource.property.ovs_connection_args
|
60
|
+
opts.property.uuid = result[2]["uuid"][1]
|
41
61
|
end
|
42
62
|
|
43
63
|
# A new resource uses the default connection arguments (ip adress, port, socket, etc) to connect with a ovsdb-server instance
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omf_rc_openflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0.pre.
|
4
|
+
version: 6.0.0.pre.2
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omf_rc
|
16
|
-
requirement: &
|
16
|
+
requirement: &14482080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 6.0.0.pre
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *14482080
|
25
25
|
description: OMF6 Resource Controllers related to the Openflow technology
|
26
26
|
email:
|
27
27
|
- kohoumas@gmail.com
|