omf_rc 6.0.0.pre.8 → 6.0.0.pre.9
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/install_omf_rc +79 -0
- data/bin/omf_rc +52 -36
- data/config/config.yml +8 -0
- data/init/debian +51 -0
- data/init/fedora +54 -0
- data/init/run_omf_rc.sh +62 -0
- data/init/ubuntu +12 -0
- data/lib/omf_rc/omf_error.rb +5 -5
- data/lib/omf_rc/resource_factory.rb +7 -11
- data/lib/omf_rc/resource_proxy/abstract_resource.rb +327 -228
- data/lib/omf_rc/resource_proxy/application.rb +61 -56
- data/lib/omf_rc/resource_proxy/net.rb +2 -2
- data/lib/omf_rc/resource_proxy/node.rb +11 -2
- data/lib/omf_rc/resource_proxy/virtual_machine.rb +1 -1
- data/lib/omf_rc/resource_proxy/wlan.rb +2 -0
- data/lib/omf_rc/resource_proxy_dsl.rb +22 -1
- data/lib/omf_rc/util/common_tools.rb +2 -4
- data/lib/omf_rc/util/hostapd.rb +4 -3
- data/lib/omf_rc/util/ip.rb +8 -5
- data/lib/omf_rc/util/iw.rb +18 -8
- data/lib/omf_rc/util/sysfs.rb +14 -0
- data/lib/omf_rc/util/vmbuilder.rb +1 -1
- data/lib/omf_rc/util/wpa.rb +4 -3
- data/lib/omf_rc/version.rb +1 -1
- data/lib/omf_rc.rb +3 -1
- data/omf_rc.gemspec +4 -2
- data/test/omf_rc/message_process_error_spec.rb +3 -3
- data/test/omf_rc/resource_factory_spec.rb +14 -7
- data/test/omf_rc/resource_proxy/abstract_resource_spec.rb +47 -21
- data/test/omf_rc/resource_proxy/application_spec.rb +156 -119
- data/test/omf_rc/resource_proxy/mock_spec.rb +6 -1
- data/test/omf_rc/resource_proxy/node_spec.rb +32 -12
- data/test/omf_rc/resource_proxy_dsl_spec.rb +31 -19
- data/test/omf_rc/util/common_tools_spec.rb +8 -11
- data/test/omf_rc/util/ip_spec.rb +7 -1
- data/test/omf_rc/util/iw_spec.rb +18 -13
- data/test/omf_rc/util/mock_spec.rb +6 -1
- data/test/omf_rc/util/mod_spec.rb +17 -10
- data/test/test_helper.rb +3 -0
- metadata +51 -48
- data/config/omf_rc.yml +0 -70
- data/lib/omf_rc/resource_proxy/openflow_slice.rb +0 -79
- data/lib/omf_rc/resource_proxy/openflow_slice_factory.rb +0 -71
@@ -1,79 +0,0 @@
|
|
1
|
-
# This resource is created from the parent :openflow_slice_factory resource.
|
2
|
-
# It is related with a slice of a flowvisor instance, and behaves as a proxy between experimenter and the actual flowvisor slice.
|
3
|
-
#
|
4
|
-
module OmfRc::ResourceProxy::OpenflowSlice
|
5
|
-
include OmfRc::ResourceProxyDSL
|
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
|
-
|
15
|
-
register_proxy :openflow_slice
|
16
|
-
|
17
|
-
utility :openflow_tools
|
18
|
-
|
19
|
-
|
20
|
-
# Slice's name is initiated with value "nil"
|
21
|
-
hook :before_ready do |resource|
|
22
|
-
resource.property.name = nil
|
23
|
-
end
|
24
|
-
|
25
|
-
# Before release, the related flowvisor instance should also remove the corresponding slice
|
26
|
-
hook :before_release do |resource|
|
27
|
-
resource.flowvisor_connection.call("api.deleteSlice", resource.property.name)
|
28
|
-
end
|
29
|
-
|
30
|
-
|
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
|
-
# Configures the slice password
|
48
|
-
configure :passwd do |resource, passwd|
|
49
|
-
resource.flowvisor_connection.call("api.changePasswd", resource.property.name, passwd.to_s)
|
50
|
-
passwd.to_s
|
51
|
-
end
|
52
|
-
|
53
|
-
# Configures the slice parameters
|
54
|
-
[:contact_email, :drop_policy, :controller_hostname, :controller_port].each do |configure_sym|
|
55
|
-
configure configure_sym do |resource, value|
|
56
|
-
resource.flowvisor_connection.call("api.changeSlice", resource.property.name, configure_sym.to_s, value.to_s)
|
57
|
-
value.to_s
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# Adds/removes a flow to this slice, specified by device, port, etc.
|
62
|
-
configure :flows do |resource, parameters|
|
63
|
-
resource.flowvisor_connection.call("api.changeFlowSpace", resource.transformed_parameters(parameters))
|
64
|
-
resource.flows
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
# Returns a hash table with the name of this slice, its controller (ip and port) and other related information
|
69
|
-
request :info do |resource|
|
70
|
-
result = resource.flowvisor_connection.call("api.getSliceInfo", resource.property.name)
|
71
|
-
result[:name] = resource.property.name
|
72
|
-
result
|
73
|
-
end
|
74
|
-
|
75
|
-
# Returns a string with statistics about the use of this slice
|
76
|
-
request :stats do |resource|
|
77
|
-
resource.flowvisor_connection.call("api.getSliceStats", resource.property.name)
|
78
|
-
end
|
79
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# This resourse is related with a flowvisor instance and behaves as a proxy between experimenter and flowvisor.
|
2
|
-
#
|
3
|
-
module OmfRc::ResourceProxy::OpenflowSliceFactory
|
4
|
-
include OmfRc::ResourceProxyDSL
|
5
|
-
|
6
|
-
# The default arguments of the communication between this resource and the flowvisor instance
|
7
|
-
FLOWVISOR_CONNECTION_DEFAULTS = {
|
8
|
-
host: "localhost",
|
9
|
-
path: "/xmlrc",
|
10
|
-
port: "8080",
|
11
|
-
proxy_host: nil,
|
12
|
-
proxy_port: nil,
|
13
|
-
user: "fvadmin",
|
14
|
-
password: "openflow",
|
15
|
-
use_ssl: "true",
|
16
|
-
timeout: nil
|
17
|
-
}
|
18
|
-
|
19
|
-
|
20
|
-
register_proxy :openflow_slice_factory
|
21
|
-
|
22
|
-
utility :openflow_tools
|
23
|
-
|
24
|
-
|
25
|
-
# 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 = nil|
|
27
|
-
if type.to_sym != :openflow_slice
|
28
|
-
raise "This resource doesn't create resources of type "+type
|
29
|
-
end
|
30
|
-
begin
|
31
|
-
resource.flowvisor_connection
|
32
|
-
rescue
|
33
|
-
raise "This resource is not connected with a flowvisor instance, so it cannot create openflow slices"
|
34
|
-
end
|
35
|
-
opts.property ||= Hashie::Mash.new
|
36
|
-
opts.property.flowvisor_connection_args = resource.property.flowvisor_connection_args
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
# A new resource uses the default connection arguments (ip adress, port, etc) to connect with a flowvisor instance
|
41
|
-
hook :before_ready do |resource|
|
42
|
-
resource.property.flowvisor_connection_args = FLOWVISOR_CONNECTION_DEFAULTS
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
# Configures the flowvisor connection arguments (ip adress, port, etc)
|
47
|
-
configure :flowvisor_connection do |resource, flowvisor_connection_args|
|
48
|
-
raise "Connection with a new flowvisor instance is not allowed if there exist created slices" if !resource.children.empty?
|
49
|
-
resource.property.flowvisor_connection_args.update(flowvisor_connection_args)
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
# Returns the flowvisor connection arguments (ip adress, port, etc)
|
54
|
-
request :flowvisor_connection do |resource|
|
55
|
-
resource.property.flowvisor_connection_args
|
56
|
-
end
|
57
|
-
|
58
|
-
# Returns a list of the existed slices or the connected devices
|
59
|
-
{:slices => "listSlices", :devices => "listDevices"}.each do |request_sym, handler_name|
|
60
|
-
request request_sym do |resource|
|
61
|
-
resource.flowvisor_connection.call("api.#{handler_name}")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Returns information or statistics for a device specified by the given id
|
66
|
-
{:device_info => "getDeviceInfo", :device_stats => "getSwitchStats"}.each do |request_sym, handler_name|
|
67
|
-
request request_sym do |resource, device|
|
68
|
-
resource.flowvisor_connection.call("api.#{handler_name}", device.to_s)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|