omf_rc 6.0.0.pre.6 → 6.0.0.pre.7

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.
@@ -20,63 +20,77 @@
20
20
  # THE SOFTWARE.
21
21
 
22
22
  #
23
- # This module defines a Resource Proxy (RP) for a Generic Application
23
+ # This module defines a Resource Proxy (RP) for an Application
24
24
  #
25
25
  # Utility dependencies: platform_toos, common_tools
26
26
  #
27
- # This Generic Application Proxy has the following properties:
27
+ # This Application Proxy has the following properties:
28
28
  #
29
29
  # - binary_path (String) the path to the binary of this app
30
- # - pkg_tarball (String) the URI of the installation tarball of this app
30
+ # - pkg_tarball (String) the URI of the installation tarball of this app
31
31
  # - pkg_ubuntu (String) the name of the Ubuntu package for this app
32
32
  # - pkg_fedora (String) the name of the Fedora package for this app
33
- # - state (String) the state of this Application RP
33
+ # - state (String) the state of this Application RP
34
34
  # (stop, run, pause, install)
35
35
  # - installed (Boolean) is this application installed? (default false)
36
- # - force_tarball_install (Boolean) if true then force the installation
37
- # from tarball even if other distribution-specific
36
+ # - force_tarball_install (Boolean) if true then force the installation
37
+ # from tarball even if other distribution-specific
38
38
  # installation are available (default false)
39
- # - map_err_to_out (Boolean) if true then map StdErr to StdOut for this
39
+ # - map_err_to_out (Boolean) if true then map StdErr to StdOut for this
40
40
  # app (default false)
41
41
  # - platform (Symbol) the OS platform where this app is running
42
- #
43
42
  # - environment (Hash) the environment variables to set prior to starting
44
43
  # this app. {k1 => v1, ...} will result in "env -i K1=v1 ... "
45
44
  # (with k1 being either a String or a Symbol)
46
- #
45
+ # - use_oml (Boolean) if true enable OML for this application (default false)
46
+ # - oml_loglevel (Integer) set a specific OML log level (default unset)
47
+ # - oml_logfile (String) set a specific path for OML log file (default unset)
48
+ # - 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
52
+ # - :collection (Hash) list of required OML Measurement Stream to collect
53
+ # when this application is running, as defined at
54
+ # http://omf.mytestbed.net/doc/oml/html/liboml2.conf.html
55
+ # - :experiment (String) name of the experiment in which this application
56
+ # is running
57
+ # - :id (String) OML id to use for this application when it is running
47
58
  # - parameters (Hash) the command line parameters available for this app.
48
59
  # This hash is of the form: { :param1 => attribut1, ... }
49
60
  # with param1 being the id of this parameter for this Proxy and
50
61
  # with attribut1 being another Hash with the following possible
51
62
  # keys and values (all are optional):
52
- # :cmd (String) the command line for this parameter
53
- # :order (Fixnum) the appearance order on the command line, default FIFO
63
+ # :cmd (String) the command line for this parameter
64
+ # :order (Fixnum) the appearance order on the command line, default FIFO
54
65
  # :dynamic (Boolean) parameter can be dynammically changed, default false
55
66
  # :type (Numeric|String|Boolean) this parameter's type
56
- # :default value given by default to this parameter
67
+ # :default value given by default to this parameter
57
68
  # :value value to set for this parameter
58
69
  # :mandatory (Boolean) this parameter is mandatory, default false
59
70
  #
71
+ # Note: this application proxy will merge new Hash values for the properties
72
+ # environment, oml, and parameters properties with the old Hash values.
73
+ #
60
74
  # Two examples of valid parameters definition are:
61
75
  #
62
- # { :host => {:default => 'localhost', :type => 'String',
76
+ # { :host => {:default => 'localhost', :type => 'String',
63
77
  # :mandatory => true, :order => 2},
64
- # :port => {:default => 5000, :type => 'Numeric', :cmd => '-p',
65
- # :mandatory => true, :order => 1},
66
- # :size => {:default => 512, :type => 'Numeric', :cmd => '--pkt-size',
78
+ # :port => {:default => 5000, :type => 'Numeric', :cmd => '-p',
79
+ # :mandatory => true, :order => 1},
80
+ # :size => {:default => 512, :type => 'Numeric', :cmd => '--pkt-size',
67
81
  # :mandatory => true, :dynamic => true}
68
- # :title => {:type => 'String', :mandatory => false}
82
+ # :title => {:type => 'String', :mandatory => false}
69
83
  # }
