Module: ProviderTesting
- Defined in:
- lib/provider-testing.rb,
lib/provider-testing/sfcb.rb,
lib/provider-testing/mkreg.rb,
lib/provider-testing/helper.rb,
lib/provider-testing/pegasus.rb,
lib/provider-testing/registration.rb
Overview
register
args: Hash
:klass => CIM class name
:namespace => namespace, defaults to test/test
:mofdir => where to find <klass>.mof, defaults to TOPLEVEL/samples/mof
:regdir => where to find <klass>.registration, defaults to TOPLEVEL/samples/registration
Defined Under Namespace
Classes: Helper, Pegasus, Sfcb
Constant Summary collapse
- VERSION =
gem version
'0.4.0'
Class Method Summary collapse
-
.convert_registrations(outfile, *regfiles) ⇒ Object
converts multiple registrations to a config readable by CIMOM input: outfile file to write config to input: regfiles registration files to read.
-
.mkreg(from, out) ⇒ Object
create a provider registration config input: from registration data input: out file to write registration config to.
-
.mkrepos ⇒ Object
create (sfcb) provider repository.
-
.rdreg(from) ⇒ Object
read .registration file, return array of 0 1 2 3 4..-1 classname namespace providername providermodule caps.
-
.register(klass, namespace, mofdir, regdir) ⇒ Object
do a full registration of a CIM class within a namespace input: klass CIM class to register input: namespace namespace to register to input: mofdir directory of .mof files input: regdir directory of .reg files.
-
.register_file(file) ⇒ Object
register a provider from file.
-
.register_klass(args) ⇒ Object
register a class (served by a provider).
-
.setup(klass = "", namespace = "root/cimv2") ⇒ Object
toplevel initialization routine.
-
.teardown ⇒ Object
toplevel teardown routine.
Class Method Details
.convert_registrations(outfile, *regfiles) ⇒ Object
converts multiple registrations to a config readable by CIMOM input: outfile file to write config to input: regfiles registration files to read
43 44 45 46 47 48 49 50 |
# File 'lib/provider-testing/mkreg.rb', line 43 def self.convert_registrations outfile, *regfiles # STDERR.puts "convert_registrations => #{outfile}" File.open(outfile, "w+") do |out| regfiles.each do |regfile| mkreg regfile, out end end end |
.mkreg(from, out) ⇒ Object
create a provider registration config input: from registration data input: out file to write registration config to
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/provider-testing/mkreg.rb', line 26 def self.mkreg from, out # STDERR.puts "mkreg #{from}" self.rdreg from do |reg| # 0 1 2 3 4..-1 # classname namespace providername providermodule caps out.puts "[#{reg[0]}]" out.puts " provider: #{reg[2]}" out.puts " location: #{reg[3]}" out.puts " type: #{reg[4..-1].join(' ')}" out.puts " namespace: #{reg[1]}" end end |
.mkrepos ⇒ Object
create (sfcb) provider repository
53 54 55 56 57 58 59 |
# File 'lib/provider-testing/registration.rb', line 53 def self.mkrepos cimom = Helper.cimom cmd = "sfcbrepos -f -s #{cimom.stage_dir} -r #{cimom.registration_dir}" # STDERR.puts cmd res = `#{cmd} 2> #{TMPDIR}/sfcbrepos.err` raise "Failed: #{cmd}" unless $? == 0 end |
.rdreg(from) ⇒ Object
read .registration file, return array of
0 1 2 3 4..-1
classname namespace providername providermodule caps
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/provider-testing/mkreg.rb', line 10 def self.rdreg from File.open(from, "r") do |f| while (l = f.gets) next if l =~ /^\s*#.*$/ l.chomp! next if l.empty? reg = l.split(" ") raise unless reg.size > 4 yield reg end end end |
.register(klass, namespace, mofdir, regdir) ⇒ Object
do a full registration of a CIM class within a namespace input: klass CIM class to register input: namespace namespace to register to input: mofdir directory of .mof files input: regdir directory of .reg files
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/provider-testing/registration.rb', line 38 def self.register klass, namespace, mofdir, regdir raise "No :klass passed to registration" unless klass tmpregname = File.join(TMPDIR, "#{klass}.reg") # convert generic <klass>.registration to sfcb-specific <klass>.reg convert_registrations tmpregname, File.join(regdir, "#{klass}.registration") # stage .reg+.mof to namespace cmd = "sfcbstage -s #{Helper.cimom.stage_dir} -n #{namespace} -r #{tmpregname} #{File.join(mofdir,klass)}.mof" # STDERR.puts cmd res = `#{cmd} 2> #{TMPDIR}/sfcbstage.err` raise "Failed: #{cmd}" unless $? == 0 end |
.register_file(file) ⇒ Object
register a provider from file
17 18 19 20 21 22 23 |
# File 'lib/provider-testing/registration.rb', line 17 def self.register_file file self.rdreg file do |reg| # 0 1 2 3 4..-1 # classname namespace providername providermodule caps self.register_klass :klass => reg[0], :namespace => reg[1] end end |
.register_klass(args) ⇒ Object
register a class (served by a provider)
26 27 28 29 30 31 |
# File 'lib/provider-testing/registration.rb', line 26 def self.register_klass args args[:mofdir] ||= File.join(TOPLEVEL, "mof") args[:regdir] ||= File.join(TOPLEVEL, "registration") args[:namespace] ||= "test/test" self.register args[:klass], args[:namespace], args[:mofdir], args[:regdir] end |