omf_rc 6.0.0.pre.4 → 6.0.0.pre.5

Sign up to get free protection for your applications and to get access to all the features.
data/bin/omf_rc CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "optparse"
4
- require 'omf_common'
5
4
  require 'omf_rc'
6
5
  require 'omf_rc/resource_factory'
7
6
  $stdout.sync = true
@@ -27,8 +26,8 @@ option_parser = OptionParser.new do |opts|
27
26
  options[:server] = server
28
27
  end
29
28
 
30
- opts.on("-n NODE", "PubSub node to create, also becomes the uid of the resource") do |node|
31
- options[:uid] = node
29
+ opts.on("-t TOPIC", "PubSub topic to create, also becomes the uid of the resource") do |topic|
30
+ options[:uid] = topic
32
31
  end
33
32
 
34
33
  opts.on("-d", "--debug", "Debug mode") do
@@ -1,4 +1,3 @@
1
- require 'omf_common'
2
1
  require 'securerandom'
3
2
  require 'hashie'
4
3
  require 'omf_rc/resource_proxy_dsl'
@@ -9,13 +8,10 @@ require 'omf_rc/resource_proxy/abstract_resource'
9
8
  class OmfRc::ResourceFactory
10
9
  # List of registered resource proxies
11
10
  @@proxy_list = []
12
- # List of registered utilities
13
- @@utility_list = []
14
11
 
15
- # By default, we use xmpp_blather dsl, which based on blather
12
+ # By default, we use xmpp dsl, which based on blather
16
13
  DEFAULT_OPTS = {
17
- dsl: 'xmpp_blather',
18
- pubsub_host: 'pubsub'
14
+ dsl: 'xmpp'
19
15
  }
20
16
 
21
17
  class << self
@@ -31,7 +27,7 @@ class OmfRc::ResourceFactory
31
27
  # Create a new instance of abstract resource
32
28
  resource = OmfRc::ResourceProxy::AbstractResource.new(type, opts, comm)
33
29
  # Then extend this instance with relevant module identified by type
34
- resource.extend("OmfRc::ResourceProxy::#{type.camelcase}".constant)
30
+ resource.extend("OmfRc::ResourceProxy::#{type.camelize}".constantize)
35
31
  # Execute resource before_ready hook if any
36
32
  resource.before_ready if resource.respond_to? :before_ready
37
33
  resource
@@ -44,17 +40,7 @@ class OmfRc::ResourceFactory
44
40
 
45
41
  # Add a proxy to the list
46
42
  def register_proxy(proxy)
47
- @@proxy_list << proxy
48
- end
49
-
50
- # Return the utility list
51
- def utility_list
52
- @@utility_list
53
- end
54
-
55
- # Add a utility to the list
56
- def register_utility(utility)
57
- @@utility_list << utility
43
+ @@proxy_list << proxy unless @@proxy_list.include?(proxy)
58
44
  end
59
45
 
60
46
  # Require files from default resource proxy library folder
@@ -1,18 +1,17 @@
1
- require 'omf_common'
2
1
  require 'omf_rc/deferred_process'
3
2
  require 'omf_rc/message_process_error'
4
3
  require 'securerandom'
5
4
  require 'hashie'
6
5
 
7
6
  class OmfRc::ResourceProxy::AbstractResource
8
- # Time to wait before shutting down event loop, wait for deleting pubsub nodes
7
+ # Time to wait before shutting down event loop, wait for deleting pubsub topics
9
8
  DISCONNECT_WAIT = 5
10
- # Time to wait before releasing resource, wait for deleting pubsub nodes
9
+ # Time to wait before releasing resource, wait for deleting pubsub topics
11
10
  RELEASE_WAIT = 5
12
11
 
13
- # @!attribute metadata
12
+ # @!attribute property
14
13
  # @return [String] the resource's internal meta data storage
15
- attr_accessor :uid, :hrn, :type, :comm, :metadata
14
+ attr_accessor :uid, :hrn, :type, :comm, :property
16
15
  attr_reader :opts, :children, :host
17
16
 
18
17
  # Initialisation
@@ -21,11 +20,11 @@ class OmfRc::ResourceProxy::AbstractResource
21
20
  # @param [Hash] opts options to be initialised
22
21
  # @option opts [String] :uid Unique identifier
23
22
  # @option opts [String] :hrn Human readable name
24
- # @option opts [String] :pubsub_host pubsub server subdomain, default to 'pubsub'
25
23
  # @option opts [String] :dsl Which pubsub DSL to be used for pubsub communication
26
24
  # @option opts [String] :user pubsub user id
27
25
  # @option opts [String] :password pubsub user password
28
26
  # @option opts [String] :server pubsub server domain
27
+ # @option opts [String] :property A hash for keeping internal state
29
28
  # @param [Comm] comm communicator instance, pass this to new resource proxy instance if want to use a common communicator instance.
30
29
  def initialize(type, opts = nil, comm = nil)
31
30
  @opts = Hashie::Mash.new(opts)
