omf_rc 6.0.0.pre.7 → 6.0.0.pre.8

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/bin/omf_rc CHANGED
@@ -35,12 +35,16 @@ begin
35
35
  opts.on("-d", "--debug", "Debug mode") do
36
36
  options[:debug] = true
37
37
  end
38
+
39
+ opts.on("-l LOG_FILE_DIR", "Write log file to this folder") do |file_dir|
40
+ options[:log_file_dir] = file_dir
41
+ end
38
42
  end
39
43
  rescue => e
40
44
  # Right now OML4R does not raise proper exceptions :(
41
45
  # OML4R requires --oml-noop to be set if we want to run without doing any
42
46
  # measurements... this is too restrictive here, we want to run without OML
43
- # if no OML parameters were set and this even if --oml-noop is not set.
47
+ # if no OML parameters were set and this even if --oml-noop is not set.
44
48
  if e.message.include?('OML4R: Missing values for parameters :expID ')
45
49
  puts "Warning: Missing some OML options to instrument this RC, so it will "+
46
50
  "run without instrumentation. (see --oml-help)"
@@ -60,6 +64,14 @@ end
60
64
  Logging.logger.root.level = :debug if options[:debug]
61
65
  Blather.logger = logger
62
66
 
67
+ if options[:log_file_dir] && File.exist?(options[:log_file_dir])
68
+ Logging.logger.root.add_appenders(
69
+ Logging.appenders.file(
70
+ "#{options[:log_file_dir]}/omf_rc.log",
71
+ :layout => Logging.layouts.pattern(:date_pattern => '%F %T %z',
72
+ :pattern => '[%d] %-5l %c: %m\n')))
73
+ end
74
+
63
75
  OmfRc::ResourceFactory.load_default_resource_proxies
64
76
 
65
77
  EM.run do
@@ -7,7 +7,7 @@ require 'hashie'
7
7
  # This MP is for measurements about messages published by the Resource Proxy
8
8
  class OmfRc::ResourceProxy::MPPublished < OML4R::MPBase
9
9
  name :proxy_published
10
- param :time, :type => :double # Time (s) when this message was published
10
+ param :time, :type => :double # Time (s) when this message was published
11
11
  param :uid, :type => :string # UID for this Resource Proxy
12
12
  param :topic, :type => :string # Pubsub topic to publish this message to
13
13
  param :msg_id, :type => :string # Unique ID this message
@@ -17,7 +17,7 @@ end
17
17
  # This MP is for measurements about messages received by the Resource Proxy
18
18
  class OmfRc::ResourceProxy::MPReceived < OML4R::MPBase
19
19
  name :proxy_received
20
- param :time, :type => :double # Time (s) when this message was received
20
+ param :time, :type => :double # Time (s) when this message was received
21
21
  param :uid, :type => :string # UID for this Resource Proxy
22
22
  param :topic, :type => :string # Pubsub topic where this message came from
23
23
  param :msg_id, :type => :string # Unique ID this message
@@ -45,7 +45,7 @@ class OmfRc::ResourceProxy::AbstractResource
45
45
  # @option opts [String] :password pubsub user password
46
46
  # @option opts [String] :server pubsub server domain
47
47
  # @option opts [String] :property A hash for keeping internal state
48
- # @option opts [hash] :instrument A hash for keeping instrumentation-related state
48
+ # @option opts [hash] :instrument A hash for keeping instrumentation-related state
49
49
  # @param [Comm] comm communicator instance, pass this to new resource proxy instance if want to use a common communicator instance.
50
50
  def initialize(type, opts = nil, comm = nil)
51
51
  @opts = Hashie::Mash.new(opts)
@@ -66,7 +66,12 @@ class OmfRc::ResourceProxy::AbstractResource
66
66
  @comm.create_topic(uid) do |s|
67
67
  # Creating topic failed, no point to continue; clean up and disconnect
68
68
  # Otherwise go subscribe to this pubsub topic
69
- s.error? ? disconnect : @comm.subscribe(uid)
69
+ if s.error?
70
+ warn "Could not create topic '#{uid}', will shutdown, trying to clean up old topics. Please start it again once it has been shutdown."
71
+ disconnect
72
+ else
73
+ @comm.subscribe(uid)
74
+ end
70
75
  end
71
76
  end
72
77
 
@@ -86,14 +91,18 @@ class OmfRc::ResourceProxy::AbstractResource
86
91
  # If method missing, try the property mash