70
- #
84
+ #
71
85
  # and
72
86
  #
73
- # { :title => {:value => "My First Application"} }
87
+ # { :title => {:value => "My First Application"} }
74
88
  #
75
- module OmfRc::ResourceProxy::GenericApplication
89
+ module OmfRc::ResourceProxy::Application
76
90
  include OmfRc::ResourceProxyDSL
77
91
  require 'omf_common/exec_app'
78
92
 
79
- register_proxy :generic_application
93
+ register_proxy :application
80
94
  utility :platform_tools
81
95
  utility :common_tools
82
96
 
@@ -84,27 +98,32 @@ module OmfRc::ResourceProxy::GenericApplication
84
98
  DEFAULT_MANDATORY_PARAMETER = false
85
99
 
86
100
  hook :before_ready do |res|
87
- res.property.app_id ||= nil
88
- res.property.binary_path ||= nil
89
- res.property.platform ||= nil
90
- res.property.pkg_tarball ||= nil
91
- res.property.tarball_install_path ||= '/'
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 ||= '/'
92
106
  res.property.force_tarball_install ||= false
93
- res.property.pkg_ubuntu ||= nil
94
- res.property.pkg_fedora ||= nil
95
- res.property.state ||= :stop
96
- res.property.installed ||= false
97
- res.property.map_err_to_out ||= false
98
- res.property.event_sequence ||= 0
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
99
113
  res.property.parameters ||= Hash.new
100
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
101
120
  define_method("on_app_event") { |*args| process_event(self, *args) }
102
121
  end
103
122
 
104
123
  # This method processes an event coming from the application instance, which
105
124
  # was started by this Resource Proxy (RP). It is a callback, which is usually
106
125
  # called by the ExecApp class in OMF
107
- #
126
+ #
108
127
  # @param [AbstractResource] res this RP
109
128
  # @param [String] event_type the type of event from the app instance
110
129
  # (STARTED, DONE.OK, DONE.ERROR, STDOUT, STDERR)
@@ -128,46 +147,32 @@ module OmfRc::ResourceProxy::GenericApplication
128
147
  res.property.installed = true if app_id.include?("_INSTALL") &&
129
148
  event_type.to_s.include?('DONE.OK')
130
149
  end
131
-
132
- # Request the basic properties of this Generic Application RP.
133
- # @see OmfRc::ResourceProxy::GenericApplication
134
- #
135
- %w(binary_path pkg_tarball pkg_ubuntu pkg_fedora state installed \
136
- force_tarball_install map_err_to_out tarball_install_path).each do |prop|
137
- request(prop) { |res| res.property[prop].to_s }
138
- end
139
150
 
140
- # Request the platform property of this Generic Application RP
141
- # @see OmfRc::ResourceProxy::GenericApplication
151
+ # Request the platform property of this Application RP
152
+ # @see OmfRc::ResourceProxy::Application
142
153
  #
143
154
  request :platform do |res|
144
155
  res.property.platform = detect_platform if res.property.platform.nil?
145
156
  res.property.platform.to_s
146
157
  end
147
158
 
148
- # Configure the basic properties of this Generic Application RP
149
- # @see OmfRc::ResourceProxy::GenericApplication
150
- #
151
- %w(binary_path pkg_tarball pkg_ubuntu pkg_fedora force_tarball_install \
152
- map_err_to_out tarball_install_path).each do |prop|
153
- configure(prop) { |res, value| res.property[prop] = value }
154
- end
155
-
156
- # Configure the environments property of this Generic Application RP
157
- # @see OmfRc::ResourceProxy::GenericApplication
159
+ # Configure the environments property of this Application RP
160
+ # @see OmfRc::ResourceProxy::Application
158
161
  #
159
- configure :environments do |res, envs|
160
- if envs.kind_of? Hash
161
- res.property.environments = res.property.environments.merge(envs)
162
- else
163
- res.log_inform_error "Environment configuration failed! "+
164
- "Environments not passed as Hash (#{envs.inspect})"
162
+ %w(environments oml).each do |prop|
163
+ configure(prop) do |res, value|
164
+ if value.kind_of? Hash
165
+ res.property[prop] = res.property[prop].merge(value)
166
+ else
167
+ res.log_inform_error "Configuration failed for '#{prop}'! "+
168
+ "Value not passed as Hash (#{value.inspect})"
169
+ end
170
+ res.property[prop]
165
171
  end
