omf_ec 6.0.8.pre.1 → 6.0.8.pre.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmRmNjg3NjEwYzNkMWJlODQ3MWYyYTMzYmUwYzc1YWRkZjhmMWZiNg==
4
+ MWEyOGNkMWYxODcyY2Q0MDUxN2QxYWNhMWMyZTYyNWNiMzdlZGYzOA==
5
5
  data.tar.gz: !binary |-
6
- ZjgxMTE4NGZhODc1NGEzNWJlNDgwMjM3NTIxN2EwMGViZjQ2M2NmNw==
6
+ NWQ4MzQ5NjY2MWYxNGVjZTMzZWFmNzliY2ViNjAzMmYwMzlkZWRkZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZWFlMjZmZjdlOWM5M2QzYzhiZDE2NzNmN2M5ZDY1ZDMyNjNkMjdjZDRhZmQ4
10
- Y2NiM2U3OWE5YjQ2OTkzM2I1ZjgzZjg5YzJmMzhhNTc5MjcwNWU2ZjYwYWQ2
11
- YTgwYmIwOWM5ZDUyYTI1ZmVhMmI1YTA1MzYzYTBjM2IxZWM2MDY=
9
+ Y2MzYmFjMmM3MDZmNWQ4OTk4Y2JlYTYwYWFiOGQ3ODk5YzUzNzhiZGIxMjIx
10
+ ZWNhODM0MmFjMmU3ZTNhMmM3ZTY3YzNhYTVjZjdkMWQ5MGYzYzdlN2NhMGM4
11
+ NWNkOGZlZWM3ZWZmM2ZlYTk5MTEzNmRhOWIwYmZmODMwMjk0YzU=
12
12
  data.tar.gz: !binary |-
13
- YmNhZGJmMzZkYTNlZjkxZTI4YTdmYmVmNTgyZTg1YWQwOTQ2ZmIzZGVjMDdk
14
- N2Y5NTlmNDM0N2FkYmU1ODM1YmU2ZGU5MmNkNjUxYWU4M2JhYTAwNzc1NWQz
15
- NDNhMDI4ZWQwZjFmNWEwMzdiNTBhYzA5M2M3ZWFjZmQ1MDI3MzY=
13
+ ZmE5N2VkOWJmM2Y5NzExOGVmN2M0YzFlY2FkN2E5ZTVmMTUzNjMyMzJkNmYx
14
+ YWIxM2JhOTZhNDAzZjhlOTc0MGYzNzBlMGQ0ZjE5ZTZlM2MzOWMxYzNhYzdj
15
+ N2MyOWEzMGVhMmRhNGFjMzRlY2Q5ZWYxZDk4NWI3OGY1ZTg4MDE=
data/bin/omf_ec CHANGED
@@ -44,6 +44,9 @@ desc "Logging config file"
44
44
  arg_name "file"
45
45
  flag [:log_config]
46
46
 
47
+ desc "Add some colours to logging"
48
+ switch [:colour]
49
+
47
50
  # the path given here is relative to the user's home directory
48
51
  config_file(".config/omf_ec.yml")
49
52
 
@@ -52,7 +55,11 @@ arg_name "path_to_script_file [-- --experiment_property value]"
52
55
  command :exec do |c|
53
56
  c.desc "Experiment name"
54
57
  c.arg_name "experiment_name"
55
- c.flag [:e, :experiment]
58
+ c.flag [:e, :experiment, "experiment-id"]
59
+
60
+ c.desc "Slice name [Deprecated]"
61
+ c.arg_name "slice_name"
62
+ c.flag [:slice]
56
63
 
57
64
  c.desc "OML URI to use for collecting the experiment's measurements"
58
65
  c.arg_name "uri"
@@ -73,6 +80,9 @@ command :exec do |c|
73
80
  c.desc "Check script version (you need to define OMF_VERSIONS in your script"
74
81
  c.switch "version_check"
75
82
 
83
+ c.desc "Parse graph definition to construct graph information in log output"
84
+ c.switch [:g, "show-graph"]
85
+
76
86
  c.action do |global_options, options, args|