@@ -34,24 +33,24 @@ class OmfRc::ResourceProxy::AbstractResource
34
33
  @hrn = @opts.hrn
35
34
  @children ||= []
36
35
  @host = nil
37
- @metadata = @opts.metadata || Hashie::Mash.new
36
+ @property = @opts.property || Hashie::Mash.new
38
37
 
39
38
  @comm = comm || OmfCommon::Comm.new(@opts.dsl)
40
39
  # Fire when connection to pubsub server established
41
40
  @comm.when_ready do
42
41
  logger.info "CONNECTED: #{@comm.jid.inspect}"
43
- @host = "#{@opts.pubsub_host}.#{@comm.jid.domain}"
42
+ @host = @comm.jid.domain
44
43
 
45
- # Once connection established, create a pubsub node, then subscribe to it
46
- @comm.create_node(uid, host) do |s|
47
- # Creating node failed, no point to continue; clean up and disconnect
48
- # Otherwise go subscribe to this pubsub node
44
+ # Once connection established, create a pubsub topic, then subscribe to it
45
+ @comm.create_topic(uid, host) do |s|
46
+ # Creating topic failed, no point to continue; clean up and disconnect
47
+ # Otherwise go subscribe to this pubsub topic
49
48
  s.error? ? disconnect : @comm.subscribe(uid, host)
50
49
  end
51
50
  end
52
51
 
53
52
  # Fire when message published
54
- @comm.node_event do |e|
53
+ @comm.topic_event do |e|
55
54
  e.items.each do |item|
56
55
  process_omf_message(item.payload, e.node)
57
56
  end
@@ -68,21 +67,21 @@ class OmfRc::ResourceProxy::AbstractResource
68
67
  @comm.connect(opts.user, opts.password, opts.server)
69
68
  end
70
69
 
71
- # Try to clean up pubsub nodes, and wait for DISCONNECT_WAIT seconds, then shutdown event machine loop
70
+ # Try to clean up pubsub topics, and wait for DISCONNECT_WAIT seconds, then shutdown event machine loop
72
71
  def disconnect
73
- @comm.pubsub.affiliations(host) do |a|
74
- my_pubsub_nodes = a[:owner] ? a[:owner].size : 0
75
- if my_pubsub_nodes > 0
76
- logger.info "Cleaning #{my_pubsub_nodes} pubsub node(s)"
77
- a[:owner].each { |node| @comm.delete_node(node, host) }
72
+ @comm.affiliations(host) do |a|
73
+ my_pubsub_topics = a[:owner] ? a[:owner].size : 0
74
+ if my_pubsub_topics > 0
75
+ logger.info "Cleaning #{my_pubsub_topics} pubsub topic(s)"
76
+ a[:owner].each { |topic| @comm.delete_topic(topic, host) }
78
77
  else
79
78
  logger.info "Disconnecting now"
80
- @comm.disconnect(host)
79
+ @comm.disconnect
81
80
  end
82
81
  end
83
82
  logger.info "Disconnecting in #{DISCONNECT_WAIT} seconds"
84
83
  EM.add_timer(DISCONNECT_WAIT) do
85
- @comm.disconnect(host)
84
+ @comm.disconnect
86
85
  end
87
86
  end
88
87
 
@@ -99,15 +98,13 @@ class OmfRc::ResourceProxy::AbstractResource
99
98
  # Release a resource
100
99
  #
101
100
  def release
102
- pubsub_nodes_left = []
101
+ pubsub_topics_left = []
103
102
  children.each do |c|
104
103
  c.before_release if c.respond_to? :before_release
105
- pubsub_nodes_left << c.uid
106
- c.freeze
104
+ pubsub_topics_left << c.uid
107
105
  end.clear
108
106
  before_release if respond_to? :before_release
109
- freeze
110
- pubsub_nodes_left
107
+ pubsub_topics_left
111
108
  end
112
109
 
113
110
  # Return a list of all properties can be requested and configured
@@ -147,7 +144,7 @@ class OmfRc::ResourceProxy::AbstractResource
147
144
 
148
145
  # Parse omf message and execute as instructed by the message
149
146
  #
150
- def process_omf_message(pubsub_item_payload, node)
147
+ def process_omf_message(pubsub_item_payload, topic)
151
148
  dp = OmfRc::DeferredProcess.new
152
149
 
153
150
  dp.callback do |end_result|
@@ -155,7 +152,7 @@ class OmfRc::ResourceProxy::AbstractResource
155
152
  case end_result[:operation]
156
153
  when :create
157
154
  new_uid = end_result[:result]
158
- @comm.create_node(new_uid, host) do
155
+ @comm.create_topic(new_uid, host) do
159
156
  @comm.subscribe(new_uid, host) do
160
157
  inform_msg = OmfCommon::Message.inform(end_result[:context_id], 'CREATED') do |i|
161
158
  i.element('resource_id', new_uid)