87
92
  def method_missing(method_name, *args)
88
93
  if (method_name =~ /request_(.+)/)
89
- property.key?($1) ? property.send($1) : (raise OmfRc::UnknownPropertyError)
94
+ property.key?($1) ? property.send($1) : (raise OmfRc::UnknownPropertyError, method_name.to_s)
90
95
  elsif (method_name =~ /configure_(.+)/)
91
- property.key?($1) ? property.send("[]=", $1, *args) : (raise OmfRc::UnknownPropertyError)
96
+ property.key?($1) ? property.send("[]=", $1, *args) : (raise OmfRc::UnknownPropertyError, method_name.to_s)
92
97
  else
93
98
  super
94
99
  end
95
100
  end
96
101
 
102
+ def get_binding
103
+ binding
104
+ end
105
+
97
106
  # Connect to pubsub server
98
107
  def connect
99
108
  @comm.connect(opts.user, opts.password, opts.server)
@@ -101,17 +110,8 @@ class OmfRc::ResourceProxy::AbstractResource
101
110
 
102
111
  # Try to clean up pubsub topics, and wait for DISCONNECT_WAIT seconds, then shutdown event machine loop
103
112
  def disconnect
104
- @comm.affiliations do |a|
105
- my_pubsub_topics = a[:owner] ? a[:owner].size : 0
106
- if my_pubsub_topics > 0
107
- logger.info "Cleaning #{my_pubsub_topics} pubsub topic(s)"
108
- a[:owner].each { |topic| @comm.delete_topic(topic) }
109
- else
110
- logger.info "Disconnecting now"
111
- @comm.disconnect
112
- end
113
- end
114
- logger.info "Disconnecting in #{DISCONNECT_WAIT} seconds"
113
+ @comm.disconnect(delete_affiliations: true)
114
+ logger.info "Disconnecting #{hrn}(#{uid}) in #{DISCONNECT_WAIT} seconds"
115
115
  EM.add_timer(DISCONNECT_WAIT) do
116
116
  @comm.disconnect
117
117
  end
@@ -137,15 +137,19 @@ class OmfRc::ResourceProxy::AbstractResource
137
137
  #
138
138
  def release(resource_id)
139
139
  obj = children.find { |v| v.uid == resource_id }
140
- raise StandardError, "Resource #{resource_id} could not be found" if obj.nil?
140
+ if obj.nil?
141
+ warn "#{resource_id} does not belong to #{self.uid}(#{self.hrn})"
142
+ nil
143
+ else
144
+ # Release children resource recursively
145
+ obj.children.each do |c|
146
+ obj.release(c.uid)
147
+ end
148
+ obj.before_release if obj.respond_to? :before_release
141
149
 
142
- # Release children resource recursively
143
- obj.children.each do |c|
144
- obj.release(c.uid)
150
+ @comm.delete_topic(obj.uid)
151
+ children.delete(obj)
145
152
  end
146
- obj.before_release if obj.respond_to? :before_release
147
-
148
- children.delete(obj)
149
153
  end
150
154
 
151
155
  # Return a list of all properties can be requested and configured
@@ -168,6 +172,14 @@ class OmfRc::ResourceProxy::AbstractResource
168
172
  hrn
169
173
  end
170
174
 
175
+ alias_method :request_name, :request_hrn
176
+ alias_method :name, :hrn
177
+ alias_method :name=, :hrn=
178
+
179
+ def request_type(*args)
180
+ type
181
+ end
182
+
171
183
  # Make hrn configurable through pubsub interface
172
184
  def configure_hrn(hrn)
173
185
  @hrn = hrn
@@ -180,13 +192,27 @@ class OmfRc::ResourceProxy::AbstractResource
180
192
  # @param [Array] name of group topics
181
193
  def configure_membership(*args)
182
194
  new_membership = [args[0]].flatten
183
- @membership = new_membership
195
+ new_membership.each do |n_m|
196
+ @membership << n_m unless @membership.include?(n_m)
197
+ end
184
198
  @membership.each do |m|
185
- @comm.subscribe(m)
199
+ @comm.subscribe(m) do |stanza|
200
+ if stanza.error?
201
+ warn "Group #{m} disappeared"
202
+ EM.next_tick do
203
+ @membership.delete(m)
204
+ end
205
+ end
206
+ end
186
207
  end
187
208
  @membership
188
209
  end
189
210
 
211
+ # Query resource's membership
212
+ def request_membership(*args)
213
+ @membership
214
+ end
215
+
190
216
  # Request child resources