77
87
  help_now! "Missing experiment script" if args[0].nil?
78
88
  help_now! "Experiment script not found" unless File.exist?(File.expand_path(args[0]))
@@ -94,6 +104,8 @@ command :exec do |c|
94
104
  OmfEc.experiment.cmdline_properties = properties
95
105
  end
96
106
 
107
+ OmfEc.experiment.show_graph = options['show-graph']
108
+
97
109
  # FIXME this loading script is way too simple
98
110
  load_exp(File.expand_path(args[0]), global_options, options, properties)
99
111
  end
@@ -250,6 +262,12 @@ def setup_logging(global_options = {})
250
262
  Logging.consolidate 'OmfCommon', 'OmfRc'
251
263
  end
252
264
 
265
+ if global_options[:colour]
266
+ Logging.logger.root.appenders.first.layout = Logging.layouts.pattern(date_pattern: '%F %T %z',
267
+ color_scheme: 'default',
268
+ pattern: '[%d] %-5l %c: %m\n')
269
+ end
270
+
253
271
  # FIXME this should go to common setup
254
272
  if global_options[:log_file_dir] && File.exist?(File.expand_path(global_options[:log_file_dir]))
255
273
  Logging.logger.root.add_appenders(
@@ -279,8 +297,7 @@ def load_exp(exp_path, global_options = {} , options = {}, properties = {})
279
297
  appenders: {
280
298
  stdout: {
281
299
  date_pattern: '%H:%M:%S',
282
- pattern: '%d %-5l %c{2}: %m\n',
283
- color_scheme: 'default'
300
+ pattern: '%d %-5l %c{2}: %m\n'
284
301
  }
285
302
  }
286
303
  }
@@ -298,14 +315,16 @@ def load_exp(exp_path, global_options = {} , options = {}, properties = {})
298
315
  info "Execute: #{exp_path}"
299
316
  info "Properties: #{OmfEc.experiment.cmdline_properties}"
300
317
 
301
- ec_cert = OmfCommon.load_credentials(
302
- root_cert_dir: global_options[:root_cert_dir],
303
- entity_cert: global_options[:cert],
304
- entity_key: global_options[:key]
305
- )
318
+ if opts[:communication][:auth] && opts[:communication][:auth][:authenticate]
319
+ ec_cert = OmfCommon.load_credentials(
320
+ root_cert_dir: global_options[:root_cert_dir],
321
+ entity_cert: global_options[:cert],
322
+ entity_key: global_options[:key]
323
+ )
306
324
 
307
- ec_cert.resource_id = OmfCommon.comm.local_address
308
- OmfCommon::Auth::CertificateStore.instance.register(ec_cert)
325
+ ec_cert.resource_id = OmfCommon.comm.local_address
326
+ OmfCommon::Auth::CertificateStore.instance.register(ec_cert)
327
+ end
309
328
 
310
329
  begin
311
330
  include OmfEc::Backward::DefaultEvents
@@ -15,6 +15,7 @@ module OmfEc
15
15
  v5_style(:onEvent, base)
16
16
  v5_style(:allGroups, base)
17
17
  v5_style(:allNodes!, base)
18
+ v5_style(:defGraph, base)
18
19
  end
19
20
 
20
21
  def v5_style(name, base)
@@ -49,7 +50,7 @@ module OmfEc
49
50
  def wait(duration)
50
51
  info "Request from Experiment Script: Wait for #{duration}s...."
51
52
  warn "Calling 'wait' or 'sleep' will block entire EC event loop. Please try 'after' or 'every'"
52
- sleep duration
53
+ sleep duration.to_s.to_i
53
54
  end
54
55
  end
55
56
  end
@@ -88,5 +88,14 @@ module OmfEc::Context
88
88
  end
89
89
  p
90
90
  end
91
+
92
+ def mp_table_names
93
+ {}.tap do |m_t_n|
94
+ @oml_collections.map { |v| v[:streams] }.flatten.each do |s|
95
+ mp = s[:mp].to_s
96
+ m_t_n[mp] = "#{self.app_def.name}_#{mp}"
97
+ end
98
+ end
99
+ end
91
100
  end