@@ -185,7 +182,7 @@ class OmfRc::ResourceProxy::AbstractResource
185
182
  end
186
183
 
187
184
  end_result[:result].each do |n|
188
- @comm.delete_node(n, host)
185
+ @comm.delete_topic(n, host)
189
186
  end
190
187
 
191
188
  EM.add_timer(RELEASE_WAIT) do
@@ -207,10 +204,10 @@ class OmfRc::ResourceProxy::AbstractResource
207
204
  # Get the context id, which will be included when informing
208
205
  context_id = message.read_content("context_id")
209
206
 
210
- obj = node == uid ? self : children.find { |v| v.uid == node }
207
+ obj = topic == uid ? self : children.find { |v| v.uid == topic }
211
208
 
212
209
  begin
213
- raise "Resource disappeard #{node}" if obj.nil?
210
+ raise "Resource disappeard #{topic}" if obj.nil?
214
211
 
215
212
  case message.operation
216
213
  when :create
@@ -32,7 +32,7 @@ module OmfRc::ResourceProxyDSL
32
32
  #
33
33
  # Currently the system supports two hooks:
34
34
  #
35
- # * before_ready, called when a resource created, before creating an associated pubsub node
35
+ # * before_ready, called when a resource created, before creating an associated pubsub topic
36
36
  # * before_release, called before a resource released
37
37
  #
38
38
  # @param [Symbol] name hook name. :before_create or :before_release
@@ -75,12 +75,12 @@ module OmfRc::ResourceProxyDSL
75
75
  name = name.to_s
76
76
  begin
77
77
  # In case of module defined inline
78
- include "OmfRc::Util::#{name.camelcase}".constant
78
+ include "OmfRc::Util::#{name.camelize}".constantize
79
79
  rescue NameError
80
80
  begin
81
81
  # Then we try to require the file and include the module
82
82
  require "#{UTIL_DIR}/#{name}"
83
- include "OmfRc::Util::#{name.camelcase}".constant
83
+ include "OmfRc::Util::#{name.camelize}".constantize
84
84
  rescue LoadError => le
85
85
  logger.error le.message
86
86
  rescue NameError => ne
@@ -89,22 +89,6 @@ module OmfRc::ResourceProxyDSL
89
89
  end
90
90
  end
91
91
 
92
- # Register a named utility entry with factory class, normally this should be done in the utility module
93
- #
94
- # @param [Symbol] name of the resource proxy
95
- # @example suppose we define a utility for iw command interaction
96
- #
97
- # module OmfRc::Util::Iw
98
- # include OmfRc::ResourceProxyDSL
99
- #
100
- # # Let the factory know it is available
101
- # register_utility :iw
102
- # end
103
- def register_utility(name)
104
- name = name.to_sym
105
- OmfRc::ResourceFactory.register_utility(name)
106
- end
107
-
108
92
  # Register a configurable property
109
93
  #
110
94
  # @param [Symbol] name of the property
@@ -1,10 +1,11 @@
1
1
  require 'hashie'
2
+
2
3
  module OmfRc::Util::Iw
3
4
  include OmfRc::ResourceProxyDSL
4
5
 
5
6
  OmfCommon::Command.execute("iw help").chomp.gsub(/^\t/, '').split("\n").map {|v| v.match(/[phy|dev] <.+> set (\w+) .*/) && $1 }.compact.uniq.each do |p|
6
7
  configure p do |resource, value|
7
- OmfCommon::Command.execute("#{IW_CMD} #{resource.hrn} set #{p} #{value}")
8
+ OmfCommon::Command.execute("iw #{resource.hrn} set #{p} #{value}")
8
9
  end
9
10
  end
10
11
 
@@ -1,8 +1,6 @@
1
1
  module OmfRc::Util::Mock
2
2
  include OmfRc::ResourceProxyDSL
3
3
 
4
- register_utility :mock
5
-
6
4
  request :nothing do |resource|
7
5
  resource.uid
8
6
  end
@@ -17,10 +15,6 @@ module OmfRc::Util::Mock
17
15
  OmfRc::ResourceFactory.proxy_list
18
16
  end
19
17
 
20
- request :resource_utility_list do
21
- OmfRc::ResourceFactory.utility_list
22
- end
23
-
24
18
  request :kernel_version do
25
19
  OmfCommon::Command.execute("uname -r")
26
20
  end
@@ -1,12 +1,10 @@
1
1
  module OmfRc::Util::Mod
2
2
  include OmfRc::ResourceProxyDSL
3
3
 
4
- register_utility :mod
5
-
6
4
  request :modules do
7
5
  OmfCommon::Command.execute('lsmod').split("\n").map do |v|
8
- v.match(/^(.+)\W*.+$/) && $1
9
- end.compact
6
+ v.match(/^(\w+).+$/) && $1
7
+ end.compact.tap { |ary| ary.shift }
10
8
  end
11
9
 
12
10
  configure :load_module do |resource, value|
@@ -1,3 +1,3 @@
1
1
  module OmfRc
