Add Openwsman#epr_uri_for
Creates full endpoint reference URI for namespace and classname
diff --git a/bindings/ruby/openwsman/openwsman.rb b/bindings/ruby/openwsman/openwsman.rb
index 01c33c3..1c5ce63 100644
--- a/bindings/ruby/openwsman/openwsman.rb
+++ b/bindings/ruby/openwsman/openwsman.rb
@@ -36,16 +36,13 @@
#
def self.epr_prefix_for classname, namespace = nil
schema = classname.split("_")[0] rescue nil
- return case schema
+ prefix = case schema
# dmtf CIM
when "CIM" then "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2"
# dmtf reserved
when "PRS" then "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2"
# Microsoft WMI
- when "Win32"
- prefix = "http://schemas.microsoft.com/wbem/wsman/1/wmi"
- prefix += "/#{namespace}" if namespace
- prefix
+ when "Win32" then "http://schemas.microsoft.com/wbem/wsman/1/wmi"
# openwbem.org
when "OpenWBEM" then "http://schema.openwbem.org/wbem/wscim/1/cim-schema/2"
# sblim
@@ -61,5 +58,14 @@
else
raise "Unsupported schema #{schema.inspect} of class #{classname.inspect}"
end
+ prefix += "/#{namespace}" if namespace
+ prefix
+ end
+
+ # create full endpoint reference URI for namespace and classname
+ def self.epr_uri_for namespace, classname
+ raise "Namespace must not be nil" unless namespace
+ raise "Classname must not be nil" unless classname
+ "#{self.epr_prefix_for(classname)}/#{namespace}/#{classname}"
end
end
diff --git a/bindings/ruby/tests/cim_system_configuration.rb b/bindings/ruby/tests/cim_system_configuration.rb
index 047692f..2a59fb6 100644
--- a/bindings/ruby/tests/cim_system_configuration.rb
+++ b/bindings/ruby/tests/cim_system_configuration.rb
@@ -1,4 +1,4 @@
-# cim_computer_system.rb
+# cim_system_configuration.rb
# enumerate/pull/release for CIM_SystemConfiguration
require 'test/unit'
@@ -13,8 +13,8 @@
assert client
options = Openwsman::ClientOptions.new
assert options
- classname = "CIM_ManagedElement"
- uri = "#{Openwsman.epr_prefix_for(classname)}/#{classname}"
+ classname = "CIM_SystemConfiguration"
+ uri = Openwsman.epr_uri_for "root/cimv2", classname
result = client.enumerate( options, nil, uri )
assert result
# puts result
diff --git a/bindings/ruby/tests/cimenum.rb b/bindings/ruby/tests/cimenum.rb
index 20a188e..bbfae60 100644
--- a/bindings/ruby/tests/cimenum.rb
+++ b/bindings/ruby/tests/cimenum.rb
@@ -17,7 +17,7 @@
end
debug = nil
-namespace = nil
+namespace = "root/cimv2"
classname = nil
loop do
@@ -31,11 +31,15 @@
end
end
+raise "No classname given" unless classname
client = Client.open
options = Openwsman::ClientOptions.new
-uri = "#{Openwsman.epr_prefix_for(classname,namespace)}/#{classname}"
+uri = Openwsman.epr_uri_for namespace, classname
result = client.enumerate( options, nil, uri )
+
+raise "Connection failed" unless result
+
STDERR.puts result.to_xml if debug
show_fault result
diff --git a/bindings/ruby/tests/winenum.rb b/bindings/ruby/tests/winenum.rb
index 5ad31f6..f7f812b 100644
--- a/bindings/ruby/tests/winenum.rb
+++ b/bindings/ruby/tests/winenum.rb
@@ -77,7 +77,7 @@
# puts "max_envelope_size #{options.max_envelope_size}"
options.set_dump_request if parms[:debug]
- uri = "#{Openwsman.epr_prefix_for(classname,namespace)}/#{classname}"
+ uri = Openwsman.epr_uri_for namespace, classname
STDERR.puts "URI <#{uri}>"
result = client.enumerate( options, filter, uri )
show_fault result if result.fault?