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,219 @@
1
+ #
2
+ # Provider RCP_ArrayDataTypes for class RCP_ArrayDataTypes:CIM::Class
3
+ #
4
+ require 'syslog'
5
+
6
+ require 'cmpi/provider'
7
+
8
+ STDERR.puts "\t\t *** rcp_array_data_types.rb"
9
+
10
+ module Cmpi
11
+ #
12
+ # A dummy class to represent array data types
13
+ #
14
+ class RCP_ArrayDataTypes < InstanceProvider
15
+
16
+ #
17
+ # Provider initialization
18
+ #
19
+ def initialize( name, broker, context )
20
+ @trace_file = STDERR
21
+ @trace_file.puts "#{self.class}.new #{name}"
22
+ super broker
23
+ end
24
+
25
+ def cleanup( context, terminating )
26
+ @trace_file.puts "cleanup terminating? #{terminating}"
27
+ true
28
+ end
29
+
30
+ def self.typemap
31
+ {
32
+ "Name" => Cmpi::string,
33
+ "bool" => Cmpi::booleanA,
34
+ "text" => Cmpi::stringA,
35
+ "char_16" => Cmpi::char16A,
36
+ "unsigned_int_8" => Cmpi::uint8A,
37
+ "unsigned_int_16" => Cmpi::uint16A,
38
+ "unsigned_int_32" => Cmpi::uint32A,
39
+ "unsigned_int_64" => Cmpi::uint64A,
40
+ "byte" => Cmpi::sint8A,
41
+ "short" => Cmpi::sint16A,
42
+ "int" => Cmpi::sint32A,
43
+ "long" => Cmpi::sint64A,
44
+ "float" => Cmpi::real32A,
45
+ "double" => Cmpi::real64A,
46
+ "date_time" => Cmpi::dateTimeA,
47
+ }
48
+ end
49
+
50
+ private
51
+ #
52
+ # Iterator for names and instances
53
+ # yields references matching reference and properties
54
+ #
55
+ def each( context, reference, properties = nil, want_instance = false )
56
+ if want_instance
57
+ result = Cmpi::CMPIObjectPath.new reference.namespace, "RCP_ArrayDataTypes"
58
+ result = Cmpi::CMPIInstance.new result
59
+ else
60
+ result = Cmpi::CMPIObjectPath.new reference.namespace, "RCP_ArrayDataTypes"
61
+ end
62
+
63
+ @trace_file.puts "reference(#{reference.class}:#{reference})"
64
+ ["Empty", "One", "More", "Null"].each do |name|
65
+
66
+ if reference.Name
67
+ @trace_file.puts "Expect Name = #{reference.Name.inspect}, have #{name.inspect}"
68
+ next unless name == reference.Name
69
+ end
70
+ # Set key properties
71
+
72
+ @trace_file.puts "result.Name = #{name}"
73
+ result.Name = name # string (-> RCP_ArrayDataTypes)
74
+ if want_instance
75
+ @trace_file.puts "want_instance"
76
+
77
+ case name
78
+ when "Empty"
79
+ # Instance: Set non-key properties
80
+
81
+ result.bool = [] # boolean[] (-> RCP_ArrayDataTypes)
82
+ result.text = [] # string[] (-> RCP_ArrayDataTypes)
83
+ result.char_16 = [] # char16[] (-> RCP_ArrayDataTypes)
84
+ result.unsigned_int_8 = [] # uint8[] (-> RCP_ArrayDataTypes)
85
+ result.unsigned_int_16 = [] # uint16[] (-> RCP_ArrayDataTypes)
86
+ result.unsigned_int_32 = [] # uint32[] (-> RCP_ArrayDataTypes)
87
+ result.unsigned_int_64 = [] # uint64[] (-> RCP_ArrayDataTypes)
88
+ result.byte = [] # sint8[] (-> RCP_ArrayDataTypes)
89
+ result.short = [] # sint16[] (-> RCP_ArrayDataTypes)
90
+ result.int = [] # sint32[] (-> RCP_ArrayDataTypes)
91
+ result.long = [] # sint64[] (-> RCP_ArrayDataTypes)
92
+ result.float = [] # real32[] (-> RCP_ArrayDataTypes)
93
+ result.double = [] # real64[] (-> RCP_ArrayDataTypes)
94
+ result.date_time = [] # dateTime[] (-> RCP_ArrayDataTypes)
95
+ when "One"
96
+ # Instance: Set non-key properties
97
+
98
+ @trace_file.puts "result for #{name}"
99
+ result.bool = [true] # boolean[] (-> RCP_ArrayDataTypes)
100
+ result.text = ["One element"] # string[] (-> RCP_ArrayDataTypes)
101
+ result.char_16 = [65535] # char16[] (-> RCP_ArrayDataTypes)
102
+ result.unsigned_int_8 = [1] # uint8[] (-> RCP_ArrayDataTypes)
103
+ result.unsigned_int_16 = [1] # uint16[] (-> RCP_ArrayDataTypes)
104
+ result.unsigned_int_32 = [1] # uint32[] (-> RCP_ArrayDataTypes)
105
+ result.unsigned_int_64 = [1] # uint64[] (-> RCP_ArrayDataTypes)
106
+ result.byte = [1] # sint8[] (-> RCP_ArrayDataTypes)
107
+ result.short = [1] # sint16[] (-> RCP_ArrayDataTypes)
108
+ result.int = [1] # sint32[] (-> RCP_ArrayDataTypes)
109
+ result.long = [1] # sint64[] (-> RCP_ArrayDataTypes)
110
+ result.float = [Math::PI] # real32[] (-> RCP_ArrayDataTypes)
111
+ result.double = [Math::PI] # real64[] (-> RCP_ArrayDataTypes)
112
+ result.date_time = [Time.now] # dateTime[] (-> RCP_ArrayDataTypes)
113
+ when "More"
114
+ # Instance: Set non-key properties
115
+
116
+ result.bool = [true,false,true] # boolean[] (-> RCP_ArrayDataTypes)
117
+ result.text = ["Element one", "Element two", "Element three"] # string[] (-> RCP_ArrayDataTypes)
118
+ result.char_16 = ["1", "2", "3"] #[49, 50, 51] # '1','2','3' char16[] (-> RCP_ArrayDataTypes)
119
+ result.unsigned_int_8 = [1,2,3] # uint8[] (-> RCP_ArrayDataTypes)
120
+ result.unsigned_int_16 = [1,2,3] # uint16[] (-> RCP_ArrayDataTypes)
121
+ result.unsigned_int_32 = [1,2,3] # uint32[] (-> RCP_ArrayDataTypes)
122
+ result.unsigned_int_64 = [1,2,3] # uint64[] (-> RCP_ArrayDataTypes)
123
+ result.byte = [1,2,3] # sint8[] (-> RCP_ArrayDataTypes)
124
+ result.short = [1,2,3] # sint16[] (-> RCP_ArrayDataTypes)
125
+ result.int = [1,2,3] # sint32[] (-> RCP_ArrayDataTypes)
126
+ result.long = [1,2,3] # sint64[] (-> RCP_ArrayDataTypes)
127
+ result.float = [Math::PI,Math::PI,Math::PI] # real32[] (-> RCP_ArrayDataTypes)
128
+ result.double = [Math::PI,Math::PI,Math::PI] # real64[] (-> RCP_ArrayDataTypes)
129
+ result.date_time = [Time.now, 31536000000000, "-31536000", "19520311040242.424242-060", "12345678010203.123456:000"] # dateTime[] (-> RCP_ArrayDataTypes)
130
+ when "Null"
131
+ # Instance: Set non-key properties
132
+
133
+ result.bool = nil # boolean[] (-> RCP_ArrayDataTypes)
134
+ result.text = nil # string[] (-> RCP_ArrayDataTypes)
135
+ result.char_16 = nil # char16[] (-> RCP_ArrayDataTypes)
136
+ result.unsigned_int_8 = nil # uint8[] (-> RCP_ArrayDataTypes)
137
+ result.unsigned_int_16 = nil # uint16[] (-> RCP_ArrayDataTypes)
138
+ result.unsigned_int_32 = nil # uint32[] (-> RCP_ArrayDataTypes)
139
+ result.unsigned_int_64 = nil # uint64[] (-> RCP_ArrayDataTypes)
140
+ result.byte = nil # sint8[] (-> RCP_ArrayDataTypes)
141
+ result.short = nil # sint16[] (-> RCP_ArrayDataTypes)
142
+ result.int = nil # sint32[] (-> RCP_ArrayDataTypes)
143
+ result.long = nil # sint64[] (-> RCP_ArrayDataTypes)
144
+ result.float = nil # real32[] (-> RCP_ArrayDataTypes)
145
+ result.double = nil # real64[] (-> RCP_ArrayDataTypes)
146
+ result.date_time = nil # dateTime[] (-> RCP_ArrayDataTypes)
147
+ end
148
+ end # if want_instance
149
+ @trace_file.puts "\tyield #{result}"
150
+ yield result
151
+ end
152
+ end
153
+ public
154
+
155
+ def enum_instance_names( context, result, reference )
156
+ @trace_file.puts "enum_instance_names ref #{reference}"
157
+ each(context, reference) do |ref|
158
+ @trace_file.puts "ref #{ref}"
159
+ result.return_objectpath ref
160
+ end
161
+ result.done
162
+ true
163
+ end
164
+
165
+ def enum_instances( context, result, reference, properties )
166
+ @trace_file.puts "enum_instances ref #{reference}, props #{properties.inspect}"
167
+ each(context, reference, properties, true) do |instance|
168
+ @trace_file.puts "instance #{instance}"
169
+ result.return_instance instance
170
+ end
171
+ result.done
172
+ true
173
+ end
174
+
175
+ def get_instance( context, result, reference, properties )
176
+ @trace_file.puts "get_instance ref #{reference}, props #{properties.inspect}"
177
+ each(context, reference, properties, true) do |instance|
178
+ @trace_file.puts "instance #{instance}"
179
+ result.return_instance instance
180
+ break # only return first instance
181
+ end
182
+ result.done
183
+ true
184
+ end
185
+
186
+ def create_instance( context, result, reference, newinst )
187
+ @trace_file.puts "create_instance ref #{reference}, newinst #{newinst.inspect}"
188
+ # Create instance according to reference and newinst
189
+ result.return_objectpath reference
190
+ result.done
191
+ true
192
+ end
193
+
194
+ def set_instance( context, result, reference, newinst, properties )
195
+ @trace_file.puts "set_instance ref #{reference}, newinst #{newinst.inspect}, props #{properties.inspect}"
196
+ properties.each do |prop|
197
+ newinst.send "#{prop.name}=".to_sym, FIXME
198
+ end
199
+ result.return_instance newinst
200
+ result.done
201
+ true
202
+ end
203
+
204
+ def delete_instance( context, result, reference )
205
+ @trace_file.puts "delete_instance ref #{reference}"
206
+ result.done
207
+ true
208
+ end
209
+
210
+ # query : String
211
+ # lang : String
212
+ def exec_query( context, result, reference, query, lang )
213
+ @trace_file.puts "exec_query ref #{reference}, query #{query}, lang #{lang}"
214
+ result.done
215
+ true
216
+ end
217
+
218
+ end
219
+ end
@@ -0,0 +1,54 @@
1
+ #
2
+ # Provider RCP_ClassMethod for class RCP_ClassMethod:CIM::Class
3
+ #
4
+ require 'syslog'
5
+
6
+ require 'cmpi/provider'
7
+
8
+ module Cmpi
9
+ #
10
+ # A class method
11
+ #
12
+ class RCP_ClassMethod < MethodProvider
13
+
14
+ #
15
+ # Provider initialization
16
+ #
17
+ def initialize( name, broker, context )
18
+ @trace_file = STDERR
19
+ super broker
20
+ end
21
+
22
+ def cleanup( context, terminating )
23
+ @trace_file.puts "cleanup terminating? #{terminating}"
24
+ true
25
+ end
26
+
27
+ def self.typemap
28
+ {
29
+ }
30
+ end
31
+
32
+ # Methods
33
+
34
+ # RCP_ClassMethod: string Classname(...)
35
+ #
36
+ # type information for Classname(...)
37
+ def classname_args; [[],[Cmpi::string, ]] end
38
+ #
39
+ # Input args
40
+ #
41
+ # Additional output args
42
+ #
43
+ def classname( context, reference )
44
+ @trace_file.puts "classname #{context}, #{reference}"
45
+ method_return_value = "RCP_ClassMethod" # string
46
+
47
+ # function body goes here
48
+
49
+ return method_return_value
50
+ end
51
+
52
+
53
+ end
54
+ end
@@ -0,0 +1,170 @@
1
+ #
2
+ # Provider RCP_ComplexMethod for class RCP_ComplexMethod:CIM::Class
3
+ #
4
+ require 'syslog'
5
+
6
+ require 'cmpi/provider'
7
+
8
+ module Cmpi
9
+ #
10
+ # A class to implement complex methods
11
+ #
12
+ class RCP_ComplexMethod < MethodProvider
13
+
14
+ include InstanceProviderIF
15
+ #
16
+ # Provider initialization
17
+ #
18
+ def initialize( name, broker, context )
19
+ @trace_file = STDERR
20
+ super broker
21
+ end
22
+
23
+ def cleanup( context, terminating )
24
+ @trace_file.puts "cleanup terminating? #{terminating}"
25
+ true
26
+ end
27
+
28
+ def self.typemap
29
+ {
30
+ "Name" => Cmpi::string,
31
+ }
32
+ end
33
+
34
+ # Methods
35
+
36
+ # RCP_ComplexMethod: uint32 InOut(...)
37
+ #
38
+ def in_out_args; [["count", Cmpi::uint32, "str", Cmpi::string],[Cmpi::uint32, "result", Cmpi::string]] end
39
+ #
40
+ # A method to concatenate count * str, passing theresult via an out
41
+ # parameter. Returning the result length
42
+ #
43
+ # Input args
44
+ # count : uint32
45
+ # str : string
46
+ #
47
+ # Additional output args
48
+ # result : string
49
+ #
50
+ def in_out( context, reference, count, str )
51
+ @trace_file.puts "in_out #{context}, #{reference}, #{count.inspect}, #{str.inspect}"
52
+ result = str * count # string
53
+ return_value = result.size # uint32
54
+
55
+ return [return_value, result]
56
+ end
57
+
58
+ # RCP_ComplexMethod: uint32 Size(...)
59
+ #
60
+ # type information for Size(...)
61
+ def size_args; [["strA", Cmpi::stringA],[Cmpi::uint32, ]] end
62
+ #
63
+ # Input args
64
+ # strA : string[]
65
+ #
66
+ # Additional output args
67
+ #
68
+ def size( context, reference, str_a )
69
+ @trace_file.puts "size #{context}, #{reference}, #{str_a.inspect}"
70
+ str_a ||= []
71
+ method_return_value = str_a.size # uint32
72
+
73
+ # function body goes here
74
+
75
+ return method_return_value
76
+ end
77
+
78
+
79
+ private
80
+ #
81
+ # Iterator for names and instances
82
+ # yields references matching reference and properties
83
+ #
84
+ def each( context, reference, properties = nil, want_instance = false )
85
+ if want_instance
86
+ result = Cmpi::CMPIObjectPath.new reference.namespace, "RCP_ComplexMethod"
87
+ result = Cmpi::CMPIInstance.new result
88
+ else
89
+ result = Cmpi::CMPIObjectPath.new reference.namespace, "RCP_ComplexMethod"
90
+ end
91
+
92
+ # Set key properties
93
+
94
+ result.Name = "Method" # string (-> RCP_ComplexMethod)
95
+ unless want_instance
96
+ yield result
97
+ return
98
+ end
99
+
100
+ # Instance: Set non-key properties
101
+
102
+ yield result
103
+ end
104
+ public
105
+
106
+ def enum_instance_names( context, result, reference )
107
+ @trace_file.puts "enum_instance_names ref #{reference}"
108
+ each(context, reference) do |ref|
109
+ @trace_file.puts "ref #{ref}"
110
+ result.return_objectpath ref
111
+ end
112
+ result.done
113
+ true
114
+ end
115
+
116
+ def enum_instances( context, result, reference, properties )
117
+ @trace_file.puts "enum_instances ref #{reference}, props #{properties.inspect}"
118
+ each(context, reference, properties, true) do |instance|
119
+ @trace_file.puts "instance #{instance}"
120
+ result.return_instance instance
121
+ end
122
+ result.done
123
+ true
124
+ end
125
+
126
+ def get_instance( context, result, reference, properties )
127
+ @trace_file.puts "get_instance ref #{reference}, props #{properties.inspect}"
128
+ each(context, reference, properties, true) do |instance|
129
+ @trace_file.puts "instance #{instance}"
130
+ result.return_instance instance
131
+ break # only return first instance
132
+ end
133
+ result.done
134
+ true
135
+ end
136
+
137
+ def create_instance( context, result, reference, newinst )
138
+ @trace_file.puts "create_instance ref #{reference}, newinst #{newinst.inspect}"
139
+ # Create instance according to reference and newinst
140
+ result.return_objectpath reference
141
+ result.done
142
+ true
143
+ end
144
+
145
+ def set_instance( context, result, reference, newinst, properties )
146
+ @trace_file.puts "set_instance ref #{reference}, newinst #{newinst.inspect}, props #{properties.inspect}"
147
+ properties.each do |prop|
148
+ newinst.send "#{prop.name}=".to_sym, FIXME
149
+ end
150
+ result.return_instance newinst
151
+ result.done
152
+ true
153
+ end
154
+
155
+ def delete_instance( context, result, reference )
156
+ @trace_file.puts "delete_instance ref #{reference}"
157
+ result.done
158
+ true
159
+ end
160
+
161
+ # query : String
162
+ # lang : String
163
+ def exec_query( context, result, reference, query, lang )
164
+ @trace_file.puts "exec_query ref #{reference}, query #{query}, lang #{lang}"
165
+ result.done
166
+ true
167
+ end
168
+
169
+ end
170
+ end
@@ -0,0 +1,130 @@
1
+ #
2
+ # Provider RCP_PassCData for class RCP_PassCData:CIM::Class
3
+ #
4
+ require 'syslog'
5
+
6
+ require 'cmpi/provider'
7
+
8
+ module Cmpi
9
+ #
10
+ # Passing CDATA string property values
11
+ #
12
+ class RCP_PassCData < InstanceProvider
13
+
14
+ #
15
+ # Provider initialization
16
+ #
17
+ def initialize( name, broker, context )
18
+ @trace_file = STDERR
19
+ super broker
20
+ end
21
+
22
+ def cleanup( context, terminating )
23
+ @trace_file.puts "cleanup terminating? #{terminating}"
24
+ true
25
+ end
26
+
27
+ def self.typemap
28
+ {
29
+ "Name" => Cmpi::string,
30
+ "Strange" => Cmpi::string,
31
+ "CData" => Cmpi::string,
32
+ "XmlData" => Cmpi::string,
33
+ }
34
+ end
35
+
36
+ private
37
+ #
38
+ # Iterator for names and instances
39
+ # yields references matching reference and properties
40
+ #
41
+ def each( context, reference, properties = nil, want_instance = false )
42
+ if want_instance
43
+ result = Cmpi::CMPIObjectPath.new reference.namespace, "RCP_PassCData"
44
+ result = Cmpi::CMPIInstance.new result
45
+ else
46
+ result = Cmpi::CMPIObjectPath.new reference.namespace, "RCP_PassCData"
47
+ end
48
+
49
+ # Set key properties
50
+
51
+ result.Name = nil # string (-> RCP_PassCData)
52
+ unless want_instance
53
+ yield result
54
+ return
55
+ end
56
+
57
+ # Instance: Set non-key properties
58
+
59
+ # result.Strange = nil # string (-> RCP_PassCData)
60
+ # result.CData = nil # string (-> RCP_PassCData)
61
+ # result.XmlData = nil # string (-> RCP_PassCData)
62
+ yield result
63
+ end
64
+ public
65
+
66
+ def enum_instance_names( context, result, reference )
67
+ @trace_file.puts "enum_instance_names ref #{reference}"
68
+ each(context, reference) do |ref|
69
+ @trace_file.puts "ref #{ref}"
70
+ result.return_objectpath ref
71
+ end
72
+ result.done
73
+ true
74
+ end
75
+
76
+ def enum_instances( context, result, reference, properties )
77
+ @trace_file.puts "enum_instances ref #{reference}, props #{properties.inspect}"
78
+ each(context, reference, properties, true) do |instance|
79
+ @trace_file.puts "instance #{instance}"
80
+ result.return_instance instance
81
+ end
82
+ result.done
83
+ true
84
+ end
85
+
86
+ def get_instance( context, result, reference, properties )
87
+ @trace_file.puts "get_instance ref #{reference}, props #{properties.inspect}"
88
+ each(context, reference, properties, true) do |instance|
89
+ @trace_file.puts "instance #{instance}"
90
+ result.return_instance instance
91
+ break # only return first instance
92
+ end
93
+ result.done
94
+ true
95
+ end
96
+
97
+ def create_instance( context, result, reference, newinst )
98
+ @trace_file.puts "create_instance ref #{reference}, newinst #{newinst.inspect}"
99
+ # Create instance according to reference and newinst
100
+ result.return_objectpath reference
101
+ result.done
102
+ true
103
+ end
104
+
105
+ def set_instance( context, result, reference, newinst, properties )
106
+ @trace_file.puts "set_instance ref #{reference}, newinst #{newinst.inspect}, props #{properties.inspect}"
107
+ properties.each do |prop|
108
+ newinst.send "#{prop.name}=".to_sym, FIXME
109
+ end
110
+ result.return_instance newinst
111
+ result.done
112
+ true
113
+ end
114
+
115
+ def delete_instance( context, result, reference )
116
+ @trace_file.puts "delete_instance ref #{reference}"
117
+ result.done
118
+ true
119
+ end
120
+
121
+ # query : String
122
+ # lang : String
123
+ def exec_query( context, result, reference, query, lang )
124
+ @trace_file.puts "exec_query ref #{reference}, query #{query}, lang #{lang}"
125
+ result.done
126
+ true
127
+ end
128
+
129
+ end
130
+ end
@@ -0,0 +1,134 @@
1
+ #
2
+ # Provider RCP_ShowContext for class RCP_ShowContext:CIM::Class
3
+ #
4
+ require 'syslog'
5
+
6
+ require 'cmpi/provider'
7
+
8
+ module Cmpi
9
+ #
10
+ # A class to return the CMPIContext passed by the CIMOM
11
+ #
12
+ class RCP_ShowContext < InstanceProvider
13
+
14
+ #
15
+ # Provider initialization
16
+ #
17
+ def initialize( name, broker, context )
18
+ @trace_file = STDERR
19
+ super broker
20
+ end
21
+
22
+ def cleanup( context, terminating )
23
+ @trace_file.puts "cleanup terminating? #{terminating}"
24
+ true
25
+ end
26
+
27
+ def self.typemap
28
+ {
29
+ "name" => Cmpi::string,
30
+ "context" => Cmpi::stringA,
31
+ }
32
+ end
33
+
34
+ private
35
+ #
36
+ # Iterator for names and instances
37
+ # yields references matching reference and properties
38
+ #
39
+ def each( context, reference, properties = nil, want_instance = false )
40
+ result = Cmpi::CMPIObjectPath.new reference.namespace, "RCP_ShowContext"
41
+ STDERR.puts "*** result #{result}"
42
+ if want_instance
43
+ result = Cmpi::CMPIInstance.new result
44
+ STDERR.puts "*** result #{result}"
45
+ end
46
+ result.name = "CMPIContext"
47
+ unless want_instance
48
+ yield result
49
+ return
50
+ end
51
+
52
+ # Instance: Set non-key properties
53
+ count = context.get_entry_count
54
+ res = []
55
+ i = 0
56
+ while i < count
57
+ name, data = context[i]
58
+ i += 1
59
+ res << name
60
+ res << data.to_s
61
+ end
62
+ # Set key properties
63
+ STDERR.puts "res #{res.inspect}"
64
+ result.context = res # string[] (-> RCP_ShowContext)
65
+
66
+ yield result
67
+ end
68
+ public
69
+
70
+ def enum_instance_names( context, result, reference )
71
+ @trace_file.puts "enum_instance_names ref #{reference}"
72
+ each(context, reference) do |ref|
73
+ @trace_file.puts "ref #{ref}"
74
+ result.return_objectpath ref
75
+ end
76
+ result.done
77
+ true
78
+ end
79
+
80
+ def enum_instances( context, result, reference, properties )
81
+ @trace_file.puts "enum_instances ref #{reference}, props #{properties.inspect}"
82
+ each(context, reference, properties, true) do |instance|
83
+ @trace_file.puts "instance #{instance}"
84
+ result.return_instance instance
85
+ end
86
+ result.done
87
+ true
88
+ end
89
+
90
+ def get_instance( context, result, reference, properties )
91
+ @trace_file.puts "get_instance ref #{reference}, props #{properties.inspect}"
92
+ each(context, reference, properties, true) do |instance|
93
+ @trace_file.puts "instance #{instance}"
94
+ result.return_instance instance
95
+ break # only return first instance
96
+ end
97
+ result.done
98
+ true
99
+ end
100
+
101
+ def create_instance( context, result, reference, newinst )
102
+ @trace_file.puts "create_instance ref #{reference}, newinst #{newinst.inspect}"
103
+ # Create instance according to reference and newinst
104
+ result.return_objectpath reference
105
+ result.done
106
+ true
107
+ end
108
+
109
+ def set_instance( context, result, reference, newinst, properties )
110
+ @trace_file.puts "set_instance ref #{reference}, newinst #{newinst.inspect}, props #{properties.inspect}"
111
+ properties.each do |prop|
112
+ newinst.send "#{prop.name}=".to_sym, FIXME
113
+ end
114
+ result.return_instance newinst
115
+ result.done
116
+ true
117
+ end
118
+
119
+ def delete_instance( context, result, reference )
120
+ @trace_file.puts "delete_instance ref #{reference}"
121
+ result.done
122
+ true
123
+ end
124
+
125
+ # query : String
126
+ # lang : String
127
+ def exec_query( context, result, reference, query, lang )
128
+ @trace_file.puts "exec_query ref #{reference}, query #{query}, lang #{lang}"
129
+ result.done
130
+ true
131
+ end
132
+
133
+ end
134
+ end