omf_ec 6.0.0.pre.2 → 6.0.0.pre.3

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/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rake/testtask'
2
2
  require "bundler/gem_tasks"
3
3
 
4
+ task :default => :test
5
+
4
6
  Rake::TestTask.new do |t|
5
7
  t.pattern = "test/**/*_spec.rb"
6
8
  t.verbose = true
data/bin/omf ADDED
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ require 'gli'
4
+ require 'omf_ec'
5
+
6
+ include GLI::App
7
+
8
+ program_desc "Run a command on the testbed(s)"
9
+
10
+ version OmfEc::VERSION
11
+
12
+ desc "Debug (this script only, not passed to omf exec)"
13
+ switch [:d, :debug]
14
+
15
+ desc "Execute an experiment script"
16
+ arg_name 'Describe arguments to exec here'
17
+ command :exec do |c|
18
+ c.desc 'Describe a switch to exec'
19
+ c.switch :s
20
+
21
+ c.desc 'Describe a flag to exec'
22
+ c.default_value 'default'
23
+ c.flag :f
24
+ c.action do |global_options,options,args|
25
+
26
+ # Your command logic here
27
+
28
+ # If you have any errors, just raise them
29
+ # raise "that command made no sense"
30
+ end
31
+ end
32
+
33
+ desc "Load a disk image on a given set of nodes"
34
+ command :load do |c|
35
+ c.desc 'Describe a flag to exec'
36
+ c.default_value 'default'
37
+ c.flag :f
38
+
39
+ c.desc "Aggregate Name"
40
+ c.arg_name "AGGREGATE"
41
+ c.flag [:c, :config]
42
+
43
+ c.desc "A valid topology file or description. If a file 'TOPOLOGY' doesn't exist, interpret it as a comma-separated list of nodes)"
44
+ c.default_value "system:topo:all"
45
+ c.arg_name "TOPOLOGY"
46
+ c.flag [:t, :topology]
47
+
48
+ c.desc "Disk image to load"
49
+ c.default_value "baseline.ndz"
50
+ c.arg_name "IMAGE"
51
+ c.flag [:i, :image]
52
+
53
+ c.desc "A duration (in sec.) after which imageNodes should stop waiting for nodes that have not finished their image installation"
54
+ c.default_value "800"
55
+ c.arg_name "SECONDS"
56
+ c.flag [:o, :timeout]
57
+
58
+ c.desc "Path where the resulting Topologies should be saved"
59
+ c.default_value "/tmp"
60
+ c.arg_name "PATH"
61
+ c.flag [:outpath]
62
+
63
+ c.desc "Prefix to use for naming the resulting Topologies"
64
+ c.default_value "your experiment ID"
65
+ c.arg_name "PREFIX"
66
+ c.flag [:outprefix]
67
+
68
+ c.action do |global_options,options,args|
69
+ end
70
+ end
71
+
72
+ desc "Save a disk image from a given node into a file"
73
+ command :save do |c|
74
+ c.desc "Aggregate Name"
75
+ c.arg_name "AGGREGATE"
76
+ c.flag [:c, :config]
77
+
78
+ c.desc "Save image node"
79
+ c.arg_name "NODE"
80
+ c.flag [:n, :node]
81
+
82
+ c.action do |global_options,options,args|
83
+ end
84
+ end
85
+
86
+ desc "Switch a given set of nodes ON/OFF or reboot them"
87
+ long_desc <<-DESC
88
+ Specify a CMC action:
89
+
90
+ on - turn node(s) ON
91
+
92
+ offs - turn node(s) OFF (soft)
93
+
94
+ offh - turn node(s) OFF (hard)
95
+
96
+ reboot - treboots node(s) (soft)
97
+
98
+ reset - tresets node(s) (hard)
99
+ DESC
100
+ command :tell do |c|
101
+ c.desc "A valid topology file or description. If a file 'TOPOLOGY' doesn't exist, interpret it as a comma-separated list of nodes)"
102
+ c.default_value "system:topo:all"
103
+ c.arg_name "TOPOLOGY"
104
+ c.flag [:t, :topology]
105
+
106
+ c.desc "Aggregate Name"
107
+ c.arg_name "AGGREGATE"
108
+ c.flag [:c, :config]
109
+
110
+ c.desc "CMC action"
111
+ c.arg_name "ACTION"
112
+ c.flag [:a, :action], :must_match => %w(on offs offh reboot reset)
113
+
114
+ c.action do |global_options,options,args|
115
+ end
116
+ end
117
+
118
+ desc "Returns the status of a given set of nodes"
119
+ command :stat do |c|
120
+ c.desc "Print a summary of the node status for the testbed"
121
+ c.switch [:s, :summary]
122
+
123
+ c.desc "A valid topology file or description. If a file 'TOPOLOGY' doesn't exist, interpret it as a comma-separated list of nodes)"
124
+ c.default_value "system:topo:all"
125
+ c.arg_name "TOPOLOGY"
126
+ c.flag [:t, :topology]
127
+
128
+ c.desc "Aggregate Name"
129
+ c.arg_name "AGGREGATE"
130
+ c.flag [:c, :config]
131
+
132
+ c.action do |global_options,options,args|
133
+ end
134
+ end
135
+
136
+ pre do |global,command,options,args|
137
+ true
138
+ end
139
+
140
+ post do |global,command,options,args|
141
+ end
142
+
143
+ on_error do |exception|
144
+ true
145
+ end
146
+
147
+ exit run(ARGV)
data/bin/omf_pre ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ require 'gli'
4
+ require 'omf_ec'
5
+ require 'omf_common'
6
+ $stdout.sync = true
7
+
8
+ include GLI::App
9
+ include OmfCommon
10
+
11
+ program_desc "Run a command on the testbed(s)"
12
+
13
+ version OmfEc::VERSION
14
+ desc "Debug mode (printing debug logging messages)"
15
+ switch [:d, :debug]
16
+
17
+ desc "Execute an experiment script"
18
+ arg_name 'path_to_script_file'
19
+ command :exec do |c|
20
+ c.desc "XMPP user name"
21
+ c.arg_name "USER"
22
+ c.flag [:u, :user]
23
+
24
+ c.desc "XMPP user password"
25
+ c.arg_name "PASSWORD"
26
+ c.flag [:p, :password]
27
+
28
+ c.desc "XMPP server domain"
29
+ c.arg_name "DOMAIN"
30
+ c.flag [:s, :server]
31
+
32
+ c.desc "Check script version (you need to define OMF_VERSIONS in your script"
33
+ c.switch [:c, :check]
34
+
35
+ c.action do |global_options,options,args|
36
+ if global_options[:debug]
37
+ Logging.logger.root.level = :debug
38
+ Blather.logger = logger
39
+ end
40
+ unless options[:user] && options[:password] && options[:server]
41
+ help_now! "Incomplete options"
42
+ end
43
+ @opts = options
44
+ @comm = Comm.new(:xmpp)
45
+
46
+ # Check version
47
+ if options[:check]
48
+ File.open(args[0], 'r') do |f|
49
+ f.read.chomp.match(/OMF_VERSIONS\W*=\W*(.*)/)
50
+ versions = $1
51
+ unless versions && versions.split(',').include?(PROTOCOL_VERSION)
52
+ raise StandardError, "Could not find compatibile protocol version number in your script"
53
+ end
54
+ end
55
+ end
56
+
57
+ begin
58
+ load args[0], true
59
+ rescue => e
60
+ logger.fatal e.message
61
+ logger.fatal e.backtrace.join("\n")
62
+ end
63
+
64
+ EM.run do
65
+ @comm.connect(@opts[:user], @opts[:password], @opts[:server])
66
+ trap(:INT) { @comm.disconnect }
67
+ trap(:TERM) { @comm.disconnect }
68
+ end
69
+ end
70
+ end
71
+
72
+ on_error do |exception|
73
+ true
74
+ end
75
+
76
+ exit run(ARGV)
data/bin/omf_test CHANGED
@@ -5,7 +5,7 @@ require 'omf_common'
5
5
  $stdout.sync = true
