Class: Wbem::CimxmlClient

Inherits:
WbemClient show all
Defined in:
lib/wbem/cimxml.rb

Instance Attribute Summary

Attributes inherited from WbemClient

#auth_scheme, #product, #response, #url

Instance Method Summary collapse

Methods inherited from WbemClient

#fault_string, #namespaces, #network_class_name, #networks, #processes, #response_code, #service_class_name, #services, #storage_class_name, #storages, #system_class_name, #systems

Constructor Details

#initialize(url, auth_scheme = nil) ⇒ CimxmlClient

Initialize a CIMXML client connection



52
53
54
55
56
# File 'lib/wbem/cimxml.rb', line 52

def initialize url, auth_scheme = nil
  super url, auth_scheme
  @client = Sfcc::Cim::Client.connect( { :uri => url, :verify => false } )
  _identify
end

Instance Method Details

#class_names(namespace, deep_inheritance = false) ⇒ Object

Return list of classnames for given namespace



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/wbem/cimxml.rb', line 81

def class_names namespace, deep_inheritance = false
  STDERR.puts "#{@client}.class_names(#{namespace})"
  ret = []
  op = Sfcc::Cim::ObjectPath.new(namespace)
  flags = deep_inheritance ? Sfcc::Flags::DeepInheritance : 0
  begin
    @client.class_names(op,flags).each do |name|
	ret << name.to_s
    end
  rescue Sfcc::Cim::ErrorInvalidNamespace
  end
  ret
end

#each_instance(ns, cn) ⇒ Object

Return instances for namespace and classname



68
69
70
71
72
73
74
75
76
# File 'lib/wbem/cimxml.rb', line 68

def each_instance( ns, cn )
  op = objectpath ns, cn
  begin
    @client.instances(op).each do |inst|
      yield inst
    end
  rescue Sfcc::Cim::ErrorInvalidClass, Sfcc::Cim::ErrorInvalidNamespace
  end
end

#instance_names(namespace, classname) ⇒ Object

Return list of Wbem::EndpointReference (object pathes) for instances

of namespace, classname


99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/wbem/cimxml.rb', line 99

def instance_names namespace, classname
  objectpath = Sfcc::Cim::ObjectPath.new(namespace,classname)
  STDERR.puts "#{@client}.instance_names(#{objectpath})"
  ret = []
  begin
    @client.instance_names(objectpath).each do |path|
      path.namespace = namespace # add missing data
	ret << path
    end
  rescue Sfcc::Cim::ErrorInvalidClass, Sfcc::Cim::ErrorInvalidNamespace
  end
  ret
end

#objectpath(namespace, classname = nil) ⇒ Object

Create ObjectPath from namespace and classname



61
62
63
# File 'lib/wbem/cimxml.rb', line 61

def objectpath namespace, classname = nil
  Sfcc::Cim::ObjectPath.new(namespace, classname)
end