omf_rc 6.2.0 → 6.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/omf_rc/resource_proxy/abstract_resource.rb +1 -1
- data/lib/omf_rc/util/hostapd.rb +8 -7
- data/lib/omf_rc/util/ip.rb +16 -11
- data/lib/omf_rc/util/iw.rb +15 -12
- data/lib/omf_rc/util/mod.rb +5 -3
- data/lib/omf_rc/util/wpa.rb +8 -7
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzY2ZTVhMmQ0NjQ0MDBmNjAxYjM1OTc0NWIyZDJlZjI0MzI0MGM5ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTZlZDIxMTE0OTVjYmZhNzQ1ZGFlNmU0YmRmOTNjZTI5YjI2ZGNjMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Mjg5OTdkYzVhNTNiNzRiNTEwN2EyYjhmNjVjOGI3ZWM1ZjFkOTNmOWYxM2I1
|
10
|
+
NGVhNDdiYWExNThlNjVhOWYyMmIxNTYyMjM5YjUzMmNlODU4YjE3Y2RkYzgw
|
11
|
+
NTI2Y2VhYzljNDJmZmU3NzdiNjRiMmQ5YmU1OGY5MWQ3YWUwZmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWM5MTJhNjJjODlkNGY5MTc4ZmEzNzlmNzc1ZDRkZDdmNjlmMzYxN2QzNGU2
|
14
|
+
YTljM2NiNzRiMzM4YjUwYzFkMDJiOWY4NDVjNThhMDU3ZDFmZDgxZTVmZDFm
|
15
|
+
MWMwNzUwZDgxMTljNzEyNWYxMjhkNDIzNDMyNGUyZjM0M2U5NGE=
|
@@ -184,7 +184,7 @@ class OmfRc::ResourceProxy::AbstractResource
|
|
184
184
|
creation_callback.call(self) if creation_callback
|
185
185
|
rescue => e
|
186
186
|
error "Encountered exception: #{e.message}, returning ERROR message"
|
187
|
-
|
187
|
+
error e.backtrace.join("\n")
|
188
188
|
t.inform(:creation_failed,
|
189
189
|
{ reason: e.message },
|
190
190
|
{ src: self.resource_address })
|
data/lib/omf_rc/util/hostapd.rb
CHANGED
@@ -41,9 +41,9 @@ module OmfRc::Util::Hostapd
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
CommandLine.new("hostapd", "-B -P :ap_pid :ap_conf"
|
45
|
-
|
46
|
-
|
44
|
+
c=CommandLine.new("hostapd", "-B -P :ap_pid :ap_conf")
|
45
|
+
c.run({ :ap_pid => device.property.ap_pid,
|
46
|
+
:ap_conf => device.property.ap_conf })
|
47
47
|
end
|
48
48
|
|
49
49
|
# @!method stop_hostapd
|
@@ -51,12 +51,13 @@ module OmfRc::Util::Hostapd
|
|
51
51
|
begin
|
52
52
|
File.open(device.property.ap_pid,'r') do |f|
|
53
53
|
logger.debug "Stopping hostapd process at PID: #{device.property.ap_pid}"
|
54
|
-
CommandLine.new("kill", "-9 :pid"
|
54
|
+
c1=CommandLine.new("kill", "-9 :pid")
|
55
|
+
c1.run({ :pid => f.read.chomp })
|
55
56
|
end
|
56
57
|
|
57
|
-
CommandLine.new("rm", "-f :ap_pid :ap_conf"
|
58
|
-
|
59
|
-
:ap_conf => device.property.ap_conf)
|
58
|
+
c2=CommandLine.new("rm", "-f :ap_pid :ap_conf")
|
59
|
+
c2.run({ :ap_pid => device.property.ap_pid,
|
60
|
+
:ap_conf => device.property.ap_conf})
|
60
61
|
rescue => e
|
61
62
|
logger.warn "Failed to clean hostapd and its related files '#{device.property.ap_pid}' and '#{device.property.ap_conf}'!"
|
62
63
|
logger.warn e.message
|
data/lib/omf_rc/util/ip.rb
CHANGED
@@ -18,7 +18,8 @@ module OmfRc::Util::Ip
|
|
18
18
|
# @!macro request
|
19
19
|
# @!method request_ip_addr
|
20
20
|
request :ip_addr do |resource|
|
21
|
-
|
21
|
+
c = CommandLine.new("ip", "addr show dev :device")
|
22
|
+
addr = c.run( { :device => resource.property.if_name })
|
22
23
|
addr && addr.chomp.match(/inet ([[0-9]\:\/\.]+)/) && $1
|
23
24
|
end
|
24
25
|
|
@@ -28,12 +29,14 @@ module OmfRc::Util::Ip
|
|
28
29
|
# @!macro request
|
29
30
|
# @!method request_mac_addr
|
30
31
|
request :mac_addr do |resource|
|
31
|
-
|
32
|
+
c = CommandLine.new("ip", "addr show dev :device")
|
33
|
+
addr = c.run( { :device => resource.property.if_name })
|
32
34
|
addr && addr.chomp.match(/link\/ether ([\d[a-f][A-F]\:]+)/) && $1
|
33
35
|
end
|
34
36
|
|
35
37
|
request :state do |device|
|
36
|
-
|
38
|
+
c = CommandLine.new("ip", "link show :device")
|
39
|
+
link = c.run({ :device => device.property.if_name })
|
37
40
|
link && link.chomp.match(/state (\w+) /) && $1
|
38
41
|
end
|
39
42
|
|
@@ -55,10 +58,10 @@ module OmfRc::Util::Ip
|
|
55
58
|
end
|
56
59
|
# Remove all ip addrs associated with the device
|
57
60
|
resource.flush_ip_addrs
|
58
|
-
CommandLine.new("ip", "addr add :ip_address dev :device"
|
59
|
-
|
60
|
-
|
61
|
-
|
61
|
+
c=CommandLine.new("ip", "addr add :ip_address dev :device")
|
62
|
+
c.run({ :ip_address => value,
|
63
|
+
:device => resource.property.if_name })
|
64
|
+
|
62
65
|
resource.interface_up
|
63
66
|
resource.request_ip_addr
|
64
67
|
end
|
@@ -69,11 +72,13 @@ module OmfRc::Util::Ip
|
|
69
72
|
# @!macro work
|
70
73
|
# @!method interface_up
|
71
74
|
work :interface_up do |resource|
|
72
|
-
CommandLine.new("ip", "link set :dev up"
|
75
|
+
c=CommandLine.new("ip", "link set :dev up")
|
76
|
+
c.run({ :dev => resource.property.if_name })
|
73
77
|
end
|
74
78
|
|
75
79
|
work :interface_down do |device|
|
76
|
-
CommandLine.new("ip", "link set :dev down"
|
80
|
+
c=CommandLine.new("ip", "link set :dev down")
|
81
|
+
c.run({ :dev => device.property.if_name })
|
77
82
|
end
|
78
83
|
|
79
84
|
# Remove IP addresses associated with the interface
|
@@ -81,8 +86,8 @@ module OmfRc::Util::Ip
|
|
81
86
|
# @!macro work
|
82
87
|
# @!method flush_ip_addrs
|
83
88
|
work :flush_ip_addrs do |resource|
|
84
|
-
CommandLine.new("ip", "addr flush dev :device"
|
85
|
-
|
89
|
+
c=CommandLine.new("ip", "addr flush dev :device")
|
90
|
+
c.run({ :device => resource.property.if_name })
|
86
91
|
end
|
87
92
|
# @!endgroup
|
88
93
|
end
|
data/lib/omf_rc/util/iw.rb
CHANGED
@@ -28,10 +28,10 @@ module OmfRc::Util::Iw
|
|
28
28
|
CommandLine.new("iw", "help").run.chomp.gsub(/^\t/, '').split("\n").map {|v| v.match(/[phy|dev] <.+> set (\w+) .*/) && $1 }.compact.uniq.each do |p|
|
29
29
|
next if p == 'type'
|
30
30
|
configure p do |device, value|
|
31
|
-
CommandLine.new("iw", "dev :dev set :property :value"
|
32
|
-
|
31
|
+
c=CommandLine.new("iw", "dev :dev set :property :value")
|
32
|
+
c.run ({ :dev => device.property.if_name,
|
33
33
|
:property => p,
|
34
|
-
:value => value)
|
34
|
+
:value => value })
|
35
35
|
end
|
36
36
|
end
|
37
37
|
rescue Cocaine::CommandNotFoundError
|
@@ -53,9 +53,9 @@ module OmfRc::Util::Iw
|
|
53
53
|
request :link do |device|
|
54
54
|
known_properties = Mash.new
|
55
55
|
|
56
|
-
command = CommandLine.new("iw", "dev :dev link"
|
56
|
+
command = CommandLine.new("iw", "dev :dev link")
|
57
57
|
|
58
|
-
command.run.chomp.gsub(/^\t/, '').split("\n").drop(1).each do |v|
|
58
|
+
command.run({ :dev => device.property.if_name }).chomp.gsub(/^\t/, '').split("\n").drop(1).each do |v|
|
59
59
|
v.match(/^(.+):\W*(.+)$/).tap do |m|
|
60
60
|
m && known_properties[m[1].downcase.gsub(/\W+/, '_')] = m[2].gsub(/^\W+/, '')
|
61
61
|
end
|
@@ -76,9 +76,9 @@ module OmfRc::Util::Iw
|
|
76
76
|
request :info do |device|
|
77
77
|
known_properties = Mash.new
|
78
78
|
|
79
|
-
command = CommandLine.new("iw", "dev :dev info"
|
79
|
+
command = CommandLine.new("iw", "dev :dev info")
|
80
80
|
|
81
|
-
command.run.chomp.split("\n").drop(1).each do |v|
|
81
|
+
command.run({ :dev => device.property.if_name }).chomp.split("\n").drop(1).each do |v|
|
82
82
|
v.match(/^\W*(.+) (.+)$/).tap do |m|
|
83
83
|
m && known_properties[m[1].downcase.gsub(/\W+/, '_')] = m[2].gsub(/^\W+/, '')
|
84
84
|
end
|
@@ -167,7 +167,8 @@ module OmfRc::Util::Iw
|
|
167
167
|
# @return [String] iw command output
|
168
168
|
# @!macro work
|
169
169
|
work :delete_interface do |device|
|
170
|
-
CommandLine.new("iw", "dev :dev del"
|
170
|
+
c=CommandLine.new("iw", "dev :dev del")
|
171
|
+
c.run({ :dev => device.property.if_name })
|
171
172
|
end
|
172
173
|
|
173
174
|
# Add interface to device
|
@@ -175,10 +176,11 @@ module OmfRc::Util::Iw
|
|
175
176
|
# @return [String] iw command output
|
176
177
|
# @!macro work
|
177
178
|
work :add_interface do |device, type|
|
178
|
-
CommandLine.new("iw", "phy :phy interface add :dev type :type"
|
179
|
+
c=CommandLine.new("iw", "phy :phy interface add :dev type :type")
|
180
|
+
c.run( {
|
179
181
|
:phy => device.property.phy,
|
180
182
|
:dev => device.property.if_name,
|
181
|
-
:type => type.to_s)
|
183
|
+
:type => type.to_s })
|
182
184
|
end
|
183
185
|
|
184
186
|
# Set up or join a ibss network
|
@@ -186,10 +188,11 @@ module OmfRc::Util::Iw
|
|
186
188
|
# @return [String] iw command output
|
187
189
|
# @!macro work
|
188
190
|
work :join_ibss do |device|
|
189
|
-
CommandLine.new("iw", "dev :device ibss join :essid :frequency"
|
191
|
+
c=CommandLine.new("iw", "dev :device ibss join :essid :frequency")
|
192
|
+
c.run( {
|
190
193
|
:device => device.property.if_name.to_s,
|
191
194
|
:essid => device.property.essid.to_s,
|
192
|
-
:frequency => device.property.frequency.to_s)
|
195
|
+
:frequency => device.property.frequency.to_s })
|
193
196
|
end
|
194
197
|
|
195
198
|
# Validate internal properties based on interface mode
|
data/lib/omf_rc/util/mod.rb
CHANGED
@@ -48,13 +48,15 @@ module OmfRc::Util::Mod
|
|
48
48
|
end
|
49
49
|
|
50
50
|
if value.unload
|
51
|
-
CommandLine.new("modprobe", "-r :mod_names"
|
51
|
+
c=CommandLine.new("modprobe", "-r :mod_names")
|
52
|
+
c.run({ :mod_names => [value.unload].flatten.join(' ') })
|
52
53
|
end
|
53
54
|
|
54
|
-
CommandLine.new("modprobe", ":flags :mod_name :module_parameters"
|
55
|
+
c=CommandLine.new("modprobe", ":flags :mod_name :module_parameters")
|
56
|
+
c.run({
|
55
57
|
:mod_name => value.name.to_s,
|
56
58
|
:flags => flags_string,
|
57
|
-
:module_parameters => value.mod_params.to_s)
|
59
|
+
:module_parameters => value.mod_params.to_s })
|
58
60
|
|
59
61
|
"#{value.name} loaded"
|
60
62
|
end
|
data/lib/omf_rc/util/wpa.rb
CHANGED
@@ -29,10 +29,10 @@ module OmfRc::Util::Wpa
|
|
29
29
|
File.open(device.property.wpa_conf, "w") do |f|
|
30
30
|
f << "network={\n ssid=\"#{device.property.essid}\"\n scan_ssid=1\n key_mgmt=NONE\n}"
|
31
31
|
end
|
32
|
-
CommandLine.new("wpa_supplicant", "-B -P :wpa_pid -i:dev -c:wpa_conf"
|
33
|
-
|
32
|
+
c=CommandLine.new("wpa_supplicant", "-B -P :wpa_pid -i:dev -c:wpa_conf")
|
33
|
+
c.run({ :dev => device.property.if_name,
|
34
34
|
:wpa_conf => device.property.wpa_conf,
|
35
|
-
:wpa_pid => device.property.wpa_pid)
|
35
|
+
:wpa_pid => device.property.wpa_pid })
|
36
36
|
end
|
37
37
|
|
38
38
|
# @!method stop_wpa
|
@@ -40,12 +40,13 @@ module OmfRc::Util::Wpa
|
|
40
40
|
begin
|
41
41
|
File.open(device.property.wpa_pid,'r') do |f|
|
42
42
|
info "Stopping wpa supplicant at PID: #{device.property.wpa_pid}"
|
43
|
-
CommandLine.new("kill", "-9 :pid"
|
43
|
+
c1=CommandLine.new("kill", "-9 :pid")
|
44
|
+
c1.run({ :pid => f.read.chomp })
|
44
45
|
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
:wpa_conf => device.property.wpa_conf)
|
47
|
+
c2=CommandLine.new("rm", "-f :wpa_pid :wpa_conf")
|
48
|
+
c2.run({ :wpa_pid => device.property.wpa_pid,
|
49
|
+
:wpa_conf => device.property.wpa_conf })
|
49
50
|
rescue => e
|
50
51
|
logger.warn "Failed to clean wpa supplicant and its related files '#{device.property.wpa_pid}' and '#{device.property.wpa_conf}'!"
|
51
52
|
logger.warn e.message
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omf_rc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.2.
|
4
|
+
version: 6.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NICTA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 6.2.
|
75
|
+
version: 6.2.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 6.2.
|
82
|
+
version: 6.2.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: cocaine
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|