6
6
 
7
7
  options = {
8
- dsl: 'xmpp_blather',
8
+ dsl: 'xmpp',
9
9
  pubsub_host: 'pubsub',
10
10
  }
11
11
 
@@ -56,12 +56,12 @@ comm = OmfCommon::Comm.new(options[:dsl])
56
56
  host = nil
57
57
 
58
58
  # Create a resource of type mock
59
- create_msg = OmfCommon::Message.create { |v| v.property('type', 'mock') }.sign
59
+ create_msg = OmfCommon::Message.create { |v| v.property('type', 'mock') }
60
60
 
61
61
  create_wifi_msg = OmfCommon::Message.create do |v|
62
62
  v.property('hrn', 'wlan0')
63
63
  v.property('type', 'wifi')
64
- end.sign
64
+ end
65
65
 
66
66
  # A request message to be sent to mock
67
67
  request_mock_property = OmfCommon::Message.request do |v|
@@ -70,12 +70,12 @@ request_mock_property = OmfCommon::Message.request do |v|
70
70
  v.property('resource_proxy_list')
71
71
  v.property('resource_utility_list')
72
72
  v.property('bob')
73
- end.sign
73
+ end
74
74
 
75
75
  request_wifi_property = OmfCommon::Message.request do |v|
76
76
  v.property('link')