191
217
  # @return [Hashie::Mash] child resource mash with uid and hrn
192
218
  def request_child_resources(*args)
@@ -303,25 +329,36 @@ class OmfRc::ResourceProxy::AbstractResource
303
329
  begin
304
330
  default_response = {
305
331
  operation: message.operation,
306
- context_id: message.context_id,
332
+ context_id: message.msg_id,
307
333
  inform_to: inform_to_address(obj, message.publish_to)
308
334
  }
309
335
 
336
+ guard = message.read_element("guard").first
337
+
338
+ unless guard.nil? || guard.element_children.empty?
339
+ guard_check = guard.element_children.all? do |g|
340
+ obj.__send__("request_#{g.attr('key')}") == g.content.ducktype
341
+ end
342
+ next nil unless guard_check
343
+ end
344
+
310
345
  case message.operation
311
346
  when :create
312
- new_opts = opts.dup.merge(uid: nil)
347
+ new_name = message.read_property(:name) || message.read_property(:hrn)
348
+ new_opts = opts.dup.merge(uid: nil, hrn: new_name)
313
349
  new_obj = obj.create(message.read_property(:type), new_opts)
314
350
  message.each_property do |p|
315
- unless p.attr('key') == 'type'
351
+ unless %w(type hrn name).include?(p.attr('key'))
316
352
  method_name = "configure_#{p.attr('key')}"
317
- new_obj.__send__(method_name, message.read_property(p.attr('key')))
353
+ p_value = message.read_property(p.attr('key'), new_obj.get_binding)
354
+ new_obj.__send__(method_name, p_value)
318
355
  end
319
356
  end
320
357
  new_obj.after_initial_configured if new_obj.respond_to? :after_initial_configured
321
358
  default_response.merge(resource_id: new_obj.uid)
322
359
  when :request, :configure
323
360
  result = Hashie::Mash.new.tap do |mash|
324
- properties = message.read_element("//property")
361
+ properties = message.read_element("property")
325
362
  if message.operation == :request && properties.empty?
326
363
  obj.request_available_properties.request.each do |r_p|
327
364
  method_name = "request_#{r_p.to_s}"
@@ -330,14 +367,18 @@ class OmfRc::ResourceProxy::AbstractResource
330
367
  else
331
368
  properties.each do |p|
332
369
  method_name = "#{message.operation.to_s}_#{p.attr('key')}"
333
- mash[p.attr('key')] ||= obj.__send__(method_name, message.read_property(p.attr('key')))
370
+ p_value = message.read_property(p.attr('key'), obj.get_binding)
371
+ mash[p.attr('key')] ||= obj.__send__(method_name, p_value)
334
372
  end
335
373
  end
336
374
  end
375
+ # Always return uid
376
+ result.uid = obj.uid
337
377
  default_response.merge(status: result)
338
378
  when :release
339
379
  resource_id = message.resource_id
340
- default_response.merge(resource_id: obj.release(resource_id).uid)
380
+ released_obj = obj.release(resource_id)
381
+ released_obj ? default_response.merge(resource_id: released_obj.uid) : nil
341
382
  when :inform
342
383
  nil # We really don't care about inform messages which created from here
343
384
  else
@@ -348,8 +389,8 @@ class OmfRc::ResourceProxy::AbstractResource
348
389
  end
349
390
  rescue => e
350
391
  if (e.kind_of? OmfRc::UnknownPropertyError) && (message.operation == :configure || message.operation == :request)
351
- msg = "Cannot #{message.operation} unknown property "+
352
- "'#{message.read_element("//property")}' for resource '#{type}'"
392
+ msg = "Cannot #{message.operation} unknown property '#{e.message}' for resource '#{obj.type}'. Original message fragment: " +
393
+ "'#{message.read_element("property")}'"
353
394
  logger.warn msg
354
395
  raise OmfRc::MessageProcessError.new(message.context_id, inform_to_address(obj, message.publish_to), msg)
355
396
  else
@@ -20,7 +20,8 @@
20
20
  # THE SOFTWARE.
21
21
 
22
22
  #
23
- # This module defines a Resource Proxy (RP) for an Application
23
+ # This module defines a Resource Proxy (RP) for an Application.
24
+ # For a detailed usage tutorial see {file:doc/RESOURCE\_PROXY.mkd Resource Proxy tutorial}
24
25
  #
25
26
  # Utility dependencies: platform_toos, common_tools
