module Cmpi
The Common Manageablity Programming Interface (CMPI) defines a common standard of interfacing Manageability Instrumentation (providers, instrumentation) to Management Brokers (CIM Object Manager). The purpose of CMPI is to standardize Manageability Instrumentation. This allows to write and build instrumentation once and run it in different CIM environments (on one platform).
CIMOM Context¶ ↑
Provider Interface¶ ↑
Constants
- CMPI_ARRAY
- broker
Public Class Methods
# File cmpi.rb, line 84 def self.args ((16+2)<<8) end
# File cmpi.rb, line 164 def self.argsA CMPI_ARRAY | self.args end
# File cmpi.rb, line 40 def self.boolean (2+0) end
# File cmpi.rb, line 120 def self.booleanA CMPI_ARRAY | self.boolean end
# File cmpi/provider.rb, line 20 def self.broker @@broker end
# File cmpi.rb, line 43 def self.char16 (2+1) end
# File cmpi.rb, line 123 def self.char16A CMPI_ARRAY | self.char16 end
# File cmpi.rb, line 96 def self.chars ((16+7)<<8) end
# File cmpi.rb, line 176 def self.charsA CMPI_ARRAY | self.chars end
# File cmpi.rb, line 105 def self.charsptr ((16+10)<<8) end
# File cmpi.rb, line 185 def self.charsptrA CMPI_ARRAY | self.charsptrA end
Convert CIM DateTime string representation (see DSP0004, 2.2.1) to Ruby Time (timestamp) or Float (interval, as seconds with fraction)
00000000001111111111222222 01234567890123456789012345
East: yyyymmddhhmmss.mmmmmm+utc -> Time (utc = offset in minutes) West: yyyymmddhhmmss.mmmmmm-utc -> Time Interval: ddddddddhhmmss.mmmmmm:000 -> Float (interval in seconds, with fraction)
# File cmpi.rb, line 318 def self.cimdatetime_to_ruby str # puts "Cmpi.cimdatetime_to_ruby(#{str})" case str[21,1] when '+', '-' # create Time from yyyymmddhhmmss and utc t = Time.new(str[0,4].to_i, str[4,2].to_i, str[6,2].to_i, str[8,2].to_i, str[10,2].to_i, str[12,2].to_i, str[22,3].to_i * ((str[21,1]=='+')?60:-60)) off = str[15,6].to_i / 1000 # Add fractional part return t + off when ':' # time offset off = str[0,8].to_i * 24 * 60 * 60 off += str[8,2].to_i * 60 * 60 + str[10,2].to_i * 60 + str[12,2].to_i off += str[15,6].to_i / 1000 return off else raise RCErrInvalidParameter.new(CMPI_RC_ERR_INVALID_PARAMETER, "Invalid CIM DateTime '#{str}'") end end
# File cmpi.rb, line 99 def self.dateTime ((16+8)<<8) end
# File cmpi.rb, line 179 def self.dateTimeA CMPI_ARRAY | self.dateTime end
# File cmpi.rb, line 111 def self.embedded_instance ((1)<<15) end
# File cmpi.rb, line 191 def self.embedded_instanceA CMPI_ARRAY | self.embedded_instance end
# File cmpi.rb, line 108 def self.embedded_object ((1)<<14) end
# File cmpi.rb, line 188 def self.embedded_objectA CMPI_ARRAY | self.embedded_object end
# File cmpi.rb, line 90 def self.enumeration ((16+5)<<8) end
# File cmpi.rb, line 170 def self.enumerationA CMPI_ARRAY | self.enumeration end
# File cmpi.rb, line 87 def self.filter ((16+4)<<8) end
# File cmpi.rb, line 167 def self.filterA CMPI_ARRAY | self.filter end
# File cmpi.rb, line 78 def self.instance ((16+0)<<8) end
# File cmpi.rb, line 158 def self.instanceA CMPI_ARRAY | self.instance end
# File cmpi.rb, line 37 def self.null 0 end
# File cmpi.rb, line 102 def self.ptr ((16+9)<<8) end
# File cmpi.rb, line 182 def self.ptrA CMPI_ARRAY | self.ptr end
convert CMPIStatus rc code to Ruby exception
# File cmpi.rb, line 283 def self.rc_to_exception rc return nil if rc == 0 klass = [nil, # 0 /** Success */ CMPI_RC_OK = 0, RCErrFailed, # 1 /** Generic failure */ CMPI_RC_ERR_FAILED = 1, RCErrAccessDenied, # 2 /** Specified user does not have access to perform the requested action */ CMPI_RC_ERR_ACCESS_DENIED = 2, RCErrInvalidNamespace, # 3 /** invalid namespace specified */ CMPI_RC_ERR_INVALID_NAMESPACE = 3, RCErrInvalidParameter, # 4 /** invalid parameter specified */ CMPI_RC_ERR_INVALID_PARAMETER = 4, RCErrInvalidClass, # 5 /** Invalid class specified */ CMPI_RC_ERR_INVALID_CLASS = 5, RCErrNotFound, # 6 /** Item was not found */ CMPI_RC_ERR_NOT_FOUND = 6, RCErrNotSupported, # 7 /** Operation not supported */ CMPI_RC_ERR_NOT_SUPPORTED = 7, RCErrClassHasChildren, # 8 /** Object has child objects */ CMPI_RC_ERR_CLASS_HAS_CHILDREN = 8, RCErrClassHasInstances, # 9 /** Object has instances */ CMPI_RC_ERR_CLASS_HAS_INSTANCES = 9, RCErrInvalidSuperclass, # 10 /** Invalid super class specified */ CMPI_RC_ERR_INVALID_SUPERCLASS = 10, RCErrAlreadyExists, # 11 /** specified object already exists */ CMPI_RC_ERR_ALREADY_EXISTS = 11, RCErrNoSuchProperty, # 12 /** Property does not exist */ CMPI_RC_ERR_NO_SUCH_PROPERTY = 12, RCErrTypeMismatch, # 13 /** This is a type mismatch */ CMPI_RC_ERR_TYPE_MISMATCH = 13, RCErrQueryLanguageNotSupported, # 14 /** Query language not supported */ CMPI_RC_ERR_QUERY_LANGUAGE_NOT_SUPPORTED = 14, RCErrInvalidQuery, # 15 /** Invalid query */ CMPI_RC_ERR_INVALID_QUERY = 15, RCErrMethodNotAvailable,# 16 /** Method is not available */ CMPI_RC_ERR_METHOD_NOT_AVAILABLE = 16, RCErrMethodNotFound # 17 /** could not find the specified method */ CMPI_RC_ERR_METHOD_NOT_FOUND = 17, ][rc] return RuntimeError unless klass klass end
# File cmpi.rb, line 47 def self.real32 ((2+0)<<2) end
# File cmpi.rb, line 127 def self.real32A CMPI_ARRAY | self.real32 end
# File cmpi.rb, line 50 def self.real64 ((2+1)<<2) end
# File cmpi.rb, line 130 def self.real64A CMPI_ARRAY | self.real64 end
# File cmpi.rb, line 81 def self.ref ((16+1)<<8) end
# File cmpi.rb, line 161 def self.refA CMPI_ARRAY | self.ref end
Convert Ruby value to CIM DateTime string representation (see DSP0004, 2.2.1)
00000000001111111111222222 01234567890123456789012345
East: yyyymmddhhmmss.mmmmmm+utc -> Time (utc = offset in minutes, mmmmmm is the microsecond within the second West: yyyymmddhhmmss.mmmmmm-utc -> Time Interval: ddddddddhhmmss.mmmmmm:000 -> Float (interval in seconds, with fraction)
# File cmpi.rb, line 346 def self.ruby_to_cimdatetime val require 'date' # puts "Cmpi.ruby_to_cimdatetime(#{val}[#{val.class}])" t = nil case val when Time s = val.strftime "%Y%m%d%H%M%S.%6N" utc = val.utc_offset # offset in seconds if utc < 0 s << "-" utc = -utc else s << "+" end val = s + ("%03d" % (utc/60)) when Numeric if val < 0 # treat it as seconds before epoch val = self.ruby_to_cimdatetime( Time.at(val) ) else # treat as interval in microseconds secs = (val / 1000000).to_i usecs = (val % 1000000).to_i days = secs / (24 * 60 * 60) secs = secs % (24 * 60 * 60) # seconds within the day hours = (secs / (60 * 60)).to_i secs = secs % (60 * 60) mins = (secs / 60).to_i secs = secs % 60 val = "%08d%02d%02d%02d.%06d:000" % [ days, hours, mins, secs, usecs ] end when /^\d{14}\.\d{6}[-+:]\d{3}$/ # fallthru when String val = self.ruby_to_cimdatetime val.to_f # retry as Numeric else val = self.ruby_to_cimdatetime val.to_s # retry as string end val end
# File cmpi.rb, line 69 def self.sint16 ((8+5)<<4) end
# File cmpi.rb, line 149 def self.sint16A CMPI_ARRAY | self.sint16 end
# File cmpi.rb, line 72 def self.sint32 ((8+6)<<4) end
# File cmpi.rb, line 152 def self.sint32A CMPI_ARRAY | self.sint32 end
# File cmpi.rb, line 75 def self.sint64 ((8+7)<<4) end
# File cmpi.rb, line 155 def self.sint64A CMPI_ARRAY | self.sint64 end
# File cmpi.rb, line 66 def self.sint8 ((8+4)<<4) end
# File cmpi.rb, line 146 def self.sint8A CMPI_ARRAY | self.sint8 end
# File cmpi.rb, line 93 def self.string ((16+6)<<8) end
# File cmpi.rb, line 173 def self.stringA CMPI_ARRAY | self.string end
# File cmpi.rb, line 57 def self.uint16 ((8+1)<<4) end
# File cmpi.rb, line 137 def self.uint16A CMPI_ARRAY | self.uint16 end
# File cmpi.rb, line 60 def self.uint32 ((8+2)<<4) end
# File cmpi.rb, line 140 def self.uint32A CMPI_ARRAY | self.uint32 end
# File cmpi.rb, line 63 def self.uint64 ((8+3)<<4) end
# File cmpi.rb, line 143 def self.uint64A CMPI_ARRAY | self.uint64 end
# File cmpi.rb, line 54 def self.uint8 ((8+0)<<4) end
# File cmpi.rb, line 134 def self.uint8A CMPI_ARRAY | self.uint8 end
Public Instance Methods
# File cmpi/provider.rb, line 23 def not_implemented klass, name STDERR.puts "#{klass}.#{name}: not implemented" nil end