77
77
  v.property('available_properties')
78
- end.sign
78
+ end
79
79
 
80
80
  # A request message to be sent to node
81
81
  request_node_property = OmfCommon::Message.request do |v|
@@ -86,10 +86,10 @@ end
86
86
  # A configure message to be sent to mock
87
87
  configure_mock_property = OmfCommon::Message.configure do |v|
88
88
  v.property('hrn', 'human_readable_name')
89
- end.sign
89
+ end
90
90
 
91
91
  # Simple release message
92
- release_message = OmfCommon::Message.release.sign
92
+ release_message = OmfCommon::Message.release
93
93
 
94
94
  # For simplicity, use comm instance directly
95
95
  comm.when_ready do
@@ -101,7 +101,7 @@ comm.when_ready do
101
101
  if e.error?
102
102
  comm.disconnect(host)
103
103
  else
104
- # Publish the create message to RC's pubsub node
104
+ # Publish the create message to RC's pubsub topic
105
105
  comm.publish(options[:uid], request_node_property, host)
106
106
  comm.publish(options[:uid], create_wifi_msg, host)
107
107
  end
@@ -0,0 +1,75 @@
1
+ # @comm is default communicator defined in script runner
2
+ #
3
+ @node = @comm.get_topic(`hostname`.chomp)
4
+
5
+ @node.on_message lambda {|m| m.operation == :inform && m.read_content('inform_type') == 'FAILED' } do |message|
6
+ logger.error message
7
+ end
8
+
9
+ device_request = @comm.request_message([:devices])
10
+
11
+ device_request.on_inform_status do |message|
12
+ @devices = message.read_property('devices').items
13
+
14
+ logger.info <<-LOG
15
+ DEVICES ->
16
+ #{@devices.map { |item| "Name: #{item.name}, Driver: #{item.driver}, Proxy: #{item.proxy}"}.join("\n") }
17
+ LOG
18
+
19
+ first_wlan = @devices.find { |v| v.proxy == 'wlan' }
20
+ first_eth = @devices.find { |v| v.proxy == 'net' }
21
+
22
+ wlan_create = @comm.create_message([type: first_wlan.proxy, hrn: first_wlan.name])
23
+ eth_create = @comm.create_message([type: first_eth.proxy, hrn: first_eth.name])
24
+
25
+ wlan_create.on_inform_created do |message|
26
+ @wlan = @comm.get_topic(message.resource_id)
27
+
28
+ @wlan.subscribe do
29
+ wlan_p = @comm.request_message([:link, :ip_addr])
30
+
31
+ wlan_p.on_inform_status do |message|
32
+ freq = message.read_property(:link).freq
33
+ ip_addr = message.read_property(:ip_addr)
34
+ logger.info "WLAN : #{freq}, #{ip_addr}"
35
+ end
36
+
37
+ wlan_p.publish @wlan.id
38
+ end
39
+ end
40
+
41
+ eth_create.on_inform_created do |message|
42
+ @eth = @comm.get_topic(message.resource_id)
43
+ @eth.on_message lambda {|m| m.operation == :inform && m.read_content('inform_type') == 'FAILED' } do |message|
44
+ logger.error message.read_content(:reason)
45
+ end
46
+
47
+ @eth.subscribe do
48
+ eth_ip = @comm.request_message([:ip_addr])
49
+
50
+ eth_ip.on_inform_status do |m|
51
+ logger.info "ETH #{m.read_property(:ip_addr)}"
52
+ end
53
+
54
+ eth_ip_conf = @comm.configure_message([{ip_addr: '192.168.7.1'}])
55
+
56
+ eth_ip.on_inform_status do |m|
57
+ logger.info "ETH #{m.read_property(:ip_addr)}"
58
+ end
59
+
60
+ eth_ip.publish @eth.id
61
+ eth_ip_conf.publish @eth.id
62
+ end
63
+ end
64
+
65
+ wlan_create.publish @node.id
66
+ eth_create.publish @node.id
67
+ end
68
+
69
+ @comm.when_ready do
70
+ logger.info "CONNECTED: #{@comm.jid.inspect}"
71
+
72
+ @node.subscribe do
73
+ device_request.publish @node.id
74
+ end
75
+ end
@@ -1,3 +1,3 @@
1
1
  module OmfEc