26
27
  #
@@ -31,35 +32,35 @@
31
32
  # - pkg_ubuntu (String) the name of the Ubuntu package for this app
32
33
  # - pkg_fedora (String) the name of the Fedora package for this app
33
34
  # - state (String) the state of this Application RP
34
- # (stop, run, pause, install)
35
+ # (stop, run, pause, install)
35
36
  # - installed (Boolean) is this application installed? (default false)
36
37
  # - force_tarball_install (Boolean) if true then force the installation
37
- # from tarball even if other distribution-specific
38
- # installation are available (default false)
38
+ # from tarball even if other distribution-specific installation are
39
+ # available (default false)
39
40
  # - map_err_to_out (Boolean) if true then map StdErr to StdOut for this
40
- # app (default false)
41
+ # app (default false)
41
42
  # - platform (Symbol) the OS platform where this app is running
42
- # - environment (Hash) the environment variables to set prior to starting
43
- # this app. {k1 => v1, ...} will result in "env -i K1=v1 ... "
44
- # (with k1 being either a String or a Symbol)
43
+ # - environment (Hash) the environment variables to set prior to starting
44
+ # this app. { k1 => v1, ... } will result in "env -i K1=v1 ... "
45
+ # (with k1 being either a String or a Symbol)
45
46
  # - use_oml (Boolean) if true enable OML for this application (default false)
46
47
  # - oml_loglevel (Integer) set a specific OML log level (default unset)
47
48
  # - oml_logfile (String) set a specific path for OML log file (default unset)
48
49
  # - oml_configfile (String) path of the OML config file (optional)
49
- # - oml (Hash) OML specific properties (optional), this Hash contains the
50
- # following keys:
51
- # - :available_mps (Hash) list of available OML Measurement Points
50
+ # - oml (Hash) OML specific properties (optional), this Hash contains the
51
+ # following keys:
52
+ # - :available_mps (Array) list of available OML Measurement Points (Hash)
52
53
  # - :collection (Hash) list of required OML Measurement Stream to collect
53
- # when this application is running, as defined at
54
+ # when this application is running (defined in liboml2.conf manpage)
54
55
  # http://omf.mytestbed.net/doc/oml/html/liboml2.conf.html
55
56
  # - :experiment (String) name of the experiment in which this application
56
57
  # is running
57
58
  # - :id (String) OML id to use for this application when it is running
58
59
  # - parameters (Hash) the command line parameters available for this app.
59
- # This hash is of the form: { :param1 => attribut1, ... }
60
- # with param1 being the id of this parameter for this Proxy and
61
- # with attribut1 being another Hash with the following possible
62
- # keys and values (all are optional):
60
+ # This hash is of the form: { :param1 => attribut1, ... }
61
+ # with param1 being the id of this parameter for this Proxy and
62
+ # with attribut1 being another Hash with the following possible
63
+ # keys and values (all are optional):
63
64
  # :cmd (String) the command line for this parameter
64
65
  # :order (Fixnum) the appearance order on the command line, default FIFO
65
66
  # :dynamic (Boolean) parameter can be dynammically changed, default false
@@ -87,7 +88,7 @@
87
88
  # { :title => {:value => "My First Application"} }
88
89
  #
89
90
  module OmfRc::ResourceProxy::Application
90
- include OmfRc::ResourceProxyDSL
91
+ include OmfRc::ResourceProxyDSL
91
92
  require 'omf_common/exec_app'
92
93
 
93
94
  register_proxy :application
@@ -97,26 +98,28 @@ module OmfRc::ResourceProxy::Application
97
98
  MAX_PARAMETER_NUMBER = 1000
98
99
  DEFAULT_MANDATORY_PARAMETER = false
99
100
 
101
+ property :app_id, :default => nil
102
+ property :description, :default => ''
103
+ property :binary_path, :default => nil
104
+ property :platform, :default => nil
105
+ property :pkg_tarball, :default => nil
106
+ property :tarball_install_path, :default => '/'
107
+ property :force_tarball_install, :default => false
108
+ property :pkg_ubuntu, :default => nil
109
+ property :pkg_fedora, :default => nil
110
+ property :state, :default => :stop
111
+ property :installed, :default => false
112
+ property :map_err_to_out, :default => false
113
+ property :event_sequence, :default => 0
114
+ property :parameters, :default => Hash.new
115
+ property :environments, :default => Hash.new
116
+ property :use_oml, :default => false
117
+ property :oml_configfile, :default => nil
118
+ property :oml, :default => Hash.new
119
+ property :oml_logfile, :default => nil
120
+ property :oml_loglevel, :default => nil
121
+
100
122
  hook :before_ready do |res|