2
- VERSION = "6.0.0.pre.4"
2
+ VERSION = "6.0.0.pre.5"
3
3
  end
data/lib/omf_rc.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'omf_common'
1
2
  require "omf_rc/version"
2
3
 
3
4
  module OmfRc
@@ -0,0 +1,228 @@
1
+ Usage: iw [options] command
2
+ Options:
3
+ --debug enable netlink debugging
4
+ --version show version (3.4)
5
+ Commands:
6
+ help [command]
7
+ Print usage for all or a specific command, e.g.
8
+ "help wowlan" or "help wowlan enable".
9
+
10
+ event [-t] [-r] [-f]
11
+ Monitor events from the kernel.
12
+ -t - print timestamp
13
+ -r - print relative timstamp
14
+ -f - print full frame for auth/assoc etc.
15
+
16
+ phy
17
+ list
18
+ List all wireless devices and their capabilities.
19
+
20
+ phy <phyname> info
21
+ Show capabilities for the specified wireless device.
22
+
23
+ dev
24
+ List all network interfaces for wireless hardware.
25
+
26
+ dev <devname> info
27
+ Show information for this interface.
28
+
29
+ dev <devname> del
30
+ Remove this virtual interface
31
+
32
+ dev <devname> interface add <name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*]
33
+ phy <phyname> interface add <name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*]
34
+ Add a new virtual interface with the given configuration.
35
+ Valid interface types are: managed, ibss, monitor, mesh, wds.
36
+
37
+ The flags are only used for monitor interfaces, valid flags are:
38
+ none: no special flags
39
+ fcsfail: show frames with FCS errors
40
+ control: show control frames
41
+ otherbss: show frames from other BSSes
42
+ cook: use cooked mode
43
+
44
+ The mesh_id is used only for mesh mode.
45
+
46
+ dev <devname> ibss join <SSID> <freq in MHz> [HT20|HT40+|HT40-|NOHT] [fixed-freq] [<fixed bssid>] [beacon-interval <TU>] [basic-rates <rate in Mbps,rate2,...>] [mcast-rate <rate in Mbps>] [key d:0:abcde]
47
+ Join the IBSS cell with the given SSID, if it doesn't exist create
48
+ it on the given frequency. When fixed frequency is requested, don't
49
+ join/create a cell on a different frequency. When a fixed BSSID is
50
+ requested use that BSSID and do not adopt another cell's BSSID even
51
+ if it has higher TSF and the same SSID. If an IBSS is created, create
52
+ it with the specified basic-rates, multicast-rate and beacon-interval.
53
+
54
+ dev <devname> ibss leave
55
+ Leave the current IBSS cell.
56
+
57
+ dev <devname> station dump
58
+ List all stations known, e.g. the AP on managed interfaces
59
+
60
+ dev <devname> station set <MAC address> vlan <ifindex>
61
+ Set an AP VLAN for this station.
62
+
63
+ dev <devname> station set <MAC address> plink_action <open|block>
64
+ Set mesh peer link action for this station (peer).
65
+
66
+ dev <devname> station del <MAC address>
67
+ Remove the given station entry (use with caution!)
68
+
69
+ dev <devname> station get <MAC address>
70
+ Get information for a specific station.
71
+
72
+ dev <devname> survey dump
73
+ List all gathered channel survey data
74
+
75
+ dev <devname> mesh leave
76
+ Leave a mesh.
77
+
78
+ dev <devname> mesh join <mesh ID> [mcast-rate <rate in Mbps>] [<param>=<value>]*
79
+ Join a mesh with the given mesh ID with mcast-rate and mesh parameters.
80
+
81
+ dev <devname> mpath dump
82
+ List known mesh paths.
83
+
84
+ dev <devname> mpath set <destination MAC address> next_hop <next hop MAC address>
85
+ Set an existing mesh path's next hop.
86
+
87
+ dev <devname> mpath new <destination MAC address> next_hop <next hop MAC address>
88
+ Create a new mesh path (instead of relying on automatic discovery).
89
+
90
+ dev <devname> mpath del <MAC address>
91
+ Remove the mesh path to the given node.
92
+
93
+ dev <devname> mpath get <MAC address>
94
+ Get information on mesh path to the given node.
95
+
96
+ dev <devname> scan [-u] [freq <freq>*] [ies <hex as 00:11:..>] [ssid <ssid>*|passive]
97
+ Scan on the given frequencies and probe for the given SSIDs
98
+ (or wildcard if not given) unless passive scanning is requested.
99
+ If -u is specified print unknown data in the scan results.
100
+ Specified (vendor) IEs must be well-formed.
101
+
102
+ dev <devname> scan trigger [freq <freq>*] [ies <hex as 00:11:..>] [ssid <ssid>*|passive]
103
+ Trigger a scan on the given frequencies with probing for the given
104
+ SSIDs (or wildcard if not given) unless passive scanning is requested.
105
+
106
+ dev <devname> scan dump [-u]
107
+ Dump the current scan results. If -u is specified, print unknown
108
+ data in scan results.
109
+
110
+ reg get
111
+ Print out the kernel's current regulatory domain information.
112
+
113
+ reg set <ISO/IEC 3166-1 alpha2>
114
+ Notify the kernel about the current regulatory domain.
115
+
116
+ dev <devname> connect [-w] <SSID> [<freq in MHz>] [<bssid>] [key 0:abcde d:1:6162636465]
117
+ Join the network with the given SSID (and frequency, BSSID).
118
+ With -w, wait for the connect to finish or fail.
119
+
120
+ dev <devname> disconnect
121
+ Disconnect from the current network.
122
+
123
+ dev <devname> link
124
+ Print information about the current link, if any.
125
+
126
+ dev <devname> offchannel <freq> <duration>
127
+ Leave operating channel and go to the given channel for a while.
128
+
129
+ dev <devname> cqm rssi <threshold|off> [<hysteresis>]
130
+ Set connection quality monitor RSSI threshold.
131
+
132
+
133
+ phy <phyname> wowlan show
134
+ Show WoWLAN status.
135
+
136
+ phy <phyname> wowlan disable
137
+ Disable WoWLAN.
138
+
139
+ phy <phyname> wowlan enable [any] [disconnect] [magic-packet] [gtk-rekey-failure] [eap-identity-request] [4way-handshake] [rfkill-release] [patterns <pattern>*]
140
+ Enable WoWLAN with the given triggers.
141
+ Each pattern is given as a bytestring with '-' in places where any byte
142
+ may be present, e.g. 00:11:22:-:44 will match 00:11:22:33:44 and
143
+ 00:11:22:33:ff:44 etc.
144
+
145
+ dev <devname> roc start <freq> <time>
146
+
147
+
148
+ phy <phyname> set antenna <bitmap> | all | <tx bitmap> <rx bitmap>
149
+ Set a bitmap of allowed antennas to use for TX and RX.
150
+ The driver may reject antenna configurations it cannot support.
151
+
152
+ dev <devname> set txpower <auto|fixed|limit> [<tx power in mBm>]
153
+ Specify transmit power level and setting type.
154
+
155
+ phy <phyname> set txpower <auto|fixed|limit> [<tx power in mBm>]
156
+ Specify transmit power level and setting type.
157
+
158
+ phy <phyname> set distance <distance>
159
+ Set appropriate coverage class for given link distance in meters.
160
+ Valid values: 0 - 114750
161
+
162
+ phy <phyname> set coverage <coverage class>
163
+ Set coverage class (1 for every 3 usec of air propagation time).
164
+ Valid values: 0 - 255.
165
+
166
+ phy <phyname> set netns <pid>
167
+ Put this wireless device into a different network namespace
168
+
169
+ phy <phyname> set rts <rts threshold|off>
170
+ Set rts threshold.
171
+
172
+ phy <phyname> set frag <fragmentation threshold|off>
173
+ Set fragmentation threshold.
174
+
175
+ dev <devname> set channel <channel> [HT20|HT40+|HT40-]
176
+ phy <phyname> set channel <channel> [HT20|HT40+|HT40-]
177
+ dev <devname> set freq <freq> [HT20|HT40+|HT40-]
178
+ phy <phyname> set freq <freq> [HT20|HT40+|HT40-]
179
+ Set frequency/channel the hardware is using, including HT
180
+ configuration.
181
+
182
+ phy <phyname> set name <new name>
183
+ Rename this wireless device.
184
+
185
+ dev <devname> set peer <MAC address>
186
+ Set interface WDS peer.
187
+
188
+ dev <devname> set noack_map <map>
189
+ Set the NoAck map for the TIDs. (0x0009 = BE, 0x0006 = BK, 0x0030 = VI, 0x00C0 = VO)
190
+
191
+ dev <devname> set 4addr <on|off>
192
+ Set interface 4addr (WDS) mode.
193
+
194
+ dev <devname> set type <type>
195
+ Set interface type/mode.
196
+ Valid interface types are: managed, ibss, monitor, mesh, wds.
197
+
198
+ dev <devname> set meshid <meshid>
199
+ dev <devname> set monitor <flag>*
200
+ Set monitor flags. Valid flags are:
201
+ none: no special flags
202
+ fcsfail: show frames with FCS errors
203
+ control: show control frames
204
+ otherbss: show frames from other BSSes
205
+ cook: use cooked mode
206
+
207
+ dev <devname> set mesh_param <param>=<value> [<param>=<value>]*
208
+ Set mesh parameter (run command without any to see available ones).
209
+
210
+ dev <devname> set power_save <on|off>
211
+ Set power save state to on or off.
212
+
213
+ dev <devname> set bitrates [legacy-<2.4|5> <legacy rate in Mbps>*] [mcs-<2.4|5> <MCS index>*]
214
+ Sets up the specified rate masks.
215
+ Not passing any arguments would clear the existing mask (if any).
216
+
217
+ dev <devname> get mesh_param [<param>]
218
+ Retrieve mesh parameter (run command without any to see available ones).
219
+
220
+ dev <devname> get power_save <param>
221
+ Retrieve power save state.
222
+
223
+
224
+ You can omit the 'phy' or 'dev' if the identification is unique,
225
+ e.g. "iw wlan0 info" or "iw phy0 info". (Don't when scripting.)
226
+
227
+ Do NOT screenscrape this tool, we don't consider its output stable.
228
+
@@ -0,0 +1,11 @@
1
+ Connected to 00:14:bf:0c:e7:a4 (on wlan0)
2
+ SSID: dd-wrt
3
+ freq: 2427
4
+ RX: 1772745 bytes (25092 packets)
5
+ TX: 9473 bytes (111 packets)
6
+ signal: -37 dBm
7
+ tx bitrate: 1.0 MBit/s
8
+
9
+ bss flags: short-preamble short-slot-time
10
+ dtim period: 0
11
+ beacon int: 100
@@ -0,0 +1,106 @@
1
+ Module Size Used by
2
+ ip6table_filter 12540 0
3
+ ip6_tables 22175 1 ip6table_filter
4
+ iptable_filter 12536 0
5
+ ip_tables 22042 1 iptable_filter
6
+ ebtable_nat 12580 0
7
+ ebtables 26235 1 ebtable_nat
8
+ x_tables 19073 5 ebtables,ip_tables,iptable_filter,ip6_tables,ip6table_filter
9
+ parport_pc 22364 0
10
+ ppdev 12763 0
11
+ lp 17149 0
12
+ parport 31858 3 lp,ppdev,parport_pc
13
+ rfcomm 33656 8
14
+ bnep 17567 2
15
+ cpufreq_stats 12866 0
16
+ cpufreq_userspace 12576 0
17
+ cpufreq_powersave 12454 0
18
+ cpufreq_conservative 13147 0
19
+ pci_stub 12429 1
20
+ vboxpci 19066 0
21
+ autofs4 27582 2
22
+ vboxnetadp 25443 0
23
+ vboxnetflt 23571 0
24
+ vboxdrv 190105 3 vboxnetflt,vboxnetadp,vboxpci
25
+ uinput 17440 1
26
+ nfsd 211858 2
27
+ nfs 312243 0
28
+ nfs_acl 12511 2 nfs,nfsd
29
+ auth_rpcgss 37143 2 nfs,nfsd
30
+ fscache 36739 1 nfs
31
+ lockd 67328 2 nfs,nfsd
32
+ sunrpc 173671 6 lockd,auth_rpcgss,nfs_acl,nfs,nfsd
33
+ loop 22641 0
34
+ fuse 61981 1
35
+ kvm 287662 0
36
+ snd_hda_codec_conexant 45252 1
37
+ joydev 17266 0
38
+ arc4 12458 2
39
+ coretemp 12898 0
40
+ crc32c_intel 12747 0
41
+ btusb 17502 2
42
+ bluetooth 119406 23 btusb,bnep,rfcomm
43
+ crc16 12343 1 bluetooth
44
+ snd_hda_intel 26345 0
45
+ ghash_clmulni_intel 13133 0
46
+ i2c_i801 16870 0
47
+ snd_hda_codec 78031 2 snd_hda_intel,snd_hda_codec_conexant
48
+ snd_hwdep 13186 1 snd_hda_codec
49
+ snd_pcm 63900 2 snd_hda_codec,snd_hda_intel
50
+ snd_page_alloc 13003 2 snd_pcm,snd_hda_intel
51
+ aesni_intel 50667 0
52
+ aes_x86_64 16796 1 aesni_intel
53
+ pcspkr 12579 0
54
+ psmouse 64455 0
55
+ thinkpad_acpi 61270 0
56
+ aes_generic 33026 2 aes_x86_64,aesni_intel
57
+ nvram 13049 1 thinkpad_acpi
58
+ cryptd 14517 2 aesni_intel,ghash_clmulni_intel
59
+ serio_raw 12931 0
60
+ snd_seq 45093 0
61
+ evdev 17562 15
62
+ snd_seq_device 13176 1 snd_seq
63
+ snd_timer 22917 2 snd_seq,snd_pcm
64
+ iwlwifi 170823 0
65
+ i915 355994 3
66
+ mac80211 192768 1 iwlwifi
67
+ snd 52850 9 snd_timer,snd_seq_device,snd_seq,thinkpad_acpi,snd_pcm,snd_hwdep,snd_hda_codec,snd_hda_intel,snd_hda_codec_conexant
68
+ cfg80211 137140 2 mac80211,iwlwifi
69
+ drm_kms_helper 27227 1 i915
70
+ iTCO_wdt 17081 0
71
+ iTCO_vendor_support 12704 1 iTCO_wdt
72
+ drm 167670 4 drm_kms_helper,i915
73
+ soundcore 13065 1 snd
74
+ battery 13109 0
75
+ rfkill 19012 4 cfg80211,thinkpad_acpi,bluetooth
76
+ i2c_algo_bit 12841 1 i915
77
+ i2c_core 23876 5 i2c_algo_bit,drm,drm_kms_helper,i915,i2c_i801
78
+ ac 12624 0
79
+ power_supply 13475 2 ac,battery
80
+ tpm_tis 17454 0
81
+ tpm 17862 1 tpm_tis
82
+ tpm_bios 12948 1 tpm
83
+ video 17628 1 i915
84
+ wmi 13243 0
85
+ acpi_cpufreq 12935 1
86
+ mperf 12453 1 acpi_cpufreq
87
+ button 12937 1 i915
88
+ processor 28157 1 acpi_cpufreq
89
+ xfs 594991 4
90
+ dm_mod 63545 12
91
+ sd_mod 36136 2
92
+ crc_t10dif 12348 1 sd_mod
93
+ sdhci_pci 17976 0
94
+ ahci 24997 1
95
+ libahci 22860 1 ahci
96
+ xhci_hcd 73170 0
97
+ libata 140589 2 libahci,ahci
98
+ sdhci 27053 1 sdhci_pci
99
+ mmc_core 72460 2 sdhci,sdhci_pci
100
+ ehci_hcd 40215 0
101
+ scsi_mod 162372 2 libata,sd_mod
102
+ usbcore 128498 4 ehci_hcd,xhci_hcd,btusb
103
+ e1000e 120822 0
104
+ usb_common 12354 1 usbcore
105
+ thermal 17383 0
106
+ thermal_sys 18040 3 thermal,processor,video
@@ -0,0 +1,15 @@
1
+ FIXTURE_DIR = "#{File.dirname(__FILE__)}/fixture"
2
+
3
+ OmfCommon::Command = MiniTest::Mock.new
4
+
5
+ def mock_execute(result, command_pattern)
6
+ OmfCommon::Command.expect :execute, result, [command_pattern]
7
+ end
8
+
9
+ def mock_verify_execute
10
+ OmfCommon::Command.verify
11
+ end
12
+
13
+ def fixture(name)
14
+ File.read("#{FIXTURE_DIR}/#{name.to_s}")
15
+ end
@@ -1,13 +1,16 @@
1
1
  require 'test_helper'
2
+ require 'mock_helper'
2
3
  require 'omf_rc/resource_factory'
3
4
 
4
5
  describe OmfRc::ResourceFactory do
5
6
  describe "when resource proxies loaded" do
6
7
  it "must have list of registered proxies and utilities" do
8
+ OmfRc::ResourceFactory.load_default_resource_proxies
7
9
  OmfRc::ResourceFactory.proxy_list.must_include :mock
8
10
  end
9
11
 
10
12
  it "must be able to create new resource proxy" do
13
+ OmfRc::ResourceFactory.load_default_resource_proxies
11
14
  mock = OmfRc::ResourceFactory.new(:mock)
12
15
  mock.must_be_kind_of OmfRc::ResourceProxy::AbstractResource
13
16
  mock.must_respond_to :request_nothing
@@ -42,6 +42,11 @@ describe AbstractResource do
42
42
  @node.uid.must_match /.{8}-.{4}-.{4}-.{4}-.{12}/
43
43
  @node.request_uid.must_match /.{8}-.{4}-.{4}-.{4}-.{12}/
44
44
  end
45
+
46
+ it "could keep state inside 'property' instnace variable" do
47
+ @node.property.bob = "test"
48
+ @node.property.bob.must_equal "test"
49
+ end
45
50
  end
46
51
 
47
52
  describe "when asked to create another resource" do
@@ -59,7 +64,6 @@ describe AbstractResource do
59
64
  describe "when destroyed" do
60
65
  it "must destroy itself together with any resources created by it" do
61
66
  @node.release
62
- @node.frozen?.must_equal true
63
67
  @node.children.must_be_empty
64
68
  end
65
69
  end
@@ -78,5 +82,3 @@ describe AbstractResource do
78
82
  end
79
83
  end
80
84
  end
81
-
82
-
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+ require 'omf_rc/resource_proxy/node'
3
+
4
+ describe OmfRc::ResourceProxy::Node do
5
+ describe "when included in the resource instance" do
6
+ it "must be able to tell registered proxies" do
7
+ OmfRc::ResourceFactory.new(:node, hrn: 'node_test').request_proxies.must_include :node
8
+ end
9
+ end
10
+ end
@@ -5,7 +5,6 @@ describe OmfRc::ResourceProxyDSL do
5
5
  before do
6
6
  module OmfRc::Util::MockUtility
7
7
  include OmfRc::ResourceProxyDSL
8
- register_utility :mock_utility
9
8
  configure :alpha
10
9
  request :alpha
11
10
  end
@@ -16,9 +15,7 @@ describe OmfRc::ResourceProxyDSL do
16
15
  register_proxy :mock_proxy
17
16
  utility :mock_utility
18
17
 
19
- hook :before_ready do
20
- "bob"
21
- end
18
+ hook :before_ready
22
19
  hook :before_release
23
20
  configure :bravo
24
21
  request :bravo
@@ -28,7 +25,6 @@ describe OmfRc::ResourceProxyDSL do
28
25
  describe "when included by modules to define resource proxy functionalities" do
29
26
  it "must be able to register the modules" do
30
27
  OmfRc::ResourceFactory.proxy_list.must_include :mock_proxy
31
- OmfRc::ResourceFactory.utility_list.must_include :mock_utility
32
28
  end
33
29
 
34
30
  it "must be able to define methods" do
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+ require 'mock_helper'
3
+
4
+ mock_execute(fixture("iw/help"), "iw help")
5
+
6
+ require 'omf_rc/util/iw'
7
+
8
+ describe OmfRc::Util::Iw do
9
+ describe "when included in the resource instance" do
10
+ before do
11
+ module OmfRc::ResourceProxy::IwTest
12
+ include OmfRc::ResourceProxyDSL
13
+ register_proxy :iw_test
14
+ utility :iw
15
+ end
16
+ end
17
+
18
+ after do
19
+ mock_verify_execute
20
+ end
21
+
22
+ it "must provide features defined in proxy" do
23
+ %w(request_link configure_name configure_channel configure_bitrates).each do |m|
24
+ OmfRc::Util::Iw.method_defined?(m).must_equal true
25
+ end
26
+ end
27
+
28
+ it "could request properties of the wifi device" do
29
+ mock_execute(fixture("iw/link"), "iw wlan00 link")
30
+ OmfRc::ResourceFactory.new(:iw_test, hrn: 'wlan00').request_link.keys.must_include "ssid"
31
+ end
32
+
33
+ it "could configure the device's prorperty" do
34
+ mock_execute(nil, /iw wlan00 set */)
35
+ OmfRc::ResourceFactory.new(:iw_test, hrn: 'wlan00').configure_power_save.must_be_nil
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+ require 'mock_helper'
3
+ require 'omf_rc/util/mod'
4
+
5
+ describe OmfRc::Util::Mod do
6
+ describe "when included in the resource instance" do
7
+ before do
8
+ module OmfRc::ResourceProxy::ModTest
9
+ include OmfRc::ResourceProxyDSL
10
+ register_proxy :mod_test
11
+ utility :mod
12
+ end
13
+ end
14
+
15
+ after do
16
+ mock_verify_execute
17
+ end
18
+
19
+ it "will find out a list of modules" do
20
+ mock_execute(fixture("lsmod"), "lsmod")
21
+ OmfRc::ResourceFactory.new(:mod_test).request_modules.must_include "kvm"
22
+ OmfRc::ResourceFactory.new(:mod_test).request_modules.wont_include "Module"
23
+ end
24
+
25
+ it "could load a module" do
26
+ mock_execute(nil, /modprobe */)
27
+ OmfRc::ResourceFactory.new(:mod_test).configure_load_module('magic_module').must_be_nil
28
+ end
29
+ end
30
+ end
data/test/test_helper.rb CHANGED
@@ -5,7 +5,5 @@ require 'minitest/pride'
5
5
  require 'omf_rc'
6
6
  require 'omf_rc/resource_factory'
7
7
 
8
- OmfRc::ResourceFactory.load_default_resource_proxies
9
-
10
8
  # Shut up all the loggers
11
9
  Logging.logger.root.clear_appenders
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_rc
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.pre.4
4
+ version: 6.0.0.pre.5
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-07-04 00:00:00.000000000 Z
12
+ date: 2012-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -88,10 +88,17 @@ files:
88
88
  - lib/omf_rc/util/package.rb
89
89
  - lib/omf_rc/version.rb
90
90
  - omf_rc.gemspec
91
+ - test/fixture/iw/help
92
+ - test/fixture/iw/link
93
+ - test/fixture/lsmod
94
+ - test/mock_helper.rb
91
95
  - test/omf_rc/deferred_process_spec.rb
92
96
  - test/omf_rc/resource_factory_spec.rb
93
97
  - test/omf_rc/resource_proxy/abstract_resource_spec.rb
98
+ - test/omf_rc/resource_proxy/node_spec.rb
94
99
  - test/omf_rc/resource_proxy_dsl_spec.rb
100
+ - test/omf_rc/util/iw_spec.rb
101
+ - test/omf_rc/util/mod_spec.rb
95
102
  - test/test_helper.rb
96
103
  homepage: https://www.mytestbed.net
97
104
  licenses: []
@@ -113,9 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
120
  version: 1.3.1
114
121
  requirements: []
115
122
  rubyforge_project: omf_rc
116
- rubygems_version: 1.8.23
123
+ rubygems_version: 1.8.24
117
124
  signing_key:
118
125
  specification_version: 3
119
126
  summary: OMF resource controller
120
127
  test_files: []
121
- has_rdoc: