Module: ProviderTesting

Defined in:
lib/provider-testing/mkreg.rb,
lib/provider-testing.rb,
lib/provider-testing/sfcb.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 =
'0.3.2'

Class Method Summary collapse

Class Method Details

.convert_registrations(outfile, *regfiles) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/provider-testing/mkreg.rb', line 35

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



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/provider-testing/mkreg.rb', line 22

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

.mkreposObject



44
45
46
47
48
49
50
# File 'lib/provider-testing/registration.rb', line 44

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

classname namespace providername providermodule caps



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/provider-testing/mkreg.rb', line 9

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



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/provider-testing/registration.rb', line 30

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



15
16
17
18
19
20
21
# File 'lib/provider-testing/registration.rb', line 15

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



23
24
25
26
27
28
# File 'lib/provider-testing/registration.rb', line 23

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

.setup(klass = "", namespace = "root/cimv2") ⇒ Object



16
17
18
# File 'lib/provider-testing.rb', line 16

def self.setup klass = "", namespace = "root/cimv2"
  Helper.setup klass, namespace
end

.teardownObject



19
20
21
# File 'lib/provider-testing.rb', line 19

def self.teardown
  Helper.teardown
end