101
- res.property.app_id ||= nil
102
- res.property.binary_path ||= nil
103
- res.property.platform ||= nil
104
- res.property.pkg_tarball ||= nil
105
- res.property.tarball_install_path ||= '/'
106
- res.property.force_tarball_install ||= false
107
- res.property.pkg_ubuntu ||= nil
108
- res.property.pkg_fedora ||= nil
109
- res.property.state ||= :stop
110
- res.property.installed ||= false
111
- res.property.map_err_to_out ||= false
112
- res.property.event_sequence ||= 0
113
- res.property.parameters ||= Hash.new
114
- res.property.environments ||= Hash.new
115
- res.property.use_oml ||= false
116
- res.property.oml_configfile ||= nil
117
- res.property.oml ||= Hash.new
118
- res.property.oml_logfile ||= nil
119
- res.property.oml_loglevel ||= nil
120
123
  define_method("on_app_event") { |*args| process_event(self, *args) }
121
124
  end
122
125
 
@@ -135,19 +138,24 @@ module OmfRc::ResourceProxy::Application
135
138
  "(##{res.property.event_sequence}) - "+
136
139
  "#{event_type}: '#{msg}'"
137
140
  res.property.state = :stop if event_type.to_s.include?('DONE')
138
- res.comm.publish(res.uid,
139
- OmfCommon::Message.inform('STATUS') do |message|
140
- message.property('status_type' , 'APP_EVENT')
141
- message.property('event' , event_type.to_s.upcase)
142
- message.property('app' , app_id)
143
- message.property('msg' , "#{msg}")
144
- message.property('seq' , "#{res.property.event_sequence}")
145
- end)
141
+
142
+ (res.membership + [res.uid]).each do |m|
143
+ res.inform(:status, {
144
+ inform_to: m,
145
+ status: { status_type: 'APP_EVENT',
146
+ event: event_type.to_s.upcase,
147
+ app: app_id,
148
+ msg: msg,
149
+ seq: res.property.event_sequence,
150
+ uid: res.uid }
151
+ })
152
+ end
153
+
146
154
  res.property.event_sequence += 1
147
155
  res.property.installed = true if app_id.include?("_INSTALL") &&
148
156
  event_type.to_s.include?('DONE.OK')
149
157
  end
150
-
158
+
151
159
  # Request the platform property of this Application RP
152
160
  # @see OmfRc::ResourceProxy::Application
153
161
  #
@@ -156,7 +164,7 @@ module OmfRc::ResourceProxy::Application
156
164
  res.property.platform.to_s
157
165
  end
158
166
 
159
- # Configure the environments property of this Application RP
167
+ # Configure the environments and oml property of this Application RP
160
168
  # @see OmfRc::ResourceProxy::Application
161
169
  #
162
170
  %w(environments oml).each do |prop|
@@ -217,7 +225,7 @@ module OmfRc::ResourceProxy::Application
217
225
  # application instance is finished or paused. The Application RP can
218
226
  # only enter this state from a previous 'pause' or 'stop' state.
219
227
  # - pause: upon entering this state, the currently running instance of this
220
- # application should be paused (it is the responsibility of
228
+ # application should be paused (it is the responsibility of
221
229
  # specialised Application Proxy to ensure that! The default
222
230
  # Application Proxy does nothing to the application instance when
223
231
  # entering this state). The Application RP can only enter this
@@ -451,17 +459,28 @@ module OmfRc::ResourceProxy::Application
451
459
  # - if the 'oml_configfile' property is set with a filename, then we use that
452
460
  # file as the OML Configuration file. Thus we add the parameter
453
461
  # "--oml-config filename" to this application's command line
454
- # - if the 'oml' property is set with a Hash holding an OML configuration,
462
+ # - if the 'oml' property is set with a Hash holding an OML configuration,
455
463
  # then we write turn it into OML's XML configuration representation, write
