genprovider 0.2.0
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/CHANGELOG +8 -0
- data/CHANGELOG~ +4 -0
- data/Gemfile +4 -0
- data/LICENSE +58 -0
- data/README.rdoc +50 -0
- data/Rakefile +6 -0
- data/bin/genprovider +256 -0
- data/bin/regprovider +105 -0
- data/features/003-create.feature +10 -0
- data/features/004-modify.feature +9 -0
- data/features/005-delete.feature +7 -0
- data/features/datatypes.feature +13 -0
- data/features/ensure-format.feature +28 -0
- data/features/have-instances.feature +19 -0
- data/features/mof/trivial.mof +20 -0
- data/features/registration.feature +12 -0
- data/features/run-genprovider.feature +10 -0
- data/features/show-context.feature +9 -0
- data/features/step_definitions/genprovider.rb +52 -0
- data/features/step_definitions/mof.rb +3 -0
- data/features/step_definitions/registration.rb +21 -0
- data/features/step_definitions/wbemcli.rb +58 -0
- data/features/support/env.rb +20 -0
- data/genprovider.gemspec +36 -0
- data/lib/genprovider/class.rb +200 -0
- data/lib/genprovider/classinfo.rb +88 -0
- data/lib/genprovider/output.rb +104 -0
- data/lib/genprovider/provider.rb +721 -0
- data/lib/genprovider/rdoc.rb +149 -0
- data/lib/genprovider/registration.rb +22 -0
- data/lib/genprovider/testcase.rb +139 -0
- data/lib/genprovider/version.rb +3 -0
- data/lib/genprovider.rb +35 -0
- data/samples/mof/LMI_Embedded.mof +6 -0
- data/samples/mof/RCP_ArrayDataTypes.mof +27 -0
- data/samples/mof/RCP_ClassMethod.mof +7 -0
- data/samples/mof/RCP_ComplexMethod.mof +14 -0
- data/samples/mof/RCP_IndicationGenerator.mof +13 -0
- data/samples/mof/RCP_PassCData.mof +10 -0
- data/samples/mof/RCP_ShowContext.mof +11 -0
- data/samples/mof/RCP_SimpleClass.mof +7 -0
- data/samples/mof/RCP_SimpleDataTypes.mof +27 -0
- data/samples/mof/RCP_SimpleMethod.mof +9 -0
- data/samples/mof/qualifiers.mof +20 -0
- data/samples/provider/lmi_embedded.rb +148 -0
- data/samples/provider/rcp_array_data_types.rb +219 -0
- data/samples/provider/rcp_class_method.rb +54 -0
- data/samples/provider/rcp_complex_method.rb +170 -0
- data/samples/provider/rcp_pass_c_data.rb +130 -0
- data/samples/provider/rcp_show_context.rb +134 -0
- data/samples/provider/rcp_simple_class.rb +124 -0
- data/samples/provider/rcp_simple_data_types.rb +152 -0
- data/samples/provider/rcp_simple_method.rb +143 -0
- data/samples/registration/LMI_Embedded.registration +7 -0
- data/samples/registration/RCP_ArrayDataTypes.registration +7 -0
- data/samples/registration/RCP_ClassMethod.registration +8 -0
- data/samples/registration/RCP_ComplexMethod.registration +8 -0
- data/samples/registration/RCP_PassCData.registration +7 -0
- data/samples/registration/RCP_ShowContext.registration +7 -0
- data/samples/registration/RCP_SimpleDataTypes.registration +7 -0
- data/samples/registration/RCP_SimpleMethod.registration +8 -0
- data/samples/sfcb.reg/RCP_ComputerSystem.reg +5 -0
- data/samples/sfcb.reg/RCP_OSProcess.reg +5 -0
- data/samples/sfcb.reg/RCP_OperatingSystem.reg +5 -0
- data/samples/sfcb.reg/RCP_PhysicalMemory.reg +5 -0
- data/samples/sfcb.reg/RCP_Processor.reg +5 -0
- data/samples/sfcb.reg/RCP_RunningOS.reg +5 -0
- data/samples/sfcb.reg/RCP_SimpleClass.reg +5 -0
- data/samples/sfcb.reg/RCP_UnixProcess.reg +5 -0
- data/sfcbd +4 -0
- data/stress.sh +4 -0
- data/tasks/clean.rake +4 -0
- data/tasks/doc.rake +16 -0
- data/tasks/features.rake +8 -0
- data/tasks/prepstage.rake +16 -0
- data/tasks/registration.rake +10 -0
- data/tasks/sfcb.rake +3 -0
- data/tasks/test.rake +10 -0
- data/test/env.rb +23 -0
- data/test/helper.rb +23 -0
- data/test/mkreg.rb +32 -0
- data/test/mof/RCP_ClassMethod.rb +15 -0
- data/test/mof/RCP_ComplexMethod.rb +16 -0
- data/test/mof/RCP_SimpleMethod.rb +15 -0
- data/test/registration.rb +37 -0
- data/test/sfcb.rb +94 -0
- data/test/test_lmi_embedded.rb +64 -0
- data/test/test_rcp_array_data_types.rb +140 -0
- data/test/test_rcp_class_method.rb +31 -0
- data/test/test_rcp_complex_method.rb +68 -0
- data/test/test_rcp_simple_data_types.rb +66 -0
- data/test/test_rcp_simple_method.rb +47 -0
- data/valgrind +8 -0
- metadata +288 -0
data/CHANGELOG
ADDED
data/CHANGELOG~
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
3
|
+
(see COPYING.txt file), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b) use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c) rename any non-standard executables so the names do not conflict
|
21
|
+
with standard executables, which must also be provided.
|
22
|
+
|
23
|
+
d) make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or executable
|
26
|
+
form, provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the executables and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard executables non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under this terms.
|
43
|
+
|
44
|
+
They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
|
45
|
+
files under the ./missing directory. See each file for the copying
|
46
|
+
condition.
|
47
|
+
|
48
|
+
5. The scripts and library files supplied as input to or produced as
|
49
|
+
output from the software do not automatically fall under the
|
50
|
+
copyright of the software, but belong to whomever generated them,
|
51
|
+
and may be sold commercially, and may be aggregated with this
|
52
|
+
software.
|
53
|
+
|
54
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
55
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
56
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
57
|
+
PURPOSE.
|
58
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
= genprovider
|
2
|
+
|
3
|
+
* http://github.com/kkaemof/genprovider
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
* A generator for Ruby based CIM providers
|
8
|
+
Generates Ruby provider templates for use with cmpi-bindings
|
9
|
+
|
10
|
+
== FEATURES/PROBLEMS:
|
11
|
+
|
12
|
+
* Generates CIM class and provider templates from MOF files
|
13
|
+
|
14
|
+
== SYNOPSIS:
|
15
|
+
|
16
|
+
genprovider.rb [-d] [-h] [-q] [-I <includedir>] [-o <output>] [-n <namespace>] <moffile> [<moffile> ...]
|
17
|
+
|
18
|
+
== EXAMPLE:
|
19
|
+
|
20
|
+
# generate .registration and .rb file
|
21
|
+
bin/genprovider -n root/cimv2 sample.mof
|
22
|
+
# convert .registration to sfcb .reg file
|
23
|
+
# copy .reg to /var/lib/sfcb/stage/regs
|
24
|
+
# copy .mof to /var/lib/sfcb/mofs/<namespace>/
|
25
|
+
# run sfcbrepos -f
|
26
|
+
sudo provider-register.sh -t sfcb -n root/cimv2 -r generated/sample.registration -m sample.mof
|
27
|
+
# copy provider template
|
28
|
+
cp generated/sample.rb /usr/share/cmpi
|
29
|
+
# reload sfcb to pick up provider information
|
30
|
+
sudo rcsfcb restart
|
31
|
+
|
32
|
+
== REQUIREMENTS:
|
33
|
+
|
34
|
+
* gems:
|
35
|
+
* cim
|
36
|
+
* mof
|
37
|
+
|
38
|
+
* 'cmpi-bindings' (for provider execution)
|
39
|
+
|
40
|
+
== INSTALL:
|
41
|
+
|
42
|
+
* gem install gemprovider
|
43
|
+
|
44
|
+
== LICENSE:
|
45
|
+
|
46
|
+
(The Ruby License)
|
47
|
+
|
48
|
+
Copyright (c) 2010 Klaus Kämpf <kkaempf@suse.de>
|
49
|
+
|
50
|
+
See http://www.ruby-lang.org/en/LICENSE.txt for the full text
|
data/Rakefile
ADDED
data/bin/genprovider
ADDED
@@ -0,0 +1,256 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# genprovider
|
4
|
+
#
|
5
|
+
# Generate Ruby provider templates for use with cmpi-bindings
|
6
|
+
#
|
7
|
+
# Copyright (c) 2010, 2011 Klaus Kämpf <kkaempf@suse.de>
|
8
|
+
#
|
9
|
+
# Licensed under the Ruby license
|
10
|
+
#
|
11
|
+
# == Usage
|
12
|
+
#
|
13
|
+
# genprovider [-c] [-d] [-h] [-q] [-t] [-n <namespace>] [-I <includedir>] [-o <output>] <moffile> [<moffile> ...]
|
14
|
+
#
|
15
|
+
# -c:
|
16
|
+
# generate classinfo instead
|
17
|
+
# -d:
|
18
|
+
# turn on debugging
|
19
|
+
# -h:
|
20
|
+
# show (this) help
|
21
|
+
# -q:
|
22
|
+
# be quiet
|
23
|
+
# -I <includedir>
|
24
|
+
# additional include directories to search
|
25
|
+
# -o <outputdir>
|
26
|
+
# directory to write generated files, defaults to 'generated'
|
27
|
+
# -t:
|
28
|
+
# generate testcase only
|
29
|
+
# <moffile>
|
30
|
+
# .mof files to read
|
31
|
+
#
|
32
|
+
|
33
|
+
require 'rubygems'
|
34
|
+
|
35
|
+
require 'mof'
|
36
|
+
require 'pathname'
|
37
|
+
require 'fileutils'
|
38
|
+
|
39
|
+
$:.push(File.join(File.dirname(__FILE__), '..', 'lib'))
|
40
|
+
|
41
|
+
require 'genprovider'
|
42
|
+
|
43
|
+
#--------------------------------------------------------------------
|
44
|
+
|
45
|
+
#
|
46
|
+
# Extend CIM::Class with parent attribute, point to CIM::Class of parent
|
47
|
+
#
|
48
|
+
|
49
|
+
module CIM
|
50
|
+
class Class
|
51
|
+
attr_accessor :parent
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Convert CamelCase to underline_case
|
57
|
+
#
|
58
|
+
|
59
|
+
class String
|
60
|
+
def decamelize
|
61
|
+
# CamelCase -> under_score
|
62
|
+
self.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
63
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
64
|
+
tr("-", "_").
|
65
|
+
downcase
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# find_and_parse_superclass_of
|
71
|
+
#
|
72
|
+
# Find the superclass name of a class, parse its mof file
|
73
|
+
# returns Hash of { classname -> CIM::Class }
|
74
|
+
#
|
75
|
+
|
76
|
+
def find_and_parse_superclass_of c, options
|
77
|
+
superclasses = {}
|
78
|
+
# parent unknown
|
79
|
+
# try parent.mof
|
80
|
+
begin
|
81
|
+
parser = MOF::Parser.new options
|
82
|
+
result = parser.parse ["qualifiers.mof", "#{c.superclass}.mof"]
|
83
|
+
if result
|
84
|
+
result.each_value do |r|
|
85
|
+
r.classes.each do |parent|
|
86
|
+
if parent.name == c.superclass
|
87
|
+
c.parent = parent
|
88
|
+
superclasses[parent.name] = parent
|
89
|
+
superclasses.merge!(find_and_parse_superclass_of(parent,options)) if parent.superclass
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
else
|
94
|
+
$stderr.puts "Warn: Parent #{c.superclass} of #{c.name} not known"
|
95
|
+
end
|
96
|
+
rescue Exception => e
|
97
|
+
parser.error_handler e
|
98
|
+
end
|
99
|
+
superclasses
|
100
|
+
end
|
101
|
+
|
102
|
+
#--------------------------------------------------------------------
|
103
|
+
|
104
|
+
# path to current cim schema files
|
105
|
+
CIM_CURRENT = "/usr/share/mof/cim-current"
|
106
|
+
|
107
|
+
####
|
108
|
+
## argv handling
|
109
|
+
|
110
|
+
generate_test = ARGV.delete("-t")
|
111
|
+
|
112
|
+
generate_classinfo = ARGV.delete("-c")
|
113
|
+
|
114
|
+
#
|
115
|
+
# parse mofparse arguments
|
116
|
+
#
|
117
|
+
|
118
|
+
moffiles, options = MOF::Parser.argv_handler "genprovider", ARGV
|
119
|
+
if moffiles.empty?
|
120
|
+
$stderr.puts "No .mof files given"
|
121
|
+
exit 1
|
122
|
+
end
|
123
|
+
if !options[:namespace].nil? && options[:namespace].empty?
|
124
|
+
options[:namespace] = nil
|
125
|
+
end
|
126
|
+
|
127
|
+
if options[:namespace].nil?
|
128
|
+
$stderr.puts "** skipping registration"
|
129
|
+
$stderr.puts " Provide a namespace (-n <namespace>) to generate registration file"
|
130
|
+
end
|
131
|
+
|
132
|
+
#
|
133
|
+
# parse genprovider arguments
|
134
|
+
#
|
135
|
+
|
136
|
+
options[:style] ||= :cim
|
137
|
+
options[:includes] ||= []
|
138
|
+
options[:includes].unshift(Pathname.new ".")
|
139
|
+
options[:includes].unshift(Pathname.new CIM_CURRENT)
|
140
|
+
options[:testcase] = generate_test
|
141
|
+
|
142
|
+
#
|
143
|
+
# Extend include pathes with all directories below CIM_CURRENT
|
144
|
+
#
|
145
|
+
|
146
|
+
Dir.new(CIM_CURRENT).each do |d|
|
147
|
+
next if d[0,1] == "."
|
148
|
+
fullname = File.join(CIM_CURRENT, d)
|
149
|
+
next unless File.stat(fullname).directory?
|
150
|
+
options[:includes].unshift(Pathname.new fullname)
|
151
|
+
end
|
152
|
+
|
153
|
+
#
|
154
|
+
# Ensure that qualifiers.mof is included
|
155
|
+
#
|
156
|
+
|
157
|
+
moffiles.unshift "qualifiers.mof" unless moffiles.include? "qualifiers.mof"
|
158
|
+
qualifiers_optional = "qualifiers_optional.mof"
|
159
|
+
unless moffiles.include? qualifiers_optional
|
160
|
+
moffiles.unshift qualifiers_optional if File.readable?(File.join(CIM_CURRENT, qualifiers_optional))
|
161
|
+
end
|
162
|
+
|
163
|
+
####
|
164
|
+
## parse
|
165
|
+
|
166
|
+
#
|
167
|
+
# Parse all given mof files
|
168
|
+
#
|
169
|
+
|
170
|
+
parser = MOF::Parser.new options
|
171
|
+
begin
|
172
|
+
result = parser.parse moffiles
|
173
|
+
rescue Exception => e
|
174
|
+
parser.error_handler e
|
175
|
+
exit 1
|
176
|
+
end
|
177
|
+
|
178
|
+
exit 0 unless result
|
179
|
+
|
180
|
+
#
|
181
|
+
# collect classes to find parent classes
|
182
|
+
#
|
183
|
+
|
184
|
+
# classes: Hash of { classname -> CIM::Class }
|
185
|
+
classes = {}
|
186
|
+
# to_generate: CIM::Class of mof files given as ARGV
|
187
|
+
to_generate = []
|
188
|
+
result.each do |name, res|
|
189
|
+
puts "Result #{name}"
|
190
|
+
res.classes.each do |c|
|
191
|
+
to_generate << c
|
192
|
+
puts " Generate #{c.name}"
|
193
|
+
# complete classes hash (happens if a .mof file defines multiple classes)
|
194
|
+
classes[c.name] = c unless classes.has_key? c.name
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
#
|
199
|
+
# Iterate through parsed classes to find their superclasses
|
200
|
+
#
|
201
|
+
|
202
|
+
superclasses = {}
|
203
|
+
classes.each_value do |c|
|
204
|
+
puts "#{c.name} << #{c.superclass}"
|
205
|
+
next unless c.superclass # skip if no superclass
|
206
|
+
next if classes.has_key? c.superclass # skip if superclass known
|
207
|
+
next if superclasses.has_key? c.superclass # skip if superclass known
|
208
|
+
superclasses.merge! find_and_parse_superclass_of(c,options)
|
209
|
+
end
|
210
|
+
|
211
|
+
# extend the { classname -> CIM::Class } hash with all superclasses
|
212
|
+
|
213
|
+
classes.merge! superclasses
|
214
|
+
|
215
|
+
####
|
216
|
+
## generate
|
217
|
+
|
218
|
+
outdir = options[:output] || "generated"
|
219
|
+
Dir.mkdir outdir rescue Errno::EEXIST
|
220
|
+
|
221
|
+
to_generate.each do |c|
|
222
|
+
if generate_classinfo
|
223
|
+
klass = c
|
224
|
+
while klass
|
225
|
+
Genprovider::Output.new File.join(outdir,"#{klass.name}.rb"), options[:force] do |out|
|
226
|
+
Genprovider::ClassInfo.new klass, out
|
227
|
+
end
|
228
|
+
klass = klass.parent
|
229
|
+
end
|
230
|
+
next
|
231
|
+
end
|
232
|
+
|
233
|
+
if options[:testcase]
|
234
|
+
Genprovider::Output.new File.join(outdir,"test_#{c.name.decamelize}.rb"), options[:force] do |out|
|
235
|
+
Genprovider::Testcase.new c, options[:namespace]||"root/cimv2", out
|
236
|
+
end
|
237
|
+
next
|
238
|
+
end
|
239
|
+
|
240
|
+
providerprop = c.qualifiers["provider", :string]
|
241
|
+
providername = (providerprop ? providerprop.value.sub("cmpi:","") : c.name)
|
242
|
+
Genprovider::Output.new File.join(outdir,"#{providername.decamelize}.rb"), options[:force] do |out|
|
243
|
+
Genprovider::Provider.new c, providername, out
|
244
|
+
end
|
245
|
+
|
246
|
+
Genprovider::Output.new File.join(outdir,"#{providername}.rdoc"), options[:force] do |out|
|
247
|
+
Genprovider::RDoc.new c, out
|
248
|
+
end
|
249
|
+
|
250
|
+
if options[:namespace]
|
251
|
+
Genprovider::Output.new File.join(outdir,"#{c.name}.registration"), options[:force] do |out|
|
252
|
+
Genprovider::Registration.new c, options[:namespace], providername, out
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
data/bin/regprovider
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# register
|
4
|
+
#
|
5
|
+
# Helper to register a 'genprovider' Ruby provider
|
6
|
+
#
|
7
|
+
|
8
|
+
$mofdir = "features/mof"
|
9
|
+
$providerdir = "/usr/share/cmpi"
|
10
|
+
$generateddir = "generated"
|
11
|
+
|
12
|
+
#
|
13
|
+
# Convert CamelCase to underline_case
|
14
|
+
#
|
15
|
+
|
16
|
+
class String
|
17
|
+
def decamelize
|
18
|
+
# CamelCase -> under_score
|
19
|
+
self.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
20
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
21
|
+
tr("-", "_").
|
22
|
+
downcase
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def usage msg = nil
|
28
|
+
STDERR.puts "** Error: #{msg}" if msg
|
29
|
+
STDERR.puts "register [-h] [-c <cimom>] [-m <mofdir>] [-p <provdir] [-r <regdir>] <name>"
|
30
|
+
STDERR.puts "\tregisters <mofdir>/<name>.mof implemented by <provdir>/<name>.rb via <regdir>/<name>.registration to <cimom> (defaults to sfcb)"
|
31
|
+
STDERR.puts "\t<mofdir> defaults to #{$mofdir}"
|
32
|
+
STDERR.puts "\t<provdir> defaults to #{$generateddir}"
|
33
|
+
STDERR.puts "\t<regdir> defaults to #{$generateddir}"
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
|
37
|
+
cimom = "sfcb"
|
38
|
+
name = nil
|
39
|
+
symlink = false # symlink provider, don't install
|
40
|
+
|
41
|
+
loop do
|
42
|
+
arg = ARGV.shift
|
43
|
+
break unless arg
|
44
|
+
case arg
|
45
|
+
when "-h" then usage
|
46
|
+
when "-c" then cimom = ARGV.shift
|
47
|
+
when "-m" then mofdir = ARGV.shift
|
48
|
+
when "-r" then regdir = ARGV.shift
|
49
|
+
when "-p" then provdir = ARGV.shift
|
50
|
+
when "-l" then symlink = true
|
51
|
+
else
|
52
|
+
usage("Unknown option #{arg}") if arg[0,1] == "-"
|
53
|
+
name = arg
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
unless name
|
58
|
+
usage "Class name missing"
|
59
|
+
end
|
60
|
+
|
61
|
+
moffile = "#{mofdir || $mofdir}/#{name}.mof"
|
62
|
+
providerfile = "#{provdir || $generateddir}/#{name.decamelize}.rb"
|
63
|
+
registrationfile = "#{regdir || $generateddir}/#{name}.registration"
|
64
|
+
|
65
|
+
puts "Registering #{moffile} implemented by #{providerfile} via #{registrationfile} to #{cimom}"
|
66
|
+
|
67
|
+
classname = namespace = providername = libraryname = nil
|
68
|
+
|
69
|
+
File.open registrationfile do |reg|
|
70
|
+
while line = reg.gets
|
71
|
+
next if line[0,1] == "#"
|
72
|
+
# Classname - Namespace - Providername - Libraryname - Capabilities ...
|
73
|
+
#RCP_SimpleDataTypes root/cimv2 RCP_SimpleDataTypes rbCmpiProvider instance
|
74
|
+
values = line.split(" ")
|
75
|
+
next if values.size < 5
|
76
|
+
next unless values[0] == name
|
77
|
+
classname = values[0]
|
78
|
+
namespace = values[1]
|
79
|
+
providername = values[2]
|
80
|
+
libraryname = values[3]
|
81
|
+
break
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
cmd = "provider-register.sh -t #{cimom} -n #{namespace} -r #{registrationfile} -m #{moffile}"
|
86
|
+
result = system cmd
|
87
|
+
unless $?.success?
|
88
|
+
STDERR.puts "** Failed: #{result}"
|
89
|
+
STDERR.puts cmd
|
90
|
+
exit 1
|
91
|
+
end
|
92
|
+
|
93
|
+
if symlink
|
94
|
+
File.symlink File.expand_path(providerfile), $providerdir
|
95
|
+
else
|
96
|
+
cmd = "cp #{providerfile} #{$providerdir}"
|
97
|
+
result = system cmd
|
98
|
+
unless $?.success?
|
99
|
+
STDERR.puts "** Failed: #{result}"
|
100
|
+
STDERR.puts cmd
|
101
|
+
exit 1
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
puts "Success !"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Ability to parse a mof and create a template
|
2
|
+
In Order to verify the basic functionality
|
3
|
+
As a developer
|
4
|
+
I want to generate a simple Ruby provider
|
5
|
+
Then I should be able to access it using ruby-sfcc
|
6
|
+
Scenario: Create an instance
|
7
|
+
Given "Cmpi_Swig" is registered in namespace "test/test"
|
8
|
+
When I create an instance of "Cmpi_Swig" with "hello" set to "Hello world"
|
9
|
+
Then I should see "Cmpi_Swig" in enumerated instance names
|
10
|
+
And the instance of "Cmpi_Swig" should have property "hello" set to "Hello world"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: Ability to parse a mof and create a template
|
2
|
+
In Order to verify the basic functionality
|
3
|
+
As a developer
|
4
|
+
I want to generate a simple Ruby provider
|
5
|
+
Then I should be able to access it using ruby-sfcc
|
6
|
+
Scenario: Change an instance
|
7
|
+
Given an instance of "Cmpi_Swig" with property "hello" set to "Hello world"
|
8
|
+
When I change the property "hello" to "Goodbye, cruel world"
|
9
|
+
Then the instance of "Cmpi_Swig" should have property "hello" set to "Goodbye, cruel world"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Feature: Ability to parse a mof and create a template
|
2
|
+
In Order to verify the basic functionality
|
3
|
+
As a developer
|
4
|
+
I want to generate a simple Ruby provider
|
5
|
+
Then I should be able to access it using ruby-sfcc
|
6
|
+
Scenario: Delete an instance
|
7
|
+
Given an instance of "Cmpi_Swig" with property "hello" set to "Hello, world"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: Test providers with different data types
|
2
|
+
In Order to test different property types
|
3
|
+
I want to run providers
|
4
|
+
Then they should all work
|
5
|
+
Scenario Outline: Run providers
|
6
|
+
Given a generated provider for "samples/mof/<klass>.mof"
|
7
|
+
When I register "samples/mof/<klass>.mof" using "<klass>.registration" with sfcb
|
8
|
+
Then I should see "<klass>" in enumerated instance names
|
9
|
+
|
10
|
+
Examples:
|
11
|
+
| klass |
|
12
|
+
| RCP_SimpleDataTypes |
|
13
|
+
| RCP_ArrayDataTypes |
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Ensure genprovider output format
|
2
|
+
In Order to verify the basic functionality
|
3
|
+
As a developer
|
4
|
+
I want to generate a simple Ruby provider
|
5
|
+
Then I should be able to get it compiled
|
6
|
+
Scenario Outline: Ensure correct output format and compilation
|
7
|
+
Given I have a mof file called "<mof>"
|
8
|
+
When I pass "<mof>" to genprovider
|
9
|
+
Then comment lines should not exceed 75 characters
|
10
|
+
And its output should be accepted by Ruby
|
11
|
+
|
12
|
+
Examples:
|
13
|
+
| mof |
|
14
|
+
| features/mof/trivial.mof |
|
15
|
+
| samples/mof/qualifiers.mof |
|
16
|
+
| samples/mof/RCP_ArrayDataTypes.mof |
|
17
|
+
| samples/mof/RCP_ClassMethod.mof |
|
18
|
+
| samples/mof/RCP_ComplexMethod.mof |
|
19
|
+
| samples/mof/RCP_ComputerSystem.mof |
|
20
|
+
| samples/mof/RCP_OperatingSystem.mof|
|
21
|
+
| samples/mof/RCP_OSProcess.mof |
|
22
|
+
| samples/mof/RCP_PhysicalMemory.mof |
|
23
|
+
| samples/mof/RCP_Processor.mof |
|
24
|
+
| samples/mof/RCP_RunningOS.mof |
|
25
|
+
| samples/mof/RCP_SimpleClass.mof |
|
26
|
+
| samples/mof/RCP_SimpleDataTypes.mof|
|
27
|
+
| samples/mof/RCP_SimpleMethod.mof |
|
28
|
+
| samples/mof/RCP_UnixProcess.mof |
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Test providers with known instances
|
2
|
+
In Order to test providers known to have instances
|
3
|
+
As a developer
|
4
|
+
I want to enumerate instances
|
5
|
+
Then I should get a non-zero instance count
|
6
|
+
Scenario Outline: Enumerate instances
|
7
|
+
Given a generated provider for "samples/mof/<class>.mof"
|
8
|
+
And I register "samples/mof/<class>.mof" using "<class>.registration" with sfcb
|
9
|
+
And "<class>" is registered in namespace "test/test"
|
10
|
+
Then I should see "<class>" in enumerated instance names
|
11
|
+
|
12
|
+
Examples:
|
13
|
+
| class |
|
14
|
+
| RCP_ComputerSystem |
|
15
|
+
| RCP_OperatingSystem|
|
16
|
+
| RCP_PhysicalMemory |
|
17
|
+
| RCP_Processor |
|
18
|
+
| RCP_RunningOS |
|
19
|
+
| RCP_UnixProcess |
|
@@ -0,0 +1,20 @@
|
|
1
|
+
//
|
2
|
+
// trivial.mof - A trivial sample file for genprovider
|
3
|
+
//
|
4
|
+
//
|
5
|
+
|
6
|
+
#pragma locale ("en_US")
|
7
|
+
//#pragma namespace ("root/cimv2")
|
8
|
+
|
9
|
+
// ===================================================================
|
10
|
+
// Cmpi_Swig
|
11
|
+
// ===================================================================
|
12
|
+
|
13
|
+
[ Provider("cmpi:Cmpi_Swig"),
|
14
|
+
Description ("A sample class to demonstrate cmpi/swig" )
|
15
|
+
]
|
16
|
+
class Cmpi_Swig : CIM_ManagedElement
|
17
|
+
{
|
18
|
+
[Key, Description ("A friendly greeting") ]
|
19
|
+
string hello;
|
20
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Feature: Ability to register a provider with sfcb
|
2
|
+
In Order to verify the basic functionality
|
3
|
+
As a developer
|
4
|
+
I want to generate a simple Ruby provider
|
5
|
+
Then I should be able to register it with sfcb
|
6
|
+
Scenario Outline: Register with sfcb
|
7
|
+
When I register "<mof>" using "<registration>" with sfcb
|
8
|
+
Then I should see "<class>" in namespace "<namespace>"
|
9
|
+
|
10
|
+
Examples:
|
11
|
+
| mof | registration | class | namespace |
|
12
|
+
| features/mof/trivial.mof | Cmpi_Swig.registration | Cmpi_Swig | test/test |
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Run genprovider
|
2
|
+
In Order to verify the basic functionality
|
3
|
+
As a developer
|
4
|
+
I want to generate a simple Ruby provider
|
5
|
+
Then I should be able to get it compiled
|
6
|
+
Scenario: Run genprovider
|
7
|
+
When I run genprovider with no arguments
|
8
|
+
Then I should see an error message
|
9
|
+
When I run genprovider with "-h"
|
10
|
+
Then I should see a short usage explanation
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: Show CMPIContext passed to provider
|
2
|
+
In Order to view the CMPIContext passed to the provider by the CIMOM
|
3
|
+
As a developer
|
4
|
+
I want to run the rcp_show_context provider
|
5
|
+
Then I should get an array of key, value pairs
|
6
|
+
Scenario: Run rcp_show_context
|
7
|
+
Given a generated provider for "samples/mof/RCP_ShowContext.mof"
|
8
|
+
And I register "samples/mof/RCP_ShowContext.mof" using "RCP_ShowContext.registration" with sfcb
|
9
|
+
Then I should see "RCP_ShowContext" in enumerated instance names
|