spqr 0.3.2 → 0.3.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/VERSION +1 -1
- data/lib/spqr/app.rb +10 -6
- data/ruby-spqr.spec.in +6 -0
- data/test/helper.rb +1 -1
- metadata +27 -10
- data/test/standalone-test.rb +0 -330
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.3
|
data/lib/spqr/app.rb
CHANGED
|
@@ -18,6 +18,8 @@ require 'logger'
|
|
|
18
18
|
|
|
19
19
|
module SPQR
|
|
20
20
|
class App < Qmf::AgentHandler
|
|
21
|
+
VALID_MECHANISMS = %w{ANONYMOUS PLAIN GSSAPI}
|
|
22
|
+
|
|
21
23
|
class ClassMeta < Struct.new(:object_class, :schema_class) ; end
|
|
22
24
|
|
|
23
25
|
attr_reader :agent
|
|
@@ -52,12 +54,11 @@ module SPQR
|
|
|
52
54
|
@app_name = (options[:appname] or "SPQR application [#{Process.pid}]")
|
|
53
55
|
@qmf_host = options[:server]
|
|
54
56
|
@qmf_port = options[:port]
|
|
55
|
-
@qmf_sendUserId =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
@qmf_sendUserId = options.has_key?(:send_user_id) ? options[:send_user_id] : (options.has_key?(:user) || options.has_key?(:password))
|
|
58
|
+
|
|
59
|
+
@qmf_explicit_auth = options[:mechanism] && options[:mechanism].upcase
|
|
60
|
+
raise "Invalid authentication mechanism #{@qmf_explicit_auth}" unless (!@qmf_explicit_auth || VALID_MECHANISMS.include?(@qmf_explicit_auth))
|
|
61
|
+
|
|
61
62
|
@qmf_user = options[:user]
|
|
62
63
|
@qmf_password = options[:password]
|
|
63
64
|
end
|
|
@@ -195,6 +196,9 @@ module SPQR
|
|
|
195
196
|
|
|
196
197
|
settings.username = @qmf_user if @qmf_sendUserId
|
|
197
198
|
settings.password = @qmf_password if @qmf_sendUserId
|
|
199
|
+
|
|
200
|
+
implicit_mechanism = @qmf_sendUserId ? "PLAIN" : "ANONYMOUS"
|
|
201
|
+
settings.mechanism = @explicit_mechanism || implicit_mechanism
|
|
198
202
|
|
|
199
203
|
@connection = Qmf::Connection.new(settings)
|
|
200
204
|
@log.debug(" +-- @connection created: #{@connection}")
|
data/ruby-spqr.spec.in
CHANGED
|
@@ -70,6 +70,12 @@ rm -rf %{buildroot}
|
|
|
70
70
|
|
|
71
71
|
%changelog
|
|
72
72
|
|
|
73
|
+
* Fri Feb 4 2011 <willb@redhat> - 0.3.3-1
|
|
74
|
+
- support for alternate authentication mechanisms (BZ 675323)
|
|
75
|
+
|
|
76
|
+
* Fri Dec 17 2010 <willb@redhat> - 0.3.2-2
|
|
77
|
+
- packaging fixes (BZ 638569)
|
|
78
|
+
|
|
73
79
|
* Wed Sep 15 2010 <willb@redhat> - 0.3.2-1
|
|
74
80
|
- updated to version 0.3.2-1
|
|
75
81
|
- removed spurious debugging output
|
data/test/helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spqr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
hash: 21
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 3
|
|
9
|
+
- 3
|
|
10
|
+
version: 0.3.3
|
|
5
11
|
platform: ruby
|
|
6
12
|
authors:
|
|
7
13
|
- William Benton
|
|
@@ -9,19 +15,25 @@ autorequire:
|
|
|
9
15
|
bindir: bin
|
|
10
16
|
cert_chain: []
|
|
11
17
|
|
|
12
|
-
date:
|
|
18
|
+
date: 2011-02-04 00:00:00 -06:00
|
|
13
19
|
default_executable: spqr-gen.rb
|
|
14
20
|
dependencies:
|
|
15
21
|
- !ruby/object:Gem::Dependency
|
|
16
22
|
name: rspec
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
prerelease: false
|
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
20
26
|
requirements:
|
|
21
27
|
- - ">="
|
|
22
28
|
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 13
|
|
30
|
+
segments:
|
|
31
|
+
- 1
|
|
32
|
+
- 2
|
|
33
|
+
- 9
|
|
23
34
|
version: 1.2.9
|
|
24
|
-
|
|
35
|
+
type: :development
|
|
36
|
+
version_requirements: *id001
|
|
25
37
|
description: SPQR makes it very simple to expose methods on Ruby objects over QMF. You must install ruby-qmf in order to use SPQR.
|
|
26
38
|
email: willb@redhat.com
|
|
27
39
|
executables:
|
|
@@ -80,21 +92,27 @@ rdoc_options:
|
|
|
80
92
|
require_paths:
|
|
81
93
|
- lib
|
|
82
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
|
+
none: false
|
|
83
96
|
requirements:
|
|
84
97
|
- - ">="
|
|
85
98
|
- !ruby/object:Gem::Version
|
|
99
|
+
hash: 3
|
|
100
|
+
segments:
|
|
101
|
+
- 0
|
|
86
102
|
version: "0"
|
|
87
|
-
version:
|
|
88
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
|
+
none: false
|
|
89
105
|
requirements:
|
|
90
106
|
- - ">="
|
|
91
107
|
- !ruby/object:Gem::Version
|
|
108
|
+
hash: 3
|
|
109
|
+
segments:
|
|
110
|
+
- 0
|
|
92
111
|
version: "0"
|
|
93
|
-
version:
|
|
94
112
|
requirements: []
|
|
95
113
|
|
|
96
114
|
rubyforge_project:
|
|
97
|
-
rubygems_version: 1.3.
|
|
115
|
+
rubygems_version: 1.3.7
|
|
98
116
|
signing_key:
|
|
99
117
|
specification_version: 3
|
|
100
118
|
summary: "SPQR: {Schema Processor|Straightforward Publishing} for QMF agents in Ruby"
|
|
@@ -109,7 +127,6 @@ test_files:
|
|
|
109
127
|
- test/helper.rb
|
|
110
128
|
- test/test_failbot.rb
|
|
111
129
|
- test/test_spqr_boolprop.rb
|
|
112
|
-
- test/standalone-test.rb
|
|
113
130
|
- test/test_spqr_clicker.rb
|
|
114
131
|
- test/test_spqr_integerprop.rb
|
|
115
132
|
- test/test_user_and_context.rb
|
data/test/standalone-test.rb
DELETED
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
require 'qmf'
|
|
2
|
-
|
|
3
|
-
class App < Qmf::AgentHandler
|
|
4
|
-
class ClassMeta < Struct.new(:object_class, :schema_class) ; end
|
|
5
|
-
|
|
6
|
-
attr_reader :agent
|
|
7
|
-
|
|
8
|
-
def initialize(options=nil)
|
|
9
|
-
defaults = {:logfile=>STDERR, :loglevel=>Logger::WARN, :notifier=>nil, :server=>"localhost", :port=>5672}
|
|
10
|
-
|
|
11
|
-
# convenient shorthands for log levels
|
|
12
|
-
loglevels = {:debug => Logger::DEBUG, :info => Logger::INFO, :warn => Logger::WARN, :error => Logger::ERROR, :fatal => Logger::FATAL}
|
|
13
|
-
|
|
14
|
-
options = defaults unless options
|
|
15
|
-
|
|
16
|
-
# set unsupplied options to defaults
|
|
17
|
-
defaults.each do |k,v|
|
|
18
|
-
options[k] = v unless options[k]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# fix up shorthands
|
|
22
|
-
options[:loglevel] = loglevels[options[:loglevel]] if loglevels[options[:loglevel]]
|
|
23
|
-
|
|
24
|
-
logger_opts = ([options[:logfile]] + [options[:logoptions]]).flatten.compact
|
|
25
|
-
|
|
26
|
-
@log = Logger.new(*logger_opts)
|
|
27
|
-
@log.level = options[:loglevel]
|
|
28
|
-
|
|
29
|
-
@log.info("initializing SPQR app....")
|
|
30
|
-
|
|
31
|
-
@classes_by_name = {}
|
|
32
|
-
@classes_by_id = {}
|
|
33
|
-
@pipe = options[:notifier]
|
|
34
|
-
@app_name = (options[:appname] or "SPQR application [#{Process.pid}]")
|
|
35
|
-
@qmf_host = options[:server]
|
|
36
|
-
@qmf_port = options[:port]
|
|
37
|
-
@qmf_sendUserId = if options.has_key?(:send_user_id)
|
|
38
|
-
options[:send_user_id]
|
|
39
|
-
else
|
|
40
|
-
(options.has_key?(:user) || options.has_key?(:password))
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
@qmf_user = options[:user]
|
|
44
|
-
@qmf_password = options[:password]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def register(*ks)
|
|
48
|
-
manageable_ks = ks.select {|kl| manageable? kl}
|
|
49
|
-
unmanageable_ks = ks.select {|kl| not manageable? kl}
|
|
50
|
-
manageable_ks.each do |klass|
|
|
51
|
-
schemaclass = schematize(klass)
|
|
52
|
-
|
|
53
|
-
klass.log = @log
|
|
54
|
-
|
|
55
|
-
# XXX
|
|
56
|
-
if klass.included_modules.include?(::SPQR::Manageable)
|
|
57
|
-
@classes_by_id[klass.class_id] = klass
|
|
58
|
-
@classes_by_name[klass.spqr_meta.classname.to_s] = ClassMeta.new(klass, schemaclass)
|
|
59
|
-
else
|
|
60
|
-
@log.info "NOT registering query/lookup info for #{klass}; is it an event class?"
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
@log.info("SETTING #{klass.spqr_meta.classname}.app to #{self.inspect}")
|
|
64
|
-
klass.app = self
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
unmanageable_ks.each do |klass|
|
|
68
|
-
@log.warn("SPQR can't manage #{klass}, which was registered")
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def method_call(context, name, obj_id, args, user_id)
|
|
74
|
-
begin
|
|
75
|
-
status = 0
|
|
76
|
-
message = "OK"
|
|
77
|
-
failed = false
|
|
78
|
-
|
|
79
|
-
class_id = obj_id.object_num_high
|
|
80
|
-
obj_id = obj_id.object_num_low
|
|
81
|
-
|
|
82
|
-
Thread.current[:qmf_user_id] = user_id
|
|
83
|
-
Thread.current[:qmf_context] = context
|
|
84
|
-
|
|
85
|
-
@log.debug "calling method: context=#{context} method=#{name} object_id=#{obj_id}, user=#{user_id}"
|
|
86
|
-
|
|
87
|
-
managed_object = find_object(context, class_id, obj_id)
|
|
88
|
-
@log.debug("managed object is #{managed_object}")
|
|
89
|
-
managed_method = managed_object.class.spqr_meta.mmethods[name.to_sym]
|
|
90
|
-
|
|
91
|
-
raise RuntimeError.new("#{managed_object.class} does not have #{name} exposed as a manageable method; has #{managed_object.class.spqr_meta.mmethods.inspect}") unless managed_method
|
|
92
|
-
|
|
93
|
-
# Extract actual parameters from the Qmf::Arguments structure into a proper ruby list
|
|
94
|
-
@log.debug("actual params are: #{args.instance_variable_get(:@by_hash).inspect}") rescue nil
|
|
95
|
-
actuals_in = managed_method.formals_in.inject([]) {|acc,nm| acc << args[nm]}
|
|
96
|
-
actual_count = actuals_in.size
|
|
97
|
-
|
|
98
|
-
@log.debug("managed_object.respond_to? #{managed_method.name.to_sym} ==> #{managed_object.respond_to? managed_method.name.to_sym}")
|
|
99
|
-
@log.debug("managed_object.class.spqr_meta.mmethods.include? #{name.to_sym} ==> #{managed_object.class.spqr_meta.mmethods.include? name.to_sym}")
|
|
100
|
-
@log.debug("formals: #{managed_method.formals_in.inspect}")
|
|
101
|
-
@log.debug("actuals: #{actuals_in.inspect}")
|
|
102
|
-
|
|
103
|
-
actuals_out = []
|
|
104
|
-
|
|
105
|
-
begin
|
|
106
|
-
actuals_out = case actual_count
|
|
107
|
-
when 0 then managed_object.send(name.to_sym)
|
|
108
|
-
when 1 then managed_object.send(name.to_sym, actuals_in[0])
|
|
109
|
-
else managed_object.send(name.to_sym, *actuals_in)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
raise RuntimeError.new("#{managed_object.class} did not return the appropriate number of return values; got '#{actuals_out.inspect}', but expected #{managed_method.types_out.inspect}") unless result_valid(actuals_out, managed_method)
|
|
113
|
-
|
|
114
|
-
rescue ::SPQR::ManageableObjectError => failure
|
|
115
|
-
@log.info "#{name} called SPQR::Manageable#fail: #{failure}"
|
|
116
|
-
status = failure.status
|
|
117
|
-
message = failure.message || "ERROR"
|
|
118
|
-
# XXX: failure.result is currently ignored
|
|
119
|
-
actuals_out = failure.result || managed_method.formals_out.inject([]) {|acc, val| acc << args[val]; acc}
|
|
120
|
-
failed = true
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
if managed_method.formals_out.size == 0
|
|
124
|
-
actuals_out = [] # ignore return value in this case
|
|
125
|
-
elsif managed_method.formals_out.size == 1
|
|
126
|
-
actuals_out = [actuals_out] # wrap this up in a list
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
@log.debug("formals_out == #{managed_method.formals_out.inspect}")
|
|
130
|
-
@log.debug("actuals_out == #{actuals_out.inspect}")
|
|
131
|
-
|
|
132
|
-
unless failed
|
|
133
|
-
# Copy any out parameters from return value to the
|
|
134
|
-
# Qmf::Arguments structure; see XXX above
|
|
135
|
-
managed_method.formals_out.zip(actuals_out).each do |k,v|
|
|
136
|
-
@log.debug("fixing up out params: #{k.inspect} --> #{v.inspect}")
|
|
137
|
-
encoded_val = encode_object(v)
|
|
138
|
-
args[k] = encoded_val
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
@agent.method_response(context, status, message, args)
|
|
143
|
-
rescue Exception => ex
|
|
144
|
-
@log.error "Error calling #{name}: #{ex}"
|
|
145
|
-
@log.error " " + ex.backtrace.join("\n ")
|
|
146
|
-
@agent.method_response(context, 1, "ERROR: #{ex}", args)
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def get_query(context, query, user_id)
|
|
151
|
-
@log.debug "query: user=#{user_id} context=#{context} class=#{query.class_name} object_num=#{query.object_id.object_num_low if query.object_id} details=#{query} haveSelect=#{query.impl and query.impl.haveSelect} getSelect=#{query.impl and query.impl.getSelect} (#{query.impl and query.impl.getSelect and query.impl.getSelect.methods.inspect})"
|
|
152
|
-
|
|
153
|
-
cmeta = @classes_by_name[query.class_name]
|
|
154
|
-
objs = []
|
|
155
|
-
|
|
156
|
-
# XXX: are these cases mutually exclusive?
|
|
157
|
-
|
|
158
|
-
# handle queries for a certain class
|
|
159
|
-
if cmeta
|
|
160
|
-
objs = objs + cmeta.object_class.find_all.collect {|obj| qmfify(obj)}
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
# handle queries for a specific object
|
|
164
|
-
o = find_object(context, query.object_id.object_num_high, query.object_id.object_num_low) rescue nil
|
|
165
|
-
if o
|
|
166
|
-
objs << qmfify(o)
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
objs.each do |obj|
|
|
170
|
-
@log.debug("query_response of: #{obj.inspect}")
|
|
171
|
-
@agent.query_response(context, obj) rescue @log.error($!.inspect)
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
@log.debug("completing query....")
|
|
175
|
-
@agent.query_complete(context)
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
def main
|
|
179
|
-
settings = Qmf::ConnectionSettings.new
|
|
180
|
-
settings.host = @qmf_host
|
|
181
|
-
settings.port = @qmf_port
|
|
182
|
-
settings.sendUserId = @qmf_sendUserId
|
|
183
|
-
|
|
184
|
-
settings.username = @qmf_user if @qmf_sendUserId
|
|
185
|
-
settings.password = @qmf_password if @qmf_sendUserId
|
|
186
|
-
|
|
187
|
-
@schemaclass = Qmf::SchemaObjectClass.new("test", "testclass")
|
|
188
|
-
|
|
189
|
-
@connection = Qmf::Connection.new(settings)
|
|
190
|
-
@log.debug(" +-- @connection created: #{@connection}")
|
|
191
|
-
@log.debug(" +-- app name is '#{@app_name}'")
|
|
192
|
-
|
|
193
|
-
@agent = Qmf::Agent.new(self, @app_name)
|
|
194
|
-
@log.debug(" +-- @agent created: #{@agent}")
|
|
195
|
-
|
|
196
|
-
@agent.set_connection(@connection)
|
|
197
|
-
@log.debug(" +-- @agent.set_connection called")
|
|
198
|
-
|
|
199
|
-
@log.debug(" +-- registering classes...")
|
|
200
|
-
@classes_by_name.values.each do |km|
|
|
201
|
-
@agent.register_class(km.schema_class)
|
|
202
|
-
@log.debug(" +--+-- #{km.schema_class.package_name} #{km.schema_class.class_name} registered")
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
@log.debug("entering orbit....")
|
|
206
|
-
|
|
207
|
-
sleep
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
private
|
|
211
|
-
|
|
212
|
-
def result_valid(actuals, mm)
|
|
213
|
-
(actuals.kind_of?(Array) and mm.formals_out.size == actuals.size) or mm.formals_out.size <= 1
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
def qmf_arguments_to_hash(args)
|
|
217
|
-
result = {}
|
|
218
|
-
args.each do |k,v|
|
|
219
|
-
result[k] = v
|
|
220
|
-
end
|
|
221
|
-
result
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
def encode_object(o)
|
|
225
|
-
return o unless o.kind_of? ::SPQR::Manageable
|
|
226
|
-
@agent.alloc_object_id(*(o.qmf_id))
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
def find_object(ctx, c_id, obj_id)
|
|
230
|
-
# XXX: context is currently ignored
|
|
231
|
-
@log.debug("in find_object; class ID is #{c_id}, object ID is #{obj_id}...")
|
|
232
|
-
klass = @classes_by_id[c_id]
|
|
233
|
-
@log.debug("found class #{klass.inspect}")
|
|
234
|
-
klass.find_by_id(obj_id) if klass
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
def schematize(klass)
|
|
238
|
-
@log.info("Making a QMF schema for #{klass.spqr_meta.classname}")
|
|
239
|
-
|
|
240
|
-
if klass.respond_to? :schematize
|
|
241
|
-
@log.info("#{klass.spqr_meta.classname} knows how to schematize itself; it's probably an event class")
|
|
242
|
-
return klass.schematize
|
|
243
|
-
else
|
|
244
|
-
@log.info("#{klass.spqr_meta.classname} doesn't know how to schematize itself; it's probably an object class")
|
|
245
|
-
return schematize_object_class(klass)
|
|
246
|
-
end
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
def schematize_object_class(klass)
|
|
250
|
-
meta = klass.spqr_meta
|
|
251
|
-
package = meta.package.to_s
|
|
252
|
-
classname = meta.classname.to_s
|
|
253
|
-
@log.info("+-- class #{classname} is in package #{package}")
|
|
254
|
-
|
|
255
|
-
sc = Qmf::SchemaObjectClass.new(package, classname)
|
|
256
|
-
|
|
257
|
-
meta.manageable_methods.each do |mm|
|
|
258
|
-
@log.info("+-- creating a QMF schema for method #{mm}")
|
|
259
|
-
m_opts = mm.options
|
|
260
|
-
m_opts[:desc] ||= mm.description if mm.description
|
|
261
|
-
|
|
262
|
-
method = Qmf::SchemaMethod.new(mm.name.to_s, m_opts)
|
|
263
|
-
|
|
264
|
-
mm.args.each do |arg|
|
|
265
|
-
@log.info("| +-- creating a QMF schema for arg #{arg}")
|
|
266
|
-
|
|
267
|
-
encode_argument(arg, method)
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
sc.add_method(method)
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
add_attributes(sc, meta.properties, :add_property, Qmf::SchemaProperty)
|
|
274
|
-
add_attributes(sc, meta.statistics, :add_statistic, Qmf::SchemaStatistic)
|
|
275
|
-
|
|
276
|
-
sc
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
def add_attributes(sc, collection, msg, klass, what=nil)
|
|
280
|
-
what ||= (msg.to_s.split("_").pop rescue "property or statistic")
|
|
281
|
-
collection.each do |basic|
|
|
282
|
-
basic_name = basic.name.to_s
|
|
283
|
-
basic_type = get_xml_constant(basic.kind.to_s, ::SPQR::XmlConstants::Type)
|
|
284
|
-
@log.debug("+-- creating a QMF schema for #{what} #{basic_name} (#{basic_type}) with options #{basic.options.inspect}")
|
|
285
|
-
sc.send(msg, klass.new(basic_name, basic_type, basic.options))
|
|
286
|
-
end
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
include ::SPQR::Util
|
|
290
|
-
|
|
291
|
-
# turns an instance of a managed object into a QmfObject
|
|
292
|
-
def qmfify(obj)
|
|
293
|
-
@log.debug("trying to qmfify #{obj}: qmf_oid is #{obj.qmf_oid} and class_id is #{obj.class.class_id}")
|
|
294
|
-
cm = @classes_by_name[obj.class.spqr_meta.classname.to_s]
|
|
295
|
-
return nil unless cm
|
|
296
|
-
|
|
297
|
-
qmfobj = Qmf::AgentObject.new(cm.schema_class)
|
|
298
|
-
|
|
299
|
-
set_attrs(qmfobj, obj)
|
|
300
|
-
|
|
301
|
-
@log.debug("calling alloc_object_id(#{obj.qmf_oid}, #{obj.class.class_id})")
|
|
302
|
-
oid = @agent.alloc_object_id(obj.qmf_oid, obj.class.class_id)
|
|
303
|
-
|
|
304
|
-
@log.debug("calling qmfobj.set_object_id(#{oid})")
|
|
305
|
-
qmfobj.set_object_id(oid)
|
|
306
|
-
|
|
307
|
-
@log.debug("returning from qmfify")
|
|
308
|
-
qmfobj
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
def set_attrs(qo, o)
|
|
312
|
-
return unless o.class.respond_to? :spqr_meta
|
|
313
|
-
|
|
314
|
-
attrs = o.class.spqr_meta.properties + o.class.spqr_meta.statistics
|
|
315
|
-
|
|
316
|
-
attrs.each do |a|
|
|
317
|
-
getter = a.name.to_s
|
|
318
|
-
@log.debug("setting property/statistic #{getter} to its value from #{o}: #{o.send(getter) if o.respond_to?(getter)}")
|
|
319
|
-
value = o.send(getter) if o.respond_to?(getter)
|
|
320
|
-
|
|
321
|
-
if value || a.kind == :bool
|
|
322
|
-
# XXX: remove this line when/if Manageable includes an
|
|
323
|
-
# appropriate impl method
|
|
324
|
-
value = encode_object(value) if value.kind_of?(::SPQR::Manageable)
|
|
325
|
-
qo[getter] = value
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
end
|
|
329
|
-
end
|
|
330
|
-
end
|