omf_rc 6.0.2.pre.2 → 6.0.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_rc +19 -11
- data/config/config.yml +0 -5
- data/config/config_with_authentication.yml.example +1 -1
- data/lib/omf_rc/deferred_process.rb +5 -0
- data/lib/omf_rc/omf_error.rb +5 -0
- data/lib/omf_rc/resource_factory.rb +17 -5
- data/lib/omf_rc/resource_proxy/abstract_resource.rb +186 -85
- data/lib/omf_rc/resource_proxy/application.rb +77 -53
- data/lib/omf_rc/resource_proxy/net.rb +29 -2
- data/lib/omf_rc/resource_proxy/node.rb +53 -2
- data/lib/omf_rc/resource_proxy/virtual_machine.rb +5 -0
- data/lib/omf_rc/resource_proxy/virtual_machine_factory.rb +5 -0
- data/lib/omf_rc/resource_proxy/wlan.rb +41 -2
- data/lib/omf_rc/resource_proxy_dsl.rb +68 -8
- data/lib/omf_rc/util/common_tools.rb +5 -0
- data/lib/omf_rc/util/hostapd.rb +13 -0
- data/lib/omf_rc/util/ip.rb +39 -0
- data/lib/omf_rc/util/iw.rb +115 -39
- data/lib/omf_rc/util/libvirt.rb +5 -0
- data/lib/omf_rc/util/mod.rb +20 -1
- data/lib/omf_rc/util/openflow_tools.rb +5 -0
- data/lib/omf_rc/util/package.rb +5 -0
- data/lib/omf_rc/util/platform_tools.rb +5 -0
- data/lib/omf_rc/util/sysfs.rb +23 -3
- data/lib/omf_rc/util/vmbuilder.rb +5 -0
- data/lib/omf_rc/util/wpa.rb +12 -0
- data/lib/omf_rc/version.rb +6 -1
- data/lib/omf_rc.rb +5 -0
- data/omf_rc.gemspec +2 -1
- data/test/omf_rc/deferred_process_spec.rb +5 -0
- data/test/omf_rc/message_process_error_spec.rb +5 -0
- data/test/omf_rc/resource_factory_spec.rb +8 -6
- data/test/omf_rc/resource_proxy/abstract_resource_spec.rb +151 -89
- data/test/omf_rc/resource_proxy/application_spec.rb +10 -11
- data/test/omf_rc/resource_proxy/node_spec.rb +6 -1
- data/test/omf_rc/resource_proxy_dsl_spec.rb +31 -6
- data/test/omf_rc/util/common_tools_spec.rb +6 -1
- data/test/omf_rc/util/ip_spec.rb +9 -3
- data/test/omf_rc/util/iw_spec.rb +16 -6
- data/test/omf_rc/util/mod_spec.rb +8 -3
- data/test/test_helper.rb +6 -0
- metadata +26 -13
- data/lib/omf_rc/resource_proxy/mock.rb +0 -16
- data/lib/omf_rc/util/mock.rb +0 -22
- data/test/omf_rc/resource_proxy/mock_spec.rb +0 -20
- data/test/omf_rc/util/mock_spec.rb +0 -31
data/bin/omf_rc
CHANGED
@@ -17,7 +17,8 @@ gem_version = Gem::Specification.find_by_name('omf_rc').version.to_s
|
|
17
17
|
|
18
18
|
begin
|
19
19
|
oml_enabled = OML4R::init(ARGV, appName: executable_name) do |opts|
|
20
|
-
opts.banner = "
|
20
|
+
opts.banner = "OMF Resource Controller version '#{gem_version}'\n"
|
21
|
+
opts.banner += "Usage: #{executable_name} [options]"
|
21
22
|
|
22
23
|
opts.on("-c CONFIGFILE", "Configuration File") do |file|
|
23
24
|
options[:configfile] = file
|
@@ -35,9 +36,19 @@ begin
|
|
35
36
|
options[:environment] = environment
|
36
37
|
end
|
37
38
|
|
38
|
-
opts.on("-i UID", "UID
|
39
|
+
opts.on("-i UID", "UID (and pubsub topic) of the resource, defaults to hostname") do |uid|
|
39
40
|
options[:uid] = uid
|
40
41
|
end
|
42
|
+
|
43
|
+
opts.on("-v", "--version", "Show version") do
|
44
|
+
puts "OMF Resource Controller version '#{gem_version}'"
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on("-h", "--help", "Show this message") do
|
49
|
+
puts opts
|
50
|
+
exit
|
51
|
+
end
|
41
52
|
end
|
42
53
|
rescue OML4R::MissingArgumentException => e
|
43
54
|
puts "Warning: #{e.message} to instrument this RC, so it will run without instrumentation. (see --oml-help)"
|
@@ -94,35 +105,32 @@ if options[:factories]
|
|
94
105
|
end
|
95
106
|
|
96
107
|
if options[:auth]
|
97
|
-
if File.exist?(options[:auth][:root_cert])
|
98
|
-
root = OmfCommon::Auth::Certificate.create_from_x509(File.read(options[:auth][:root_cert]))
|
99
|
-
end
|
100
|
-
|
101
108
|
if File.exist?(options[:auth][:entity_cert]) && File.exist?(options[:auth][:entity_key])
|
102
109
|
entity = OmfCommon::Auth::Certificate.create_from_x509(File.read(options[:auth][:entity_cert]),
|
103
110
|
File.read(options[:auth][:entity_key]))
|
104
111
|
end
|
105
112
|
end
|
106
113
|
|
107
|
-
common_options[:communication][:auth] = {
|
114
|
+
common_options[:communication][:auth] = {} if entity
|
108
115
|
|
109
116
|
OmfCommon.init(options[:environment].to_sym, common_options) do |el|
|
110
117
|
info "Starting OMF Resource Controller version '#{gem_version}'"
|
111
118
|
|
112
119
|
OmfCommon.comm.on_connected do |comm|
|
120
|
+
info "Connected using #{comm.conn_info}"
|
113
121
|
|
114
|
-
|
122
|
+
if options[:auth] && options[:auth][:root_cert_dir]
|
123
|
+
OmfCommon::Auth::CertificateStore.instance.register_default_certs(options[:auth][:root_cert_dir])
|
124
|
+
end
|
115
125
|
OmfCommon::Auth::CertificateStore.instance.register(entity) if entity
|
116
126
|
|
117
|
-
info "Connected using #{comm.conn_info}"
|
118
|
-
|
119
127
|
options[:resources].each do |res_opts|
|
120
128
|
rtype = res_opts.delete(:type)
|
121
129
|
res_opts[:certificate] = entity if entity
|
122
130
|
begin
|
123
131
|
OmfRc::ResourceFactory.create(rtype, res_opts)
|
124
132
|
rescue => e
|
125
|
-
error e.message
|
133
|
+
error "#{e.message}\n#{e.backtrace.join("\n")}"
|
126
134
|
end
|
127
135
|
end
|
128
136
|
|
data/config/config.yml
CHANGED
@@ -6,8 +6,3 @@
|
|
6
6
|
:uri: xmpp://<%= "#{Socket.gethostname}-#{Process.pid}" %>:<%= "#{Socket.gethostname}-#{Process.pid}" %>@localhost
|
7
7
|
:environment: production
|
8
8
|
:debug: false
|
9
|
-
|
10
|
-
:auth:
|
11
|
-
:root_cert: /home/jack/omf_keys/root.pem
|
12
|
-
:entity_cert: /home/jack/omf_keys/rc.pem
|
13
|
-
:entity_key: /home/jack/omf_keys/rc_key.pem
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
# To be used for handling long running processes
|
2
7
|
#
|
3
8
|
class OmfRc::DeferredProcess
|
data/lib/omf_rc/omf_error.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
# Error during message processing, include message related information cid and replyto, for publishing errors to pubsub server
|
2
7
|
#
|
3
8
|
class OmfRc::MessageProcessError < StandardError
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'securerandom'
|
2
7
|
require 'hashie'
|
3
8
|
require 'omf_rc/resource_proxy_dsl'
|
@@ -6,6 +11,8 @@ require 'omf_rc/resource_proxy/abstract_resource'
|
|
6
11
|
# Factory class for managing available proxies and creating new resource proxy instances
|
7
12
|
#
|
8
13
|
class OmfRc::ResourceFactory
|
14
|
+
include OmfRc::ResourceProxyDSL
|
15
|
+
|
9
16
|
# List of registered resource proxies
|
10
17
|
@@proxy_list = Hashie::Mash.new
|
11
18
|
|
@@ -19,17 +26,20 @@ class OmfRc::ResourceFactory
|
|
19
26
|
unless @@proxy_list.include?(type)
|
20
27
|
raise ArgumentError, "Resource type not found: #{type.to_s}" unless @@proxy_list.include?(type)
|
21
28
|
end
|
29
|
+
# Get relevant module identified by type
|
30
|
+
emodule = @@proxy_list[type].proxy_module || "OmfRc::ResourceProxy::#{type.camelize}".constantize
|
22
31
|
# Create a new instance of abstract resource
|
23
32
|
resource = OmfRc::ResourceProxy::AbstractResource.new(type, opts, creation_opts, &creation_callback)
|
24
|
-
#
|
25
|
-
emodule = @@proxy_list[type].proxy_module || "OmfRc::ResourceProxy::#{type.camelize}".constantize
|
33
|
+
# Extend newly created resource with proxy module
|
26
34
|
resource.extend(emodule)
|
35
|
+
|
27
36
|
# Initiate property hash
|
28
37
|
resource.methods.each do |m|
|
29
|
-
resource.__send__(m) if m =~ /
|
38
|
+
resource.__send__(m) if m =~ /default_property_(.+)/
|
30
39
|
end
|
31
40
|
# Execute resource before_ready hook if any
|
32
|
-
|
41
|
+
call_hook(:before_ready, resource)
|
42
|
+
|
33
43
|
resource
|
34
44
|
end
|
35
45
|
|
@@ -50,13 +60,15 @@ class OmfRc::ResourceFactory
|
|
50
60
|
end
|
51
61
|
|
52
62
|
# Require files from default resource proxy library folder
|
53
|
-
#
|
54
63
|
def load_default_resource_proxies
|
55
64
|
Dir["#{File.dirname(__FILE__)}/resource_proxy/*.rb"].each do |file|
|
56
65
|
require "omf_rc/resource_proxy/#{File.basename(file).gsub(/\.rb/, '')}"
|
57
66
|
end
|
58
67
|
end
|
59
68
|
|
69
|
+
# Require files from a folder contains resource proxy definition files
|
70
|
+
#
|
71
|
+
# @param [String] folder contains resource proxy definition files
|
60
72
|
def load_additional_resource_proxies(folder)
|
61
73
|
Dir["#{folder}/*.rb"].each do |file|
|
62
74
|
require "#{folder}/#{File.basename(file).gsub(/\.rb/, '')}"
|