omf_rc 6.0.0.pre.2 → 6.0.0.pre.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,10 @@ class OmfRc::ResourceProxy::AbstractResource
9
9
  DISCONNECT_WAIT = 5
10
10
  # Time to wait before releasing resource, wait for deleting pubsub nodes
11
11
  RELEASE_WAIT = 5
12
- attr_accessor :uid, :hrn, :type, :comm
12
+
13
+ # @!attribute metadata
14
+ # @return [String] the resource's internal meta data storage
15
+ attr_accessor :uid, :hrn, :type, :comm, :metadata
13
16
  attr_reader :opts, :children, :host
14
17
 
15
18
  # Initialisation
@@ -31,6 +34,7 @@ class OmfRc::ResourceProxy::AbstractResource
31
34
  @hrn = @opts.hrn
32
35
  @children ||= []
33
36
  @host = nil
37
+ @metadata = @opts.metadata || Hashie::Mash.new
34
38
 
35
39
  @comm = comm || OmfCommon::Comm.new(@opts.dsl)
36
40
  # Fire when connection to pubsub server established
@@ -86,6 +90,7 @@ class OmfRc::ResourceProxy::AbstractResource
86
90
  #
87
91
  # @param (see #initialize)
88
92
  def create(type, opts = nil)
93
+ before_create if respond_to? :before_create
89
94
  new_resource = OmfRc::ResourceFactory.new(type.to_sym, opts, @comm)
90
95
  children << new_resource
91
96
  new_resource
@@ -162,7 +167,7 @@ class OmfRc::ResourceProxy::AbstractResource
162
167
  when :request
163
168
  inform_msg = OmfCommon::Message.inform(end_result[:context_id], 'STATUS') do |i|
164
169
  end_result[:result].each_pair do |k, v|
165
- i.property(k) { |p| p.element('current', v) }
170
+ i.property(k, v)
166
171
  end
167
172
  end.sign
168
173
  @comm.publish(end_result[:inform_to], inform_msg, host)
@@ -170,7 +175,7 @@ class OmfRc::ResourceProxy::AbstractResource
170
175
  when :configure
171
176
  inform_msg = OmfCommon::Message.inform(end_result[:context_id], 'STATUS') do |i|
172
177
  end_result[:result].each_pair do |k, v|
173
- i.property(k) { |p| p.element('current', v) }
178
+ i.property(k, v)
174
179
  end
175
180
  end.sign
176
181
  @comm.publish(end_result[:inform_to], inform_msg, host)
@@ -3,6 +3,6 @@ module OmfRc::ResourceProxy::Wifi
3
3
 
4
4
  register_proxy :wifi
5
5
 
6
- #utility :mod
6
+ utility :mod
7
7
  utility :iw
8
8
  end
@@ -1,23 +1,15 @@
1
1
  module OmfRc::Util::Mod
2
+ include OmfRc::ResourceProxyDSL
2
3
 
3
- LSMOD_CMD = 'lsmod'
4
- MODPROBE_CMD = 'modprobe'
4
+ register_utility :mod
5
5
 
6
- def request_property(property)
7
- case property
8
- when /^(mod|driver)_(.+)$/
9
- OmfRc::Cmd.exec(LSMOD).match(/^#{$+}( )+/) ? true : false
10
- else
11
- super
12
- end
6
+ register_request :modules do
7
+ OmfCommon::Command.execute('lsmod').split("\n").map do |v|
8
+ v.match(/^(.+)\W*.+$/) && $1
9
+ end.compact
13
10
  end
14
11
 
15
- def configure_property(property, value)
16
- case property
17
- when /^(mod|driver)_(.+)$/
18
- OmfRc::Cmd.exec("#{MODPROBE} #{$+}")
19
- else
20
- super
21
- end
12
+ register_configure :load_module do |resource, value|
13
+ OmfCommon::Command.execute("modprobe #{value}")
22
14
  end
23
15
  end
@@ -1,3 +1,5 @@
1
+ # Package management utility, could be included in application resource proxy
2
+ #
1
3
  module OmfRc::ResourceProxy::Package
2
4
  include OmfRc::ResourceProxyDSL
3
5
 
@@ -1,3 +1,3 @@
1
1
  module OmfRc
2
- VERSION = "6.0.0.pre.2"
2
+ VERSION = "6.0.0.pre.3"
3
3
  end
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.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-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -84,7 +84,6 @@ files:
84
84
  - lib/omf_rc/message_process_error.rb
85
85
  - lib/omf_rc/resource_factory.rb
86
86
  - lib/omf_rc/resource_proxy/abstract_resource.rb
87
- - lib/omf_rc/resource_proxy/interface.rb
88
87
  - lib/omf_rc/resource_proxy/mock.rb
89
88
  - lib/omf_rc/resource_proxy/node.rb
90
89
  - lib/omf_rc/resource_proxy/wifi.rb
@@ -1,48 +0,0 @@
1
- require 'hashie'
2
-
3
- module OmfRc::ResourceProxy::Interface
4
- include OmfRc::ResourceProxyDSL
5
-
6
- register_proxy :interface
7
-
8
- IPTABLES = 'iptables'
9
- ROUTE = 'route'
10
-
11
- def configure_property(property, value)
12
- case property
13
- when /^forwarding$/
14
- OmfRc::Cmd.exec("echo #{value ? '1' : '0'} > /proc/sys/net/ipv4/conf/#{uid}/forwarding")
15
- when /^gateway$/
16
- # FIXME Not sure about this one, hard coded everything?
17
- OmfRc::Cmd.exec("route del default dev eth1; route add default gw #{value}; route add 224.10.10.6 dev eth1")
18
- when /^route$/
19
- value = Hashie::Mash.new(value)
20
- arguments = %w(net gw mask).map {|v| "-#{v} #{value.send(v)}" if value.send(v)}.join(' ')
21
- OmfRc::Cmd.exec("#{ROUTE} #{value.op} #{arguments} dev #{uid}")
22
- when /^filter$/
23
- operation = case value.op
24
- when /^add$/
25
- '-A'
26
- when /^del$/
27
- '-D'
28
- when /^clear$/
29
- '-F'
30
- end
31
- chain = "#{value.chain.upcase} -i #{uid}" if value.chain
32
- protocol = case value.proto
33
- when /^(tcp|udp)$/
34
- [ ("-p #{value.proto}"),
35
- ("-s #{value.src}" if value.src),
36
- ("-d #{value.dst}" if value.dst),
37
- ("--sport #{value.sport}" if value.sport),
38
- ("--dport #{value.dport}" if value.dport) ].join(' ')
39
- when /^mac$/
40
- "-m mac --mac-source #{value.src}"
41
- end
42
- target = "#{value.target.upcase}" if value.target
43
- OmfRc::Cmd.exec("#{IPTABLES} #{operation} #{chain} #{protocol} #{chain}")
44
- else
45
- super
46
- end
47
- end
48
- end