omf_ec 6.0.0.pre.3 → 6.0.0.pre.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/bin/omf_ec +264 -0
- data/example/engine_oedl.rb +52 -0
- data/example/engine_test.rb +90 -0
- data/example/test_exp/test00.rb +12 -0
- data/example/test_exp/test01.rb +22 -0
- data/example/test_exp/test02.rb +30 -0
- data/{exp_repo/test/exp → example/test_exp}/test03.rb +2 -42
- data/{exp_repo/test/exp → example/test_exp}/test04.rb +2 -2
- data/{exp_repo/test/exp → example/test_exp}/test05.rb +4 -4
- data/{exp_repo/test/exp → example/test_exp}/test06.rb +6 -6
- data/example/test_exp/test07.rb +65 -0
- data/lib/omf_ec/app_definition.rb +57 -0
- data/lib/omf_ec/backward/app_definition.rb +35 -0
- data/lib/omf_ec/backward/core_ext/array.rb +19 -0
- data/lib/omf_ec/backward/default_events.rb +71 -0
- data/lib/omf_ec/backward/dsl.rb +83 -0
- data/lib/omf_ec/backward/exp/testbed.rb +47 -0
- data/lib/omf_ec/backward/group.rb +72 -0
- data/lib/omf_ec/context/app_context.rb +54 -0
- data/lib/omf_ec/context/def_app_context.rb +6 -0
- data/lib/omf_ec/context/group_context.rb +88 -0
- data/lib/omf_ec/context/net_context.rb +46 -0
- data/lib/omf_ec/context.rb +10 -0
- data/lib/omf_ec/dsl.rb +159 -0
- data/lib/omf_ec/experiment.rb +71 -0
- data/lib/omf_ec/group.rb +158 -0
- data/lib/omf_ec/version.rb +1 -1
- data/lib/omf_ec.rb +34 -1
- data/omf_ec.gemspec +2 -3
- data/test/omf_ec/context_spec.rb +19 -0
- data/test/omf_ec/group_spec.rb +14 -0
- data/test/test_helper.rb +19 -0
- metadata +44 -89
- data/bin/omf +0 -147
- data/bin/omf_pre +0 -76
- data/bin/omf_test +0 -161
- data/example/net_devices.rb +0 -75
- data/exp_repo/system/exp/eventlib.rb +0 -96
- data/exp_repo/system/exp/imageNode.rb +0 -283
- data/exp_repo/system/exp/reset.rb +0 -21
- data/exp_repo/system/exp/saveNode.rb +0 -99
- data/exp_repo/system/exp/stat.rb +0 -49
- data/exp_repo/system/exp/stdlib.rb +0 -122
- data/exp_repo/system/exp/tell.rb +0 -53
- data/exp_repo/system/exp/testlib.rb +0 -12
- data/exp_repo/system/exp/winlib.rb +0 -154
- data/exp_repo/system/topo/active.rb +0 -9
- data/exp_repo/system/topo/all.rb +0 -10
- data/exp_repo/system/topo/circle.rb +0 -23
- data/exp_repo/test/app/aodvd.rb +0 -73
- data/exp_repo/test/app/appDef1.rb +0 -102
- data/exp_repo/test/app/athstats.rb +0 -76
- data/exp_repo/test/app/echo.rb +0 -36
- data/exp_repo/test/app/gennyReceiverAppDef.rb +0 -100
- data/exp_repo/test/app/gennySenderAppDef.rb +0 -106
- data/exp_repo/test/app/itgdec.rb +0 -79
- data/exp_repo/test/app/itgr.rb +0 -77
- data/exp_repo/test/app/itgs.rb +0 -105
- data/exp_repo/test/app/nop.rb +0 -36
- data/exp_repo/test/app/otg2.rb +0 -68
- data/exp_repo/test/app/otg2_mp.rb +0 -56
- data/exp_repo/test/app/otr2.rb +0 -56
- data/exp_repo/test/app/otr2_mp.rb +0 -51
- data/exp_repo/test/app/trace_oml2.rb +0 -62
- data/exp_repo/test/app/wlanconfig_oml2.rb +0 -42
- data/exp_repo/test/exp/conf-room-demo.rb +0 -118
- data/exp_repo/test/exp/planetlab.rb +0 -82
- data/exp_repo/test/exp/test01.rb +0 -42
- data/exp_repo/test/exp/test02.rb +0 -60
- data/exp_repo/test/exp/tutorial/hello-world-wired.rb +0 -79
- data/exp_repo/test/exp/tutorial/hello-world-wireless.rb +0 -87
- data/exp_repo/test/exp/tutorial/using-filters.rb +0 -69
- data/exp_repo/test/exp/tutorial/using-groups.rb +0 -64
- data/exp_repo/test/exp/tutorial/using-properties.rb +0 -93
- data/exp_repo/test/exp/tutorial/using-prototypes.rb +0 -111
- data/exp_repo/test/proto/aodvrouter.rb +0 -55
- data/exp_repo/test/proto/driverqueryapp.rb +0 -59
- data/exp_repo/test/proto/forwarder.rb +0 -73
- data/exp_repo/test/proto/itgcbrsender.rb +0 -70
- data/exp_repo/test/proto/itgdecoder.rb +0 -64
- data/exp_repo/test/proto/itgreceiver.rb +0 -55
- data/exp_repo/test/proto/itgvoipsender.rb +0 -64
- data/exp_repo/test/proto/listener2.rb +0 -62
- data/exp_repo/test/proto/nop.rb +0 -47
- data/exp_repo/test/proto/probelink.rb +0 -48
- data/exp_repo/test/proto/raw_receiver.rb +0 -64
- data/exp_repo/test/proto/receiver2_mp.rb +0 -48
- data/exp_repo/test/proto/sender2_mp.rb +0 -54
- data/exp_repo/test/proto/udp_receiver.rb +0 -55
- data/exp_repo/test/proto/udp_sender.rb +0 -61
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.
|
4
|
+
version: 6.0.0.pre.4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70297155976580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,15 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.2'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.2'
|
24
|
+
version_requirements: *70297155976580
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: omf_common
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70297155974820 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
30
|
- - ~>
|
@@ -37,105 +32,63 @@ dependencies:
|
|
37
32
|
version: 6.0.0.pre
|
38
33
|
type: :runtime
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 6.0.0.pre
|
35
|
+
version_requirements: *70297155974820
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: gli
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &70297155973900 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
41
|
- - ~>
|
52
42
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
43
|
+
version: 2.4.1
|
54
44
|
type: :runtime
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.0.0.pre
|
46
|
+
version_requirements: *70297155973900
|
62
47
|
description: Experiment controller of OMF, a generic framework for controlling and
|
63
48
|
managing networking testbeds.
|
64
49
|
email:
|
65
50
|
- omf-user@lists.nicta.com.au
|
66
51
|
executables:
|
67
|
-
-
|
52
|
+
- omf_ec
|
68
53
|
extensions: []
|
69
54
|
extra_rdoc_files: []
|
70
55
|
files:
|
71
56
|
- .gitignore
|
72
57
|
- Gemfile
|
73
58
|
- Rakefile
|
74
|
-
- bin/
|
75
|
-
- bin/omf_pre
|
76
|
-
- bin/omf_test
|
59
|
+
- bin/omf_ec
|
77
60
|
- config/ec.yml
|
78
|
-
- example/
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
- exp_repo/system/topo/active.rb
|
89
|
-
- exp_repo/system/topo/all.rb
|
90
|
-
- exp_repo/system/topo/circle.rb
|
91
|
-
- exp_repo/test/app/aodvd.rb
|
92
|
-
- exp_repo/test/app/appDef1.rb
|
93
|
-
- exp_repo/test/app/athstats.rb
|
94
|
-
- exp_repo/test/app/echo.rb
|
95
|
-
- exp_repo/test/app/gennyReceiverAppDef.rb
|
96
|
-
- exp_repo/test/app/gennySenderAppDef.rb
|
97
|
-
- exp_repo/test/app/itgdec.rb
|
98
|
-
- exp_repo/test/app/itgr.rb
|
99
|
-
- exp_repo/test/app/itgs.rb
|
100
|
-
- exp_repo/test/app/nop.rb
|
101
|
-
- exp_repo/test/app/otg2.rb
|
102
|
-
- exp_repo/test/app/otg2_mp.rb
|
103
|
-
- exp_repo/test/app/otr2.rb
|
104
|
-
- exp_repo/test/app/otr2_mp.rb
|
105
|
-
- exp_repo/test/app/trace_oml2.rb
|
106
|
-
- exp_repo/test/app/wlanconfig_oml2.rb
|
107
|
-
- exp_repo/test/exp/conf-room-demo.rb
|
108
|
-
- exp_repo/test/exp/planetlab.rb
|
109
|
-
- exp_repo/test/exp/test01.rb
|
110
|
-
- exp_repo/test/exp/test02.rb
|
111
|
-
- exp_repo/test/exp/test03.rb
|
112
|
-
- exp_repo/test/exp/test04.rb
|
113
|
-
- exp_repo/test/exp/test05.rb
|
114
|
-
- exp_repo/test/exp/test06.rb
|
115
|
-
- exp_repo/test/exp/tutorial/hello-world-wired.rb
|
116
|
-
- exp_repo/test/exp/tutorial/hello-world-wireless.rb
|
117
|
-
- exp_repo/test/exp/tutorial/using-filters.rb
|
118
|
-
- exp_repo/test/exp/tutorial/using-groups.rb
|
119
|
-
- exp_repo/test/exp/tutorial/using-properties.rb
|
120
|
-
- exp_repo/test/exp/tutorial/using-prototypes.rb
|
121
|
-
- exp_repo/test/proto/aodvrouter.rb
|
122
|
-
- exp_repo/test/proto/driverqueryapp.rb
|
123
|
-
- exp_repo/test/proto/forwarder.rb
|
124
|
-
- exp_repo/test/proto/itgcbrsender.rb
|
125
|
-
- exp_repo/test/proto/itgdecoder.rb
|
126
|
-
- exp_repo/test/proto/itgreceiver.rb
|
127
|
-
- exp_repo/test/proto/itgvoipsender.rb
|
128
|
-
- exp_repo/test/proto/listener2.rb
|
129
|
-
- exp_repo/test/proto/nop.rb
|
130
|
-
- exp_repo/test/proto/probelink.rb
|
131
|
-
- exp_repo/test/proto/raw_receiver.rb
|
132
|
-
- exp_repo/test/proto/receiver2_mp.rb
|
133
|
-
- exp_repo/test/proto/sender2_mp.rb
|
134
|
-
- exp_repo/test/proto/udp_receiver.rb
|
135
|
-
- exp_repo/test/proto/udp_sender.rb
|
61
|
+
- example/engine_oedl.rb
|
62
|
+
- example/engine_test.rb
|
63
|
+
- example/test_exp/test00.rb
|
64
|
+
- example/test_exp/test01.rb
|
65
|
+
- example/test_exp/test02.rb
|
66
|
+
- example/test_exp/test03.rb
|
67
|
+
- example/test_exp/test04.rb
|
68
|
+
- example/test_exp/test05.rb
|
69
|
+
- example/test_exp/test06.rb
|
70
|
+
- example/test_exp/test07.rb
|
136
71
|
- lib/omf_ec.rb
|
72
|
+
- lib/omf_ec/app_definition.rb
|
73
|
+
- lib/omf_ec/backward/app_definition.rb
|
74
|
+
- lib/omf_ec/backward/core_ext/array.rb
|
75
|
+
- lib/omf_ec/backward/default_events.rb
|
76
|
+
- lib/omf_ec/backward/dsl.rb
|
77
|
+
- lib/omf_ec/backward/exp/testbed.rb
|
78
|
+
- lib/omf_ec/backward/group.rb
|
79
|
+
- lib/omf_ec/context.rb
|
80
|
+
- lib/omf_ec/context/app_context.rb
|
81
|
+
- lib/omf_ec/context/def_app_context.rb
|
82
|
+
- lib/omf_ec/context/group_context.rb
|
83
|
+
- lib/omf_ec/context/net_context.rb
|
84
|
+
- lib/omf_ec/dsl.rb
|
85
|
+
- lib/omf_ec/experiment.rb
|
86
|
+
- lib/omf_ec/group.rb
|
137
87
|
- lib/omf_ec/version.rb
|
138
88
|
- omf_ec.gemspec
|
89
|
+
- test/omf_ec/context_spec.rb
|
90
|
+
- test/omf_ec/group_spec.rb
|
91
|
+
- test/test_helper.rb
|
139
92
|
homepage: https://www.mytestbed.net
|
140
93
|
licenses: []
|
141
94
|
post_install_message:
|
@@ -156,9 +109,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
109
|
version: 1.3.1
|
157
110
|
requirements: []
|
158
111
|
rubyforge_project: omf_ec
|
159
|
-
rubygems_version: 1.8.
|
112
|
+
rubygems_version: 1.8.17
|
160
113
|
signing_key:
|
161
114
|
specification_version: 3
|
162
115
|
summary: OMF experiment controller
|
163
|
-
test_files:
|
164
|
-
|
116
|
+
test_files:
|
117
|
+
- test/omf_ec/context_spec.rb
|
118
|
+
- test/omf_ec/group_spec.rb
|
119
|
+
- test/test_helper.rb
|
data/bin/omf
DELETED
@@ -1,147 +0,0 @@
|
|
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
DELETED
@@ -1,76 +0,0 @@
|
|
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
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "optparse"
|
4
|
-
require 'omf_common'
|
5
|
-
$stdout.sync = true
|
6
|
-
|
7
|
-
options = {
|
8
|
-
dsl: 'xmpp',
|
9
|
-
pubsub_host: 'pubsub',
|
10
|
-
}
|
11
|
-
|
12
|
-
executable_name = File.basename($PROGRAM_NAME)
|
13
|
-
|
14
|
-
option_parser = OptionParser.new do |opts|
|
15
|
-
opts.banner = "usage: #{executable_name} [options]"
|
16
|
-
|
17
|
-
opts.on("-u USER", "Username") do |user|
|
18
|
-
options[:user] = user
|
19
|
-
end
|
20
|
-
|
21
|
-
opts.on("-p PASSWORD", "Password") do |password|
|
22
|
-
options[:password] = password
|
23
|
-
end
|
24
|
-
|
25
|
-
opts.on("-s SERVER", "XMPP server") do |server|
|
26
|
-
options[:server] = server
|
27
|
-
end
|
28
|
-
|
29
|
-
opts.on("-n NODE", "PubSub node to subscribe") do |node|
|
30
|
-
options[:uid] = node
|
31
|
-
end
|
32
|
-
|
33
|
-
opts.on("-d", "--debug", "Debug mode") do
|
34
|
-
options[:debug] = true
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
begin
|
39
|
-
option_parser.parse!
|
40
|
-
rescue => e
|
41
|
-
puts e.message
|
42
|
-
puts ""
|
43
|
-
puts option_parser.help
|
44
|
-
exit(1)
|
45
|
-
end
|
46
|
-
|
47
|
-
unless options[:server] && options[:user] && options[:server]
|
48
|
-
puts option_parser.help
|
49
|
-
exit(1)
|
50
|
-
end
|
51
|
-
|
52
|
-
Logging.logger.root.level = :debug if options[:debug]
|
53
|
-
Blather.logger = logger
|
54
|
-
|
55
|
-
comm = OmfCommon::Comm.new(options[:dsl])
|
56
|
-
host = nil
|
57
|
-
|
58
|
-
# Create a resource of type mock
|
59
|
-
create_msg = OmfCommon::Message.create { |v| v.property('type', 'mock') }
|
60
|
-
|
61
|
-
create_wifi_msg = OmfCommon::Message.create do |v|
|
62
|
-
v.property('hrn', 'wlan0')
|
63
|
-
v.property('type', 'wifi')
|
64
|
-
end
|
65
|
-
|
66
|
-
# A request message to be sent to mock
|
67
|
-
request_mock_property = OmfCommon::Message.request do |v|
|
68
|
-
v.property('available_properties')
|
69
|
-
v.property('kernel_version')
|
70
|
-
v.property('resource_proxy_list')
|
71
|
-
v.property('resource_utility_list')
|
72
|
-
v.property('bob')
|
73
|
-
end
|
74
|
-
|
75
|
-
request_wifi_property = OmfCommon::Message.request do |v|
|
76
|
-
v.property('link')
|
77
|
-
v.property('available_properties')
|
78
|
-
end
|
79
|
-
|
80
|
-
# A request message to be sent to node
|
81
|
-
request_node_property = OmfCommon::Message.request do |v|
|
82
|
-
v.property('available_properties')
|
83
|
-
v.property('proxies')
|
84
|
-
end
|
85
|
-
|
86
|
-
# A configure message to be sent to mock
|
87
|
-
configure_mock_property = OmfCommon::Message.configure do |v|
|
88
|
-
v.property('hrn', 'human_readable_name')
|
89
|
-
end
|
90
|
-
|
91
|
-
# Simple release message
|
92
|
-
release_message = OmfCommon::Message.release
|
93
|
-
|
94
|
-
# For simplicity, use comm instance directly
|
95
|
-
comm.when_ready do
|
96
|
-
logger.info "CONNECTED: #{comm.jid.inspect}"
|
97
|
-
host = "#{options[:pubsub_host]}.#{comm.jid.domain}"
|
98
|
-
|
99
|
-
# We assume the node where RC runs started already
|
100
|
-
comm.subscribe(options[:uid], host) do |e|
|
101
|
-
if e.error?
|
102
|
-
comm.disconnect(host)
|
103
|
-
else
|
104
|
-
# Publish the create message to RC's pubsub topic
|
105
|
-
comm.publish(options[:uid], request_node_property, host)
|
106
|
-
comm.publish(options[:uid], create_wifi_msg, host)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
# Fired when messages published to the nodes I subscribed to
|
112
|
-
comm.node_event do |e|
|
113
|
-
e.items.each do |item|
|
114
|
-
begin
|
115
|
-
# Parse the message (pubsub item payload)
|
116
|
-
message = OmfCommon::Message.parse(item.payload)
|
117
|
-
context_id = message.read_content("context_id")
|
118
|
-
|
119
|
-
# We are only interested in inform messages for the moment
|
120
|
-
if message.operation == :inform
|
121
|
-
inform_type = message.read_content("inform_type")
|
122
|
-
|
123
|
-
case inform_type
|
124
|
-
when 'CREATED'
|
125
|
-
resource_id = message.read_content("resource_id")
|
126
|
-
logger.info "Resource #{resource_id} created"
|
127
|
-
|
128
|
-
comm.subscribe(resource_id, host) do |m|
|
129
|
-
EM.add_periodic_timer(2) do
|
130
|
-
comm.publish(resource_id, request_wifi_property, host)
|
131
|
-
#comm.publish(resource_id, request_mock_property, host)
|
132
|
-
#comm.publish(resource_id, configure_mock_property, host)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
when 'STATUS'
|
137
|
-
message.read_element("//property").each do |p|
|
138
|
-
logger.info "#{p.attr('key')} => #{p.content.strip}"
|
139
|
-
end
|
140
|
-
when 'RELEASED'
|
141
|
-
logger.info "Resource #{message.read_content("resource_id")} released"
|
142
|
-
when 'FAILED'
|
143
|
-
logger.error message.read_content("error_message")
|
144
|
-
end
|
145
|
-
end
|
146
|
-
rescue => e
|
147
|
-
logger.error "#{e.message}\n#{e.backtrace.join("\n")}"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
trap(:INT) { comm.disconnect(host) }
|
153
|
-
trap(:TERM) { comm.disconnect(host) }
|
154
|
-
|
155
|
-
EM.run do
|
156
|
-
comm.connect(options[:user], options[:password], options[:server])
|
157
|
-
|
158
|
-
EM.add_timer(5) do
|
159
|
-
comm.publish(options[:uid], release_message, host)
|
160
|
-
end
|
161
|
-
end
|
data/example/net_devices.rb
DELETED
@@ -1,75 +0,0 @@
|
|
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
|