166
- res.property.environments
167
172
  end
168
173
 
169
- # Configure the parameters property of this Generic Application RP
170
- # @see OmfRc::ResourceProxy::GenericApplication
174
+ # Configure the parameters property of this Application RP
175
+ # @see OmfRc::ResourceProxy::Application
171
176
  #
172
177
  configure :parameters do |res, params|
173
178
  if params.kind_of? Hash
@@ -178,10 +183,9 @@ module OmfRc::ResourceProxy::GenericApplication
178
183
  v[:order] = MAX_PARAMETER_NUMBER if v[:order].nil?
179
184
  # if this param has no set mandatory field, assign it a default one
180
185
  v[:mandatory] = DEFAULT_MANDATORY_PARAMETER if v[:mandatory].nil?
181
- merged_val = res.property.parameters[p].nil? ? v : res.property.parameters[p].merge(v)
182
- new_val = res.sanitize_parameter(p,merged_val)
186
+ new_val = res.property.parameters[p].nil? ? v : res.property.parameters[p].merge(v)
183
187
  # only set this new parameter if it passes the type check
184
- if res.pass_type_checking?(new_val)
188
+ if res.pass_type_checking?(new_val)
185
189
  res.property.parameters[p] = new_val
186
190
  res.dynamic_parameter_update(p,new_val)
187
191
  else
@@ -202,32 +206,32 @@ module OmfRc::ResourceProxy::GenericApplication
202
206
  res.property.parameters[p]
203
207
  end
204
208
 
205
- # Configure the state of this Generic Application RP. The valid states are
209
+ # Configure the state of this Application RP. The valid states are
206
210
  # stop, run, pause, install. The semantic of each states are:
207
211
  #
208
- # - stop: the initial state for an Application RP, and the final state for
209
- # an applicaiton RP, for which the application instance finished
210
- # its execution or its installation
211
- # - run: upon entering in this state, a new instance of the application is
212
- # started, the Application RP stays in this state until the
213
- # application instance is finished or paused. The Application RP can
214
- # only enter this state from a previous 'pause' or 'stop' state.
212
+ # - stop: the initial state for an Application RP, and the final state for
213
+ # an applicaiton RP, for which the application instance finished
214
+ # its execution or its installation
215
+ # - run: upon entering in this state, a new instance of the application is
216
+ # started, the Application RP stays in this state until the
217
+ # application instance is finished or paused. The Application RP can
218
+ # only enter this state from a previous 'pause' or 'stop' state.
215
219
  # - pause: upon entering this state, the currently running instance of this
216
- # application should be paused (it is the responsibility of
217
- # specialised Application Proxy to ensure that! The default Generic
218
- # Application Proxy does nothing to the application instance when
219
- # entering this state). The Application RP can only enter this
220
- # state from a previous 'run' state.
220
+ # application should be paused (it is the responsibility of
221
+ # specialised Application Proxy to ensure that! The default
222
+ # Application Proxy does nothing to the application instance when
223
+ # entering this state). The Application RP can only enter this
224
+ # state from a previous 'run' state.
221
225
  # - install: upon entering in this state, a new installation of the
222
- # application will be performed by the Application RP, which will
223
- # stay in this state until the installation is finished. The
224
- # Application RP can only enter this state from a previous 'stop'
225
- # state, and can only enter a 'stop' state once the installation
226
- # is finished.
227
- # Supported install methods are: Tarball, Ubuntu, and Fedora
228
- #
226
+ # application will be performed by the Application RP, which will
227
+ # stay in this state until the installation is finished. The
228
+ # Application RP can only enter this state from a previous 'stop'
229
+ # state, and can only enter a 'stop' state once the installation
230
+ # is finished.
231
+ # Supported install methods are: Tarball, Ubuntu, and Fedora
232
+ #
229
233
  # @yieldparam [String] value the state to set this app into
230
- #
234
+ #
231
235
  configure :state do |res, value|
232
236
  case value.to_s.downcase.to_sym
233
237
  when :install then res.switch_to_install
@@ -249,19 +253,19 @@ module OmfRc::ResourceProxy::GenericApplication
249
253
  # Select the proper installation method based on the platform
250
254
  # and the value of 'force_tarball_install'
251
255
  res.property.state = :install
252
- if res.property.force_tarball_install ||
256
+ if res.property.force_tarball_install ||
253
257
  (res.property.platform == :unknown)
