omf_rc 6.0.2.pre.2 → 6.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/omf_rc +19 -11
- data/config/config.yml +0 -5
- data/config/config_with_authentication.yml.example +1 -1
- data/lib/omf_rc/deferred_process.rb +5 -0
- data/lib/omf_rc/omf_error.rb +5 -0
- data/lib/omf_rc/resource_factory.rb +17 -5
- data/lib/omf_rc/resource_proxy/abstract_resource.rb +186 -85
- data/lib/omf_rc/resource_proxy/application.rb +77 -53
- data/lib/omf_rc/resource_proxy/net.rb +29 -2
- data/lib/omf_rc/resource_proxy/node.rb +53 -2
- data/lib/omf_rc/resource_proxy/virtual_machine.rb +5 -0
- data/lib/omf_rc/resource_proxy/virtual_machine_factory.rb +5 -0
- data/lib/omf_rc/resource_proxy/wlan.rb +41 -2
- data/lib/omf_rc/resource_proxy_dsl.rb +68 -8
- data/lib/omf_rc/util/common_tools.rb +5 -0
- data/lib/omf_rc/util/hostapd.rb +13 -0
- data/lib/omf_rc/util/ip.rb +39 -0
- data/lib/omf_rc/util/iw.rb +115 -39
- data/lib/omf_rc/util/libvirt.rb +5 -0
- data/lib/omf_rc/util/mod.rb +20 -1
- data/lib/omf_rc/util/openflow_tools.rb +5 -0
- data/lib/omf_rc/util/package.rb +5 -0
- data/lib/omf_rc/util/platform_tools.rb +5 -0
- data/lib/omf_rc/util/sysfs.rb +23 -3
- data/lib/omf_rc/util/vmbuilder.rb +5 -0
- data/lib/omf_rc/util/wpa.rb +12 -0
- data/lib/omf_rc/version.rb +6 -1
- data/lib/omf_rc.rb +5 -0
- data/omf_rc.gemspec +2 -1
- data/test/omf_rc/deferred_process_spec.rb +5 -0
- data/test/omf_rc/message_process_error_spec.rb +5 -0
- data/test/omf_rc/resource_factory_spec.rb +8 -6
- data/test/omf_rc/resource_proxy/abstract_resource_spec.rb +151 -89
- data/test/omf_rc/resource_proxy/application_spec.rb +10 -11
- data/test/omf_rc/resource_proxy/node_spec.rb +6 -1
- data/test/omf_rc/resource_proxy_dsl_spec.rb +31 -6
- data/test/omf_rc/util/common_tools_spec.rb +6 -1
- data/test/omf_rc/util/ip_spec.rb +9 -3
- data/test/omf_rc/util/iw_spec.rb +16 -6
- data/test/omf_rc/util/mod_spec.rb +8 -3
- data/test/test_helper.rb +6 -0
- metadata +26 -13
- data/lib/omf_rc/resource_proxy/mock.rb +0 -16
- data/lib/omf_rc/util/mock.rb +0 -22
- data/test/omf_rc/resource_proxy/mock_spec.rb +0 -20
- data/test/omf_rc/util/mock_spec.rb +0 -31
data/lib/omf_rc/util/ip.rb
CHANGED
@@ -1,19 +1,48 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'cocaine'
|
2
7
|
|
3
8
|
module OmfRc::Util::Ip
|
4
9
|
include OmfRc::ResourceProxyDSL
|
5
10
|
include Cocaine
|
6
11
|
|
12
|
+
# @!macro extend_dsl
|
13
|
+
|
14
|
+
# @!macro group_request
|
15
|
+
# Retrieve IP address
|
16
|
+
#
|
17
|
+
# @return [String] IP address
|
18
|
+
# @!macro request
|
19
|
+
# @!method request_ip_addr
|
7
20
|
request :ip_addr do |resource|
|
8
21
|
addr = CommandLine.new("ip", "addr show dev :device", :device => resource.property.if_name).run
|
9
22
|
addr && addr.chomp.match(/inet ([[0-9]\:\/\.]+)/) && $1
|
10
23
|
end
|
11
24
|
|
25
|
+
# Retrieve MAC address
|
26
|
+
#
|
27
|
+
# @return [String] MAC address
|
28
|
+
# @!macro request
|
29
|
+
# @!method request_mac_addr
|
12
30
|
request :mac_addr do |resource|
|
13
31
|
addr = CommandLine.new("ip", "addr show dev :device", :device => resource.property.if_name).run
|
14
32
|
addr && addr.chomp.match(/link\/ether ([\d[a-f][A-F]\:]+)/) && $1
|
15
33
|
end
|
34
|
+
# @!endgroup
|
16
35
|
|
36
|
+
# @!macro group_configure
|
37
|
+
# Configure IP address
|
38
|
+
#
|
39
|
+
# @param value value of IP address, it should have netmask. (e.g. 0.0.0.0/24)
|
40
|
+
#
|
41
|
+
# @raise [ArgumentError] if provided no IP address or incorrect format
|
42
|
+
#
|
43
|
+
# @return [String] IP address
|
44
|
+
# @!macro configure
|
45
|
+
# @!method configure_ip_addr
|
17
46
|
configure :ip_addr do |resource, value|
|
18
47
|
if value.nil? || value.split('/')[1].nil?
|
19
48
|
raise ArgumentError, "You need to provide an IP address with netmask. E.g. 0.0.0.0/24. Got #{value}."
|
@@ -27,13 +56,23 @@ module OmfRc::Util::Ip
|
|
27
56
|
resource.interface_up
|
28
57
|
resource.request_ip_addr
|
29
58
|
end
|
59
|
+
# @!endgroup
|
30
60
|
|
61
|
+
# @!macro group_work
|
62
|
+
# Bring up network interface
|
63
|
+
# @!macro work
|
64
|
+
# @!method interface_up
|
31
65
|
work :interface_up do |resource|
|
32
66
|
CommandLine.new("ip", "link set :dev up", :dev => resource.property.if_name).run
|
33
67
|
end
|
34
68
|
|
69
|
+
# Remove IP addresses associated with the interface
|
70
|
+
#
|
71
|
+
# @!macro work
|
72
|
+
# @!method flush_ip_addrs
|
35
73
|
work :flush_ip_addrs do |resource|
|
36
74
|
CommandLine.new("ip", "addr flush dev :device",
|
37
75
|
:device => resource.property.if_name).run
|
38
76
|
end
|
77
|
+
# @!endgroup
|
39
78
|
end
|
data/lib/omf_rc/util/iw.rb
CHANGED
@@ -1,11 +1,23 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'hashie'
|
2
7
|
require 'cocaine'
|
3
8
|
|
9
|
+
# Utility for executing command 'iw'
|
4
10
|
module OmfRc::Util::Iw
|
5
11
|
include OmfRc::ResourceProxyDSL
|
12
|
+
|
6
13
|
include Cocaine
|
7
14
|
include Hashie
|
8
15
|
|
16
|
+
# @!macro extend_dsl
|
17
|
+
#
|
18
|
+
# @!parse include OmfRc::Util::Ip
|
19
|
+
# @!parse include OmfRc::Util::Wpa
|
20
|
+
# @!parse include OmfRc::Util::Hostapd
|
9
21
|
utility :ip
|
10
22
|
utility :wpa
|
11
23
|
utility :hostapd
|
@@ -26,8 +38,18 @@ module OmfRc::Util::Iw
|
|
26
38
|
logger.warn "Command iw not found"
|
27
39
|
end
|
28
40
|
|
41
|
+
# @!macro group_request
|
42
|
+
#
|
29
43
|
# Parse iw link command output and return as a mash
|
30
44
|
#
|
45
|
+
# @example return value
|
46
|
+
#
|
47
|
+
# { ssid: 'ap', freq: '2412', signal: '-67 dBm' }
|
48
|
+
#
|
49
|
+
# @return [Mash]
|
50
|
+
#
|
51
|
+
# @!method request_link
|
52
|
+
# @!macro request
|
31
53
|
request :link do |device|
|
32
54
|
known_properties = Mash.new
|
33
55
|
|
@@ -44,6 +66,13 @@ module OmfRc::Util::Iw
|
|
44
66
|
|
45
67
|
# Parse iw info command output and return as a mash
|
46
68
|
#
|
69
|
+
# @example return value
|
70
|
+
#
|
71
|
+
# { ifindex: '3', type: 'managed', wiphy: '0' }
|
72
|
+
#
|
73
|
+
# @return [Mash]
|
74
|
+
# @!method request_info
|
75
|
+
# @!macro request
|
47
76
|
request :info do |device|
|
48
77
|
known_properties = Mash.new
|
49
78
|
|
@@ -58,14 +87,93 @@ module OmfRc::Util::Iw
|
|
58
87
|
known_properties
|
59
88
|
end
|
60
89
|
|
90
|
+
# @!endgroup
|
91
|
+
|
92
|
+
# @!macro group_configure
|
93
|
+
#
|
94
|
+
# Configure the interface with mode: managed, master, adhoc or monitor
|
95
|
+
#
|
96
|
+
# @example Sample opts for mode property
|
97
|
+
# # Master
|
98
|
+
# { mode: :master, hw_mode: 'a', channel: 1, essid: 'bob' }
|
99
|
+
#
|
100
|
+
# # Managed
|
101
|
+
# { mode: :managed, essid: 'bob' }
|
102
|
+
#
|
103
|
+
# # Ad-hoc
|
104
|
+
# { mode: :adhoc, essid: 'bob', frequency: 2412 }
|
105
|
+
#
|
106
|
+
# # Monitor
|
107
|
+
# { mode: :monitor }
|
108
|
+
#
|
109
|
+
# @param [Hash] opts the hash to set up mode of wireless interface
|
110
|
+
#
|
111
|
+
# @option opts [Symbol] :mode wireless connection mode (:master, :managed, :adhoc)
|
112
|
+
# @option opts [Symbol] :hw_mode wireless connection hardware mode ('a', 'b', 'g', 'n')
|
113
|
+
# @option opts [Symbol] :essid
|
114
|
+
# @option opts [Symbol] :channel
|
115
|
+
# @option opts [Symbol] :frequency
|
116
|
+
#
|
117
|
+
# @raise [ArgumentError] if wifi device specified cannot be found on the system
|
118
|
+
#
|
119
|
+
# @return [String] ip address of the device if configured properly
|
120
|
+
#
|
121
|
+
# @!method configure_mode(opts)
|
122
|
+
# @!macro configure
|
123
|
+
configure :mode do |device, opts|
|
124
|
+
# capture opts hash and store internally
|
125
|
+
device.property.update(opts)
|
126
|
+
|
127
|
+
if device.property.phy && device.property.phy =~ /^%(\d+)%$/
|
128
|
+
wlan_phy_device = device.request_wlan_devices[$1.to_i]
|
129
|
+
if wlan_phy_device
|
130
|
+
device.property.phy = wlan_phy_device[:name]
|
131
|
+
else
|
132
|
+
raise ArgumentError, "Could not find your wifi device no #{$1.to_i}"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
device.validate_iw_properties
|
137
|
+
|
138
|
+
device.delete_interface rescue logger.warn "Interface #{device.property.if_name} not found"
|
139
|
+
|
140
|
+
# TODO should just remove all interfaces from physical device, at least make it optional
|
141
|
+
|
142
|
+
case device.property.mode.to_sym
|
143
|
+
when :master
|
144
|
+
device.add_interface(:managed)
|
145
|
+
device.hostapd
|
146
|
+
when :managed
|
147
|
+
device.add_interface(:managed)
|
148
|
+
device.wpasup
|
149
|
+
when :adhoc
|
150
|
+
device.add_interface(:adhoc)
|
151
|
+
device.interface_up
|
152
|
+
device.join_ibss
|
153
|
+
when :monitor
|
154
|
+
device.add_interface(:monitor)
|
155
|
+
device.interface_up
|
156
|
+
end
|
157
|
+
|
158
|
+
device.configure_ip_addr(device.property.ip_addr) if device.property.ip_addr
|
159
|
+
end
|
160
|
+
|
161
|
+
# @!endgroup
|
162
|
+
#
|
163
|
+
# @!macro group_work
|
164
|
+
#
|
61
165
|
# Delete current interface, clean up
|
62
166
|
#
|
167
|
+
# @return [String] iw command output
|
168
|
+
# @!macro work
|
63
169
|
work :delete_interface do |device|
|
64
170
|
CommandLine.new("iw", "dev :dev del", :dev => device.property.if_name).run
|
65
171
|
end
|
66
172
|
|
67
173
|
# Add interface to device
|
68
174
|
#
|
175
|
+
# @return [String] iw command output
|
176
|
+
# @!macro work
|
69
177
|
work :add_interface do |device, type|
|
70
178
|
CommandLine.new("iw", "phy :phy interface add :dev type :type",
|
71
179
|
:phy => device.property.phy,
|
@@ -75,6 +183,8 @@ module OmfRc::Util::Iw
|
|
75
183
|
|
76
184
|
# Set up or join a ibss network
|
77
185
|
#
|
186
|
+
# @return [String] iw command output
|
187
|
+
# @!macro work
|
78
188
|
work :join_ibss do |device|
|
79
189
|
CommandLine.new("iw", "dev :device ibss join :essid :frequency",
|
80
190
|
:device => device.property.if_name.to_s,
|
@@ -84,6 +194,10 @@ module OmfRc::Util::Iw
|
|
84
194
|
|
85
195
|
# Validate internal properties based on interface mode
|
86
196
|
#
|
197
|
+
# @raise [ArgumentError] if validation failed
|
198
|
+
#
|
199
|
+
# @return [nil]
|
200
|
+
# @!macro work
|
87
201
|
work :validate_iw_properties do |device|
|
88
202
|
raise ArgumentError, "Missing phyical device name" if device.property.phy.nil?
|
89
203
|
|
@@ -110,43 +224,5 @@ module OmfRc::Util::Iw
|
|
110
224
|
end
|
111
225
|
end
|
112
226
|
|
113
|
-
#
|
114
|
-
#
|
115
|
-
configure :mode do |device, value|
|
116
|
-
# capture value hash and store internally
|
117
|
-
device.property.update(value)
|
118
|
-
|
119
|
-
if device.property.phy && device.property.phy =~ /^%(\d+)%$/
|
120
|
-
wlan_phy_device = device.request_wlan_devices[$1.to_i]
|
121
|
-
if wlan_phy_device
|
122
|
-
device.property.phy = wlan_phy_device[:name]
|
123
|
-
else
|
124
|
-
raise ArgumentError, "Could not find your wifi device no #{$1.to_i}"
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
device.validate_iw_properties
|
129
|
-
|
130
|
-
device.delete_interface rescue logger.warn "Interface #{device.property.if_name} not found"
|
131
|
-
|
132
|
-
# TODO should just remove all interfaces from physical device, at least make it optional
|
133
|
-
|
134
|
-
case device.property.mode.to_sym
|
135
|
-
when :master
|
136
|
-
device.add_interface(:managed)
|
137
|
-
device.hostapd
|
138
|
-
when :managed
|
139
|
-
device.add_interface(:managed)
|
140
|
-
device.wpasup
|
141
|
-
when :adhoc
|
142
|
-
device.add_interface(:adhoc)
|
143
|
-
device.interface_up
|
144
|
-
device.join_ibss
|
145
|
-
when :monitor
|
146
|
-
device.add_interface(:monitor)
|
147
|
-
device.interface_up
|
148
|
-
end
|
149
|
-
|
150
|
-
device.configure_ip_addr(device.property.ip_addr) if device.property.ip_addr
|
151
|
-
end
|
227
|
+
# @!endgroup
|
152
228
|
end
|
data/lib/omf_rc/util/libvirt.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
#
|
2
7
|
# Copyright (c) 2012 National ICT Australia (NICTA), Australia
|
3
8
|
#
|
data/lib/omf_rc/util/mod.rb
CHANGED
@@ -1,17 +1,35 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'hashie'
|
2
7
|
require 'cocaine'
|
3
8
|
|
9
|
+
# Manage Linux modules
|
4
10
|
module OmfRc::Util::Mod
|
5
11
|
include OmfRc::ResourceProxyDSL
|
6
12
|
include Cocaine
|
7
13
|
include Hashie
|
14
|
+
# @!macro extend_dsl
|
8
15
|
|
16
|
+
# @!macro group_request
|
17
|
+
# @!macro request
|
18
|
+
# @!method request_modules
|
9
19
|
request :modules do
|
10
20
|
CommandLine.new('lsmod').run.split("\n").map do |v|
|
11
21
|
v.match(/^(\w+).+$/) && $1
|
12
22
|
end.compact.tap { |ary| ary.shift }
|
13
23
|
end
|
14
|
-
|
24
|
+
# @!endgroup
|
25
|
+
|
26
|
+
# @!macro group_configure
|
27
|
+
#
|
28
|
+
# Load additional modules
|
29
|
+
#
|
30
|
+
# @param value name of the module to load
|
31
|
+
# @!macro configure
|
32
|
+
# @!method configure_load_module
|
15
33
|
configure :load_module do |resource, value|
|
16
34
|
raise ArgumentError, "Please provide at least module name" if value.name.nil?
|
17
35
|
|
@@ -38,4 +56,5 @@ module OmfRc::Util::Mod
|
|
38
56
|
|
39
57
|
"#{value.name} loaded"
|
40
58
|
end
|
59
|
+
# @!endgroup
|
41
60
|
end
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'xmlrpc/client'
|
2
7
|
|
3
8
|
module OmfRc::Util::OpenflowTools
|
data/lib/omf_rc/util/package.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
# Package management utility, could be included in application resource proxy
|
2
7
|
#
|
3
8
|
module OmfRc::ResourceProxy::Package
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
#
|
2
7
|
# Copyright (c) 2012 National ICT Australia (NICTA), Australia
|
3
8
|
#
|
data/lib/omf_rc/util/sysfs.rb
CHANGED
@@ -1,6 +1,21 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
6
|
+
# Getting available hardware by browsing sysfs directories
|
1
7
|
module OmfRc::Util::Sysfs
|
2
8
|
include OmfRc::ResourceProxyDSL
|
9
|
+
# @!macro extend_dsl
|
3
10
|
|
11
|
+
# @!macro group_request
|
12
|
+
# @!macro request
|
13
|
+
# @!method request_devices
|
14
|
+
#
|
15
|
+
# @example Sample return value
|
16
|
+
# [
|
17
|
+
# { name: 'eth0', driver: 'e1000e', category: 'net', proxy: 'net' },
|
18
|
+
# { name: 'phy0', driver: 'iwlwifi', category: 'net', subcategory: 'wlan', proxy: 'wlan' } ]
|
4
19
|
request :devices do |resource|
|
5
20
|
devices = []
|
6
21
|
# Support net devices for now
|
@@ -18,16 +33,16 @@ module OmfRc::Util::Sysfs
|
|
18
33
|
File.exist?("#{v}/operstate") && File.open("#{v}/operstate") do |fo|
|
19
34
|
device[:op_state] = (fo.read || '').chomp
|
20
35
|
end
|
21
|
-
# Let's see if the interface is already up
|
36
|
+
# Let's see if the interface is already up
|
22
37
|
# NOTE: THIS MAY NOT BE ROBUST
|
23
38
|
s = `ifconfig #{File.basename(v)}`
|
24
39
|
unless s.empty?
|
25
40
|
if m = s.match(/inet addr:\s*([0-9.]+)/)
|
26
41
|
device[:ip4] = m[1]
|
27
|
-
end
|
42
|
+
end
|
28
43
|
if m = s.match(/inet6 addr:\s*([0-9a-f.:\/]+)/)
|
29
44
|
device[:ip6] = m[1]
|
30
|
-
end
|
45
|
+
end
|
31
46
|
end
|
32
47
|
devices << device
|
33
48
|
end
|
@@ -47,6 +62,11 @@ module OmfRc::Util::Sysfs
|
|
47
62
|
devices
|
48
63
|
end
|
49
64
|
|
65
|
+
# @!macro request
|
66
|
+
# @!method request_wlan_devices
|
67
|
+
#
|
68
|
+
# @example Sample return value
|
69
|
+
# [ { name: 'phy0', driver: 'iwlwifi', category: 'net', subcategory: 'wlan', proxy: 'wlan' } ]
|
50
70
|
request :wlan_devices do |resource|
|
51
71
|
resource.request_devices.find_all { |v| v[:proxy] == 'wlan' }
|
52
72
|
end
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
#
|
2
7
|
# Copyright (c) 2012 National ICT Australia (NICTA), Australia
|
3
8
|
#
|
data/lib/omf_rc/util/wpa.rb
CHANGED
@@ -1,18 +1,28 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'hashie'
|
2
7
|
require 'cocaine'
|
3
8
|
require 'tempfile'
|
4
9
|
|
10
|
+
# Manage WPA instances
|
5
11
|
module OmfRc::Util::Wpa
|
6
12
|
include OmfRc::ResourceProxyDSL
|
7
13
|
include Cocaine
|
14
|
+
# @!macro extend_dsl
|
8
15
|
|
16
|
+
# @!macro group_work
|
9
17
|
# Initialise wpa related conf and pid location
|
10
18
|
#
|
19
|
+
# @!method init_wpa_conf_pid
|
11
20
|
work :init_wpa_conf_pid do |device|
|
12
21
|
device.property.wpa_conf = Tempfile.new(["wpa.#{device.property.if_name}", ".conf"]).path
|
13
22
|
device.property.wpa_pid = Tempfile.new(["wpa.#{device.property.if_name}", ".pid"]).path
|
14
23
|
end
|
15
24
|
|
25
|
+
# @!method wpasup
|
16
26
|
work :wpasup do |device|
|
17
27
|
device.init_wpa_conf_pid
|
18
28
|
|
@@ -25,6 +35,7 @@ module OmfRc::Util::Wpa
|
|
25
35
|
:wpa_pid => device.property.wpa_pid).run
|
26
36
|
end
|
27
37
|
|
38
|
+
# @!method stop_wpa
|
28
39
|
work :stop_wpa do |device|
|
29
40
|
begin
|
30
41
|
File.open(device.property.wpa_pid,'r') do |f|
|
@@ -40,4 +51,5 @@ module OmfRc::Util::Wpa
|
|
40
51
|
logger.warn e.message
|
41
52
|
end
|
42
53
|
end
|
54
|
+
# @!endgroup
|
43
55
|
end
|
data/lib/omf_rc/version.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
module OmfRc
|
2
|
-
VERSION = "6.0.2
|
7
|
+
VERSION = "6.0.2"
|
3
8
|
end
|
data/lib/omf_rc.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'omf_common'
|
2
7
|
require 'omf_rc/version'
|
3
8
|
|
data/omf_rc.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency "em-minitest-spec", "~> 1.1.1"
|
26
26
|
s.add_development_dependency "pry"
|
27
27
|
s.add_development_dependency "simplecov"
|
28
|
-
s.add_runtime_dependency "omf_common", "~> 6.0.2
|
28
|
+
s.add_runtime_dependency "omf_common", "~> 6.0.2"
|
29
29
|
s.add_runtime_dependency "cocaine", "~> 0.3.0"
|
30
|
+
s.add_runtime_dependency "mocha"
|
30
31
|
end
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'test_helper'
|
2
7
|
require 'em/minitest/spec'
|
3
8
|
require 'omf_rc/deferred_process'
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'test_helper'
|
2
7
|
|
3
8
|
describe OmfRc::MessageProcessError do
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'test_helper'
|
2
7
|
require 'omf_rc/resource_factory'
|
3
8
|
|
@@ -10,17 +15,14 @@ describe OmfRc::ResourceFactory do
|
|
10
15
|
|
11
16
|
it "must have list of registered proxies and utilities" do
|
12
17
|
OmfRc::ResourceFactory.load_default_resource_proxies
|
13
|
-
OmfRc::ResourceFactory.proxy_list.must_include :
|
18
|
+
OmfRc::ResourceFactory.proxy_list.must_include :node
|
14
19
|
end
|
15
20
|
|
16
21
|
it "must be able to create new resource proxy" do
|
17
22
|
OmfCommon.stub :comm, @xmpp do
|
18
23
|
OmfRc::ResourceFactory.load_default_resource_proxies
|
19
|
-
|
20
|
-
|
21
|
-
mock.must_respond_to :request_nothing
|
22
|
-
mock.request_nothing.must_equal mock.uid
|
23
|
-
mock.must_respond_to :configure_nothing
|
24
|
+
node = OmfRc::ResourceFactory.create(:node)
|
25
|
+
node.must_be_kind_of OmfRc::ResourceProxy::AbstractResource
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|