456
- # it to a temporary file, and add the parameter "--oml-config tmpfile" to
457
- # this application's command line. The OML configuration hash is based
458
- # on the liboml2.conf man page here:
459
- # http://omf.mytestbed.net/doc/oml/latest/liboml2.conf.html
464
+ # it to a temporary file, and add the parameter "--oml-config tmpfile" to
465
+ # this application's command line. The OML configuration hash is based
466
+ # on the liboml2.conf man page, an example of which is:
467
+ # <omlc domain="my_experiment" id="my_source_id">
468
+ # <collect url="tcp://10.0.0.200">
469
+ # <stream mp="radiotap" interval="2">
470
+ # <filter field="sig_strength_dBm" />
471
+ # <filter field="noise_strength_dBm" />
472
+ # <filter field="power" />
473
+ # </stream>
474
+ # <stream mp="udp" samples="10">
475
+ # <filter field="udp_len" />
476
+ # </stream>
477
+ # </collect>
478
+ # </omlc>
460
479
  #
461
480
  # The 'oml_configfile' case takes precedence over the 'oml' case above.
462
481
  #
463
- # Regardless of which case is performed, we will always set the
464
- # '--oml-log-level' and '--oml-log-file' parameter on the command line if
482
+ # Regardless of which case is performed, we will always set the
483
+ # '--oml-log-level' and '--oml-log-file' parameter on the command line if
465
484
  # the corresponsding 'oml_logfile' and 'oml_loglevel' properties are set for
466
485
  # this application resource.
467
486
  #
@@ -490,16 +509,18 @@ module OmfRc::ResourceProxy::Application
490
509
  s = "interval='#{m.interval}'" if m.interval
491
510
  s = "samples='#{m.samples}'" if m.samples
492
511
  of << " <stream mp='#{m.mp}' #{s}>\n"
493
- m.filters.each do |f|
494
- line = " <filter field='#{f.field}' "
495
- line += "operation='#{f.operation}' " unless f.operation.nil?
496
- line += "rename='#{f.rename}' " unless f.rename.nil?
497
- line += "/>\n"
498
- of << line
512
+ unless m.filters.nil?
513
+ m.filters.each do |f|
514
+ line = " <filter field='#{f.field}' "
515
+ line += "operation='#{f.operation}' " unless f.operation.nil?
516
+ line += "rename='#{f.rename}' " unless f.rename.nil?
517
+ line += "/>\n"
518
+ of << line
519
+ end
499
520
  end
500
521
  of << " </stream>\n"
501
522
  end
502
- of << " </collect>\n"
523
+ of << " </collect>\n"
503
524
  end
504
525
  of << "</omlc>\n"
505
526
  of.close
@@ -4,4 +4,5 @@ module OmfRc::ResourceProxy::Net
4
4
  register_proxy :net
5
5
 
6
6
  utility :ip
7
+ utility :sysfs
7
8
  end
@@ -4,6 +4,7 @@ module OmfRc::ResourceProxy::Node
4
4
  register_proxy :node
5
5
 
6
6
  utility :mod
7
+ utility :sysfs
7
8
 
8
9
  request :proxies do
9
10
  OmfRc::ResourceFactory.proxy_list
@@ -21,35 +22,4 @@ module OmfRc::ResourceProxy::Node
21
22
  end.sort { |x, y| x[:name] <=> y[:name] }
22
23
  end
23
24
 
24
- request :devices do |resource|
25
- devices = []
26
- # Support net devices for now
27
- category = "net"
28
-
29
- Dir.glob("/sys/class/net/eth*").each do |v|
30
- File.exist?("#{v}/uevent") && File.open("#{v}/uevent") do |f|
31
- subcategory = f.read.match(/DEVTYPE=(.+)/) && $1
32
- proxy = "net"
33
- File.exist?("#{v}/device/uevent") && File.open("#{v}/device/uevent") do |f|
34
- driver = f.read.match(/DRIVER=(.+)/) && $1
35
- device = { name: File.basename(v), driver: driver, category: category }
36
- device[:subcategory] = subcategory if subcategory
37
- device[:proxy] = proxy if resource.request_proxies.include?(proxy.to_sym)
38
- devices << device
39
- end
40
- end
41
- end
42
-
43
- Dir.glob("/sys/class/ieee80211/*").each do |v|
44
- subcategory = "wlan"
45
- proxy = "wlan"
46
- File.exist?("#{v}/device/uevent") && File.open("#{v}/device/uevent") do |f|
47
- driver = f.read.match(/DRIVER=(.+)/) && $1
48
- device = { name: File.basename(v), driver: driver, category: category, subcategory: subcategory }
49
- device[:proxy] = proxy if resource.request_proxies.include?(proxy.to_sym)
50
- devices << device
51
- end
52
- end
53
- devices
54
- end
55
25
  end