genprovider 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/CHANGELOG +8 -0
  2. data/CHANGELOG~ +4 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +58 -0
  5. data/README.rdoc +50 -0
  6. data/Rakefile +6 -0
  7. data/bin/genprovider +256 -0
  8. data/bin/regprovider +105 -0
  9. data/features/003-create.feature +10 -0
  10. data/features/004-modify.feature +9 -0
  11. data/features/005-delete.feature +7 -0
  12. data/features/datatypes.feature +13 -0
  13. data/features/ensure-format.feature +28 -0
  14. data/features/have-instances.feature +19 -0
  15. data/features/mof/trivial.mof +20 -0
  16. data/features/registration.feature +12 -0
  17. data/features/run-genprovider.feature +10 -0
  18. data/features/show-context.feature +9 -0
  19. data/features/step_definitions/genprovider.rb +52 -0
  20. data/features/step_definitions/mof.rb +3 -0
  21. data/features/step_definitions/registration.rb +21 -0
  22. data/features/step_definitions/wbemcli.rb +58 -0
  23. data/features/support/env.rb +20 -0
  24. data/genprovider.gemspec +36 -0
  25. data/lib/genprovider/class.rb +200 -0
  26. data/lib/genprovider/classinfo.rb +88 -0
  27. data/lib/genprovider/output.rb +104 -0
  28. data/lib/genprovider/provider.rb +721 -0
  29. data/lib/genprovider/rdoc.rb +149 -0
  30. data/lib/genprovider/registration.rb +22 -0
  31. data/lib/genprovider/testcase.rb +139 -0
  32. data/lib/genprovider/version.rb +3 -0
  33. data/lib/genprovider.rb +35 -0
  34. data/samples/mof/LMI_Embedded.mof +6 -0
  35. data/samples/mof/RCP_ArrayDataTypes.mof +27 -0
  36. data/samples/mof/RCP_ClassMethod.mof +7 -0
  37. data/samples/mof/RCP_ComplexMethod.mof +14 -0
  38. data/samples/mof/RCP_IndicationGenerator.mof +13 -0
  39. data/samples/mof/RCP_PassCData.mof +10 -0
  40. data/samples/mof/RCP_ShowContext.mof +11 -0
  41. data/samples/mof/RCP_SimpleClass.mof +7 -0
  42. data/samples/mof/RCP_SimpleDataTypes.mof +27 -0
  43. data/samples/mof/RCP_SimpleMethod.mof +9 -0
  44. data/samples/mof/qualifiers.mof +20 -0
  45. data/samples/provider/lmi_embedded.rb +148 -0
  46. data/samples/provider/rcp_array_data_types.rb +219 -0
  47. data/samples/provider/rcp_class_method.rb +54 -0
  48. data/samples/provider/rcp_complex_method.rb +170 -0
  49. data/samples/provider/rcp_pass_c_data.rb +130 -0
  50. data/samples/provider/rcp_show_context.rb +134 -0
  51. data/samples/provider/rcp_simple_class.rb +124 -0
  52. data/samples/provider/rcp_simple_data_types.rb +152 -0
  53. data/samples/provider/rcp_simple_method.rb +143 -0
  54. data/samples/registration/LMI_Embedded.registration +7 -0
  55. data/samples/registration/RCP_ArrayDataTypes.registration +7 -0
  56. data/samples/registration/RCP_ClassMethod.registration +8 -0
  57. data/samples/registration/RCP_ComplexMethod.registration +8 -0
  58. data/samples/registration/RCP_PassCData.registration +7 -0
  59. data/samples/registration/RCP_ShowContext.registration +7 -0
  60. data/samples/registration/RCP_SimpleDataTypes.registration +7 -0
  61. data/samples/registration/RCP_SimpleMethod.registration +8 -0
  62. data/samples/sfcb.reg/RCP_ComputerSystem.reg +5 -0
  63. data/samples/sfcb.reg/RCP_OSProcess.reg +5 -0
  64. data/samples/sfcb.reg/RCP_OperatingSystem.reg +5 -0
  65. data/samples/sfcb.reg/RCP_PhysicalMemory.reg +5 -0
  66. data/samples/sfcb.reg/RCP_Processor.reg +5 -0
  67. data/samples/sfcb.reg/RCP_RunningOS.reg +5 -0
  68. data/samples/sfcb.reg/RCP_SimpleClass.reg +5 -0
  69. data/samples/sfcb.reg/RCP_UnixProcess.reg +5 -0
  70. data/sfcbd +4 -0
  71. data/stress.sh +4 -0
  72. data/tasks/clean.rake +4 -0
  73. data/tasks/doc.rake +16 -0
  74. data/tasks/features.rake +8 -0
  75. data/tasks/prepstage.rake +16 -0
  76. data/tasks/registration.rake +10 -0
  77. data/tasks/sfcb.rake +3 -0
  78. data/tasks/test.rake +10 -0
  79. data/test/env.rb +23 -0
  80. data/test/helper.rb +23 -0
  81. data/test/mkreg.rb +32 -0
  82. data/test/mof/RCP_ClassMethod.rb +15 -0
  83. data/test/mof/RCP_ComplexMethod.rb +16 -0
  84. data/test/mof/RCP_SimpleMethod.rb +15 -0
  85. data/test/registration.rb +37 -0
  86. data/test/sfcb.rb +94 -0
  87. data/test/test_lmi_embedded.rb +64 -0
  88. data/test/test_rcp_array_data_types.rb +140 -0
  89. data/test/test_rcp_class_method.rb +31 -0
  90. data/test/test_rcp_complex_method.rb +68 -0
  91. data/test/test_rcp_simple_data_types.rb +66 -0
  92. data/test/test_rcp_simple_method.rb +47 -0
  93. data/valgrind +8 -0
  94. metadata +288 -0