92
101
  end
data/lib/omf_ec/dsl.rb CHANGED
@@ -174,6 +174,21 @@ module OmfEc
174
174
  end
175
175
  end
176
176
 
177
+ # Define a new graph widget showing experiment related measurements to be
178
+ # be used in a LabWiki column.
179
+ #
180
+ # The block is called with an instance of the 'LabWiki::OMFBridge::GraphDescription'
181
+ # class. See that classes' documentation on the methods supported.
182
+ #
183
+ # @param name short/easy to remember name for this graph
184
+ def def_graph(name = nil, &block)
185
+ if OmfEc.experiment.show_graph
186
+ gd = OmfEc::Graph::GraphDescription.create(name)
187
+ block.call(gd)
188
+ gd._report
189
+ end
190
+ end
191
+
177
192
  include OmfEc::Backward::DSL
178
193
  end
179
194
  end
@@ -15,7 +15,7 @@ module OmfEc
15
15
 
16
16
  include MonitorMixin
17
17
 
18
- attr_accessor :name, :oml_uri, :app_definitions, :property, :cmdline_properties
18
+ attr_accessor :name, :oml_uri, :app_definitions, :property, :cmdline_properties, :show_graph
19
19
  attr_reader :groups, :sub_groups, :state
20
20
 
21
21
  def initialize
@@ -27,6 +27,7 @@ module OmfEc
27
27
  @app_definitions ||= Hash.new
28
28
  @sub_groups ||= []
29
29
  @cmdline_properties ||= Hash.new
30
+ @show_graph = false
30
31
  end
31
32
 
32
33
  def property
@@ -140,7 +141,7 @@ module OmfEc
140
141
 
141
142
  # Unique experiment id
142
143
  def id
143
- @name.nil? ? @id : @name
144
+ @name || @id
144
145
  end
145
146
 
146
147
  # Parsing user defined events, checking conditions against internal state, and execute callbacks if triggered
@@ -160,6 +161,14 @@ module OmfEc
160
161
  end
161
162
  end
162
163
 
164
+ def mp_table_names
165
+ {}.tap do |m_t_n|
166
+ groups.map(&:app_contexts).flatten.map(&:mp_table_names).each do |v|
167
+ m_t_n.merge!(v)
168
+ end
169
+ end
170
+ end
171
+
163
172
  # Purely for backward compatibility
164
173
  class << self
165
174
  # Disconnect communicator, try to delete any XMPP affiliations