254
- installing = res.install_tarball(res.property.pkg_tarball,
258
+ installing = res.install_tarball(res.property.pkg_tarball,
255
259
  res.property.tarball_install_path)
256
- elsif res.property.platform == :ubuntu
260
+ elsif res.property.platform == :ubuntu
257
261
  installing = res.install_ubuntu(res.property.pkg_ubuntu)
258
- elsif res.property.platform == :fedora
262
+ elsif res.property.platform == :fedora
259
263
  installing = res.install_fedora(res.property.pkg_fedora)
260
264
  end
261
265
  res.property.state = :stop unless installing
262
266
  end
263
267
  else
264
- # cannot install as we are not stopped
268
+ # cannot install as we are not stopped
265
269
  res.log_inform_warn "Not in STOP state. Cannot switch to INSTALL state!"
266
270
  end
267
271
  end
@@ -298,15 +302,15 @@ module OmfRc::ResourceProxy::GenericApplication
298
302
  # (see the description of configure :state)
299
303
  #
300
304
  work('switch_to_run') do |res|
301
- if res.property.state == :stop
302
- # start a new instance of this app
303
- res.property.app_id = res.hrn.nil? ? res.uid : res.hrn
305
+ if res.property.state == :stop
306
+ # start a new instance of this app
307
+ res.property.app_id = res.hrn.nil? ? res.uid : res.hrn
304
308
  # we need at least a defined binary path to run an app...
305
309
  if res.property.binary_path.nil?
306
310
  res.log_inform_warn "Binary path not set! No Application to run!"
307
311
  else
308
- ExecApp.new(res.property.app_id, res,
309
- res.build_command_line,
312
+ ExecApp.new(res.property.app_id, res,
313
+ res.build_command_line,
310
314
  res.property.map_err_to_out)
311
315
  res.property.state = :run
312
316
  end
@@ -324,7 +328,7 @@ module OmfRc::ResourceProxy::GenericApplication
324
328
  # (see the description of configure :state)
325
329
  #
326
330
  work('switch_to_pause') do |res|
327
- if res.property.state == :run
331
+ if res.property.state == :run
328
332
  # pause this app
329
333
  res.property.state = :pause
330
334
  # do more things here...
@@ -336,7 +340,7 @@ module OmfRc::ResourceProxy::GenericApplication
336
340
  #
337
341
  # @yieldparam [String] name the parameter id as known by this app
338
342
  # @yieldparam [Hash] att the Hash holding the parameter's attributs
339
- # @see OmfRc::ResourceProxy::GenericApplication
343
+ # @see OmfRc::ResourceProxy::Application
340
344
  #
341
345
  work('dynamic_parameter_update') do |res,name,att|
342
346
  # Only update a parameter if it is dynamic and the application is running
@@ -351,44 +355,15 @@ module OmfRc::ResourceProxy::GenericApplication
351
355
  end
352
356
  end
353
357
 
354
- # First, convert any 'true' or 'false' strings from the :mandatory and
355
- # :dynamic attributs of a given parameter into TrueClass or FalseClass
356
- # instances.
357
- # Second, if that parameter is of a type Boolean, then perform the same
358
- # conversion on the assigned default and value of this parameter
359
- #
360
- # @yieldparam [String] name the parameter id as known by this app
361
- # @yieldparam [Hash] att the Hash holding the parameter's attributs
362
- #
363
- # [Hash] a copy of the input Hash with the above conversion performed in it
364
- #
365
- work('sanitize_parameter') do |res,name,att|
366
- begin
367
- if !att[:mandatory].nil? && !res.boolean?(att[:mandatory])
368
- att[:mandatory] = eval(att[:mandatory].downcase)
369
- end
370
- if !att[:dynamic].nil? && !res.boolean?(att[:dynamic])
371
- att[:dynamic] = eval(att[:dynamic].downcase)
372
- end
373
- if (att[:type] == 'Boolean')
374
- att[:value] = eval(att[:value].downcase) if !att[:value].nil? && !res.boolean?(att[:value])
375
- att[:default] = eval(att[:default].downcase) if !att[:default].nil? && !res.boolean?(att[:default])
376
- end
377
- rescue Exception => ex
378
- res.log_inform_error "Cannot sanitize the parameter '#{name}' (#{att.inspect})"
379
- end
380
- att
381
- end
382
-
383
- # Check if a requested value or default for a parameter has the same
358
+ # Check if a configured value or default for a parameter has the same
384
359
  # type as the type defined for that parameter
385
360
  # The checking procedure is as follows:
386
361
  # - first check if a type was set for this parameter, if not then return true
387
- # Thus if no type was defined for this parameter then return true
388
- # regardless of the type of the given value or default
362
+ # (thus if no type was defined for this parameter then return true
363
+ # regardless of the type of the given value or default)
389
364
  # - second check if a value is given, if so check if it has the same type as
390
365
  # the defined type, if so then return true, if not then return false.
391
- # - third if no value is given but a default is given, then perform the same
366
+ # - third if no value is given but a default is given, then perform the same
392
367
  # check as above but using the default in-place of the value
393
368
  #
394
369
  # @yieldparam [Hash] att the Hash holding the parameter's attributs
@@ -404,11 +379,11 @@ module OmfRc::ResourceProxy::GenericApplication
404
379
  elsif att[:default].nil? && att[:value].nil?
405
380
  passed = true
406
381
  elsif att[:default].nil?
407
- passed = true if res.boolean?(att[:value])
382
+ passed = true if res.boolean?(att[:value])
408
383
  elsif att[:value].nil?
409
- passed = true if res.boolean?(att[:default])
384
+ passed = true if res.boolean?(att[:default])
410
385
  end
411
- else # HACK: Now for all other types...
386
+ else # Now for all other types...
412
387
  klass = Module.const_get(att[:type].capitalize.to_sym)
413
388
  if !att[:default].nil? && !att[:value].nil?
414
389
  passed = true if att[:default].kind_of?(klass) && att[:value].kind_of?(klass)
@@ -426,13 +401,15 @@ module OmfRc::ResourceProxy::GenericApplication
426
401
  passed
427
402
  end
428
403
 
429
- # Build the command line, which will be used to start this app
404
+ # Build the command line, which will be used to start this app.
405
+ #
430
406
  # This command line will be of the form:
431
- # "env -i VAR1=value1 ... application_path parameterA valueA ..."
407
+ # "env -i VAR1=value1 ... application_path parameterA valueA ..."
432
408
  #
433
- # The environment variables and the parameters in that command line are
409
+ # The environment variables and the parameters in that command line are
434
410
  # taken respectively from the 'environments' and 'parameters' properties of
435
- # this Generic Application Resource Proxy.
411
+ # this Application Resource Proxy. If the 'use_oml' property is set, then
412
+ # add to the command line the necessary oml parameters.
436
413
  #
437
414
  # [String] the full command line
438
415
  #
@@ -449,13 +426,12 @@ module OmfRc::ResourceProxy::GenericApplication
449
426
  needed = false
450
427
  needed = att[:mandatory] if res.boolean?(att[:mandatory])
451
428
  # For mandatory parameter without a value, take the default one
452
- val = att[:value]
453
- val = att[:default] if needed && att[:value].nil?
429
+ val = (needed && att[:value].nil?) ? att[:default] : att[:value]
454
430
  # Finally add the parameter if is value/default is not nil
455
431
  unless val.nil?
456
432
  if att[:type] == "Boolean"
457
- # for Boolean param, only the command is printed if value==true
458
- cmd_line += "#{att[:cmd]} " if val == true
433
+ # for Boolean param, only the command is printed if value==true
434
+ cmd_line += "#{att[:cmd]} " if val == true
459
435
  else
460
436
  # for all other type of param, we print "cmd value"
461
437
  # with a user-provided prefix/suffix if defined
@@ -465,7 +441,78 @@ module OmfRc::ResourceProxy::GenericApplication
465
441
  end
466
442
  end
467
443
  end
444
+ # Add OML parameters if required
445
+ cmd_line = res.build_oml_config(cmd_line) if res.property.use_oml
468
446
  cmd_line
469
447
  end
470
448
 
449
+ # Add the required OML parameter to the command line for this application
450
+ #
451
+ # - if the 'oml_configfile' property is set with a filename, then we use that
452
+ # file as the OML Configuration file. Thus we add the parameter
453
+ # "--oml-config filename" to this application's command line
454
+ # - if the 'oml' property is set with a Hash holding an OML configuration,
455
+ # 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
460
+ #
461
+ # The 'oml_configfile' case takes precedence over the 'oml' case above.
462
+ #
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
465
+ # the corresponsding 'oml_logfile' and 'oml_loglevel' properties are set for
466
+ # this application resource.
467
+ #
468
+ # @yieldparam [String] cmd the String to which OML parameters will be added
469
+ #
470
+ # [String] the resulting command line
471
+ #
472
+ work('build_oml_config') do |res, cmd|
473
+ if !res.property.oml_configfile.nil?
474
+ if File.exist?(res.property.oml_configfile)
475
+ cmd += "--oml-config #{res.property.oml_configfile} "
476
+ else
477
+ res.log_inform_warn "OML enabled but OML config file does not exist"+
478
+ "(file: '#{res.property.oml_configfile}')"
479
+ end
480
+ elsif !res.property.oml.collection.nil?
481
+ o = res.property.oml
482
+ ofile = "/tmp/#{res.uid}-#{Time.now.to_i}.xml"
483
+ of = File.open(ofile,'w')
484
+ of << "<omlc experiment='#{o.experiment}' id='#{o.id}'>\n"
485
+ o.collection.each do |c|
486
+ of << " <collect url='#{c.url}'>\n"
487
+ c.streams.each do |m|
488
+ # samples as precedence over interval
489
+ s = ''
490
+ s = "interval='#{m.interval}'" if m.interval
491
+ s = "samples='#{m.samples}'" if m.samples
492
+ 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
499
+ end
500
+ of << " </stream>\n"
501
+ end
502
+ of << " </collect>\n"
503
+ end
504
+ of << "</omlc>\n"
505
+ of.close
506
+ cmd += "--oml-config #{ofile}"
507
+ else
508
+ res.log_inform_warn "OML enabled but no OML configuration was given"+
509
+ "(file: '#{res.property.oml_configfile}' - "+
510
+ "config: '#{res.property.oml.inspect}')"
511
+ end
512
+ cmd += "--oml-log-level #{res.property.oml_loglevel} " unless res.property.oml_loglevel.nil?
513
+ cmd += "--oml-log-file #{res.property.oml_logfile} " unless res.property.oml_logfile.nil?
514
+ cmd
515
+ end
516
+
517
+
471
518
  end
@@ -3,41 +3,53 @@ module OmfRc::ResourceProxy::Node
3
3
 
4
4
  register_proxy :node
5
5
 
6
+ utility :mod
7
+
6
8
  request :proxies do
7
9
  OmfRc::ResourceFactory.proxy_list
8
10
  end
9
11
 
12
+ request :interfaces do |node|
13
+ node.children.find_all { |v| v.type == 'net' || v.type == 'wlan' }.map do |v|
14
+ { name: v.hrn, type: v.type, uid: v.uid }
15
+ end.sort { |x, y| x[:name] <=> y[:name] }
16
+ end
17
+
18
+ request :applications do |node|
19
+ node.children.find_all { |v| v.type =~ /application/ }.map do |v|
20
+ { name: v.hrn, type: v.type, uid: v.uid }
21
+ end.sort { |x, y| x[:name] <=> y[:name] }
22
+ end
23
+
10
24
  request :devices do |resource|
11
25
  devices = []
12
- Dir.chdir("/sys/class") do
13
- # Support net devices for now
14
- category = "net"
15
-
16
- Dir.glob("net/eth*").each do |v|
17
- File.exist?("#{v}/uevent") && File.open("#{v}/uevent") do |f|
18
- subcategory = f.read.match(/DEVTYPE=(.+)/) && $1
19
- proxy = "net"
20
- File.exist?("#{v}/device/uevent") && File.open("#{v}/device/uevent") do |f|
21
- driver = f.read.match(/DRIVER=(.+)/) && $1
22
- device = { name: File.basename(v), driver: driver, category: category }
23
- device[:subcategory] = subcategory if subcategory
24
- device[:proxy] = proxy if resource.request_proxies.include?(proxy.to_sym)
25
- devices << device
26
- end
27
- end
28
- end
26
+ # Support net devices for now
27
+ category = "net"
29
28
 
30
- Dir.glob("ieee80211/*").each do |v|
31
- subcategory = "wlan"
32
- proxy = "wlan"
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
33
  File.exist?("#{v}/device/uevent") && File.open("#{v}/device/uevent") do |f|
34
34
  driver = f.read.match(/DRIVER=(.+)/) && $1
35
- device = { name: File.basename(v), driver: driver, category: category, subcategory: subcategory }
35
+ device = { name: File.basename(v), driver: driver, category: category }
36
+ device[:subcategory] = subcategory if subcategory
36
37
  device[:proxy] = proxy if resource.request_proxies.include?(proxy.to_sym)
37
38
  devices << device
38
39
  end
39
40
  end
40
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
41
53
  devices
42
54
  end
43
55
  end