@@ -0,0 +1,149 @@
1
+ #
2
+ # Genprovider::Class
3
+ #
4
+
5
+ #
6
+ # make element description
7
+ #
8
+
9
+ module Genprovider
10
+ class RDoc
11
+ def description element
12
+ p = element.qualifiers["description", :string]
13
+ return unless p
14
+ p.value.split("\n").each do |l|
15
+ @out.puts l
16
+ @out.puts
17
+ end
18
+ end
19
+
20
+ #
21
+ # make feature doc
22
+ #
23
+
24
+ def doc_feature feature
25
+ k = feature.key? ? " [Key]" : nil
26
+ @out.puts "== #{feature.name} : #{feature.type.to_s}#{k}"
27
+ description feature
28
+ @out.puts
29
+ vm = feature.qualifiers["valuemap"]
30
+ vs = feature.qualifiers["values"]
31
+ if vm && vs
32
+ @out.puts "* Mapped values"
33
+ vm = vm.value
34
+ vs = vs.value
35
+ loop do
36
+ m = vm.shift
37
+ s = vs.shift
38
+ @out.puts " * #{m} -> #{s}"
39
+ break if vm.empty? || vs.empty?
40
+ end
41
+ end
42
+ feature.qualifiers.each do |q|
43
+ n = q.name.downcase
44
+ next if n == "description"
45
+ next if n == "values" || n == "valuemap"
46
+ @out.puts "* #{q}"
47
+ end
48
+ @out.puts
49
+
50
+ return unless feature.method?
51
+ args = nil
52
+ feature.parameters.each do |p|
53
+ args ||= []
54
+ if p.qualifiers.include?(:out,:bool)
55
+ args << "#{p.name.decamelize}_out"
56
+ else
57
+ args << p.name.decamelize
58
+ end
59
+ end
60
+ n = feature.name.decamelize
61
+ @out.puts "* #{n}(#{args})"
62
+ end
63
+
64
+ #
65
+ # generate code for property
66
+ #
67
+
68
+ def doc_property property
69
+ doc_feature property
70
+ end
71
+
72
+ #
73
+ # generate code for reference
74
+ #
75
+
76
+ def doc_reference reference
77
+ doc_feature reference
78
+ end
79
+
80
+ #
81
+ # generate code for method
82
+ #
83
+
84
+ def doc_method method
85
+ doc_feature method
86
+ end
87
+
88
+ #
89
+ # generate provider code for features matching match
90
+ #
91
+
92
+ def doc_features header, features, match
93
+ features.each do |f|
94
+ next unless f.instance_of? match
95
+ if header
96
+ # @out.puts header
97
+ header = nil
98
+ end
99
+ case f
100
+ when CIM::Property then doc_property f
101
+ when CIM::Reference then doc_reference f
102
+ when CIM::Method then doc_method f
103
+ else
104
+ raise "Unknown feature class #{f.class}"
105
+ end
106
+ end
107
+ end
108
+
109
+ def doc_class c = nil
110
+ c = @klass unless c
111
+ @out.puts "= #{c.name}"
112
+ description c
113
+
114
+ if c.superclass
115
+ @out.puts
116
+ @out.puts "=== Superclass: #{c.superclass}"
117
+ end
118
+
119
+ doc_features "==Properties", c.features, CIM::Property
120
+ doc_features "==References", c.features, CIM::Reference
121
+ doc_features "==Methods", c.features, CIM::Method
122
+ end
123
+
124
+ def each_parent
125
+ parent = @klass.parent
126
+ while parent
127
+ yield parent
128
+ parent = parent.parent
129
+ end
130
+ end
131
+
132
+ #
133
+ # generate provider code for class 'c'
134
+ #
135
+
136
+ def initialize c, out
137
+ @klass = c
138
+ @out = out
139
+ @out.puts "= Documentation for #{c.name}"
140
+ each_parent do |k|
141
+ @out.puts "* #{k.name}"
142
+ end
143
+ doc_class
144
+ each_parent do |k|
145
+ doc_class k
146
+ end
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,22 @@
1
+ #
2
+ # registration.rb
3
+ #
4
+
5
+ module Genprovider
6
+ class Registration
7
+ def initialize c, namespace, providername, out
8
+ out.comment.comment "Registration for provider #{providername} of class #{c.class}"
9
+ out.comment.comment "Generated by 'genprovider' for use with cmpi-bindings-ruby"
10
+ out.comment.comment "Classname - Namespace - Providername - Libraryname - Capabilities ..."
11
+
12
+ mask = Genprovider.classmask c
13
+ capabilities = ""
14
+ capabilities << " instance" if (mask & INSTANCE_MASK) != 0
15
+ capabilities << " method" if (mask & METHOD_MASK) != 0
16
+ capabilities << " association" if (mask & ASSOCIATION_MASK) != 0
17
+ capabilities << " indication" if (mask & INDICATION_MASK) != 0
18
+
19
+ out.puts "#{c.name} #{namespace} #{providername} rbCmpiProvider#{capabilities}"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,139 @@
1
+ #
2
+ # testcase.rb
3
+ #
4
+
5
+ module Genprovider
6
+ class Testcase
7
+ # return Ruby type equivalent
8
+ def rubytype type
9
+ case type.to_sym
10
+ when :boolean then return ""
11
+ when :string then return "String"
12
+ when :char16 then return "Integer"
13
+ when :uint8 then return "Integer"
14
+ when :uint16 then return "Integer"
15
+ when :uint32 then return "Integer"
16
+ when :uint64 then return "Integer"
17
+ when :sint8 then return "Integer"
18
+ when :sint16 then return "Integer"
19
+ when :sint32 then return "Integer"
20
+ when :sint64 then return "Integer"
21
+ when :real32 then return "Float"
22
+ when :real64 then return "Float"
23
+ when :dateTime then return "Time"
24
+ when :reference then return "Sfcc::Cim::ObjectPath"
25
+ when :class then return "Sfcc::Cim::Class"
26
+ else
27
+ STDERR.puts "Unhandled type #{type}"
28
+ end
29
+ end
30
+
31
+ def initialize c, namespace, out
32
+ out.comment.comment "Testcase for #{namespace}:#{c.name}"
33
+ out.comment.comment "Generated by 'genprovider' for use with cmpi-bindings-ruby"
34
+ out.puts "require 'rubygems'"
35
+ out.puts "require 'sfcc'"
36
+ out.puts "require 'test/unit'"
37
+ out.puts
38
+ out.puts "class Test_#{c.name} < Test::Unit::TestCase"
39
+ out.inc
40
+ out.def "setup"
41
+ out.puts "@client = Sfcc::Cim::Client.connect(:uri => 'https://wsman:secret@localhost:5989', :verify => false)"
42
+ out.puts "@op = Sfcc::Cim::ObjectPath.new('#{namespace}', '#{c.name}')"
43
+ out.end
44
+ out.puts
45
+ out.def "test_registered"
46
+ out.puts "cimclass = @client.get_class(@op)"
47
+ out.puts "assert cimclass"
48
+ out.end # test_registered
49
+ out.puts
50
+ out.def "test_instance_names"
51
+ out.puts "names = @client.instance_names(@op)"
52
+ out.puts "assert names.size > 0"
53
+ out.puts "names.each do |ref|"
54
+ out.inc
55
+ out.puts "ref.namespace = @op.namespace"
56
+ out.puts "instance = @client.get_instance ref"
57
+ out.puts "assert instance"
58
+ out.puts
59
+ #
60
+ # Properties
61
+ #
62
+ c.features.each do |p|
63
+ next unless p.property?
64
+ element = "instance.#{p.name}"
65
+ out.puts "assert #{element}"
66
+ if p.type.array?
67
+ out.puts "assert_kind_of Array, #{element} # #{p.type}"
68
+ out.puts "tmp = #{element}[0]"
69
+ element = "tmp"
70
+ end
71
+ rtype = rubytype p.type
72
+ raise "Unsupported type #{p.type} [#{rtype.class}]" if rtype.nil?
73
+ out.puts "if #{element}"
74
+ out.inc
75
+ if rtype.empty?
76
+ out.puts "assert #{element}.is_a?(TrueClass) || #{element}.is_a?(FalseClass)"
77
+ else
78
+ out.puts "assert_kind_of #{rubytype p.type}, #{element} # #{p.type}"
79
+ end
80
+ out.end
81
+ end
82
+ out.end # names.each
83
+ out.end # test_instance_names
84
+ #
85
+ # References
86
+ #
87
+ out.puts
88
+ c.features.each do |r|
89
+ next unless r.reference?
90
+ end
91
+ #
92
+ # Methods
93
+ #
94
+ out.puts
95
+ c.features.each do |m|
96
+ next unless m.method?
97
+ out.puts
98
+ out.def "test_method_#{m.name}"
99
+ if m.static?
100
+ # class-level method
101
+ else
102
+ # instance level method
103
+ out.puts "@client.instances(@op).each do |inst|"
104
+ out.inc
105
+ m.parameters.each do |p|
106
+ desc = p.description
107
+ out.comment desc if desc
108
+ if p.out?
109
+ out.puts "p_out_#{p.name} = {} # #{p.type}"
110
+ else
111
+ out.puts "p_in_#{p.name} = nil # #{p.type}"
112
+ end
113
+ end
114
+ s = "res = inst.#{m.name}("
115
+ first = true
116
+ m.parameters.each do |p|
117
+ if first
118
+ first = false
119
+ else
120
+ s << ", "
121
+ end
122
+ if p.includes? :out
123
+ s << "p_out_#{p.name}"
124
+ else
125
+ s << "p_in_#{p.name}"
126
+ end
127
+ end
128
+ s << ")"
129
+ out.puts s
130
+ out.puts "assert_kind_of #{rubytype m.type}, res"
131
+ out.end
132
+ end
133
+ out.end # test_method_<name>
134
+ end
135
+ out.puts
136
+ out.end # class
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,3 @@
1
+ module Genprovider
2
+ VERSION = '0.2.0'
3
+ end
@@ -0,0 +1,35 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module Genprovider
5
+ INSTANCE_MASK = 1
6
+ METHOD_MASK = 2
7
+ ASSOCIATION_MASK = 4
8
+ INDICATION_MASK = 8
9
+
10
+ def self.classmask klass
11
+ c = klass
12
+ mask = 0
13
+ while c
14
+ mask |= INSTANCE_MASK if c.instance?
15
+ mask |= METHOD_MASK if c.method?
16
+ mask |= ASSOCIATION_MASK if c.association?
17
+ mask |= INDICATION_MASK if c.indication?
18
+ c = c.parent
19
+ end
20
+ if mask == 0
21
+ STDERR.puts "Assuming that #{klass.name} defines an Instance"
22
+ mask |= INSTANCE_MASK
23
+ end
24
+ mask
25
+ end
26
+
27
+ require 'genprovider/version'
28
+ require 'genprovider/output'
29
+ require 'genprovider/class'
30
+ require 'genprovider/provider'
31
+ require 'genprovider/registration'
32
+ require 'genprovider/testcase'
33
+ require 'genprovider/classinfo'
34
+ require 'genprovider/rdoc'
35
+ end
@@ -0,0 +1,6 @@
1
+ class LMI_Embedded
2
+ {
3
+ [Key] string InstanceID;
4
+ [EmbeddedObject("CIM_ManagedElement")] string Embedded;
5
+ string Str;
6
+ };
@@ -0,0 +1,27 @@
1
+ [ Description ("A dummy class to represent array data types" )
2
+ ]
3
+ class RCP_ArrayDataTypes
4
+ {
5
+ [Key]
6
+ string Name;
7
+
8
+ boolean bool[];
9
+
10
+ string text[];
11
+ char16 char_16[];
12
+
13
+ uint8 unsigned_int_8[];
14
+ uint16 unsigned_int_16[];
15
+ uint32 unsigned_int_32[];
16
+ uint64 unsigned_int_64[];
17
+
18
+ sint8 byte[];
19
+ sint16 short[];
20
+ sint32 int[];
21
+ sint64 long[];
22
+
23
+ real32 float[];
24
+ real64 double[];
25
+
26
+ datetime date_time[];
27
+ };
@@ -0,0 +1,7 @@
1
+ [ Description ("A class method" )
2
+ ]
3
+ class RCP_ClassMethod
4
+ {
5
+ [Static, Description("A class method")]
6
+ string Classname();
7
+ };
@@ -0,0 +1,14 @@
1
+ [ Description ("A class to implement complex methods" )
2
+ ]
3
+ class RCP_ComplexMethod
4
+ {
5
+ [Key]
6
+ string Name;
7
+
8
+ [Description("A method to concatenate count * str, passing the"
9
+ "result via an out parameter. Returning the result length")]
10
+ uint32 InOut(uint32 count, [in] string str, [out] string result);
11
+
12
+ [Description("A method to count array elements")]
13
+ uint32 Size([in] string strA[]);
14
+ };
@@ -0,0 +1,13 @@
1
+ /*
2
+ * sample indication generator
3
+ * modeled after
4
+ * http://sourceforge.net/apps/mediawiki/pywbem/index.php?title=Indications_Tutorial
5
+ */
6
+
7
+ class RCP_IndicationGenerator
8
+ {
9
+ [Static, Description("Generate one or more indications")]
10
+ uint16 generate_indications(
11
+ string ind_text,
12
+ uint16 num_to_send );
13
+ };
@@ -0,0 +1,10 @@
1
+ [ Description ("Passing CDATA string property values" )
2
+ ]
3
+ class RCP_PassCData
4
+ {
5
+ [Key]
6
+ string Name;
7
+ string Strange;
8
+ string CData;
9
+ string XmlData;
10
+ };
@@ -0,0 +1,11 @@
1
+ [ Description ("A class to return the CMPIContext passed by the CIMOM" )
2
+ ]
3
+ class RCP_ShowContext
4
+ {
5
+ [Key]
6
+ string name;
7
+ [ Description ("Array of alternating key, value strings from"
8
+ "CMPIContext." )
9
+ ]
10
+ string context[];
11
+ };
@@ -0,0 +1,7 @@
1
+ [ Description ("A simple class to detect memory leaks in cmpi-bindings" )
2
+ ]
3
+ class RCP_SimpleClass
4
+ {
5
+ [Key]
6
+ string Name;
7
+ };
@@ -0,0 +1,27 @@
1
+ [ Description ("A dummy class to represent various data types" )
2
+ ]
3
+ class RCP_SimpleDataTypes
4
+ {
5
+ [Key]
6
+ string Name;
7
+
8
+ boolean bool;
9
+
10
+ string text;
11
+ char16 char_16;
12
+
13
+ uint8 unsigned_int_8;
14
+ uint16 unsigned_int_16;
15
+ uint32 unsigned_int_32;
16
+ uint64 unsigned_int_64;
17
+
18
+ sint8 byte;
19
+ sint16 short;
20
+ sint32 int;
21
+ sint64 long;
22
+
23
+ real32 float;
24
+ real64 double;
25
+
26
+ datetime date_time;
27
+ };
@@ -0,0 +1,9 @@
1
+ [ Description ("A simple class to implement methods" )
2
+ ]
3
+ class RCP_SimpleMethod
4
+ {
5
+ [Key]
6
+ string Name;
7
+
8
+ boolean ReturnTrue();
9
+ };
@@ -0,0 +1,20 @@
1
+ //
2
+ // qualifiers.mof - Qualifier definitions for stand-alone mof compilation
3
+ //
4
+ //
5
+
6
+ #pragma locale ("en_US")
7
+ //#pragma namespace ("root/cimv2")
8
+
9
+ Qualifier Provider : string = null,
10
+ Scope(any);
11
+ Qualifier Description : string = null,
12
+ Scope(any),
13
+ Flavor(EnableOverride, ToSubclass, Translatable);
14
+ Qualifier Key : boolean = false,
15
+ Scope(property, reference),
16
+ Flavor(DisableOverride, ToSubclass);
17
+ Qualifier Association : boolean = false,
18
+ Scope(class);
19
+ Qualifier Indication : boolean = false,
20
+ Scope(class);
@@ -0,0 +1,148 @@
1
+ #
2
+ # Provider LMI_Embedded for class LMI_Embedded:CIM::Class
3
+ #
4
+ require 'syslog'
5
+
6
+ require 'cmpi/provider'
7
+
8
+ module Cmpi
9
+
10
+ class CIM_ManagedElement < InstanceProvider
11
+ # typemap for embedded instance
12
+ def self.typemap
13
+ {
14
+ "InstanceID" => Cmpi::string,
15
+ "Caption" => Cmpi::string,
16
+ "Description" => Cmpi::string,
17
+ "ElementName" => Cmpi::string,
18
+ "Generation" => Cmpi::uint64,
19
+ }
20
+ end
21
+ end
22
+ #
23
+ class LMI_Embedded < InstanceProvider
24
+
25
+ #
26
+ # Provider initialization
27
+ #
28
+ def initialize( name, broker, context )
29
+ @trace_file = STDERR
30
+ super broker
31
+ end
32
+
33
+ def cleanup( context, terminating )
34
+ @trace_file.puts "cleanup terminating? #{terminating}"
35
+ true
36
+ end
37
+
38
+ def self.typemap
39
+ {
40
+ "InstanceID" => Cmpi::string,
41
+ "Embedded" => Cmpi::embedded_instance,
42
+ "Str" => Cmpi::string,
43
+ }
44
+ end
45
+
46
+ private
47
+ #
48
+ # Iterator for names and instances
49
+ # yields references matching reference and properties
50
+ #
51
+ def each( context, reference, properties = nil, want_instance = false )
52
+ value = "Hello world"
53
+
54
+ # create embedded instance
55
+ ns = reference.namespace
56
+ pembedded = Cmpi::CMPIObjectPath.new ns, "CIM_ManagedElement"
57
+ pembedded.InstanceID = "id"
58
+ @trace_file.puts "pembedded #{pembedded}"
59
+
60
+ embedded = Cmpi::CMPIInstance.new pembedded
61
+ embedded.Description = "descr"
62
+
63
+ result = Cmpi::CMPIObjectPath.new reference.namespace, "LMI_Embedded"
64
+ if want_instance
65
+ result = Cmpi::CMPIInstance.new result
66
+ end
67
+
68
+ # Set key properties
69
+
70
+ result.InstanceID = "Hello world" # string (-> LMI_Embedded)
71
+ unless want_instance
72
+ yield result
73
+ return
74
+ end
75
+
76
+ # Instance: Set non-key properties
77
+
78
+ result.Embedded = embedded
79
+ result.Str = "sample string"
80
+ yield result
81
+ end
82
+ public
83
+
84
+ def enum_instance_names( context, result, reference )
85
+ @trace_file.puts "enum_instance_names ref #{reference}"
86
+ each(context, reference) do |ref|
87
+ @trace_file.puts "ref #{ref}"
88
+ result.return_objectpath ref
89
+ end
90
+ result.done
91
+ true
92
+ end
93
+
94
+ def enum_instances( context, result, reference, properties )
95
+ @trace_file.puts "enum_instances ref #{reference}, props #{properties.inspect}"
96
+ each(context, reference, properties, true) do |instance|
97
+ @trace_file.puts "instance #{instance}"
98
+ result.return_instance instance
99
+ end
100
+ result.done
101
+ true
102
+ end
103
+
104
+ def get_instance( context, result, reference, properties )
105
+ @trace_file.puts "get_instance ref #{reference}, props #{properties.inspect}"
106
+ each(context, reference, properties, true) do |instance|
107
+ @trace_file.puts "instance #{instance}"
108
+ result.return_instance instance
109
+ break # only return first instance
110
+ end
111
+ result.done
112
+ true
113
+ end
114
+
115
+ def create_instance( context, result, reference, newinst )
116
+ @trace_file.puts "create_instance ref #{reference}, newinst #{newinst.inspect}"
117
+ # Create instance according to reference and newinst
118
+ result.return_objectpath reference
119
+ result.done
120
+ true
121
+ end
122
+
123
+ def set_instance( context, result, reference, newinst, properties )
124
+ @trace_file.puts "set_instance ref #{reference}, newinst #{newinst.inspect}, props #{properties.inspect}"
125
+ properties.each do |prop|
126
+ newinst.send "#{prop.name}=".to_sym, FIXME
127
+ end
128
+ result.return_instance newinst
129
+ result.done
130
+ true
131
+ end
132
+
133
+ def delete_instance( context, result, reference )
134
+ @trace_file.puts "delete_instance ref #{reference}"
135
+ result.done
136
+ true
137
+ end
138
+
139
+ # query : String
140
+ # lang : String
141
+ def exec_query( context, result, reference, query, lang )
142
+ @trace_file.puts "exec_query ref #{reference}, query #{query}, lang #{lang}"
143
+ result.done
144
+ true
145
+ end
146
+
147
+ end
148
+ end