@@ -0,0 +1,117 @@
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
+ require 'sequel'
7
+ require 'json'
8
+
9
+ module OmfEc::Graph
10
+ # Describes a graph which can be displayed through the web interface or any other defined graph visualiser.
11
+ class GraphDescription
12
+ @@gds = {}
13
+
14
+ def self.create(name = nil)
15
+ if name
16
+ @@gds[name.to_sym] ||= self.new(name)
17
+ else
18
+ self.new("Unknown #{self.object_id}")
19
+ end
20
+ end
21
+
22
+ # Define text to be shown above the graph
23
+ #
24
+ # @param text
25
+ #
26
+ def postfix(text)
27
+ @postfix = text
28
+ end
29
+
30
+ # Define the measurement stream to be visualized in
31
+ # the graph. The optional 'context' parameter defines
32
+ # the context in which the MS is used in the graph. This
33
+ # is necessary for graphs, such as 'networks' which need
34
+ # more than one MS to describe the visualization.
35
+ #
36
+ # @param ms_name
37
+ # @param context
38
+ #
39
+ def ms(ms_name, context = :default)
40
+ if (table_name = OmfEc.experiment.mp_table_names[ms_name])
41
+ (@ms[context] ||= []) << (msb = MSBuilder.new(@db[table_name.to_sym]))
42
+ else
43
+ warn "Measurement point '#{ms_name}' NOT defined"
44
+ end
45
+ msb
46
+ end
47
+
48
+ # Defines the mapping of columns in the measurement tuples to properties
49
+ # of the visualization.
50
+ #
51
+ # @param mhash Hash of mappings specific to the graph ifentified by 'type'
52
+ def mapping(mhash)
53
+ @mapping = mhash
54
+ end
55
+
56
+ def type(gtype)
57
+ @gtype = gtype
58
+ end
59
+
60
+ def xaxis(props)
61
+ (@axis ||= {})[:x] = props
62
+ end
63
+
64
+ def yaxis(props)
65
+ (@axis ||= {})[:y] = props
66
+ end
67
+
68
+ def caption(text)
69
+ @caption = text
70
+ end
71
+
72
+ def _report
73
+ info "REPORT:START: #{@name}"
74
+ info "REPORT:TYPE: #{@gtype}"
75
+ info "REPORT:POSTFIX: #{URI.encode(@postfix)}" if @postfix
76
+ @ms.each do |ctxt, a|
77
+ a.each do |ms|
78
+ info "REPORT:MS:#{ctxt}: #{URI.encode(ms.sql)}"
79
+ end
80
+ end
81
+ info "REPORT:MAPPING: #{URI.encode(@mapping.to_json)}"
82
+ if @axis
83
+ info "REPORT:AXIS: #{URI.encode(@axis.to_json)}"
84
+ end
85
+ info "REPORT:CAPTION: #{URI.encode(@caption)}" if @caption
86
+ info "REPORT:STOP"
87
+ end
88
+
89
+ protected
90
+
91
+ def initialize(name)
92
+ @name = name
93
+ @ms = {}
94
+ # Create a generic Sequel object which can be used to serialize the query.
95
+ # TODO: Make sure this is generic enough
96
+ @db = Sequel.postgres
97
+ @db.instance_variable_set('@server_version', 90105)
98
+ end
99
+ end
100
+
101
+ class MSBuilder
102
+ def initialize(data_set)
103
+ @data_set = data_set
104
+ end
105
+
106
+ def method_missing(symbol, *args, &block)
107
+ debug "Calling #{symbol}::#{args.inspect}"
108
+ res = @data_set.send(symbol, *args, &block)
109
+ if res.is_a? Sequel::Postgres::Dataset
110
+ @data_set = res
111
+ res = self
112
+ end
113
+ debug "Result: #{res.class}"
114
+ res
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,6 @@
1
+ require "omf_ec/graph/graph_description"
2
+
3
+ module OmfEc
4
+ module Graph
5
+ end
6
+ end
data/lib/omf_ec.rb CHANGED
@@ -16,6 +16,7 @@ require "omf_ec/experiment"
16
16
  require "omf_ec/group"
17
17
  require "omf_ec/app_definition"
18
18
  require "omf_ec/context"
19
+ require "omf_ec/graph"
19
20
  require "omf_ec/dsl"
20
21
 
21
22
  module OmfEc
data/omf_ec.gemspec CHANGED
@@ -29,4 +29,5 @@ Gem::Specification.new do |s|
29
29
 
30
30
  s.add_runtime_dependency "omf_common", "= #{OmfCommon::VERSION}"
31
31
  s.add_runtime_dependency "gli"
32
+ s.add_runtime_dependency "sequel"
32
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_ec
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.8.pre.1
4
+ version: 6.0.8.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - NICTA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-19 00:00:00.000000000 Z
11
+ date: 2013-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: 6.0.8.pre.1
89
+ version: 6.0.8.pre.2
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 6.0.8.pre.1
96
+ version: 6.0.8.pre.2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: gli
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sequel
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: Experiment controller of OMF, a generic framework for controlling and
112
126
  managing networking testbeds.
113
127
  email:
@@ -146,6 +160,8 @@ files:
146
160
  - lib/omf_ec/dsl.rb
147
161
  - lib/omf_ec/experiment.rb
148
162
  - lib/omf_ec/experiment_property.rb
163
+ - lib/omf_ec/graph.rb
164
+ - lib/omf_ec/graph/graph_description.rb
149
165
  - lib/omf_ec/group.rb
150
166
  - lib/omf_ec/version.rb
151
167
  - omf_ec.gemspec