2
- VERSION = "6.0.0.pre.2"
2
+ VERSION = "6.0.0.pre.3"
3
3
  end
data/omf_ec.gemspec CHANGED
@@ -15,10 +15,12 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ #s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.executables = ["omf_pre"]
19
20
  s.require_paths = ["lib"]
20
21
 
21
22
  # specify any dependencies here; for example:
22
- s.add_development_dependency "minitest", "~> 2.11.3"
23
+ s.add_development_dependency "minitest", "~> 3.2"
23
24
  s.add_runtime_dependency "omf_common", "~> 6.0.0.pre"
25
+ s.add_runtime_dependency "gli", "~> 2.0.0.pre"
24
26
  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.0.pre.2
4
+ version: 6.0.0.pre.3
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: 2012-05-29 00:00:00.000000000 Z
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.11.3
21
+ version: '3.2'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 2.11.3
29
+ version: '3.2'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: omf_common
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -43,20 +43,39 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: 6.0.0.pre
46
+ - !ruby/object:Gem::Dependency
47
+ name: gli
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.0.0.pre
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.0.pre
46
62
  description: Experiment controller of OMF, a generic framework for controlling and
47
63
  managing networking testbeds.
48
64
  email:
49
65
  - omf-user@lists.nicta.com.au
50
66
  executables:
51
- - omf_test
67
+ - omf_pre
52
68
  extensions: []
53
69
  extra_rdoc_files: []
54
70
  files:
55
71
  - .gitignore
56
72
  - Gemfile
57
73
  - Rakefile
74
+ - bin/omf
75
+ - bin/omf_pre
58
76
  - bin/omf_test
59
77
  - config/ec.yml
78
+ - example/net_devices.rb
60
79
  - exp_repo/system/exp/eventlib.rb
61
80
  - exp_repo/system/exp/imageNode.rb
62
81
  - exp_repo/system/exp/reset.rb
@@ -137,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
156
  version: 1.3.1
138
157
  requirements: []
139
158
  rubyforge_project: omf_ec
140
- rubygems_version: 1.8.23
159
+ rubygems_version: 1.8.24
141
160
  signing_key:
142
161
  specification_version: 3
143
162
  summary: OMF experiment controller