omf_ec 6.0.2.pre.1 → 6.0.2.pre.2

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_ec CHANGED
@@ -17,7 +17,7 @@ switch [:d, :debug]
17
17
 
18
18
  desc "URI for communication layer"
19
19
  arg_name "URI"
20
- default_value "xmpp://bob:password@localhost"
20
+ default_value "xmpp://localhost"
21
21
  flag [:u, :uri]
22
22
 
23
23
  desc "Debug XMPP traffic mode (include XMPP debug logging messages under debug mode)."
@@ -1,12 +1,34 @@
1
1
  module OmfEc
2
2
  module Backward
3
3
  module AppDefinition
4
- # The following are ODEL 5 methods
4
+ # The following are OEDL 5 methods
5
5
 
6
- # Add a new parameter to this Application Definition
7
- # This method is for backward compatibility with previous OEDL 5
6
+ # Add a new parameter to this Application Definition.
7
+ # This method is for backward compatibility with previous OEDL 5.
8
+ #
9
+ # @param [String] name name of the property to define (mandatory)
10
+ # @param [String] description description of this property; oml2-scaffold uses this for the help message (popt: descrip)
11
+ # @param [String] parameter command-line parameter to introduce this property, including dashes if needed (can be nil)
12
+ # @param [Hash] options list of options associated with this property
13
+ # @option options [String] :type type of the property: :integer, :string and :boolean are supported; oml2-scaffold extends this with :int and :double (popt: argInfo)
14
+ # @option options [Boolean] :dynamic true if the property can be changed at run-time
15
+ # @option options [Fixnum] :order used to order properties when creating the command line
16
+ #
17
+ # The OML code-generation tool, oml2-scaffold extends the range of
18
+ # options supported in the options hash to support generation of
19
+ # popt(3) command line parsing code. As for the parameters, depending
20
+ # on the number of dashes (two/one) in parameter, it is used as the
21
+ # longName/shortName for popt(3), otherwise the former defaults to
22
+ # name, and the latter defaults to either :mnemonic or nothing.
23
+ #
24
+ # @option options [String] :mnemonic one-letter mnemonic for the option (also returned by poptGetNextOpt as val)
25
+ # @option options [String] :unit unit in which this property is expressed; oml2-scaffold uses this for the help message (popt: argDescrip)
26
+ # @option options [String] :default default value if argument unspecified (optional; defaults to something sane for the :type)
27
+ # @option options [String] :var_name name of the C variable for popt(3) to store the property value into (optional; popt: arg; defaults to name, after sanitisation)
28
+ #
29
+ # @see http://oml.mytestbed.net/doc/oml/latest/oml2-scaffold.1.html
30
+ # @see http://linux.die.net/man/3/popt
8
31
  #
9
- # @param [String] name name of the application to define
10
32
  def defProperty(name = :mandatory, description = nil, parameter = nil, options = {})
11
33
  opts = {:description => description, :cmd => parameter}
12
34
  # Map old OMF5 types to OMF6
@@ -21,6 +43,7 @@ module OmfEc
21
43
  @fields << {:field => name, :type => type}
22
44
  end
23
45
 
46
+ # XXX: This should be provided by the omf-oml glue.
24
47
  def defMeasurement(name,&block)
25
48
  mp = {:mp => name, :fields => []}
26
49
  @fields = []
@@ -1,32 +1,28 @@
1
1
  def create_app(testbed)
2
- testbed.create(:application) do |reply|
2
+ testbed.create(:application, binary_path: @cmd) do |reply|
3
3
  if reply.success?
4
4
  app = reply.resource
5
5
 
6
6
  app.on_subscribed do
7
- app.request([:platform])
8
-
9
- after(1) { app.configure(binary_path: @cmd) }
10
- after(2) { app.configure(state: :running) }
7
+ app.configure(state: :running)
11
8
 
12
9
  app.on_status do |m|
13
- if m[:status_type] == 'APP_EVENT'
14
- after(2) { OmfCommon.comm.disconnect } if m[:event] =~ /DONE.(OK|ERROR)/
15
- info m[:msg]
16
- else
17
- m.each_property do |k, v|
18
- info "#{k} => #{v.strip}" unless v.nil?
10
+ case m.itype
11
+ when 'STATUS'
12
+ if m[:status_type] == 'APP_EVENT'
13
+ after(2) { OmfCommon.comm.disconnect } if m[:event] =~ /DONE.(OK|ERROR)/
14
+ info m[:msg] if m[:msg]
15
+ else
16
+ m.each_property do |k, v|
17
+ info "#{k} => #{v.strip}" unless v.nil?
18
+ end
19
19
  end
20
+ when 'WARN'
21
+ warn m[:reason]
22
+ when 'ERROR'
23
+ error m[:reason]
20
24
  end
21
25
  end
22
-
23
- app.on_warn do |m|
24
- warn m[:reason]
25
- end
26
-
27
- app.on_error do |m|
28
- error m[:reason]
29
- end
30
26
  end
31
27
  else
32
28
  error reply[:reason]
@@ -65,13 +65,30 @@ module OmfEc
65
65
  end
66
66
  else
67
67
  info "Newly discovered resource >> #{name}"
68
- @state << Hashie::Mash.new({ address: name }).merge(opts)
68
+ res = Hashie::Mash.new({ address: name }).merge(opts)
69
+ @state << res
70
+
71
+ # Re send membership configure
72
+ planned_groups = groups_by_res(res[:address])
73
+
74
+ unless planned_groups.empty?
75
+ OmfEc.subscribe_and_monitor(name) do |res|
76
+ info "Config #{name} to join #{planned_groups.map(&:name).join(', ')}"
77
+ res.configure(membership: planned_groups.map(&:id).join(', '))
78
+ end
79
+ end
69
80
  end
70
81
  end
71
82
  end
72
83
 
73
84
  alias_method :add_resource, :add_or_update_resource_state
74
85
 
86
+ # Find all groups a given resource belongs to
87
+ #
88
+ def groups_by_res(res_addr)
89
+ groups.find_all { |g| g.members.include?(res_addr) }
90
+ end
91
+
75
92
  def sub_group(name)
76
93
  @sub_groups.find { |v| v == name }
77
94
  end
@@ -1,3 +1,3 @@
1
1
  module OmfEc
2
- VERSION = "6.0.2.pre.1"
2
+ VERSION = "6.0.2.pre.2"
3
3
  end
data/omf_ec.gemspec CHANGED
@@ -25,6 +25,6 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency "em-minitest-spec", "~> 1.1.1"
26
26
  s.add_development_dependency "simplecov"
27
27
  s.add_development_dependency "pry"
28
- s.add_runtime_dependency "omf_common", "~> 6.0.0"
28
+ s.add_runtime_dependency "omf_common", "~> 6.0.2.pre.2"
29
29
  s.add_runtime_dependency "gli", "~> 2.5.3"
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_ec
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.2.pre.1
4
+ version: 6.0.2.pre.2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-29 00:00:00.000000000 Z
12
+ date: 2013-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 6.0.0
85
+ version: 6.0.2.pre.2
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 6.0.0
93
+ version: 6.0.2.pre.2
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: gli
96
96
  requirement: !ruby/object:Gem::Requirement