You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(26) |
Dec
(13) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(5) |
Feb
(16) |
Mar
(5) |
Apr
(5) |
May
(13) |
Jun
(12) |
Jul
(1) |
Aug
(2) |
Sep
(13) |
Oct
(6) |
Nov
(1) |
Dec
(29) |
2008 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
(57) |
May
(35) |
Jun
(45) |
Jul
(132) |
Aug
(87) |
Sep
(141) |
Oct
(86) |
Nov
(17) |
Dec
(2) |
2009 |
Jan
(3) |
Feb
(2) |
Mar
(3) |
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2010 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <ba...@us...> - 2008-09-16 04:29:47
|
Revision: 985 http://omc.svn.sourceforge.net/omc/?rev=985&view=rev Author: bartw Date: 2008-09-16 04:29:58 +0000 (Tue, 16 Sep 2008) Log Message: ----------- renamed package Modified Paths: -------------- pybase/trunk/setup.py Modified: pybase/trunk/setup.py =================================================================== --- pybase/trunk/setup.py 2008-09-16 03:54:18 UTC (rev 984) +++ pybase/trunk/setup.py 2008-09-16 04:29:58 UTC (rev 985) @@ -13,10 +13,10 @@ os.unlink(manifest) -setup(name='omc-pybase-providers', +setup(name='cmpi-pywbem-base', author='Jon Carey, Bart Whiteley', author_email='jc...@no..., bwh...@su...', - version='0.1.0', + version='0.2.0', description='Base Providers', url='http://pywbem.sf.net/', py_modules=['OMC_InitdService', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-16 03:45:05
|
Revision: 983 http://omc.svn.sourceforge.net/omc/?rev=983&view=rev Author: bartw Date: 2008-09-16 03:45:16 +0000 (Tue, 16 Sep 2008) Log Message: ----------- finished porting base providers to new interface Modified Paths: -------------- pybase/trunk/OMC_Base.sfcb.reg pybase/trunk/OMC_InitdService.py pybase/trunk/OMC_SyslogNG.py pybase/trunk/OMC_TimeService.py Modified: pybase/trunk/OMC_Base.sfcb.reg =================================================================== --- pybase/trunk/OMC_Base.sfcb.reg 2008-09-16 02:37:53 UTC (rev 982) +++ pybase/trunk/OMC_Base.sfcb.reg 2008-09-16 03:45:16 UTC (rev 983) @@ -97,5 +97,90 @@ type: instance namespace: root/cimv2 +# Initd service +[OMC_InitdService] + provider: OMC_InitdService + location: pyCmpiProvider + type: instance method + namespace: root/cimv2 +# Syslog +[OMC_SyslogNGRecordLogCapabilities] + provider: OMC_SyslogNG + location: pyCmpiProvider + type: instance + namespace: root/cimv2 +[OMC_SyslogNGRecordLogCapabilities] + provider: OMC_SyslogNG + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + +[OMC_SyslogNGUseOfLog] + provider: OMC_SyslogNG + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + +[OMC_SyslogNGLogManagesRecord] + provider: OMC_SyslogNG + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + +[OMC_SyslogNGLogRecord] + provider: OMC_SyslogNG + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + +[OMC_SyslogNGRecordLog] + provider: OMC_SyslogNG + location: pyCmpiProvider + type: instance method + namespace: root/cimv2 + +# TimeService +[OMC_SystemTimeService] + provider: OMC_TimeService + location: pyCmpiProvider + type: instance method + namespace: root/cimv2 + +[OMC_HostedTimeService] + provider: OMC_TimeService + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + +[OMC_RemoteTimeServicePort] + provider: OMC_TimeService + location: pyCmpiProvider + type: instance method + namespace: root/cimv2 + +[OMC_TimeServiceAccessBySAP] + provider: OMC_TimeService + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + +[OMC_TimeZoneSettingData] + provider: OMC_TimeService + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + +[OMC_TimeServiceTimeZoneSettingData] + provider: OMC_TimeService + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + +[OMC_TimeServiceAvailableToElement] + provider: OMC_TimeService + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + Modified: pybase/trunk/OMC_InitdService.py =================================================================== --- pybase/trunk/OMC_InitdService.py 2008-09-16 02:37:53 UTC (rev 982) +++ pybase/trunk/OMC_InitdService.py 2008-09-16 03:45:16 UTC (rev 983) @@ -36,7 +36,7 @@ """ import pywbem -from pywbem import CIMProvider +from pywbem.cim_provider2 import CIMProvider2 import os from subprocess import call from socket import getfqdn @@ -79,7 +79,7 @@ return False -class OMC_InitdServiceProvider(CIMProvider): +class OMC_InitdServiceProvider(CIMProvider2): """Instrument the CIM class OMC_InitdService OMC_InitdService represents the function of a system init script found @@ -93,29 +93,7 @@ """ - def get_instance(self, env, model, cim_class, filtered=False): - """Return an instance. - - Keyword arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - model -- A template of the pywbem.CIMInstance to be returned. The - key properties are set on this instance to correspond to the - instanceName that was requested. The properties of the model - are already filtered according to the PropertyList from the - request. Only properties present in the model need to be - given values. If you prefer, you can set all of the - values, and the instance will be filtered for you. - cim_class -- The pywbem.CIMClass - - Possible Errors: - CIM_ERR_ACCESS_DENIED - CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized - or otherwise incorrect parameters) - CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM - Instance does not exist in the specified namespace) - CIM_ERR_FAILED (some other unspecified error occurred) - - """ + def get_instance(self, env, model, filtered=False): logger = env.get_logger() logger.log_debug('Entering %s.get_instance() for %s' \ @@ -157,34 +135,14 @@ #model['TimeOfLastStateChange'] = # TODO (type = pywbem.CIMDateTime) return model - def enum_instances(self, env, model, cim_class, keys_only): - """Enumerate instances. + def enum_instances(self, env, model, keys_only): - The WBEM operations EnumerateInstances and EnumerateInstanceNames - are both mapped to this method. - This method is a python generator - - Keyword arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - model -- A template of the pywbem.CIMInstances to be generated. - The properties of the model are already filtered according to - the PropertyList from the request. Only properties present in - the model need to be given values. If you prefer, you can - always set all of the values, and the instance will be filtered - for you. - cim_class -- The pywbem.CIMClass - keys_only -- A boolean. True if only the key properties should be - set on the generated instances. - - Possible Errors: - CIM_ERR_FAILED (some other unspecified error occurred) - - """ - logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'SystemName':None,'SystemCreationClassName':None, + 'CreationClassName':None,'Name':None}) model['SystemName'] = getfqdn() model['SystemCreationClassName'] = 'OMC_ComputerSystem' model['CreationClassName'] = 'OMC_InitdService' @@ -202,41 +160,14 @@ yield model else: try: - yield self.get_instance(env, model, cim_class, filtered=True) + yield self.get_instance(env, model, filtered=True) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): - """Return a newly created or modified instance. + def set_instance(self, env, instance, modify_existing): - Keyword arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - instance -- The new pywbem.CIMInstance. If modifying an existing - instance, the properties on this instance have been filtered by - the PropertyList from the request. - previous_instance -- The previous pywbem.CIMInstance if modifying - an existing instance. None if creating a new instance. - cim_class -- The pywbem.CIMClass - - Return the new instance. The keys must be set on the new instance. - - Possible Errors: - CIM_ERR_ACCESS_DENIED - CIM_ERR_NOT_SUPPORTED - CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized - or otherwise incorrect parameters) - CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only - valid if previous_instance is None, indicating that the operation - was CreateInstance) - CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid - if previous_instance is not None, indicating that the operation - was ModifyInstance) - CIM_ERR_FAILED (some other unspecified error occurred) - - """ - logger = env.get_logger() logger.log_debug('Entering %s.set_instance()' \ % self.__class__.__name__) @@ -245,27 +176,7 @@ return instance def delete_instance(self, env, instance_name): - """Delete an instance. - Keyword arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - instance_name -- A pywbem.CIMInstanceName specifying the instance - to delete. - - Possible Errors: - CIM_ERR_ACCESS_DENIED - CIM_ERR_NOT_SUPPORTED - CIM_ERR_INVALID_NAMESPACE - CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized - or otherwise incorrect parameters) - CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified - namespace) - CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM - Instance does not exist in the specified namespace) - CIM_ERR_FAILED (some other unspecified error occurred) - - """ - logger = env.get_logger() logger.log_debug('Entering %s.delete_instance()' \ % self.__class__.__name__) @@ -273,7 +184,7 @@ # TODO delete the resource raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement - def cim_method_requeststatechange(self, env, object_name, method, + def cim_method_requeststatechange(self, env, object_name, param_requestedstate, param_timeoutperiod): """Implements OMC_InitdService.RequestStateChange() @@ -295,7 +206,6 @@ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method RequestStateChange() should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data param_requestedstate -- The input parameter RequestedState (type pywbem.Uint16 self.Values.RequestStateChange.RequestedState) The state requested for the element. This information will be placed into the RequestedState property of the instance if the @@ -342,12 +252,12 @@ # TODO do something raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented - out_params = {} + out_params = [] #out_params['job'] = # TODO (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) rval = None # TODO (type pywbem.Uint32 self.Values.RequestStateChange) return (rval, out_params) - def cim_method_reloadservice(self, env, object_name, method): + def cim_method_reloadservice(self, env, object_name): """Implements OMC_InitdService.ReloadService() This method causes the configuration of the service to be reloaded @@ -361,7 +271,6 @@ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method ReloadService() should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.ReloadService) and a dictionary with the out-parameters @@ -384,12 +293,12 @@ logger.log_debug('Entering %s.cim_method_reloadservice()' \ % self.__class__.__name__) - out_params = {} + out_params = [] cmd = '/etc/init.d/%s reload' % object_name['name'] rval = pywbem.Uint32(call(cmd, shell=True)) return (rval, out_params) - def cim_method_stopservice(self, env, object_name, method): + def cim_method_stopservice(self, env, object_name): """Implements OMC_InitdService.StopService() This method stops the service. Return values are what is returned @@ -424,12 +333,12 @@ logger.log_debug('Entering %s.cim_method_stopservice()' \ % self.__class__.__name__) - out_params = {} + out_params = [] cmd = '/etc/init.d/%s stop' % object_name['name'] rval = pywbem.Uint32(call(cmd, shell=True)) return (rval, out_params) - def cim_method_enableservice(self, env, object_name, method): + def cim_method_enableservice(self, env, object_name): """Implements OMC_InitdService.EnableService() This method configures the service's script to be installed or @@ -444,7 +353,6 @@ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method EnableService() should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.EnableService) and a dictionary with the out-parameters @@ -469,11 +377,11 @@ # TODO do something raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented - out_params = {} + out_params = [] rval = None # TODO (type pywbem.Uint32 self.Values.EnableService) return (rval, out_params) - def cim_method_tryrestartservice(self, env, object_name, method): + def cim_method_tryrestartservice(self, env, object_name): """Implements OMC_InitdService.TryRestartService() This method restarts the service if the service is already running. @@ -486,7 +394,6 @@ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method TryRestartService() should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.TryRestartService) and a dictionary with the out-parameters @@ -511,11 +418,11 @@ # TODO do something raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented - out_params = {} + out_params = [] rval = None # TODO (type pywbem.Uint32 self.Values.TryRestartService) return (rval, out_params) - def cim_method_restartservice(self, env, object_name, method): + def cim_method_restartservice(self, env, object_name): """Implements OMC_InitdService.RestartService() This method stops and restarts the service if the service is @@ -551,12 +458,12 @@ logger.log_debug('Entering %s.cim_method_restartservice()' \ % self.__class__.__name__) - out_params = {} + out_params = [] cmd = '/etc/init.d/%s restart' % object_name['name'] rval = pywbem.Uint32(call(cmd, shell=True)) return (rval, out_params) - def cim_method_forcereloadservice(self, env, object_name, method): + def cim_method_forcereloadservice(self, env, object_name): """Implements OMC_InitdService.ForceReloadService() This method causes the configuration to be reloaded if the service @@ -569,7 +476,6 @@ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method ForceReloadService() should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.ForceReloadService) and a dictionary with the out-parameters @@ -594,11 +500,11 @@ # TODO do something raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented - out_params = {} + out_params = [] rval = None # TODO (type pywbem.Uint32 self.Values.ForceReloadService) return (rval, out_params) - def cim_method_startservice(self, env, object_name, method): + def cim_method_startservice(self, env, object_name): """Implements OMC_InitdService.StartService() This method starts the service. Return values are what is returned @@ -610,7 +516,6 @@ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method StartService() should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.StartService) and a dictionary with the out-parameters @@ -633,12 +538,12 @@ logger.log_debug('Entering %s.cim_method_startservice()' \ % self.__class__.__name__) - out_params = {} + out_params = [] cmd = '/etc/init.d/%s start' % object_name['name'] rval = pywbem.Uint32(call(cmd, shell=True)) return (rval, out_params) - def cim_method_servicestatus(self, env, object_name, method): + def cim_method_servicestatus(self, env, object_name): """Implements OMC_InitdService.ServiceStatus() This method returns the status of the service. The integer @@ -650,7 +555,6 @@ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method ServiceStatus() should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.ServiceStatus) and a dictionary with the out-parameters @@ -677,7 +581,7 @@ rval = pywbem.Uint32(call(cmd, shell=True)) return (rval, {}) - def cim_method_disableservice(self, env, object_name, method): + def cim_method_disableservice(self, env, object_name): """Implements OMC_InitdService.DisableService() This method configures the service's script to be removed or @@ -692,7 +596,6 @@ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method DisableService() should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.DisableService) and a dictionary with the out-parameters @@ -717,7 +620,7 @@ # TODO do something raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented - out_params = {} + out_params = [] rval = None # TODO (type pywbem.Uint32 self.Values.DisableService) return (rval, out_params) Modified: pybase/trunk/OMC_SyslogNG.py =================================================================== --- pybase/trunk/OMC_SyslogNG.py 2008-09-16 02:37:53 UTC (rev 982) +++ pybase/trunk/OMC_SyslogNG.py 2008-09-16 03:45:16 UTC (rev 983) @@ -5,6 +5,7 @@ """ import pywbem +from pywbem.cim_provider2 import CIMProvider2 from socket import getfqdn import os @@ -65,7 +66,7 @@ -class OMC_SyslogNGRecordLogProvider(pywbem.CIMProvider): +class OMC_SyslogNGRecordLogProvider(CIMProvider2): """Instrument the CIM class OMC_SyslogNGRecordLog Class representing a syslog-ng log file @@ -81,13 +82,13 @@ # parameters, set self.filter_results to False # self.filter_results = False - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) - ux = model.update_existing + ux = model.update try: id = model['InstanceID'] @@ -140,12 +141,13 @@ return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'InstanceID':None}) for fname in _get_syslog_list(): model['InstanceID'] = 'OMCSyslogNGRecordLog:' + fname state = 'i' @@ -153,13 +155,13 @@ yield model else: try: - yield self.get_instance(env, model, cim_class) + yield self.get_instance(env, model) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): logger = env.get_logger() logger.log_debug('Entering %s.set_instance()' \ @@ -177,7 +179,7 @@ # TODO delete the resource raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement - def cim_method_requeststatechange(self, env, object_name, method, + def cim_method_requeststatechange(self, env, object_name, param_requestedstate, param_timeoutperiod): """Implements OMC_SyslogNGRecordLog.RequestStateChange() @@ -199,7 +201,6 @@ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method RequestStateChange() should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data param_requestedstate -- The input parameter RequestedState (type pywbem.Uint16 self.Values.RequestStateChange.RequestedState) The state requested for the element. This information will be placed into the RequestedState property of the instance if the @@ -246,12 +247,12 @@ # TODO do something raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented - out_params = {} + out_params = [] #out_params['job'] = # TODO (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) rval = None # TODO (type pywbem.Uint32 self.Values.RequestStateChange) return (rval, out_params) - def cim_method_clearlog(self, env, object_name, method): + def cim_method_clearlog(self, env, object_name): """Implements OMC_SyslogNGRecordLog.ClearLog() Requests that the Log be cleared of all entries. The return value @@ -264,7 +265,6 @@ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName specifying the object on which the method ClearLog() should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.ClearLog) and a dictionary with the out-parameters @@ -298,7 +298,7 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) fo = open(file, 'w') fo.close() - out_params = {} + out_params = [] rval = self.Values.ClearLog.Completed_with_no_error return (rval, out_params) @@ -519,7 +519,7 @@ ## end of class OMC_SyslogNGRecordLogProvider -class OMC_SyslogNGLogRecordProvider(pywbem.CIMProvider): +class OMC_SyslogNGLogRecordProvider(CIMProvider2): """Instrument the CIM class OMC_SyslogNGLogRecord Class representing a record in a log file. @@ -535,13 +535,13 @@ # parameters, set self.filter_results to False # self.filter_results = False - def get_instance(self, env, model, cim_class, line=None): + def get_instance(self, env, model, line=None): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) - ux = model.update_existing + ux = model.update # TODO fetch system resource matching the following keys: # model['LogCreationClassName'] @@ -580,12 +580,14 @@ #ux(RecordFormat='') # TODO return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'LogCreationClassName':None, + 'CreationClassName':None}) model['LogCreationClassName'] = 'OMC_SyslogNGRecordLog' model['CreationClassName'] = 'OMC_SyslogNGLogRecord' for fname in _get_syslog_list(): @@ -604,13 +606,13 @@ yield model else: try: - yield self.get_instance(env, model, cim_class, line) + yield self.get_instance(env, model, line) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): logger = env.get_logger() logger.log_debug('Entering %s.set_instance()' \ @@ -629,7 +631,7 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement ## end of class OMC_SyslogNGLogRecordProvider -class OMC_SyslogNGLogManagesRecordProvider(pywbem.CIMProvider): +class OMC_SyslogNGLogManagesRecordProvider(CIMProvider2): """Instrument the CIM class OMC_SyslogNGLogManagesRecord Association between a RecordLog and its LogRecords. @@ -645,13 +647,13 @@ # parameters, set self.filter_results to False # self.filter_results = False - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) - ux = model.update_existing + ux = model.update # TODO fetch system resource matching the following keys: # model['Record'] @@ -659,7 +661,7 @@ return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ @@ -674,13 +676,13 @@ yield model else: try: - yield self.get_instance(env, model, cim_class) + yield self.get_instance(env, model) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): logger = env.get_logger() logger.log_debug('Entering %s.set_instance()' \ @@ -698,19 +700,22 @@ # TODO delete the resource raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.references()' \ % self.__class__.__name__) + + model.path.update({'Record':None,'Log':None}) + ch = env.get_cimom_handle() if (not role or role.lower() == 'record') and \ - pywbem.is_subclass(ch, object_name.namespace, + ch.is_subclass(object_name.namespace, sub=object_name.classname, super='OMC_SyslogNGLogRecord'): model['Record'] = object_name - logfilename = object_name['LogName'] + logfilename = ''.join(object_name['LogName'].split(':')[1:]) if logfilename in _get_syslog_list(): model['Log'] = pywbem.CIMInstanceName('OMC_SyslogNGRecordLog', keybindings={'InstanceID':'OMCSyslogNGRecordLog:' + \ @@ -718,7 +723,7 @@ yield model if (not role or role.lower() == 'log') and \ - pywbem.is_subclass(ch, object_name.namespace, + ch.is_subclass(object_name.namespace, sub=object_name.classname, super='OMC_SyslogNGRecordLog'): model['Log'] = object_name @@ -748,7 +753,7 @@ fo.close() ## end of class OMC_SyslogNGLogManagesRecordProvider -class OMC_SyslogNGUseOfLogProvider(pywbem.CIMProvider): +class OMC_SyslogNGUseOfLogProvider(CIMProvider2): def __init__ (self, env): logger = env.get_logger() @@ -759,13 +764,13 @@ # parameters, set self.filter_results to False # self.filter_results = False - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) - ux = model.update_existing + ux = model.update # TODO fetch system resource matching the following keys: # model['Dependent'] @@ -774,12 +779,14 @@ #ux(RecordedData='') # TODO return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'Dependent':None, + 'Antecedent':None}) for log in _get_syslog_list(): model['Dependent'] = pywbem.CIMInstanceName('OMC_ComputerSystem', keybindings={'CreationClassName':'OMC_ComputerSystem', @@ -792,13 +799,13 @@ yield model else: try: - yield self.get_instance(env, model, cim_class) + yield self.get_instance(env, model) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): logger = env.get_logger() logger.log_debug('Entering %s.set_instance()' \ @@ -816,12 +823,15 @@ # TODO delete the resource raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.references()' \ % self.__class__.__name__) + + model.path.update({'Dependent':None,'Antecedent':None}) + ch = env.get_cimom_handle() if (not role or role.lower() == 'dependent') and \ object_name.classname.lower() == 'omc_computersystem': @@ -842,7 +852,7 @@ yield model ## end of class OMC_SyslogNGUseOfLogProvider -class OMC_SyslogNGRecordLogCapabilitiesProvider(pywbem.CIMProvider): +class OMC_SyslogNGRecordLogCapabilitiesProvider(CIMProvider2): """Instrument the CIM class OMC_SyslogNGRecordLogCapabilities EnabledLogicalElementCapabilities for SyslogNGRecordLog. This class is @@ -860,13 +870,13 @@ # parameters, set self.filter_results to False # self.filter_results = False - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) - ux = model.update_existing + ux = model.update try: id = model['InstanceID'] @@ -886,25 +896,26 @@ #ux(RequestedStatesSupported=[self.Values.RequestedStatesSupported.<VAL>,]) # TODO return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'InstanceID':None}) for log in _get_syslog_list(): model['InstanceID'] = 'OMCSyslogNGRecordLog:'+log if keys_only: yield model else: try: - yield self.get_instance(env, model, cim_class) + yield self.get_instance(env, model) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): logger = env.get_logger() logger.log_debug('Entering %s.set_instance()' \ @@ -935,7 +946,7 @@ Reset = pywbem.Uint16(11) ## end of class OMC_SyslogNGRecordLogCapabilitiesProvider -class OMC_SyslogNGRecordLogToCapabilitiesProvider(pywbem.CIMProvider): +class OMC_SyslogNGRecordLogToCapabilitiesProvider(CIMProvider2): """Instrument the CIM class OMC_SyslogNGRecordLogToCapabilities Associates OMC_SyslogNGRecordLog to OMC_SyslogNGRecordLogCapabilities. @@ -951,13 +962,13 @@ # parameters, set self.filter_results to False # self.filter_results = False - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) - ux = model.update_existing + ux = model.update # TODO fetch system resource matching the following keys: # model['Capabilities'] @@ -965,12 +976,14 @@ return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'Capabilities':None, 'ManagedElement':None}) + logname = pywbem.CIMInstanceName('OMC_SyslogNGRecordLog', keybindings={}, namespace=model.path.namespace) @@ -987,13 +1000,13 @@ yield model else: try: - yield self.get_instance(env, model, cim_class) + yield self.get_instance(env, model) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): logger = env.get_logger() logger.log_debug('Entering %s.set_instance()' \ @@ -1011,13 +1024,16 @@ # TODO delete the resource raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.references()' \ % self.__class__.__name__) ch = env.get_cimom_handle() + + model.path.update({'Capabilities':None,'ManagedElement':None}) + try: id = object_name['InstanceID'] except KeyError: Modified: pybase/trunk/OMC_TimeService.py =================================================================== --- pybase/trunk/OMC_TimeService.py 2008-09-16 02:37:53 UTC (rev 982) +++ pybase/trunk/OMC_TimeService.py 2008-09-16 03:45:16 UTC (rev 983) @@ -5,6 +5,7 @@ import pywbem +from pywbem.cim_provider2 import CIMProvider2 _fqdn = socket.getfqdn() @@ -367,7 +368,7 @@ return model ############################################################################### -class OMC_SystemTimeServiceProvider(pywbem.CIMProvider): +class OMC_SystemTimeServiceProvider(CIMProvider2): """Instrument the CIM class OMC_SystemTimeService""" ########################################################################### @@ -381,7 +382,7 @@ # self.filter_results = False ########################################################################### - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -390,14 +391,20 @@ return _fill_service_instance(model, False) ########################################################################### - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({ + 'Name':None, + 'CreationClassName':None, + 'SystemName':None, + 'SystemCreationClassName':None, + }) yield _fill_service_instance(model, keys_only) ########################################################################### - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, previous_instance): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) ########################################################################### @@ -405,23 +412,23 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) ########################################################################### - def cim_method_requeststatechange(self, env, object_name, method, + def cim_method_requeststatechange(self, env, object_name, param_requestedstate, param_timeoutperiod): # Not supported return (pywbem.Uint32(1), {}) ########################################################################### - def cim_method_startservice(self, env, object_name, method): + def cim_method_startservice(self, env, object_name): # Not supported return (pywbem.Uint32(1), {}) ########################################################################### - def cim_method_stopservice(self, env, object_name, method): + def cim_method_stopservice(self, env, object_name): # Not supported return (pywbem.Uint32(1), {}) ########################################################################### - def cim_method_managetime(self, env, object_name, method, + def cim_method_managetime(self, env, object_name, param_timedata, param_getrequest, param_managedelement): logger = env.get_logger() logger.log_debug('Entering %s.cim_method_managetime()' \ @@ -483,7 +490,7 @@ ## end of class OMC_SystemTimeServiceProvider ############################################################################### -class OMC_HostedTimeServiceProvider(pywbem.CIMProvider): +class OMC_HostedTimeServiceProvider(CIMProvider2): """Instrument the CIM class OMC_HostedTimeService""" ########################################################################### @@ -493,7 +500,7 @@ % (self.__class__.__name__, __file__)) ########################################################################### - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -507,10 +514,11 @@ return model ########################################################################### - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'Antecedent':None,'Dependent':None}) model['Antecedent'] = pywbem.CIMInstanceName( classname='OMC_ComputerSystem', namespace=model.path.namespace, @@ -522,7 +530,7 @@ yield model ########################################################################### - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, previous_instance): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) ########################################################################### @@ -530,12 +538,13 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) ########################################################################### - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.references()' \ % self.__class__.__name__) ch = env.get_cimom_handle() + model.path.update({'Antecedent':None, 'Dependent':None}) if object_name.classname.lower() == 'omc_systemtimeservice': if not _is_service_ref(object_name): return @@ -544,7 +553,7 @@ if result_role and result_role.lower() != 'antecedent': return if result_class_name: - if not pywbem.is_subclass(env.get_cimom_handle(), + if not ch.is_subclass( object_name.namespace, sub='omc_computersystem', super=result_class_name): return @@ -564,7 +573,7 @@ if result_role and result_role.lower() != 'dependent': return if result_class_name: - if not pywbem.is_subclass(env.get_cimom_handle(), + if not ch.is_subclass( object_name.namespace, sub='omc_systemtimeservice', super=result_class_name): return @@ -577,7 +586,7 @@ ## end of class OMC_HostedTimeServiceProvider ############################################################################### -class OMC_RemoteTimeServicePortProvider(pywbem.CIMProvider): +class OMC_RemoteTimeServicePortProvider(CIMProvider2): """Instrument the CIM class OMC_RemoteTimeServicePort """ ########################################################################### @@ -598,7 +607,7 @@ return None ########################################################################### - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -612,16 +621,22 @@ return svr.fill_cim_obj(model, False) ########################################################################### - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) servers = NTPServer.get_servers() + model.path.update({ + 'CreationClassName':None, + 'Name':None, + 'SystemName':None, + 'SystemCreationClassName':None, + }) for svr in servers: yield svr.fill_cim_obj(model, keys_only) ########################################################################### - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, previous_instance): logger = env.get_logger() logger.log_debug('Entering %s.set_instance()' \ % self.__class__.__name__) @@ -690,7 +705,7 @@ NTPServer.delete_server(sname) ########################################################################### - def cim_method_requeststatechange(self, env, object_name, method, + def cim_method_requeststatechange(self, env, object_name, param_requestedstate, param_timeoutperiod): # Not supported @@ -699,7 +714,7 @@ ## end of class OMC_RemoteTimeServicePortProvider ############################################################################### -class OMC_TimeServiceAccessBySAPProvider(pywbem.CIMProvider): +class OMC_TimeServiceAccessBySAPProvider(CIMProvider2): """Instrument the CIM class OMC_TimeServiceAccessBySAP""" ########################################################################### @@ -709,7 +724,7 @@ % (self.__class__.__name__, __file__)) ########################################################################### - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -733,10 +748,13 @@ return model ########################################################################### - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + + model.path.update({'Antecedent':None, 'Dependent':None}) + ref = pywbem.CIMInstanceName( classname='OMC_SystemTimeService', namespace=model.path.namespace); @@ -750,7 +768,7 @@ yield model ########################################################################### - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, previous_instance): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) ########################################################################### @@ -758,12 +776,13 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) ########################################################################### - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.references()' \ % self.__class__.__name__) ch = env.get_cimom_handle() + model.path.update({'antecedent':None,'dependent':None}) if object_name.classname.lower() == 'omc_systemtimeservice': if not _is_service_ref(object_name): return @@ -772,7 +791,7 @@ if result_role and result_role.lower() != 'dependent': return if result_class_name and len(result_class_name): - if not pywbem.is_subclass(ch, object_name.namespace, + if not ch.is_subclass(object_name.namespace, sub='OMC_RemoteTimeServicePort', super=result_class_name): return @@ -790,7 +809,7 @@ if result_role and result_role.lower() != 'antecedent': return if result_class_name and len(result_class_name): - if not pywbem.is_subclass(ch, object_name.namespace, + if not ch.is_subclass(object_name.namespace, sub='OMC_SystemTimeService', super=result_class_name): return @@ -810,7 +829,7 @@ ## end of class OMC_TimeServiceAccessBySAPProvider ############################################################################### -class OMC_TimeZoneSettingDataProvider(pywbem.CIMProvider): +class OMC_TimeZoneSettingDataProvider(CIMProvider2): """Instrument the CIM class OMC_TimeZoneSettingData""" ########################################################################### @@ -820,7 +839,7 @@ % (self.__class__.__name__, __file__)) ########################################################################### - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -841,13 +860,14 @@ return model ########################################################################### - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) tzcc = _clock_conf_get_time_zone() if not tzcc: return + model.path.update({'InstanceID':None}) model['InstanceID'] = 'omc:timezone' if not keys_only: model['ElementName'] = 'omc:timezone' @@ -858,7 +878,7 @@ yield model ########################################################################### - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, previous_instance): logger = env.get_logger() logger.log_debug('Entering %s.set_instance()' \ % self.__class__.__name__) @@ -922,7 +942,7 @@ ## end of class OMC_TimeZoneSettingDataProvider ############################################################################### -class OMC_TimeServiceTimeZoneSettingDataProvider(pywbem.CIMProvider): +class OMC_TimeServiceTimeZoneSettingDataProvider(CIMProvider2): """Instrument the CIM class OMC_TimeServiceTimeZoneSettingData""" ########################################################################### @@ -932,7 +952,7 @@ % (self.__class__.__name__, __file__)) ########################################################################### - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -950,10 +970,11 @@ return model ########################################################################### - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'settingdata':None,'managedelement':None}) model['settingdata'] = pywbem.CIMInstanceName( classname='OMC_TimeZoneSettingData', namespace=model.path.namespace, @@ -967,7 +988,7 @@ yield model ########################################################################### - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, previous_instance): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) ########################################################################### @@ -975,19 +996,20 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) ########################################################################### - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.references()' \ % self.__class__.__name__) ch = env.get_cimom_handle() + model.path.update({'settingdata':None,'managedelement':None}) if object_name.classname.lower() == 'omc_systemtimeservice': if role and role.lower() != 'managedelement': return if result_role and result_role.lower() != 'settingdata': return if result_class_name: - if not pywbem.is_subclass(ch, object_name.namespace, + if not ch.is_subclass(object_name.namespace, sub='omc_timezonesettingdata', super=result_class_name): return @@ -1007,7 +1029,7 @@ if result_role and result_role.lower() != 'managedelement': return if result_class_name: - if not pywbem.is_subclass(ch, object_name.namespace, + if not ch.is_subclass(object_name.namespace, sub='omc_systemtimeservice', super=result_class_name): return @@ -1027,7 +1049,7 @@ ## end of class OMC_TimeServiceTimeZoneSettingDataProvider ############################################################################### -class OMC_TimeServiceAvailableToElementProvider(pywbem.CIMProvider): +class OMC_TimeServiceAvailableToElementProvider(CIMProvider2): """Instrument the CIM class OMC_TimeServiceAvailableToElement""" ########################################################################### @@ -1037,7 +1059,7 @@ % (self.__class__.__name__, __file__)) ########################################################################### - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -1053,10 +1075,11 @@ return model ########################################################################### - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'userofservice':None,'serviceprovided':None}) model['userofservice'] = pywbem.CIMInstanceName( classname='OMC_ComputerSystem', namespace=model.path.namespace, @@ -1068,7 +1091,7 @@ yield model ########################################################################### - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, previous_instance): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) ########################################################################### @@ -1076,19 +1099,20 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) ########################################################################### - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.references()' \ % self.__class__.__name__) ch = env.get_cimom_handle() + model.path.update({'userofservice':None,'serviceprovided':None}) if object_name.classname.lower() == 'omc_systemtimeservice': if role and role.lower() != 'serviceprovided': return if result_role and result_role.lower() != 'userofservice': return if result_class_name: - if not pywbem.is_subclass(ch, object_name.namespace, + if not ch.is_subclass(object_name.namespace, sub='omc_computersystem', super=result_class_name): return @@ -1108,7 +1132,7 @@ if result_role and result_role.lower() != 'serviceprovided': return if result_class_name: - if not pywbem.is_subclass(ch, object_name.namespace, + if not ch.is_subclass(object_name.namespace, sub='omc_systemtimeservice', super=result_class_name): return This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-16 02:37:43
|
Revision: 982 http://omc.svn.sourceforge.net/omc/?rev=982&view=rev Author: bartw Date: 2008-09-16 02:37:53 +0000 (Tue, 16 Sep 2008) Log Message: ----------- do not install cim_provider.py Modified Paths: -------------- cmpi-bindings/trunk/swig/python/CMakeLists.txt Modified: cmpi-bindings/trunk/swig/python/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-09-16 01:44:26 UTC (rev 981) +++ cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-09-16 02:37:53 UTC (rev 982) @@ -60,5 +60,4 @@ # cmpi_pywbem_bindings.py: provider implementation # INSTALL(FILES cmpi_pywbem_bindings.py DESTINATION ${PYTHON_LIB_DIR}/site-packages ) -INSTALL(FILES cim_provider.py DESTINATION ${PYTHON_LIB_DIR}/site-packages ) #INSTALL(FILES Py_UnixProcessProvider.py DESTINATION /usr/lib/pycim ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-16 01:44:15
|
Revision: 981 http://omc.svn.sourceforge.net/omc/?rev=981&view=rev Author: bartw Date: 2008-09-16 01:44:26 +0000 (Tue, 16 Sep 2008) Log Message: ----------- some better error handling Modified Paths: -------------- cmpi-bindings/trunk/src/cmpi_provider_python.c cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py Modified: cmpi-bindings/trunk/src/cmpi_provider_python.c =================================================================== --- cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-16 01:40:00 UTC (rev 980) +++ cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-16 01:44:26 UTC (rev 981) @@ -178,6 +178,7 @@ if (!PyString_Check(obstr)) TB_ERROR("getvalue() did not return a string"); + _SBLIM_TRACE(1,(PyString_AsString(obstr))); args = PyTuple_New(2); PyTuple_SetItem(args, 0, string2py("\n")); PyTuple_SetItem(args, 1, string2py("<br>")); Modified: cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py =================================================================== --- cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-09-16 01:40:00 UTC (rev 980) +++ cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-09-16 01:44:26 UTC (rev 981) @@ -461,6 +461,9 @@ def pywbem2cmpi_instname(self, iname): cop = self.broker.new_object_path(iname.namespace, str(iname.classname)) for name, val in iname.keybindings.items(): + if val is None: + raise ValueError('NULL value for key "%s.%s"' % \ + (iname.classname, name)) data, _type = self.pywbem2cmpi_value(val) cop.add_key(str(name), data, _pywbem2cmpi_typemap[_type]) return cop This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-16 01:39:53
|
Revision: 980 http://omc.svn.sourceforge.net/omc/?rev=980&view=rev Author: bartw Date: 2008-09-16 01:40:00 +0000 (Tue, 16 Sep 2008) Log Message: ----------- more porting to new interface Modified Paths: -------------- pybase/trunk/OMC_Base.sfcb.reg pybase/trunk/OMC_LogicalFile.py Modified: pybase/trunk/OMC_Base.sfcb.reg =================================================================== --- pybase/trunk/OMC_Base.sfcb.reg 2008-09-15 23:35:39 UTC (rev 979) +++ pybase/trunk/OMC_Base.sfcb.reg 2008-09-16 01:40:00 UTC (rev 980) @@ -4,6 +4,7 @@ type: instance method namespace: root/cimv2 +# Operating System [OMC_OperatingSystem] provider: OMC_OperatingSystem location: pyCmpiProvider @@ -22,6 +23,7 @@ type: instance association namespace: root/cimv2 +# Unix Process [OMC_UnixProcess] provider: OMC_UnixProcess location: pyCmpiProvider @@ -40,3 +42,60 @@ type: instance association namespace: root/cimv2 +# Logical File +[OMC_LinuxDirectoryContainsFile] + provider: OMC_LogicalFile + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + +[OMC_LinuxFileIdentity] + provider: OMC_LogicalFile + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + +[OMC_LinuxFile] + provider: OMC_LogicalFile + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + +[OMC_LinuxDataFile] + provider: OMC_LogicalFile + location: pyCmpiProvider + type: instance method + namespace: root/cimv2 + +[OMC_LinuxSocketFile] + provider: OMC_LogicalFile + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + +[OMC_LinuxDeviceFile] + provider: OMC_LogicalFile + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + +[OMC_LinuxDirectory] + provider: OMC_LogicalFile + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + +[OMC_LinuxFIFOPipeFile] + provider: OMC_LogicalFile + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + +[OMC_LinuxSymbolicLink] + provider: OMC_LogicalFile + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + + + Modified: pybase/trunk/OMC_LogicalFile.py =================================================================== --- pybase/trunk/OMC_LogicalFile.py 2008-09-15 23:35:39 UTC (rev 979) +++ pybase/trunk/OMC_LogicalFile.py 2008-09-16 01:40:00 UTC (rev 980) @@ -195,7 +195,7 @@ # DMTF_Reserved = .. # Vendor_Reserved = 0x8000.. - def get_instance (self, env, model, cim_class, stat=None): + def get_instance (self, env, model, stat=None): """Return an instance. Keyword arguments: @@ -205,7 +205,6 @@ instanceName that was requested. The properties of the model are already filtered according to the PropertyList from the request. - cim_class -- The CIMClass Possible Errors: CIM_ERR_ACCESS_DENIED @@ -274,7 +273,7 @@ model['FileInodeNumber'] = str(stat[ST_INO]) return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): """ Enumerate instances. The WBEM operations EnumerateInstances and EnumerateInstanceNames @@ -286,7 +285,6 @@ model -- A template of the CIMInstances to be generated. The properties of the model are already filtered according to the PropertyList from the request. - cim_class -- The CIMClass keys_only -- A boolean. True if only the key properties should be set on the generated instances. @@ -296,6 +294,9 @@ """ _scanmounts() + model.path.update({ + 'LFName':None,'LFCreationClassName':None,'CSCreationClassName':None, + 'FSCreationClassName':None,'FSName':None,'CSName':None}) dirs = ['/' + dir for dir in os.listdir('/')] for dir in ['/'] + dirs: stat = os.lstat(dir) @@ -304,13 +305,13 @@ yield model else: try: - yield self.get_instance(env, model, cim_class, stat=stat) + yield self.get_instance(env, model, stat=stat) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): """ Return a newly created or modified instance. Keyword arguments: @@ -318,9 +319,8 @@ instance -- The new CIMInstance. If modifying an existing instance, the properties on this instance have been filtered by the PropertyList from the request. - previous_instance -- The previous instance if modifying an existing + modify_existing -- The previous instance if modifying an existing instance. None if creating a new instance. - cim_class -- The CIMClass Return the new instance. The keys must be set on the new instance. @@ -330,17 +330,16 @@ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized or otherwise incorrect parameters) CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only - valid if previous_instance is None, indicating that the operation + valid if modify_existing is None, indicating that the operation was CreateInstance) CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid - if previous_instance is not None, indicating that the operation + if modify_existing is not None, indicating that the operation was ModifyInstance) CIM_ERR_FAILED (some other unspecified error occurred) """ - # TODO create or modify the instance - if previous_instance is None: + if not modify_existing: raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED, 'CreateInstance not supported') stat = os.lstat(instance['lfname']) @@ -442,7 +441,7 @@ """ - def get_instance (self, env, model, cim_class, stat=None): + def get_instance (self, env, model, stat=None): """Return an instance. Keyword arguments: @@ -452,7 +451,6 @@ instanceName that was requested. The properties of the model are already filtered according to the PropertyList from the request. - cim_class -- The CIMClass Possible Errors: CIM_ERR_ACCESS_DENIED @@ -479,7 +477,7 @@ print '\n***** ', model['CreationClassName'] raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) - ux = model.update_existing + ux = model.update mode = stat[ST_MODE] ux(Writeable= bool(mode & S_IWUSR)) ux(HealthState= pywbem.Uint16(5)) @@ -502,9 +500,9 @@ ux(CreationDate= pywbem.CIMDateTime.fromtimestamp(stat[ST_CTIME])) if model.classname.lower() == 'omc_linuxdevicefile': if S_ISCHR(mode): - ux(DeviceFileType=3) + ux(DeviceFileType=pywbem.Uint16(3)) elif S_ISBLK(mode): - ux(DeviceFileType=2) + ux(DeviceFileType=pywbem.Uint16(2)) ux(DeviceId=str(stat.st_rdev)) ux(DeviceMajor=str(os.major(stat.st_rdev))) ux(DeviceMinor=str(os.minor(stat.st_rdev))) @@ -513,7 +511,7 @@ return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): """ Enumerate instances. The WBEM operations EnumerateInstances and EnumerateInstanceNames @@ -525,7 +523,6 @@ model -- A template of the CIMInstances to be generated. The properties of the model are already filtered according to the PropertyList from the request. - cim_class -- The CIMClass keys_only -- A boolean. True if only the key properties should be set on the generated instances. @@ -541,6 +538,10 @@ # return the top level dirs. Other directories and files # can be reached by navigation via the DirectoryContainsFile # association. + model.path.update({ + 'Name':None,'CreationClassName':None,'CSCreationClassName':None, + 'FSCreationClassName':None,'FSName':None,'CSName':None}) + dirs = ['/' + dir for dir in os.listdir('/')] for dir in ['/'] + dirs: stat = os.lstat(dir) @@ -551,13 +552,13 @@ yield model else: try: - yield self.get_instance(env, model, cim_class, stat=stat) + yield self.get_instance(env, model, stat=stat) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): """ Return a newly created or modified instance. Keyword arguments: @@ -565,9 +566,8 @@ instance -- The new CIMInstance. If modifying an existing instance, the properties on this instance have been filtered by the PropertyList from the request. - previous_instance -- The previous instance if modifying an existing + modify_existing -- The previous instance if modifying an existing instance. None if creating a new instance. - cim_class -- The CIMClass Return the new instance. The keys must be set on the new instance. @@ -577,10 +577,10 @@ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized or otherwise incorrect parameters) CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only - valid if previous_instance is None, indicating that the operation + valid if modify_existing is None, indicating that the operation was CreateInstance) CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid - if previous_instance is not None, indicating that the operation + if modify_existing is not None, indicating that the operation was ModifyInstance) CIM_ERR_FAILED (some other unspecified error occurred) @@ -622,7 +622,7 @@ """ - def get_instance (self, env, model, cim_class): + def get_instance (self, env, model): """Return an instance. Keyword arguments: @@ -632,7 +632,6 @@ instanceName that was requested. The properties of the model are already filtered according to the PropertyList from the request. - cim_class -- The CIMClass Possible Errors: CIM_ERR_ACCESS_DENIED @@ -648,7 +647,7 @@ # and that they are indeed associated return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): """ Enumerate instances. The WBEM operations EnumerateInstances and EnumerateInstanceNames @@ -660,7 +659,6 @@ model -- A template of the CIMInstances to be generated. The properties of the model are already filtered according to the PropertyList from the request. - cim_class -- The CIMClass keys_only -- A boolean. True if only the key properties should be set on the generated instances. @@ -673,7 +671,7 @@ yield None - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): """Instrument Associations. @@ -688,7 +686,6 @@ model -- A template CIMInstance to serve as a model of the objects to be returned. Only properties present on this model need to be returned. - assoc_class -- The CIMClass result_class_name -- If not None, acts as a filter on the returned set of Objects by mandating that each returned Object MUST be either an Instance of this Class (or one of its subclasses) or be this @@ -718,6 +715,8 @@ """ + model.path.update({'SystemElement':None, 'SameElement':None}) + is_subclass = env.get_cimom_handle().is_subclass if object_name.classname.lower() == 'omc_linuxfile': model['SameElement'] = object_name try: @@ -736,7 +735,8 @@ namespace=object_name.namespace, keybindings=keybindings) yield model - else: + elif is_subclass(object_name.namespace, sub=object_name.classname, + super='CIM_LogicalFile'): model['SystemElement'] = object_name try: keybindings = { @@ -763,7 +763,7 @@ """ - def get_instance (self, env, model, cim_class): + def get_instance (self, env, model): """Return an instance. Keyword arguments: @@ -773,7 +773,6 @@ instanceName that was requested. The properties of the model are already filtered according to the PropertyList from the request. - cim_class -- The CIMClass Possible Errors: CIM_ERR_ACCESS_DENIED @@ -789,7 +788,7 @@ # and that they are indeed associated return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): """ Enumerate instances. The WBEM operations EnumerateInstances and EnumerateInstanceNames @@ -801,7 +800,6 @@ model -- A template of the CIMInstances to be generated. The properties of the model are already filtered according to the PropertyList from the request. - cim_class -- The CIMClass keys_only -- A boolean. True if only the key properties should be set on the generated instances. @@ -819,14 +817,14 @@ yield model else: try: - yield self.get_instance(env, model, cim_class) + yield self.get_instance(env, model) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): """Instrument Associations. @@ -841,7 +839,6 @@ model -- A template CIMInstance to serve as a model of the objects to be returned. Only properties present on this model need to be returned. - assoc_class -- The CIMClass result_class_name -- If not None, acts as a filter on the returned set of Objects by mandating that each returned Object MUST be either an Instance of this Class (or one of its subclasses) or be this @@ -871,7 +868,12 @@ """ + is_subclass = env.get_cimom_handle().is_subclass + if not is_subclass(object_name.namespace, sub=object_name.classname, + super = 'CIM_LogicalFile'): + return _scanmounts() + model.path.update({'GroupComponent':None, 'PartComponent':None}) try: objname = object_name['name'] if (not role or role.lower() == 'partcomponent') \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-15 23:35:28
|
Revision: 979 http://omc.svn.sourceforge.net/omc/?rev=979&view=rev Author: bartw Date: 2008-09-15 23:35:39 +0000 (Mon, 15 Sep 2008) Log Message: ----------- started porting providers to new interface Modified Paths: -------------- pybase/trunk/OMC_ComputerSystem.py pybase/trunk/OMC_LogicalFile.py pybase/trunk/OMC_OperatingSystem.py pybase/trunk/OMC_UnixProcess.py Added Paths: ----------- pybase/trunk/OMC_Base.sfcb.reg Added: pybase/trunk/OMC_Base.sfcb.reg =================================================================== --- pybase/trunk/OMC_Base.sfcb.reg (rev 0) +++ pybase/trunk/OMC_Base.sfcb.reg 2008-09-15 23:35:39 UTC (rev 979) @@ -0,0 +1,42 @@ +[OMC_ComputerSystem] + provider: OMC_ComputerSystem + location: pyCmpiProvider + type: instance method + namespace: root/cimv2 + +[OMC_OperatingSystem] + provider: OMC_OperatingSystem + location: pyCmpiProvider + type: instance method + namespace: root/cimv2 + +[OMC_InstalledOS] + provider: OMC_OperatingSystem + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + +[OMC_RunningOS] + provider: OMC_OperatingSystem + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + +[OMC_UnixProcess] + provider: OMC_UnixProcess + location: pyCmpiProvider + type: instance method + namespace: root/cimv2 + +[OMC_ProcessExecutable] + provider: OMC_UnixProcess + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + +[OMC_OSProcess] + provider: OMC_UnixProcess + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 + Modified: pybase/trunk/OMC_ComputerSystem.py =================================================================== --- pybase/trunk/OMC_ComputerSystem.py 2008-09-15 22:23:31 UTC (rev 978) +++ pybase/trunk/OMC_ComputerSystem.py 2008-09-15 23:35:39 UTC (rev 979) @@ -35,17 +35,17 @@ """ import pywbem -from pywbem import CIMProvider +from pywbem.cim_provider2 import CIMProvider2 from socket import getfqdn -class OMC_ComputerSystemProvider(CIMProvider): +class OMC_ComputerSystemProvider(CIMProvider2): """Instrument the CIM class OMC_ComputerSystem OMC Computer System """ - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): """Return an instance. Keyword arguments: @@ -103,7 +103,7 @@ #model['PowerManagementCapabilities'] = # TODO (type = [pywbem.Uint16,] self.Values.PowerManagementCapabilities) return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): """Enumerate instances. The WBEM operations EnumerateInstances and EnumerateInstanceNames @@ -131,6 +131,8 @@ logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'CreationClassName':None, 'Name':None}) + # Key properties model['CreationClassName'] = 'OMC_ComputerSystem' model['Name'] = getfqdn() @@ -144,7 +146,7 @@ pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): """Return a newly created or modified instance. Keyword arguments: @@ -209,7 +211,7 @@ # TODO delete the resource raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement - def cim_method_requeststatechange(self, env, object_name, method, + def cim_method_requeststatechange(self, env, object_name, param_requestedstate, param_timeoutperiod): """Implements OMC_ComputerSystem.RequestStateChange() @@ -273,7 +275,7 @@ rval = None # TODO (type pywbem.Uint32 self.Values.RequestStateChange) return (rval, out_params) - def cim_method_setpowerstate(self, env, object_name, method, + def cim_method_setpowerstate(self, env, object_name, param_powerstate, param_time): """Implements OMC_ComputerSystem.SetPowerState() Modified: pybase/trunk/OMC_LogicalFile.py =================================================================== --- pybase/trunk/OMC_LogicalFile.py 2008-09-15 22:23:31 UTC (rev 978) +++ pybase/trunk/OMC_LogicalFile.py 2008-09-15 23:35:39 UTC (rev 979) @@ -35,7 +35,7 @@ """ import pywbem -#from pywbem import CIMProvider +from pywbem.cim_provider2 import CIMProvider2 from stat import * from statvfs import * from socket import getfqdn @@ -142,7 +142,7 @@ -class OMC_LinuxFileProvider(pywbem.CIMProvider): +class OMC_LinuxFileProvider(CIMProvider2): """Instrument the CIM class OMC_LinuxFile The UnixFile class holds properties that are valid for various @@ -433,7 +433,7 @@ """ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED, '') -class CIM_LogicalFileProvider(pywbem.CIMProvider): +class CIM_LogicalFileProvider(CIMProvider2): """Instrument the CIM class CIM_LogicalFile A LogicalFile is a named collection of data or executable code, or @@ -611,7 +611,7 @@ """ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED, '') -class OMC_LinuxFileIdentityProvider(pywbem.CIMProvider): +class OMC_LinuxFileIdentityProvider(CIMProvider2): """Instrument the CIM class OMC_LinuxFileIdentity CIM_FileIdentity indicates that a UnixFile describes Unix-specific @@ -756,7 +756,7 @@ yield model -class OMC_LinuxDirectoryContainsFileProvider(pywbem.CIMProvider): +class OMC_LinuxDirectoryContainsFileProvider(CIMProvider2): """Instrument the CIM class OMC_LinuxDirectoryContainsFile Specifies the hierarchical arrangement of LogicalFiles in a Directory. Modified: pybase/trunk/OMC_OperatingSystem.py =================================================================== --- pybase/trunk/OMC_OperatingSystem.py 2008-09-15 22:23:31 UTC (rev 978) +++ pybase/trunk/OMC_OperatingSystem.py 2008-09-15 23:35:39 UTC (rev 979) @@ -35,7 +35,7 @@ """ import pywbem -from pywbem import CIMProvider +from pywbem.cim_provider2 import CIMProvider2 from socket import getfqdn import resource import os,sys @@ -60,13 +60,13 @@ 'Name': 'Linux', 'CSName': getfqdn()}) -class OMC_OperatingSystemProvider(CIMProvider): +class OMC_OperatingSystemProvider(CIMProvider2): """Instrument the CIM class OMC_OperatingSystem OMC Operating System """ - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -78,70 +78,69 @@ meminfo[sline[0].strip()] = int(sline[1].split()[0]) fo.close() - uex = model.update_existing - - #uex(TotalSwapSpaceSize = pywbem.Uint64(meminfo['SwapTotal'])) - uex(TotalSwapSpaceSize = None) # not distinguished from page files. - uex(FreePhysicalMemory = pywbem.Uint64(meminfo['MemFree'] + + #model.update(TotalSwapSpaceSize = pywbem.Uint64(meminfo['SwapTotal'])) + model['TotalSwapSpaceSize'] = pywbem.CIMProperty('TotalSwapSpaceSize', + type='uint64', value=None) # not distinguished from page files. + model.update(FreePhysicalMemory = pywbem.Uint64(meminfo['MemFree'] + meminfo['Buffers'] + meminfo['Cached'])) - uex(FreeVirtualMemory = pywbem.Uint64(meminfo['MemFree'] + + model.update(FreeVirtualMemory = pywbem.Uint64(meminfo['MemFree'] + meminfo['Buffers'] + meminfo['Cached'] + meminfo['SwapFree'])) - uex(TotalVisibleMemorySize = pywbem.Uint64(meminfo['MemTotal'])) - uex(TotalVirtualMemorySize = pywbem.Uint64(meminfo['MemTotal'] + + model.update(TotalVisibleMemorySize = pywbem.Uint64(meminfo['MemTotal'])) + model.update(TotalVirtualMemorySize = pywbem.Uint64(meminfo['MemTotal'] + meminfo['SwapTotal'])) - uex(FreeSpaceInPagingFiles = pywbem.Uint64(meminfo['SwapFree'])) - uex(SizeStoredInPagingFiles = pywbem.Uint64(meminfo['SwapTotal'])) + model.update(FreeSpaceInPagingFiles = pywbem.Uint64(meminfo['SwapFree'])) + model.update(SizeStoredInPagingFiles = pywbem.Uint64(meminfo['SwapTotal'])) fnames = os.listdir('/proc') numprocs = len([x for x in fnames if x.isdigit()]) - uex(NumberOfProcesses = pywbem.Uint32(numprocs)) - uex(CurrentTimeZone = pywbem.Sint16(pywbem.CIMDateTime.get_local_utcoffset())) - uex(LocalDateTime = pywbem.CIMDateTime.now()) + model.update(NumberOfProcesses = pywbem.Uint32(numprocs)) + model.update(CurrentTimeZone = pywbem.Sint16(pywbem.CIMDateTime.get_local_utcoffset())) + model.update(LocalDateTime = pywbem.CIMDateTime.now()) fo = open('/proc/uptime', 'r') - uex(LastBootUpTime = pywbem.CIMDateTime.fromtimestamp( + model.update(LastBootUpTime = pywbem.CIMDateTime.fromtimestamp( time.time() - float(fo.read().split()[0]))) fo.close() if os.path.exists('/etc/SuSE-release'): fo = open('/etc/SuSE-release', 'r') version = fo.readline().strip() - uex(Version = version) - uex(ElementName = version) - uex(Description = version) - uex(Caption = version) + model.update(Version = version) + model.update(ElementName = version) + model.update(Description = version) + model.update(Caption = version) fo.close() install_time = Popen(['/bin/rpm', '-qf','/etc/SuSE-release', '--queryformat','%{INSTALLTIME}'], stdout=PIPE).communicate()[0] - uex(InstallDate = pywbem.CIMDateTime.fromtimestamp(int(install_time))) + model.update(InstallDate = pywbem.CIMDateTime.fromtimestamp(int(install_time))) # TODO non-SUSE distros - uex(Distributed = True) + model.update(Distributed = True) #model['EnabledDefault'] = # TODO (type = pywbem.Uint16 self.Values.EnabledDefault) (default=2L) - uex(EnabledState = self.Values.EnabledState.Enabled) - uex(HealthState = self.Values.HealthState.OK) + model.update(EnabledState = self.Values.EnabledState.Enabled) + model.update(HealthState = self.Values.HealthState.OK) model['MaxNumberOfProcesses'] = pywbem.Uint32(_get_max_number_of_processes()) wk = resource.getrlimit(resource.RLIMIT_DATA)[1] if int(wk) < 0: wk = 0 - uex(MaxProcessMemorySize = pywbem.Uint64(int(wk)/1024)) + model.update(MaxProcessMemorySize = pywbem.Uint64(int(wk)/1024)) wk = resource.getrlimit(resource.RLIMIT_NPROC)[1] if int(wk) < 0: wk = 0 - uex(MaxProcessesPerUser = pywbem.Uint32(wk)) - uex(NumberOfLicensedUsers = pywbem.Uint32(0)) + model.update(MaxProcessesPerUser = pywbem.Uint32(wk)) + model.update(NumberOfLicensedUsers = pywbem.Uint32(0)) try: l = Popen([r'/usr/bin/who','-u'], stdout=PIPE).communicate()[0] - uex(NumberOfUsers = pywbem.Uint32(len(l.split('\n')))) + model.update(NumberOfUsers = pywbem.Uint32(len(l.split('\n')))) except: - uex(NumberOfUsers = pywbem.Uint32(0)) + model.update(NumberOfUsers = pywbem.Uint32(0)) - uex(OperationalStatus = [self.Values.OperationalStatus.OK]) - uex(OSType = self.Values.OSType.LINUX) + model.update(OperationalStatus = [self.Values.OperationalStatus.OK]) + model.update(OSType = self.Values.OSType.LINUX) #model['OtherEnabledState'] = # TODO (type = unicode) #model['OtherTypeDescription'] = # TODO (type = unicode) #model['RequestedState'] = # TODO (type = pywbem.Uint16 self.Values.RequestedState) (default=12L) @@ -150,12 +149,17 @@ #model['TimeOfLastStateChange'] = # TODO (type = pywbem.CIMDateTime) return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) # Key properties + model.path.update({'CSCreationClassName':None, + 'CreationClassName':None, + 'Name':None, + 'CSName':None}) + model['CSCreationClassName'] = 'OMC_ComputerSystem' model['CreationClassName'] = 'OMC_OperatingSystem' model['Name'] = 'Linux' @@ -164,19 +168,19 @@ yield model else: try: - yield self.get_instance(env, model, cim_class) + yield self.get_instance(env, model) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, previous_instance): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) def delete_instance(self, env, instance_name): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) - def cim_method_requeststatechange(self, env, object_name, method, + def cim_method_requeststatechange(self, env, object_name, param_requestedstate, param_timeoutperiod): logger = env.get_logger() @@ -188,32 +192,32 @@ if rstate == 3: # Disable logger.log_info('OS Disabled State Requested. Shutting Down now...') if os.system('/sbin/shutdown -h now'): - return (pywbem.Uint32(4), {}) - return (pywbem.Uint32(0), {}) + return (pywbem.Uint32(4), []) + return (pywbem.Uint32(0), []) elif rstate == 4: # Shutdown logger.log_info('OS Shutdown State Requested. Shutting Down now...') if os.system('/sbin/shutdown -h now'): - return (pywbem.Uint32(4), {}) - return (pywbem.Uint32(0), {}) + return (pywbem.Uint32(4), []) + return (pywbem.Uint32(0), []) elif rstate == 6: # Offline logger.log_info('OS Offline State Requested. Shutting Down now...') if os.system('/sbin/shutdown -h now'): - return (pywbem.Uint32(4), {}) - return (pywbem.Uint32(0), {}) + return (pywbem.Uint32(4), []) + return (pywbem.Uint32(0), []) elif rstate == 10: # Reboot logger.log_info('OS Reboot State Requested. Rebooting now...') if os.system('/sbin/shutdown -r now'): - return (pywbem.Uint32(4), {}) - return (pywbem.Uint32(0), {}) + return (pywbem.Uint32(4), []) + return (pywbem.Uint32(0), []) elif rstate == 11: # Reset logger.log_info('OS Reset State Requested. Rebooting now...') if os.system('/sbin/shutdown -r now'): - return (pywbem.Uint32(4), {}) - return (pywbem.Uint32(0), {}) + return (pywbem.Uint32(4), []) + return (pywbem.Uint32(0), []) # Return 'not supported' - return (pywbem.Uint32(1), {}) + return (pywbem.Uint32(1), []) - def cim_method_reboot(self, env, object_name, method): + def cim_method_reboot(self, env, object_name): logger = env.get_logger() logger.log_debug('Entering %s.cim_method_reboot()' \ % self.__class__.__name__) @@ -222,8 +226,8 @@ logger.log_info('OMC_OperatingSystem.reboot called. ' 'Rebooting system now') if os.system('/sbin/shutdown -r now'): - return ('Fail', {}) - return ('Success', {}) + return ('Fail', []) + return ('Success', []) def cim_method_shutdown(self, env, object_name, method): logger = env.get_logger() @@ -234,8 +238,8 @@ logger.log_info('OMC_OperatingSystem.shutdown called. ' 'shutdown system now') if os.system('/sbin/shutdown -h now'): - return ('Fail', {}) - return ('Success', {}) + return ('Fail', []) + return ('Success', []) class Values(object): class Status(object): @@ -429,7 +433,7 @@ ## end of class OMC_OperatingSystemProvider -class OMC_InstalledOSProvider(CIMProvider): +class OMC_InstalledOSProvider(CIMProvider2): """Instrument the CIM class OMC_InstalledOS A link between the ComputerSystem and the OperatingSystem(s) installed @@ -441,7 +445,7 @@ """ - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -449,7 +453,7 @@ #model['PrimaryOS'] = # TODO (type = bool) return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) @@ -466,46 +470,40 @@ 'Name':getfqdn()}) if model.classname.lower() == 'omc_installedos': + model.path.update({'GroupComponent':None,'PartComponent':None}) model['GroupComponent'] = cs model['PartComponent'] = os else: + model.path.update({'Dependent':None,'Antecedent':None}) model['Dependent'] = cs model['Antecedent'] = os if keys_only: yield model else: try: - yield self.get_instance(env, model, cim_class) + yield self.get_instance(env, model) except pywbem.CIMError, (num, msg): if num not in (pywbem.CIM_ERR_NOT_FOUND, pywbem.CIM_ERR_ACCESS_DENIED): raise - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, previous_instance): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) def delete_instance(self, env, instance_name): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.references()' \ % self.__class__.__name__) - if assoc_class.classname.lower() == 'omc_installedos': - cs = 'GroupComponent' - os = 'PartComponent' - else: - cs = 'Dependent' - os = 'Antecedent' - model[cs] = pywbem.CIMInstanceName( - classname='OMC_ComputerSystem', - namespace=object_name.namespace, - keybindings={'CreationClassName':'OMC_ComputerSystem', - 'Name':getfqdn()}) - model[os] = get_os_path(object_name.namespace) - yield model + if object_name.classname.lower() == 'omc_computersystem' or \ + object_name.classname.lower() == 'omc_operatingsystem': + return self.simple_refs(env, object_name, model, + result_class_name, role, result_role, keys_only) + ## end of class OMC_InstalledOSProvider def get_providers(env): Modified: pybase/trunk/OMC_UnixProcess.py =================================================================== --- pybase/trunk/OMC_UnixProcess.py 2008-09-15 22:23:31 UTC (rev 978) +++ pybase/trunk/OMC_UnixProcess.py 2008-09-15 23:35:39 UTC (rev 979) @@ -42,6 +42,8 @@ from resource import getpagesize +from pywbem.cim_provider2 import CIMProvider2 + _pagesize = getpagesize() PROC_STATE_DOESNT_EXIST = -1 @@ -449,7 +451,7 @@ kb += 1 return kb -class OMC_UnixProcessProvider(pywbem.CIMProvider): +class OMC_UnixProcessProvider(CIMProvider2): """Instrument the CIM class OMC_UnixProcess A Unix Process @@ -457,7 +459,7 @@ """ def fill_instance(self, model, lp, keys_only=False): - ux = model.update_existing + ux = model.update ux(OSCreationClassName= 'OMC_OperatingSystem') ux(CreationClassName= 'OMC_UnixProcess') ux(Handle= str(lp.pid)) @@ -476,7 +478,8 @@ ux(ProcessGroupID= pywbem.Uint64(ps['process_group'])) ux(ProcessSessionID= pywbem.Uint64(ps['session_id'])) tty_n = ps['tty_number'] - ux(ProcessTTY=None) + ux(ProcessTTY=pywbem.CIMProperty('ProcessTTY', value=None, + type='string')) if tty_n > 0: try: for fd in os.listdir('/proc/%s/fd' % lp.pid): @@ -503,7 +506,8 @@ ux(PercentCPU= pywbem.Real32(ps['percent_cpu'])) ux(KernelModeTime= pywbem.Uint64(ps['kernel_mode_time'])) ux(UserModeTime= pywbem.Uint64(ps['user_mode_time'])) - ux(ModulePath=lp.get_module_path()) + ux(ModulePath=pywbem.CIMProperty('ModulePath', type='string', + value=lp.get_module_path())) ux(SharedMemorySize= pywbem.Uint64(_bytes2KB(ps['shared_mem_size']))) ux(ResidentSetSize= pywbem.Uint64(_bytes2KB(ps['resident_set_size']))) cl = lp.get_command_line() @@ -511,16 +515,18 @@ ux(Parameters= cl) ruid = lp.get_real_uid() ux(RealUserID= pywbem.Uint64(ruid)) + ''' TODO where did this come from? Not in schema. try: ux(UserName= pwd.getpwuid(ruid)[0]) except: pass + ''' ux(ElementName= model['Name']) ux(HealthState= pywbem.Uint16(0)) ux(OperationalStatus= [pywbem.Uint16(0)]) return model - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -534,15 +540,21 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) return self.fill_instance(model, lp) - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) + model.path.update({'OSCreationClassName':None, + 'CreationClassName':None, + 'Handle':None, + 'CSCreationClassName':None, + 'OSName':None, + 'CSName':None}) for lp in LinuxProcess.procs(): yield self.fill_instance(model, lp, keys_only) - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): logger = env.get_logger() logger.log_debug('Entering %s.set_instance()' \ % self.__class__.__name__) @@ -555,7 +567,7 @@ % self.__class__.__name__) raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) - def cim_method_sendsignal(self, env, object_name, method, + def cim_method_sendsignal(self, env, object_name, param_signal): logger = env.get_logger() logger.log_debug('Entering %s.cim_method_sendsignal()' \ @@ -568,37 +580,39 @@ lp = LinuxProcess.get_proc(pid) if not lp: raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + ''' TODO put this back when env.get_user_name() is implemented user_name = env.get_user_name() ruid = lp.get_real_uid() puser_name = pwd.getpwuid(ruid)[0] if user_name != 'root' and user_name != puser_name: - return ('Fail', {}) + return ('Fail', []) logger = env.get_logger() logger.log_info('User %s sending signal %s to process %d' \ % (user_name, str(param_signal), lp.pid)) + ''' cc = lp.kill(param_signal) if cc < 0: - return ('Fail', {}) - return ('Success', {}) + return ('Fail', []) + return ('Success', []) - def cim_method_requeststatechange(self, env, object_name, method, + def cim_method_requeststatechange(self, env, object_name, param_requestedstate, param_timeoutperiod): # return 'not supported' - return (pywbem.Uint32(1), {}) + return (pywbem.Uint32(1), []) - def cim_method_killall(self, env, object_name, method, + def cim_method_killall(self, env, object_name, param_arg): logger = env.get_logger() logger.log_debug('Entering %s.cim_method_killall()' \ % self.__class__.__name__) user_name = env.get_user_name() if (user_name != 'root'): - return ('Fail', {}) + return ('Fail', []) for lp in LinuxProcess.procs(): if lp.get_exec_name() == param_arg: lp.kill(signal.SIGTERM) - return ('Success', {}) + return ('Success', []) class Values(object): class Status(object): @@ -733,14 +747,14 @@ ## end of class OMC_UnixProcessProvider -class OMC_OSProcessProvider(pywbem.CIMProvider): +class OMC_OSProcessProvider(CIMProvider2): """Instrument the CIM class OMC_OSProcess The relationship between the OperatingSystem and Process(es) running in the context of this OperatingSystem. """ - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -751,7 +765,7 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) @@ -761,25 +775,26 @@ model['GroupComponent'] = get_os_path(model.path.namespace) yield model - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement def delete_instance(self, env, instance_name): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.references()' \ % self.__class__.__name__) + model.path.update({'GroupComponent':None,'PartComponent':None}) + is_subclass = env.get_cimom_handle().is_subclass if object_name.classname.lower() == 'omc_operatingsystem': if role and role.lower() != 'groupcomponent': return if result_role and result_role.lower() != 'partcomponent': return if result_class_name: - if not pywbem.is_subclass(env.get_cimom_handle(), - object_name.namespace, sub='omc_unixprocess', + if not is_subclass(object_name.namespace, sub='omc_unixprocess', super=result_class_name): return for lp in LinuxProcess.procs(): @@ -797,8 +812,8 @@ if result_role and result_role.lower() != 'groupcomponent': return if result_class_name: - if not pywbem.is_subclass(env.get_cimom_handle(), - object_name.namespace, sub='omc_operatingsystem', + if not is_subclass(object_name.namespace, + sub='omc_operatingsystem', super=result_class_name): return lp = LinuxProcess.get_proc(object_name['handle']) @@ -809,14 +824,14 @@ yield model ## end of class OMC_OSProcessProvider -class OMC_ProcessExecutableProvider(pywbem.CIMProvider): +class OMC_ProcessExecutableProvider(CIMProvider2): """Instrument the CIM class OMC_ProcessExecutable A link between a Process and a DataFile indicating that the File participates in the execution of the Process. """ - def get_instance(self, env, model, cim_class): + def get_instance(self, env, model): logger = env.get_logger() logger.log_debug('Entering %s.get_instance()' \ % self.__class__.__name__) @@ -830,7 +845,7 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) return model - def enum_instances(self, env, model, cim_class, keys_only): + def enum_instances(self, env, model, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) @@ -841,18 +856,20 @@ model['Antecedent'] = OMC_LogicalFile.get_file_path(fname, model.path.namespace) yield model - def set_instance(self, env, instance, previous_instance, cim_class): + def set_instance(self, env, instance, modify_existing): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) def delete_instance(self, env, instance_name): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) - def references(self, env, object_name, model, assoc_class, + def references(self, env, object_name, model, result_class_name, role, result_role, keys_only): logger = env.get_logger() logger.log_debug('Entering %s.references()' \ % self.__class__.__name__) + model.path.update({'Dependent':None, 'Antecedent':None}) + is_subclass = env.get_cimom_handle().is_subclass if object_name.classname.lower() == 'omc_unixprocess': if not 'handle' in object_name: return @@ -864,11 +881,10 @@ if result_role and result_role.lower() != 'antecedent': return if result_class_name: - if pywbem.is_subclass(env.get_cimom_handle(), object_name.namespace, + if is_subclass(object_name.namespace, sub=result_class_name, super='omc_datafile'): pass - elif not pywbem.is_subclass(env.get_cimom_handle(), - object_name.namespace, sub='omc_datafile', + elif not is_subclass(object_name.namespace, sub='omc_datafile', super=result_class_name): return model['Dependent'] = object_name @@ -881,14 +897,14 @@ yield model return - if pywbem.is_subclass(env.get_cimom_handle(), object_name.namespace, + if is_subclass(object_name.namespace, sub=object_name.classname, super='omc_datafile'): if role and role.lower() != 'antecedent': return if result_role and result_role.lower() != 'dependent': return if result_class_name: - if not pywbem.is_subclass(env.get_cimom_handle(), object_name.namespace, + if not is_subclass(object_name.namespace, sub='omc_unixprocess', super=result_class_name): return model['Antecedent'] = object_name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <np...@us...> - 2008-09-15 22:23:22
|
Revision: 978 http://omc.svn.sourceforge.net/omc/?rev=978&view=rev Author: npaxton Date: 2008-09-15 22:23:31 +0000 (Mon, 15 Sep 2008) Log Message: ----------- work towards getting UpcallAtom working - includes added a few upcall wrappers, and modifying test to run Modified Paths: -------------- cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py cmpi-bindings/trunk/test/python/UpcallAtom.mof cmpi-bindings/trunk/test/python/UpcallAtomProvider.py Added Paths: ----------- cmpi-bindings/trunk/test/python/UpcallAtom.sfcb.reg Modified: cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py =================================================================== --- cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-09-15 21:35:16 UTC (rev 977) +++ cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-09-15 22:23:31 UTC (rev 978) @@ -57,6 +57,11 @@ raise StopIteration return self.proxy.cmpi2pywbem_instname(val) + def length(self): + if not self.enumeration or not self.enumeration.hasNext(): + return -1; + return self.enumeration.length(); + class CIMInstanceIterator: def __init__(self, proxy, enumeration): self.enumeration = enumeration @@ -73,6 +78,11 @@ raise StopIteration return self.proxy.cmpi2pywbem_inst(val) + def length(self): + if not self.enumeration or not self.enumeration.hasNext(): + return -1; + return self.enumeration.length(); + class BrokerCIMOMHandle(object): def __init__(self, proxy, ctx): self.broker = proxy.broker @@ -122,6 +132,20 @@ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) def EnumerateClasses(self, *args, **kwargs): raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + def CreateClass(self, *args, **kwargs): + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + def DeleteClass(self, *args, **kwargs): + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + def CreateInstance(self, path, instance): + cop = self.proxy.pywbem2cmpi_instname(path) + inst = self.proxy.pywbem2cmpi_inst(instance) + ciname = self.broker.createInstance(self.ctx, cop, inst) + if ciname is None: + return None + return self.proxy.cmpi2pywbem_instname(ciname) + def DeleteInstance(self, path): + cop = self.proxy.pywbem2cmpi_instname(path) + return self.broker.createInstance(self.ctx, cop, inst) ### Not sure whether this should be on BrokerCIMOMHandle or ### on ProviderEnvironment ### We may want to move it ? Modified: cmpi-bindings/trunk/test/python/UpcallAtom.mof =================================================================== --- cmpi-bindings/trunk/test/python/UpcallAtom.mof 2008-09-15 21:35:16 UTC (rev 977) +++ cmpi-bindings/trunk/test/python/UpcallAtom.mof 2008-09-15 22:23:31 UTC (rev 978) @@ -1,5 +1,5 @@ [ Description("Testing up-calls into the CIMOM from a provider")] -class UpcallAtom +class Test_UpcallAtom { [Description("Kickoff the method provider test")] Added: cmpi-bindings/trunk/test/python/UpcallAtom.sfcb.reg =================================================================== --- cmpi-bindings/trunk/test/python/UpcallAtom.sfcb.reg (rev 0) +++ cmpi-bindings/trunk/test/python/UpcallAtom.sfcb.reg 2008-09-15 22:23:31 UTC (rev 978) @@ -0,0 +1,17 @@ +[Test_UpcallAtom] + provider: UpcallAtomProvider + location: pyCmpiProvider + type: method + namespace: root/cimv2 + +[UpcallAtom_Indication] + provider: UpcallAtomProvider + location: pyCmpiProvider + type: indication + namespace: root/cimv2 + +#[UpcallAtom_Indication_Handler] +# provider: UpcallAtomProvider +# location: pyCmpiProvider +# type: instance method indication-handler +# namespace: root/cimv2 Modified: cmpi-bindings/trunk/test/python/UpcallAtomProvider.py =================================================================== --- cmpi-bindings/trunk/test/python/UpcallAtomProvider.py 2008-09-15 21:35:16 UTC (rev 977) +++ cmpi-bindings/trunk/test/python/UpcallAtomProvider.py 2008-09-15 22:23:31 UTC (rev 978) @@ -11,6 +11,7 @@ import os,time,socket import pywbem +from pywbem.cim_provider2 import CIMProvider2 _inst_paths = [] @@ -159,7 +160,7 @@ try: iname = pywbem.CIMInstanceName(classname='Test_Atom', \ keybindings=(keybindings), namespace='root/cimv2') - inst = ch.GetInstance(iname, PropertyList=propertylist) + inst = ch.GetInstance(ch.default_namespace, iname, PropertyList=propertylist) except pywbem.CIMError, arg: raise return inst @@ -172,7 +173,7 @@ """ try: - ta_list = ch.EnumerateInstanceNames('Test_Atom') + ta_list = ch.EnumerateInstanceNames(ch.default_namespace, 'Test_Atom') except pywbem.CIMError, arg: raise return ta_list @@ -185,7 +186,7 @@ """ try: for atom in del_instances: - ch.DeleteInstance(atom) + ch.DeleteInstance(ch.default_namespace, atom) except pywbem.CIMError, arg: raise @@ -199,6 +200,9 @@ new_instance = pywbem.CIMInstance('Test_Atom') new_instance['Name'] = name_of_atom + cop = pywbem.CIMInstanceName(namespace=ch.default_namespace, classname='Test_Atom') + cop['Name'] = name_of_atom + new_instance.path = cop new_instance['boolProp'] = False #new_instance['char16Prop'] = #new_instance['char16Propa'] = Null @@ -249,13 +253,15 @@ try: msg = '' - cipath = ch.CreateInstance(new_instance) + cipath = ch.CreateInstance(cop, new_instance) + print "#*$&#)* Got cipath=%s" %cipath new_instance.path = cipath _inst_paths.append(cipath) except pywbem.CIMError, arg: raise + print "returning new_instance path: %s instance: %s msg: %s" %(cop, new_instance, msg) return new_instance, msg ################################################################################ @@ -268,6 +274,8 @@ if not rval: continue try: + print "rval.path=%s rval=%s" %(rval.path, rval) + print "Trying to GetInstance(%s)" %(rval.path) ci = ch.GetInstance(rval.path) insts.append(ci) except pywbem.CIMError,arg: @@ -280,7 +288,7 @@ global _inst_paths for ipath in _inst_paths: try: - ch.DeleteInstance(ipath) + ch.DeleteInstance(ch.default_namespace, ipath) except pywbem.CIMError,arg: raise '#### Delete Instance failed' _inst_paths = [] @@ -323,7 +331,7 @@ logger.log_debug('#### Python authorize_filter owner: %s' % owner) ################################################################################ -class UpcallAtomProvider(pywbem.CIMProvider): +class UpcallAtomProvider(CIMProvider2): """Instrument the CIM class UpcallAtom Testing up-calls into the CIMOM from a provider @@ -341,7 +349,8 @@ # self.filter_results = False - def cim_method_starttest(self, env, object_name, method): + def cim_method_starttest(self, env, object_name): + print "Got into provider invokeMethod" """Implements UpcallAtom.starttest() Kickoff the method provider test @@ -374,7 +383,7 @@ time = pywbem.CIMDateTime.now() #Create a cimom_handle ch = env.get_cimom_handle() - ch.set_default_namespace("root/cimv2") + ch.default_namespace = "root/cimv2" logger = env.get_logger() logger.log_debug('Entering %s.cim_method_starttest()' \ % self.__class__.__name__) @@ -384,53 +393,59 @@ # 'DeleteInstance', 'DeleteQualifier', 'EnumerateClassNames', 'EnumerateClasses', # 'EnumerateInstanceNames', 'EnumerateInstances', 'EnumerateQualifiers', 'GetClass', # 'GetInstance', 'GetQualifier', 'InvokeMethod', 'ModifyClass', 'ModifyInstance', # 'ReferenceNames', 'References', 'SetQualifier', 'export_indication', # 'set_default_namespace'] #test_1_upcalls - #Written to test associators of OMC_UnixProcess class + #Written to test associators of Linux_UnixProcess class # try: logger.log_debug("Getting AssociatorNames") - ci_list = ch.EnumerateInstanceNames("OMC_UnixProcess") - if ci_list and len(ci_list) > 0: - assoc_names = ch.AssociatorNames(ci_list[0],\ - AssocClass="OMC_OSProcess") #AssocNames - if assoc_names and len(assoc_names) > 0: - #OMC_UnixProcess has an association through OMC_OSProcess - #1. OMC_OperatingSystem + ci_list = ch.EnumerateInstanceNames(ch.default_namespace, "Linux_UnixProcess") + if ci_list and ci_list.length > 0: + ci_entry=ci_list.next() + assoc_names = ch.AssociatorNames(ci_entry,\ + assocClass="Linux_OSProcess") #AssocNames + if assoc_names and assoc_names.length > 0: + #Linux_UnixProcess has an association through Linux_OSProcess + #1. Linux_OperatingSystem for name in assoc_names: - if name['CSCreationClassName'] != 'OMC_UnitaryComputerSystem' \ - and name['CreationClassName'] != 'OMC_OperatingSystem': + if name['CSCreationClassName'] != 'Linux_UnitaryComputerSystem' \ + and name['CreationClassName'] != 'Linux_OperatingSystem': raise "AssociatorName Error: %s" %str(name) - assoc = ch.AssociatorNames(ci_list[0], \ - AssocClass="OMC_ProcessExecutable")#Assoc - if assoc and len(assoc_names) > 0: - #OMC_UnixProcess has an association through OMC_ProcessExecutable - #1. OMC_LinuxDataFile + assoc = ch.AssociatorNames(ci_entry, \ + assocClass="Linux_ProcessExecutable")#Assoc + if assoc and assoc_names.length > 0: + #Linux_UnixProcess has an association through Linux_ProcessExecutable + #1. Linux_LinuxDataFile for inst in assoc: if inst['CSCreationClassName'] != 'CIM_UnitaryComputerSystem' \ - and inst['CreationClassName'] != 'OMC_LinuxDataFile': + and inst['CreationClassName'] != 'Linux_LinuxDataFile': raise "Associator Error: %s" %str(inst) # #CreateClass Method # + ''' try: cim_class = pywbem.CIMClass("Test") - ch.CreateClass(cim_class) + ch.CreateClass(ch.default_namespace, cim_class) except pywbem.CIMError,arg: logger.log_debug("**** CIMError: ch.CreateClass ****") ch.DeleteClass("Test") raise + ''' # #GetClass # + ''' try: _class = ch.GetClass("Test") except pywbem.CIMError,arg: logger.log_debug("**** CIMError: ch.GetClass ****") raise + ''' # #ModifyClass # + ''' try: _class.properties['NewBogusProperty'] = pywbem.CIMProperty('BogProp', None, 'uint64') ch.ModifyClass(_class) @@ -441,10 +456,12 @@ except pywbem.CIMError,arg: logger.log_debug("**** CIMError: ch.ModifyClass ****") raise + ''' # #DeleteClass # + ''' try: ch.DeleteClass("Test") except pywbem.CIMError,arg: @@ -458,10 +475,12 @@ except pywbem.CIMError,arg: if arg[0] != pywbem.CIM_ERR_NOT_FOUND: raise + ''' # #SetQualifier # + ''' try: # Just in case it is still there ch.DeleteQualifier('Bogus') @@ -475,10 +494,12 @@ except pywbem.CIMError, arg: logger.log_debug("**** CIMError: ch.SetQualifier ****") raise + ''' # #GetQualifier # + ''' try: q = ch.GetQualifier('Bogus') copy_q = q.copy() @@ -491,8 +512,10 @@ except pywbem.CIMError,arg: logger.log_debug("**** CIMError: ch.GetQualifier ****") raise + ''' #EnumerateQualifiers + ''' cq_list = ch.EnumerateQualifiers() if not cq_list: raise "EnumerateQualifiers Failed" @@ -506,9 +529,11 @@ raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, '*** CIMError: EnumerateQualifiers did not return ' 'qualifier that was just created') + ''' # #DeleteQualifier # + ''' try: ch.DeleteQualifier('Bogus') except pywbem.CIMError, arg: @@ -522,44 +547,47 @@ except pywbem.CIMError,arg: if arg[0] != pywbem.CIM_ERR_NOT_FOUND: raise + ''' # #InvokeMethod # try: logger.log_debug("**** Calling EnumInstances ****") - list = ch.EnumerateInstanceNames("Novell_DCAMStatGatheringService") - if list and len(list) > 0: + list = ch.EnumerateInstanceNames(ch.default_namespace, "Novell_DCAMStatGatheringService") + if list and list.length() > 0: logger.log_debug("**** Calling GetINstance ****") - service = ch.GetInstance(list[0]) + list_entry = list.next() + service = ch.GetInstance(list_entry) if service: if service['Started']: - ch.InvokeMethod("StopService", list[0]) + ch.InvokeMethod("StopService", list_entry) else: - ch.InvokeMethod("StartService", list[0]) + ch.InvokeMethod("StartService", list.entry) logger.log_debug("**** #2:Calling EnumInstances ****") - list = ch.EnumerateInstanceNames("Novell_DCAMStatGatheringService") - if list and len(list) > 0: + list = ch.EnumerateInstanceNames(ch.default_namespace, "Novell_DCAMStatGatheringService") + if list and list.length() > 0: logger.log_debug("**** #2:Calling GetInstance ****") - service = ch.GetInstance(list[0]) + list_entry = list.next() + service = ch.GetInstance(list_entry) if service: if service['Started']: pass else: - ch.InvokeMethod("StartService", list[0]) + ch.InvokeMethod("StartService", list_entry) except pywbem.CIMError, arg: logger.log_debug("**** CIMError: ch.InvokeMethod ****") #ReferenceNames try: - stat_list = ch.EnumerateInstanceNames("Novell_DCAMStatDef") - if stat_list and len(stat_list) > 0: + stat_list = ch.EnumerateInstanceNames(ch.default_namespace, "Novell_DCAMStatDef") + if stat_list and stat_list.length() > 0: for statdef in stat_list: if statdef['DefinitionID'] == "machine_type": ref_list = ch.ReferenceNames(statdef) - if ref_list and len(ref_list) > 0: + if ref_list and ref_list.length > 0: for ref in ref_list: cn = ref.classname if cn == "Novell_DCAMCurrentValueForStatDef" or\ @@ -575,12 +603,12 @@ #Reference try: - stat_list = ch.EnumerateInstanceNames("Novell_DCAMStatDef") - if stat_list and len(stat_list) > 0: + stat_list = ch.EnumerateInstanceNames(ch.default_namespace, "Novell_DCAMStatDef") + if stat_list and stat_list.length() > 0: for statdef in stat_list: if statdef['DefinitionID'] == "machine_type": ref_list = ch.References(statdef) - if ref_list and len(ref_list) > 0: + if ref_list and ref_list.length() > 0: for ref in ref_list: cn = ref.classname if cn == "Novell_DCAMCurrentValueForStatDef" or\ @@ -603,6 +631,8 @@ ################################################################################ # #test_2_create_instance + print "test_2_create_instance" + ''' try: insts = _setup(ch, time, env) for inst in insts: @@ -612,35 +642,45 @@ _cleanup(ch) except pywbem.CIMError, arg: raise "**** CreateInstance Failed ****" + ''' ################################################################################ #test_3_enum_instances #Test enumeration of instances and then compare them with the local # storage dictionary + print "test_3_enum_instances" insts = _setup(ch, time, env) paths = [] ta_list = [] try: - ta_list = ch.EnumerateInstances('Test_Atom') + ta_list = ch.EnumerateInstances(ch.default_namespace, 'Test_Atom') except pywbem.CIMError, arg: raise 'EnumerateInstances failed: %s' % str(arg) try: - paths = ch.EnumerateInstanceNames('Test_Atom') + paths = ch.EnumerateInstanceNames(ch.default_namespace, 'Test_Atom') except pywbem.CIMError, arg: raise 'EnumerateInstanceNames failed: %s' % str(arg) - if len(paths) != len(ta_list): - raise 'EnumerateInstances returned different number of '\ - 'results than EnumerateInstanceNames' + if paths.length() != ta_list.length(): + raise 'EnumerateInstances (%s) returned different number of '\ + 'results than EnumerateInstanceNames (%s)' %(ta_list.length(), paths.length()) + print "1" + for ci in insts:#Loop through instances + print "2: ci.path=%s" %ci.path + print "ta_list.length()=%d" %ta_list.length() + print "ta_list: %s" %ta_list for rci in ta_list: + print "3" print '==== rci.path:',str(rci.path) print '==== ci.path:',str(ci.path) if rci.path != ci.path: continue else: + print "4" rval = _compare_values(rci, time, logger) + print "5" if rval: break else: @@ -653,19 +693,20 @@ ################################################################################ #test_4_enum_instance_names #Test enumeration of names + print "test_4_enum_instance_names" insts = _setup(ch, time, env) try: - ta_list = ch.EnumerateInstanceNames('Test_Atom') + ta_list = ch.EnumerateInstanceNames(ch.default_namespace, 'Test_Atom') except pywbem.CIMError, arg: raise 'EnumerateInstanceNames Failed: %s' % str(arg) try: - instances = ch.EnumerateInstances('Test_Atom') + instances = ch.EnumerateInstances(ch.default_namespace, 'Test_Atom') except pywbem.CIMError, arg: raise 'EnumerateInstances Failed: %s' % str(arg) - if len(instances) != len(ta_list): + if instances.length() != ta_list.length(): raise 'EnumerateInstances returned different number of '\ 'results than EnumerateInstanceNames' @@ -735,7 +776,7 @@ mod_instance['Name'] = 'Boron' try: - ch.ModifyInstance(mod_instance) + ch.ModifyInstance(ch.default_namespace, mod_instance) except pywbem.CIMError, arg: raise @@ -774,13 +815,13 @@ del_instances = _get_instance_names(ch) for inst in del_instances: try: - ch.DeleteInstance(inst) + ch.DeleteInstance(ch.default_namespace, inst) except pywbem.CIMError, arg: raise 'DeleteInstance Failed: %s' % str(arg) else: for inst in del_instances: try: - ch.DeleteInstance(inst) + ch.DeleteInstance(ch.default_namespace, inst) except pywbem.CIMError, arg: if arg[0] != pywbem.CIM_ERR_NOT_FOUND: raise 'Unexpected exception on delete: %s' % str(arg) @@ -790,14 +831,14 @@ rval = "Finished testing Upcalls..." # TODO (type pywbem.Sint32) return (rval, out_params) - def cim_method_send_indication(self, env, object_name, method): + def cim_method_send_indication(self, env, object_name): """ Method to test the upcalls to the cimom handle for export_indications. """ global _indication_names,_indication_count cimtime = pywbem.CIMDateTime.now() ch = env.get_cimom_handle() - ch.set_default_namespace("root/cimv2") + ch.default_namespace = "root/cimv2" logger = env.get_logger() @@ -813,13 +854,13 @@ try: print '### Exporting indication. pid:',os.getpid() - ch.export_indication(alert_ind) + ch.export_indication(ch.default_namespace, alert_ind) print '### Done exporting indication' except pywbem.CIMError, arg: print '### Caught exception exporting indication' raise - indcount = len(_indication_names) + indcount = _indication_names.length() st = time.time() while _indication_count < indcount: time.sleep(.01) @@ -839,4 +880,4 @@ def get_providers(env): upcallatom_prov = UpcallAtomProvider(env) - return {'UpcallAtom': upcallatom_prov} + return {'Test_UpcallAtom': upcallatom_prov} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-15 21:35:08
|
Revision: 977 http://omc.svn.sourceforge.net/omc/?rev=977&view=rev Author: bartw Date: 2008-09-15 21:35:16 +0000 (Mon, 15 Sep 2008) Log Message: ----------- removed openwbem registration files Removed Paths: ------------- pybase/trunk/OMC_ComputerSystem-ow.reg pybase/trunk/OMC_InitdService-ow.reg pybase/trunk/OMC_LogicalFile-ow.reg pybase/trunk/OMC_OperatingSystem-ow.reg pybase/trunk/OMC_TimeService-ow.reg pybase/trunk/OMC_UnixProcess-ow.reg Deleted: pybase/trunk/OMC_ComputerSystem-ow.reg =================================================================== --- pybase/trunk/OMC_ComputerSystem-ow.reg 2008-09-15 21:31:55 UTC (rev 976) +++ pybase/trunk/OMC_ComputerSystem-ow.reg 2008-09-15 21:35:16 UTC (rev 977) @@ -1,18 +0,0 @@ -// Provider registration for OMC_UnitaryComputerSystem -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_UnitaryComputerSystem:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_UnitaryComputerSystem"; - ProviderTypes = {1,6}; // Instance, Method - ModulePath = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; -}; - -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_UnitaryComputerSystem:02"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_HostNameSettingData"; - ProviderTypes = {1}; // Instance - ModulePath = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; -}; Deleted: pybase/trunk/OMC_InitdService-ow.reg =================================================================== --- pybase/trunk/OMC_InitdService-ow.reg 2008-09-15 21:31:55 UTC (rev 976) +++ pybase/trunk/OMC_InitdService-ow.reg 2008-09-15 21:35:16 UTC (rev 977) @@ -1,10 +0,0 @@ -// Provider registration for OMC_InitdService -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_InitdService:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_InitdService"; - ProviderTypes = {1,6}; // Instance, Method - ModulePath = "/usr/lib/pycim/OMC_InitdService.py"; -}; - Deleted: pybase/trunk/OMC_LogicalFile-ow.reg =================================================================== --- pybase/trunk/OMC_LogicalFile-ow.reg 2008-09-15 21:31:55 UTC (rev 976) +++ pybase/trunk/OMC_LogicalFile-ow.reg 2008-09-15 21:35:16 UTC (rev 977) @@ -1,82 +0,0 @@ - -// Provider registration for OMC_LinuxDirectoryContainsFile -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_LinuxDirectoryContainsFile:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_LinuxDirectoryContainsFile"; - ProviderTypes = {1,3}; // Instance, Associator - ModulePath = "/usr/lib/pycim/OMC_LogicalFile.py"; -}; - -// Provider registration for OMC_LinuxFileIdentity -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_LinuxFileIdentity:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_LinuxFileIdentity"; - ProviderTypes = {1,3}; // Instance, Associator - ModulePath = "/usr/lib/pycim/OMC_LogicalFile.py"; -}; - -// Provider registration for OMC_LinuxFile -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_LinuxFile:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_LinuxFile"; - ProviderTypes = {1}; // Instance - ModulePath = "/usr/lib/pycim/OMC_LogicalFile.py"; -}; - -// Provider registration for OMC_LinuxDataFile -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_LinuxDataFile:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_LinuxDataFile"; - ProviderTypes = {1,6}; // Instance, Method - ModulePath = "/usr/lib/pycim/OMC_LogicalFile.py"; -}; - -// Provider registration for OMC_LinuxDeviceFile -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_LinuxDeviceFile:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_LinuxDeviceFile"; - ProviderTypes = {1}; // Instance - ModulePath = "/usr/lib/pycim/OMC_LogicalFile.py"; -}; - -// Provider registration for OMC_LinuxDirectory -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_LinuxDirectory:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_LinuxDirectory"; - ProviderTypes = {1}; // Instance - ModulePath = "/usr/lib/pycim/OMC_LogicalFile.py"; -}; - -// Provider registration for OMC_LinuxFIFOPipeFile -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_LinuxFIFOPipeFile:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_LinuxFIFOPipeFile"; - ProviderTypes = {1}; // Instance - ModulePath = "/usr/lib/pycim/OMC_LogicalFile.py"; -}; - -// Provider registration for OMC_LinuxSymbolicLink -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_LinuxSymbolicLink:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_LinuxSymbolicLink"; - ProviderTypes = {1}; // Instance - ModulePath = "/usr/lib/pycim/OMC_LogicalFile.py"; -}; - - Deleted: pybase/trunk/OMC_OperatingSystem-ow.reg =================================================================== --- pybase/trunk/OMC_OperatingSystem-ow.reg 2008-09-15 21:31:55 UTC (rev 976) +++ pybase/trunk/OMC_OperatingSystem-ow.reg 2008-09-15 21:35:16 UTC (rev 977) @@ -1,29 +0,0 @@ -// Provider registration for OMC_OperatingSystem -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_OperatingSystem:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_OperatingSystem"; - ProviderTypes = {1,6}; // Instance, Method - ModulePath = "/usr/lib/pycim/OMC_OperatingSystem.py"; -}; - -// Provider registration for OMC_InstalledOS -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_InstalledOS:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_InstalledOS"; - ProviderTypes = {1,3}; // Instance, Associator - ModulePath = "/usr/lib/pycim/OMC_OperatingSystem.py"; -}; - -// Provider registration for OMC_InstalledOS -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_RunningOS:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_RunningOS"; - ProviderTypes = {1,3}; // Instance, Associator - ModulePath = "/usr/lib/pycim/OMC_OperatingSystem.py"; -}; Deleted: pybase/trunk/OMC_TimeService-ow.reg =================================================================== --- pybase/trunk/OMC_TimeService-ow.reg 2008-09-15 21:31:55 UTC (rev 976) +++ pybase/trunk/OMC_TimeService-ow.reg 2008-09-15 21:35:16 UTC (rev 977) @@ -1,66 +0,0 @@ -// OpenWBEM Provider registration for OMC_TimeService -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC_TimeService:0001"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_SystemTimeService"; - ProviderTypes = {1,6}; // Instance, Method - ModulePath = "/usr/lib/pycim/OMC_TimeService.py"; -}; - -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC_TimeService:0002"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_RemoteTimeServicePort"; - ProviderTypes = {1,6}; // Instance, Method - ModulePath = "/usr/lib/pycim/OMC_TimeService.py"; -}; - -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC_TimeService:0003"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_TimeZoneSettingData"; - ProviderTypes = {1}; // Instance - ModulePath = "/usr/lib/pycim/OMC_TimeService.py"; -}; - -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC_TimeService:0004"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_HostedTimeService"; - ProviderTypes = {1,3}; // Instance, Associator - ModulePath = "/usr/lib/pycim/OMC_TimeService.py"; -}; - -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC_TimeService:0005"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_TimeServiceAccessBySAP"; - ProviderTypes = {1,3}; // Instance, Associator - ModulePath = "/usr/lib/pycim/OMC_TimeService.py"; -}; - -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC_TimeService:0006"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_TimeServiceTimeZoneSettingData"; - ProviderTypes = {1,3}; // Instance, Associator - ModulePath = "/usr/lib/pycim/OMC_TimeService.py"; -}; - -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC_TimeService:0007"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_TimeServiceAvailableToElement"; - ProviderTypes = {1,3}; // Instance, Associator - ModulePath = "/usr/lib/pycim/OMC_TimeService.py"; -}; - - - Deleted: pybase/trunk/OMC_UnixProcess-ow.reg =================================================================== --- pybase/trunk/OMC_UnixProcess-ow.reg 2008-09-15 21:31:55 UTC (rev 976) +++ pybase/trunk/OMC_UnixProcess-ow.reg 2008-09-15 21:35:16 UTC (rev 977) @@ -1,30 +0,0 @@ -// Provider registration for OMC_UnixProcess -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_UnixProcess:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_UnixProcess"; - ProviderTypes = {1,6}; // Instance, Method - ModulePath = "/usr/lib/pycim/OMC_UnixProcess.py"; -}; - -// Provider registration for OMC_ProcessExecutable -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_ProcessExecutable:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_ProcessExecutable"; - ProviderTypes = {1,3}; // Instance, Associator - ModulePath = "/usr/lib/pycim/OMC_UnixProcess.py"; -}; - -// Provider registration for OMC_OSProcess -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_OSProcess:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_OSProcess"; - ProviderTypes = {1,3}; // Instance, Associator - ModulePath = "/usr/lib/pycim/OMC_UnixProcess.py"; -}; - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-15 21:31:49
|
Revision: 976 http://omc.svn.sourceforge.net/omc/?rev=976&view=rev Author: bartw Date: 2008-09-15 21:31:55 +0000 (Mon, 15 Sep 2008) Log Message: ----------- OMC_UnitaryComputerSystem -> OMC_ComputerSystem Modified Paths: -------------- pybase/trunk/OMC_Base.mof pybase/trunk/OMC_ComputerSystem-peg.reg pybase/trunk/OMC_ComputerSystem.mof pybase/trunk/OMC_ComputerSystem.py pybase/trunk/OMC_InitdService.mof pybase/trunk/OMC_InitdService.py pybase/trunk/OMC_LogicalFile.py pybase/trunk/OMC_OperatingSystem.mof pybase/trunk/OMC_OperatingSystem.py pybase/trunk/OMC_SyslogNG.py pybase/trunk/OMC_TimeService.mof pybase/trunk/OMC_TimeService.py pybase/trunk/OMC_UnixProcess.py pybase/trunk/setup.py Modified: pybase/trunk/OMC_Base.mof =================================================================== --- pybase/trunk/OMC_Base.mof 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_Base.mof 2008-09-15 21:31:55 UTC (rev 976) @@ -1,4 +1,4 @@ -#pragma include ("OMC_UnitaryComputerSystem.mof") +#pragma include ("OMC_ComputerSystem.mof") #pragma include ("OMC_OperatingSystem.mof") #pragma include ("OMC_LogicalFile.mof") #pragma include ("OMC_UnixProcess.mof") Modified: pybase/trunk/OMC_ComputerSystem-peg.reg =================================================================== --- pybase/trunk/OMC_ComputerSystem-peg.reg 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_ComputerSystem-peg.reg 2008-09-15 21:31:55 UTC (rev 976) @@ -1,10 +1,10 @@ -//////// OMC_UnitaryComputerSystem +//////// OMC_ComputerSystem instance of PG_ProviderModule { - Name = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; + Name = "/usr/lib/pycim/OMC_ComputerSystem.py"; InterfaceType = "Python"; InterfaceVersion = "1.0.0"; - Location = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; + Location = "/usr/lib/pycim/OMC_ComputerSystem.py"; UserContext = 2; // Requestor Vendor = "OMC"; Version = "0.1.0"; @@ -12,16 +12,16 @@ instance of PG_Provider { - Name = "OMC_UnitaryComputerSystem"; - ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; + Name = "OMC_ComputerSystem"; + ProviderModuleName = "/usr/lib/pycim/OMC_ComputerSystem.py"; }; instance of PG_ProviderCapabilities { - CapabilityID = "OMC_UnitaryComputerSystem"; - ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; - ProviderName = "OMC_UnitaryComputerSystem"; - ClassName = "OMC_UnitaryComputerSystem"; + CapabilityID = "OMC_ComputerSystem"; + ProviderModuleName = "/usr/lib/pycim/OMC_ComputerSystem.py"; + ProviderName = "OMC_ComputerSystem"; + ClassName = "OMC_ComputerSystem"; Namespaces = {"root/cimv2"}; ProviderType = {2,5}; // Instance, Method }; @@ -29,8 +29,8 @@ instance of PG_ProviderCapabilities { CapabilityID = "OMC_HostNameSettingData"; - ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; - ProviderName = "OMC_UnitaryComputerSystem"; + ProviderModuleName = "/usr/lib/pycim/OMC_ComputerSystem.py"; + ProviderName = "OMC_ComputerSystem"; ClassName = "OMC_HostNameSettingData"; Namespaces = {"root/cimv2"}; ProviderType = {2}; // Instance @@ -39,8 +39,8 @@ instance of PG_ProviderCapabilities { CapabilityID = "OMC_ComputerSystemHostNameSettingData"; - ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; - ProviderName = "OMC_UnitaryComputerSystem"; + ProviderModuleName = "/usr/lib/pycim/OMC_ComputerSystem.py"; + ProviderName = "OMC_ComputerSystem"; ClassName = "OMC_ComputerSystemHostNameSettingData"; Namespaces = {"root/cimv2"}; ProviderType = {2,3}; // Instance, Associator Modified: pybase/trunk/OMC_ComputerSystem.mof =================================================================== --- pybase/trunk/OMC_ComputerSystem.mof 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_ComputerSystem.mof 2008-09-15 21:31:55 UTC (rev 976) @@ -2,8 +2,8 @@ ////////////////////////////////////////////////////////////////////////////// -[ Description("OMC Unitary Computer System"), Version("0.0.1") ] -class OMC_UnitaryComputerSystem : CIM_UnitaryComputerSystem +[ Description("OMC Computer System"), Version("0.0.1") ] +class OMC_ComputerSystem : CIM_ComputerSystem { }; Modified: pybase/trunk/OMC_ComputerSystem.py =================================================================== --- pybase/trunk/OMC_ComputerSystem.py 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_ComputerSystem.py 2008-09-15 21:31:55 UTC (rev 976) @@ -28,9 +28,9 @@ # POSSIBILITY OF SUCH DAMAGE. # #*****************************************************************************/ -"""Python Provider for OMC_UnitaryComputerSystem +"""Python Provider for OMC_ComputerSystem -Instruments the CIM class OMC_UnitaryComputerSystem +Instruments the CIM class OMC_ComputerSystem """ @@ -38,10 +38,10 @@ from pywbem import CIMProvider from socket import getfqdn -class OMC_UnitaryComputerSystemProvider(CIMProvider): - """Instrument the CIM class OMC_UnitaryComputerSystem +class OMC_ComputerSystemProvider(CIMProvider): + """Instrument the CIM class OMC_ComputerSystem - OMC Unitary Computer System + OMC Computer System """ @@ -132,7 +132,7 @@ % self.__class__.__name__) # Key properties - model['CreationClassName'] = 'OMC_UnitaryComputerSystem' + model['CreationClassName'] = 'OMC_ComputerSystem' model['Name'] = getfqdn() if keys_only: yield model @@ -212,7 +212,7 @@ def cim_method_requeststatechange(self, env, object_name, method, param_requestedstate, param_timeoutperiod): - """Implements OMC_UnitaryComputerSystem.RequestStateChange() + """Implements OMC_ComputerSystem.RequestStateChange() Requests that the state of the element be changed to the value specified in the RequestedState parameter. When the requested @@ -276,7 +276,7 @@ def cim_method_setpowerstate(self, env, object_name, method, param_powerstate, param_time): - """Implements OMC_UnitaryComputerSystem.SetPowerState() + """Implements OMC_ComputerSystem.SetPowerState() Sets the power state of the computer. The use of this method has been deprecated. Instead, use the SetPowerState method in the @@ -534,13 +534,13 @@ # DMTF_Reserved = .. # Vendor_Reserved = 32768..65535 -## end of class OMC_UnitaryComputerSystemProvider +## end of class OMC_ComputerSystemProvider def get_providers(env): # register provider - omc_unitarycomputersystem_prov = OMC_UnitaryComputerSystemProvider() - return {'OMC_UnitaryComputerSystem': omc_unitarycomputersystem_prov} + omc_computersystem_prov = OMC_ComputerSystemProvider() + return {'OMC_ComputerSystem': omc_computersystem_prov} Modified: pybase/trunk/OMC_InitdService.mof =================================================================== --- pybase/trunk/OMC_InitdService.mof 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_InitdService.mof 2008-09-15 21:31:55 UTC (rev 976) @@ -150,7 +150,7 @@ { [ Override("Antecedent"), Min(1), Max(1), Description("The hosting system") ] - OMC_UnitaryComputerSystem REF Antecedent; + OMC_ComputerSystem REF Antecedent; [ Override("Dependent"), Weak, Min(0), Description("The hosted init.d service") ] @@ -165,7 +165,7 @@ { [ Override("Antecedent"), Min(1), Max(1), Description("The hosting system") ] - OMC_UnitaryComputerSystem REF Antecedent; + OMC_ComputerSystem REF Antecedent; [ Override("Dependent"), Weak, Min(0), Description("The hosted runlevel") ] Modified: pybase/trunk/OMC_InitdService.py =================================================================== --- pybase/trunk/OMC_InitdService.py 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_InitdService.py 2008-09-15 21:31:55 UTC (rev 976) @@ -186,7 +186,7 @@ % self.__class__.__name__) model['SystemName'] = getfqdn() - model['SystemCreationClassName'] = 'OMC_UnitaryComputerSystem' + model['SystemCreationClassName'] = 'OMC_ComputerSystem' model['CreationClassName'] = 'OMC_InitdService' for file in os.listdir('/etc/init.d'): fullpath = '/etc/init.d/'+file Modified: pybase/trunk/OMC_LogicalFile.py =================================================================== --- pybase/trunk/OMC_LogicalFile.py 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_LogicalFile.py 2008-09-15 21:31:55 UTC (rev 976) @@ -128,7 +128,7 @@ else: map['Name'] = fname map['CreationClassName'] = ccname - map['CSCreationClassName'] = 'CIM_UnitaryComputerSystem' + map['CSCreationClassName'] = 'CIM_ComputerSystem' map['CSName'] = getfqdn() map['FSCreationClassName'] = 'CIM_FileSystem' try: Modified: pybase/trunk/OMC_OperatingSystem.mof =================================================================== --- pybase/trunk/OMC_OperatingSystem.mof 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_OperatingSystem.mof 2008-09-15 21:31:55 UTC (rev 976) @@ -44,7 +44,7 @@ [Override ( "Dependent" ), Max ( 1 ), Description ( "The ComputerSystem.")] - OMC_UnitaryComputerSystem REF Dependent; + OMC_ComputerSystem REF Dependent; }; // =================================================================== @@ -63,7 +63,7 @@ [Aggregate, Override ( "GroupComponent" ), Min ( 1 ), Max ( 1 ), Description ( "The ComputerSystem.")] - OMC_UnitaryComputerSystem REF GroupComponent; + OMC_ComputerSystem REF GroupComponent; [Override ( "PartComponent" ), Weak, Description ( "The OperatingSystem installed on the ComputerSystem.")] Modified: pybase/trunk/OMC_OperatingSystem.py =================================================================== --- pybase/trunk/OMC_OperatingSystem.py 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_OperatingSystem.py 2008-09-15 21:31:55 UTC (rev 976) @@ -55,7 +55,7 @@ def get_os_path(ns): return pywbem.CIMInstanceName(classname='OMC_OperatingSystem', namespace=ns, - keybindings={'CSCreationClassName': 'OMC_UnitaryComputerSystem', + keybindings={'CSCreationClassName': 'OMC_ComputerSystem', 'CreationClassName': 'OMC_OperatingSystem', 'Name': 'Linux', 'CSName': getfqdn()}) @@ -156,7 +156,7 @@ % self.__class__.__name__) # Key properties - model['CSCreationClassName'] = 'OMC_UnitaryComputerSystem' + model['CSCreationClassName'] = 'OMC_ComputerSystem' model['CreationClassName'] = 'OMC_OperatingSystem' model['Name'] = 'Linux' model['CSName'] = getfqdn() @@ -456,13 +456,13 @@ os = pywbem.CIMInstanceName('OMC_OperatingSystem', namespace=model.path.namespace, - keybindings={'CSCreationClassName':'OMC_UnitaryComputerSystem', + keybindings={'CSCreationClassName':'OMC_ComputerSystem', 'CreationClassName':'OMC_OperatingSystem', 'Name':'Linux', 'CSName':getfqdn()}) - cs = pywbem.CIMInstanceName('OMC_UnitaryComputerSystem', + cs = pywbem.CIMInstanceName('OMC_ComputerSystem', namespace=model.path.namespace, - keybindings={'CreationClassName':'OMC_UnitaryComputerSystem', + keybindings={'CreationClassName':'OMC_ComputerSystem', 'Name':getfqdn()}) if model.classname.lower() == 'omc_installedos': @@ -499,9 +499,9 @@ cs = 'Dependent' os = 'Antecedent' model[cs] = pywbem.CIMInstanceName( - classname='OMC_UnitaryComputerSystem', + classname='OMC_ComputerSystem', namespace=object_name.namespace, - keybindings={'CreationClassName':'OMC_UnitaryComputerSystem', + keybindings={'CreationClassName':'OMC_ComputerSystem', 'Name':getfqdn()}) model[os] = get_os_path(object_name.namespace) yield model Modified: pybase/trunk/OMC_SyslogNG.py =================================================================== --- pybase/trunk/OMC_SyslogNG.py 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_SyslogNG.py 2008-09-15 21:31:55 UTC (rev 976) @@ -781,8 +781,8 @@ % self.__class__.__name__) for log in _get_syslog_list(): - model['Dependent'] = pywbem.CIMInstanceName('OMC_UnitaryComputerSystem', - keybindings={'CreationClassName':'OMC_UnitaryComputerSystem', + model['Dependent'] = pywbem.CIMInstanceName('OMC_ComputerSystem', + keybindings={'CreationClassName':'OMC_ComputerSystem', 'Name':getfqdn()}, namespace=model.path.namespace) model['Antecedent'] = pywbem.CIMInstanceName('OMC_SyslogNGRecordLog', @@ -824,7 +824,7 @@ % self.__class__.__name__) ch = env.get_cimom_handle() if (not role or role.lower() == 'dependent') and \ - object_name.classname.lower() == 'omc_unitarycomputersystem': + object_name.classname.lower() == 'omc_computersystem': model['Dependent'] = object_name for log in _get_syslog_list(): model['Antecedent'] = pywbem.CIMInstanceName('OMC_SyslogNGRecordLog', @@ -835,8 +835,8 @@ if (not role or role.lower() == 'antecedent') and \ object_name.classname.lower() == 'omc_syslogngrecordlog': model['Antecedent'] = object_name - model['Dependent'] = pywbem.CIMInstanceName('OMC_UnitaryComputerSystem', - keybindings={'CreationClassName':'OMC_UnitaryComputerSystem', + model['Dependent'] = pywbem.CIMInstanceName('OMC_ComputerSystem', + keybindings={'CreationClassName':'OMC_ComputerSystem', 'Name':getfqdn()}, namespace=object_name.namespace) yield model Modified: pybase/trunk/OMC_TimeService.mof =================================================================== --- pybase/trunk/OMC_TimeService.mof 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_TimeService.mof 2008-09-15 21:31:55 UTC (rev 976) @@ -163,7 +163,7 @@ { [ Override("Antecedent"), Min(1), Max(1), Description("The hosting computer system") ] - OMC_UnitaryComputerSystem REF Antecedent; + OMC_ComputerSystem REF Antecedent; [ Override("Dependent"), Weak, Description("The hosted system time service") ] Modified: pybase/trunk/OMC_TimeService.py =================================================================== --- pybase/trunk/OMC_TimeService.py 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_TimeService.py 2008-09-15 21:31:55 UTC (rev 976) @@ -100,7 +100,7 @@ def fill_cim_obj(self, model, keys_only=False): global ntp_inst_date model['SystemName'] = _fqdn - model['SystemCreationClassName'] = 'OMC_UnitaryComputerSystem' + model['SystemCreationClassName'] = 'OMC_ComputerSystem' model['CreationClassName'] = 'OMC_RemoteTimeServicePort' model['Name'] = self.server_name if keys_only: @@ -328,7 +328,7 @@ if 'CreationClassName' not in model \ or 'Name' not in model: return False - if model['CreationClassName'].lower() != 'omc_unitarycomputersystem': + if model['CreationClassName'].lower() != 'omc_computersystem': return False return model['Name'].lower() == _fqdn.lower() @@ -337,7 +337,7 @@ for nm in ['SystemCreationClassName', 'SystemName', 'CreationClassName', 'Name']: if nm not in model: return False - if model['SystemCreationClassName'].lower() != 'omc_unitarycomputersystem': + if model['SystemCreationClassName'].lower() != 'omc_computersystem': return False if model['SystemName'].lower() != _fqdn.lower(): return False @@ -347,7 +347,7 @@ ############################################################################### def _fill_service_instance(model, keys_only): - model['SystemCreationClassName'] = 'OMC_UnitaryComputerSystem' + model['SystemCreationClassName'] = 'OMC_ComputerSystem' model['SystemName'] = _fqdn model['CreationClassName'] = 'OMC_SystemTimeService' model['Name'] = 'timeservice' @@ -512,9 +512,9 @@ logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) model['Antecedent'] = pywbem.CIMInstanceName( - classname='OMC_UnitaryComputerSystem', + classname='OMC_ComputerSystem', namespace=model.path.namespace, - keybindings={'CreationClassName':'OMC_UnitaryComputerSystem', + keybindings={'CreationClassName':'OMC_ComputerSystem', 'Name':_fqdn}) ref = pywbem.CIMInstanceName(classname='OMC_SystemTimeService', namespace=model.path.namespace) @@ -545,18 +545,18 @@ return if result_class_name: if not pywbem.is_subclass(env.get_cimom_handle(), - object_name.namespace, sub='omc_unitarycomputersystem', + object_name.namespace, sub='omc_computersystem', super=result_class_name): return model['Dependent'] = object_name model['Antecedent'] = pywbem.CIMInstanceName( - classname='OMC_UnitaryComputerSystem', + classname='OMC_ComputerSystem', namespace=object_name.namespace, - keybindings={'CreationClassName':'OMC_UnitaryComputerSystem', + keybindings={'CreationClassName':'OMC_ComputerSystem', 'Name':_fqdn}) yield model - elif object_name.classname.lower() == 'omc_unitarycomputersystem': + elif object_name.classname.lower() == 'omc_computersystem': if not _is_cs_ref(object_name): return if role and role.lower() != 'antecedent': @@ -1058,9 +1058,9 @@ logger.log_debug('Entering %s.enum_instances()' \ % self.__class__.__name__) model['userofservice'] = pywbem.CIMInstanceName( - classname='OMC_UnitaryComputerSystem', + classname='OMC_ComputerSystem', namespace=model.path.namespace, - keybindings={'CreationClassName':'OMC_UnitaryComputerSystem', + keybindings={'CreationClassName':'OMC_ComputerSystem', 'Name':_fqdn}) ref = pywbem.CIMInstanceName(classname='OMC_SystemTimeService', namespace=model.path.namespace) @@ -1089,20 +1089,20 @@ return if result_class_name: if not pywbem.is_subclass(ch, object_name.namespace, - sub='omc_unitarycomputersystem', + sub='omc_computersystem', super=result_class_name): return if not _is_service_ref(object_name): return model['serviceprovided'] = object_name model['userofservice'] = pywbem.CIMInstanceName( - classname='OMC_UnitaryComputerSystem', + classname='OMC_ComputerSystem', namespace=object_name.namespace, - keybindings={'CreationClassName':'OMC_UnitaryComputerSystem', + keybindings={'CreationClassName':'OMC_ComputerSystem', 'Name':_fqdn}) yield model - elif object_name.classname.lower() == 'omc_unitarycomputersystem': + elif object_name.classname.lower() == 'omc_computersystem': if role and role.lower() != 'userofservice': return if result_role and result_role.lower() != 'serviceprovided': Modified: pybase/trunk/OMC_UnixProcess.py =================================================================== --- pybase/trunk/OMC_UnixProcess.py 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/OMC_UnixProcess.py 2008-09-15 21:31:55 UTC (rev 976) @@ -212,7 +212,7 @@ keybindings={'OSCreationClassName':'OMC_OperatingSystem', 'CreationClassName':'OMC_UnixProcess', 'Handle':str(self.pid), - 'CSCreationClassName':'OMC_UnitaryComputerSystem', + 'CSCreationClassName':'OMC_ComputerSystem', 'OSName':'Linux', 'CSName':getfqdn()}) @@ -461,7 +461,7 @@ ux(OSCreationClassName= 'OMC_OperatingSystem') ux(CreationClassName= 'OMC_UnixProcess') ux(Handle= str(lp.pid)) - ux(CSCreationClassName= 'OMC_UnitaryComputerSystem') + ux(CSCreationClassName= 'OMC_ComputerSystem') ux(OSName= 'Linux') ux(CSName= getfqdn()) if keys_only: Modified: pybase/trunk/setup.py =================================================================== --- pybase/trunk/setup.py 2008-09-15 21:30:47 UTC (rev 975) +++ pybase/trunk/setup.py 2008-09-15 21:31:55 UTC (rev 976) @@ -22,7 +22,7 @@ py_modules=['OMC_InitdService', 'OMC_LogicalFile', 'OMC_OperatingSystem', - 'OMC_UnitaryComputerSystem', + 'OMC_ComputerSystem', 'OMC_UnixProcess', 'OMC_SyslogNG', 'OMC_TimeService',] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-15 21:30:38
|
Revision: 975 http://omc.svn.sourceforge.net/omc/?rev=975&view=rev Author: bartw Date: 2008-09-15 21:30:47 +0000 (Mon, 15 Sep 2008) Log Message: ----------- OMC_UnitaryComputerSystem -> OMC_ComputerSystem Added Paths: ----------- pybase/trunk/OMC_ComputerSystem-ow.reg pybase/trunk/OMC_ComputerSystem-peg.reg pybase/trunk/OMC_ComputerSystem.mof pybase/trunk/OMC_ComputerSystem.py Removed Paths: ------------- pybase/trunk/OMC_UnitaryComputerSystem-ow.reg pybase/trunk/OMC_UnitaryComputerSystem-peg.reg pybase/trunk/OMC_UnitaryComputerSystem.mof pybase/trunk/OMC_UnitaryComputerSystem.py Copied: pybase/trunk/OMC_ComputerSystem-ow.reg (from rev 974, pybase/trunk/OMC_UnitaryComputerSystem-ow.reg) =================================================================== --- pybase/trunk/OMC_ComputerSystem-ow.reg (rev 0) +++ pybase/trunk/OMC_ComputerSystem-ow.reg 2008-09-15 21:30:47 UTC (rev 975) @@ -0,0 +1,18 @@ +// Provider registration for OMC_UnitaryComputerSystem +instance of OpenWBEM_PyProviderRegistration +{ + InstanceID = "OMC:OMC_UnitaryComputerSystem:01"; + NamespaceNames = {"root/cimv2"}; + ClassName = "OMC_UnitaryComputerSystem"; + ProviderTypes = {1,6}; // Instance, Method + ModulePath = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; +}; + +instance of OpenWBEM_PyProviderRegistration +{ + InstanceID = "OMC:OMC_UnitaryComputerSystem:02"; + NamespaceNames = {"root/cimv2"}; + ClassName = "OMC_HostNameSettingData"; + ProviderTypes = {1}; // Instance + ModulePath = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; +}; Property changes on: pybase/trunk/OMC_ComputerSystem-ow.reg ___________________________________________________________________ Added: svn:mergeinfo + Copied: pybase/trunk/OMC_ComputerSystem-peg.reg (from rev 974, pybase/trunk/OMC_UnitaryComputerSystem-peg.reg) =================================================================== --- pybase/trunk/OMC_ComputerSystem-peg.reg (rev 0) +++ pybase/trunk/OMC_ComputerSystem-peg.reg 2008-09-15 21:30:47 UTC (rev 975) @@ -0,0 +1,48 @@ +//////// OMC_UnitaryComputerSystem +instance of PG_ProviderModule +{ + Name = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; + InterfaceType = "Python"; + InterfaceVersion = "1.0.0"; + Location = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; + UserContext = 2; // Requestor + Vendor = "OMC"; + Version = "0.1.0"; +}; + +instance of PG_Provider +{ + Name = "OMC_UnitaryComputerSystem"; + ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; +}; + +instance of PG_ProviderCapabilities +{ + CapabilityID = "OMC_UnitaryComputerSystem"; + ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; + ProviderName = "OMC_UnitaryComputerSystem"; + ClassName = "OMC_UnitaryComputerSystem"; + Namespaces = {"root/cimv2"}; + ProviderType = {2,5}; // Instance, Method +}; + +instance of PG_ProviderCapabilities +{ + CapabilityID = "OMC_HostNameSettingData"; + ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; + ProviderName = "OMC_UnitaryComputerSystem"; + ClassName = "OMC_HostNameSettingData"; + Namespaces = {"root/cimv2"}; + ProviderType = {2}; // Instance +}; + +instance of PG_ProviderCapabilities +{ + CapabilityID = "OMC_ComputerSystemHostNameSettingData"; + ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; + ProviderName = "OMC_UnitaryComputerSystem"; + ClassName = "OMC_ComputerSystemHostNameSettingData"; + Namespaces = {"root/cimv2"}; + ProviderType = {2,3}; // Instance, Associator +}; + Property changes on: pybase/trunk/OMC_ComputerSystem-peg.reg ___________________________________________________________________ Added: svn:mergeinfo + Copied: pybase/trunk/OMC_ComputerSystem.mof (from rev 974, pybase/trunk/OMC_UnitaryComputerSystem.mof) =================================================================== --- pybase/trunk/OMC_ComputerSystem.mof (rev 0) +++ pybase/trunk/OMC_ComputerSystem.mof 2008-09-15 21:30:47 UTC (rev 975) @@ -0,0 +1,9 @@ +#pragma locale ("en_US") + + +////////////////////////////////////////////////////////////////////////////// +[ Description("OMC Unitary Computer System"), Version("0.0.1") ] +class OMC_UnitaryComputerSystem : CIM_UnitaryComputerSystem +{ +}; + Property changes on: pybase/trunk/OMC_ComputerSystem.mof ___________________________________________________________________ Added: svn:mergeinfo + Copied: pybase/trunk/OMC_ComputerSystem.py (from rev 974, pybase/trunk/OMC_UnitaryComputerSystem.py) =================================================================== --- pybase/trunk/OMC_ComputerSystem.py (rev 0) +++ pybase/trunk/OMC_ComputerSystem.py 2008-09-15 21:30:47 UTC (rev 975) @@ -0,0 +1,547 @@ +#******************************************************************************* +# Copyright (C) 2007,2008 Novell, Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# - Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# - Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# - Neither the name of Novell, Inc. nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc. OR THE CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +#*****************************************************************************/ +"""Python Provider for OMC_UnitaryComputerSystem + +Instruments the CIM class OMC_UnitaryComputerSystem + +""" + +import pywbem +from pywbem import CIMProvider +from socket import getfqdn + +class OMC_UnitaryComputerSystemProvider(CIMProvider): + """Instrument the CIM class OMC_UnitaryComputerSystem + + OMC Unitary Computer System + + """ + + def get_instance(self, env, model, cim_class): + """Return an instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + model -- A template of the pywbem.CIMInstance to be returned. The + key properties are set on this instance to correspond to the + instanceName that was requested. The properties of the model + are already filtered according to the PropertyList from the + request. Only properties present in the model need to be + given values. If you prefer, you can set all of the + values, and the instance will be filtered for you. + cim_class -- The pywbem.CIMClass + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM + Instance does not exist in the specified namespace) + CIM_ERR_FAILED (some other unspecified error occurred) + + """ + + logger = env.get_logger() + logger.log_debug('Entering %s.get_instance()' \ + % self.__class__.__name__) + + #model['RequestedState'] = # TODO (type = pywbem.Uint16 self.Values.RequestedState) (default=12L) + #model['HealthState'] = # TODO (type = pywbem.Uint16 self.Values.HealthState) + #model['PowerState'] = # TODO (type = pywbem.Uint16 self.Values.PowerState) + #model['StatusDescriptions'] = # TODO (type = [unicode,]) + #model['Dedicated'] = # TODO (type = [pywbem.Uint16,] self.Values.Dedicated) + #model['OtherEnabledState'] = # TODO (type = unicode) + #model['PrimaryOwnerName'] = # TODO (type = unicode) + #model['OtherIdentifyingInfo'] = # TODO (type = [unicode,]) + #model['PowerManagementSupported'] = # TODO (type = bool) + #model['IdentifyingDescriptions'] = # TODO (type = [unicode,]) + #model['LastLoadInfo'] = # TODO (type = unicode) + #model['WakeUpType'] = # TODO (type = pywbem.Uint16 self.Values.WakeUpType) + #model['OperationalStatus'] = # TODO (type = [pywbem.Uint16,] self.Values.OperationalStatus) + #model['PrimaryOwnerContact'] = # TODO (type = unicode) + #model['OtherDedicatedDescriptions'] = # TODO (type = [unicode,]) + #model['Status'] = # TODO (type = unicode self.Values.Status) + #model['Description'] = # TODO (type = unicode) + #model['InstallDate'] = # TODO (type = pywbem.CIMDateTime) + #model['EnabledDefault'] = # TODO (type = pywbem.Uint16 self.Values.EnabledDefault) (default=2L) + #model['EnabledState'] = # TODO (type = pywbem.Uint16 self.Values.EnabledState) (default=5L) + #model['TimeOfLastStateChange'] = # TODO (type = pywbem.CIMDateTime) + #model['InitialLoadInfo'] = # TODO (type = [unicode,]) + #model['ElementName'] = # TODO (type = unicode) + #model['Roles'] = # TODO (type = [unicode,]) + #model['ResetCapability'] = # TODO (type = pywbem.Uint16 self.Values.ResetCapability) + model['NameFormat'] = self.Values.NameFormat.IP + #model['Caption'] = # TODO (type = unicode) + #model['PowerManagementCapabilities'] = # TODO (type = [pywbem.Uint16,] self.Values.PowerManagementCapabilities) + return model + + def enum_instances(self, env, model, cim_class, keys_only): + """Enumerate instances. + + The WBEM operations EnumerateInstances and EnumerateInstanceNames + are both mapped to this method. + This method is a python generator + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + model -- A template of the pywbem.CIMInstances to be generated. + The properties of the model are already filtered according to + the PropertyList from the request. Only properties present in + the model need to be given values. If you prefer, you can + always set all of the values, and the instance will be filtered + for you. + cim_class -- The pywbem.CIMClass + keys_only -- A boolean. True if only the key properties should be + set on the generated instances. + + Possible Errors: + CIM_ERR_FAILED (some other unspecified error occurred) + + """ + + logger = env.get_logger() + logger.log_debug('Entering %s.enum_instances()' \ + % self.__class__.__name__) + + # Key properties + model['CreationClassName'] = 'OMC_UnitaryComputerSystem' + model['Name'] = getfqdn() + if keys_only: + yield model + else: + try: + yield self.get_instance(env, model, cim_class) + except pywbem.CIMError, (num, msg): + if num not in (pywbem.CIM_ERR_NOT_FOUND, + pywbem.CIM_ERR_ACCESS_DENIED): + raise + + def set_instance(self, env, instance, previous_instance, cim_class): + """Return a newly created or modified instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + instance -- The new pywbem.CIMInstance. If modifying an existing + instance, the properties on this instance have been filtered by + the PropertyList from the request. + previous_instance -- The previous pywbem.CIMInstance if modifying + an existing instance. None if creating a new instance. + cim_class -- The pywbem.CIMClass + + Return the new instance. The keys must be set on the new instance. + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_NOT_SUPPORTED + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only + valid if previous_instance is None, indicating that the operation + was CreateInstance) + CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid + if previous_instance is not None, indicating that the operation + was ModifyInstance) + CIM_ERR_FAILED (some other unspecified error occurred) + + """ + + logger = env.get_logger() + logger.log_debug('Entering %s.set_instance()' \ + % self.__class__.__name__) + # TODO create or modify the instance + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement + return instance + + def delete_instance(self, env, instance_name): + """Delete an instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + instance_name -- A pywbem.CIMInstanceName specifying the instance + to delete. + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_NOT_SUPPORTED + CIM_ERR_INVALID_NAMESPACE + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified + namespace) + CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM + Instance does not exist in the specified namespace) + CIM_ERR_FAILED (some other unspecified error occurred) + + """ + + logger = env.get_logger() + logger.log_debug('Entering %s.delete_instance()' \ + % self.__class__.__name__) + + # TODO delete the resource + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement + + def cim_method_requeststatechange(self, env, object_name, method, + param_requestedstate, + param_timeoutperiod): + """Implements OMC_UnitaryComputerSystem.RequestStateChange() + + Requests that the state of the element be changed to the value + specified in the RequestedState parameter. When the requested + state change takes place, the EnabledState and RequestedState of + the element will be the same. Invoking the RequestStateChange + method multiple times could result in earlier requests being + overwritten or lost. If 0 is returned, then the task completed + successfully and the use of ConcreteJob was not required. If 4096 + (0x1000) is returned, then the task will take some time to + complete, ConcreteJob will be created, and its reference returned + in the output parameter Job. Any other return code indicates an + error condition. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName + specifying the object on which the method RequestStateChange() + should be invoked. + method -- A pywbem.CIMMethod representing the method meta-data + param_requestedstate -- The input parameter RequestedState (type pywbem.Uint16 self.Values.RequestStateChange.RequestedState) + The state requested for the element. This information will be + placed into the RequestedState property of the instance if the + return code of the RequestStateChange method is 0 ('Completed + with No Error'), 3 ('Timeout'), or 4096 (0x1000) ('Job + Started'). Refer to the description of the EnabledState and + RequestedState properties for the detailed explanations of the + RequestedState values. + + param_timeoutperiod -- The input parameter TimeoutPeriod (type pywbem.CIMDateTime) + A timeout period that specifies the maximum amount of time that + the client expects the transition to the new state to take. + The interval format must be used to specify the TimeoutPeriod. + A value of 0 or a null parameter indicates that the client has + no time requirements for the transition. If this property + does not contain 0 or null and the implementation does not + support this parameter, a return code of 'Use Of Timeout + Parameter Not Supported' must be returned. + + + Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.RequestStateChange) + and a dictionary with the out-parameters + + Output parameters: + Job -- (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) + Reference to the job (can be null if the task is completed). + + + """ + + logger = env.get_logger() + logger.log_debug('Entering %s.cim_method_requeststatechange()' \ + % self.__class__.__name__) + + # TODO do something + raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented + out_params = {} + #out_params['job'] = # TODO (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) + rval = None # TODO (type pywbem.Uint32 self.Values.RequestStateChange) + return (rval, out_params) + + def cim_method_setpowerstate(self, env, object_name, method, + param_powerstate, + param_time): + """Implements OMC_UnitaryComputerSystem.SetPowerState() + + Sets the power state of the computer. The use of this method has + been deprecated. Instead, use the SetPowerState method in the + associated PowerManagementService class. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName + specifying the object on which the method SetPowerState() + should be invoked. + method -- A pywbem.CIMMethod representing the method meta-data + param_powerstate -- The input parameter PowerState (type pywbem.Uint32 self.Values.SetPowerState.PowerState) + The Desired state for the COmputerSystem. + + param_time -- The input parameter Time (type pywbem.CIMDateTime) + Time indicates when the power state should be set, either as a + regular date-time value or as an interval value (where the + interval begins when the method invocation is received. + + + Returns a two-tuple containing the return value (type pywbem.Uint32) + and a dictionary with the out-parameters + + Output parameters: none + + """ + + logger = env.get_logger() + logger.log_debug('Entering %s.cim_method_setpowerstate()' \ + % self.__class__.__name__) + + # TODO do something + raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented + out_params = {} + rval = None # TODO (type pywbem.Uint32) + return (rval, out_params) + + class Values(object): + class Status(object): + OK = 'OK' + Error = 'Error' + Degraded = 'Degraded' + Unknown = 'Unknown' + Pred_Fail = 'Pred Fail' + Starting = 'Starting' + Stopping = 'Stopping' + Service = 'Service' + Stressed = 'Stressed' + NonRecover = 'NonRecover' + No_Contact = 'No Contact' + Lost_Comm = 'Lost Comm' + Stopped = 'Stopped' + + class RequestedState(object): + Enabled = pywbem.Uint16(2) + Disabled = pywbem.Uint16(3) + Shut_Down = pywbem.Uint16(4) + No_Change = pywbem.Uint16(5) + Offline = pywbem.Uint16(6) + Test = pywbem.Uint16(7) + Deferred = pywbem.Uint16(8) + Quiesce = pywbem.Uint16(9) + Reboot = pywbem.Uint16(10) + Reset = pywbem.Uint16(11) + Not_Applicable = pywbem.Uint16(12) + # DMTF_Reserved = .. + # Vendor_Reserved = 32768..65535 + + class HealthState(object): + Unknown = pywbem.Uint16(0) + OK = pywbem.Uint16(5) + Degraded_Warning = pywbem.Uint16(10) + Minor_failure = pywbem.Uint16(15) + Major_failure = pywbem.Uint16(20) + Critical_failure = pywbem.Uint16(25) + Non_recoverable_error = pywbem.Uint16(30) + # DMTF_Reserved = .. + + class SetPowerState(object): + class PowerState(object): + Full_Power = pywbem.Uint32(1) + Power_Save___Low_Power_Mode = pywbem.Uint32(2) + Power_Save___Standby = pywbem.Uint32(3) + Power_Save___Other = pywbem.Uint32(4) + Power_Cycle = pywbem.Uint32(5) + Power_Off = pywbem.Uint32(6) + Hibernate = pywbem.Uint32(7) + Soft_Off = pywbem.Uint32(8) + + class PowerState(object): + Unknown = pywbem.Uint16(0) + Full_Power = pywbem.Uint16(1) + Power_Save___Low_Power_Mode = pywbem.Uint16(2) + Power_Save___Standby = pywbem.Uint16(3) + Power_Save___Unknown = pywbem.Uint16(4) + Power_Cycle = pywbem.Uint16(5) + Power_Off = pywbem.Uint16(6) + Power_Save___Warning = pywbem.Uint16(7) + Power_Save___Hibernate = pywbem.Uint16(8) + Power_Save___Soft_Off = pywbem.Uint16(9) + + class EnabledDefault(object): + Enabled = pywbem.Uint16(2) + Disabled = pywbem.Uint16(3) + Not_Applicable = pywbem.Uint16(5) + Enabled_but_Offline = pywbem.Uint16(6) + No_Default = pywbem.Uint16(7) + Quiesce = pywbem.Uint16(9) + # DMTF_Reserved = .. + # Vendor_Reserved = 32768..65535 + + class EnabledState(object): + Unknown = pywbem.Uint16(0) + Other = pywbem.Uint16(1) + Enabled = pywbem.Uint16(2) + Disabled = pywbem.Uint16(3) + Shutting_Down = pywbem.Uint16(4) + Not_Applicable = pywbem.Uint16(5) + Enabled_but_Offline = pywbem.Uint16(6) + In_Test = pywbem.Uint16(7) + Deferred = pywbem.Uint16(8) + Quiesce = pywbem.Uint16(9) + Starting = pywbem.Uint16(10) + # DMTF_Reserved = 11..32767 + # Vendor_Reserved = 32768..65535 + + class ResetCapability(object): + Other = pywbem.Uint16(1) + Unknown = pywbem.Uint16(2) + Disabled = pywbem.Uint16(3) + Enabled = pywbem.Uint16(4) + Not_Implemented = pywbem.Uint16(5) + + class Dedicated(object): + Not_Dedicated = pywbem.Uint16(0) + Unknown = pywbem.Uint16(1) + Other = pywbem.Uint16(2) + Storage = pywbem.Uint16(3) + Router = pywbem.Uint16(4) + Switch = pywbem.Uint16(5) + Layer_3_Switch = pywbem.Uint16(6) + Central_Office_Switch = pywbem.Uint16(7) + Hub = pywbem.Uint16(8) + Access_Server = pywbem.Uint16(9) + Firewall = pywbem.Uint16(10) + Print = pywbem.Uint16(11) + I_O = pywbem.Uint16(12) + Web_Caching = pywbem.Uint16(13) + Management = pywbem.Uint16(14) + Block_Server = pywbem.Uint16(15) + File_Server = pywbem.Uint16(16) + Mobile_User_Device = pywbem.Uint16(17) + Repeater = pywbem.Uint16(18) + Bridge_Extender = pywbem.Uint16(19) + Gateway = pywbem.Uint16(20) + Storage_Virtualizer = pywbem.Uint16(21) + Media_Library = pywbem.Uint16(22) + ExtenderNode = pywbem.Uint16(23) + NAS_Head = pywbem.Uint16(24) + Self_contained_NAS = pywbem.Uint16(25) + UPS = pywbem.Uint16(26) + IP_Phone = pywbem.Uint16(27) + Management_Controller = pywbem.Uint16(28) + Chassis_Manager = pywbem.Uint16(29) + # DMTF_Reserved = 30..32567 + # Vendor_Reserved = 32568..65535 + + class NameFormat(object): + Other = 'Other' + IP = 'IP' + Dial = 'Dial' + HID = 'HID' + NWA = 'NWA' + HWA = 'HWA' + X25 = 'X25' + ISDN = 'ISDN' + IPX = 'IPX' + DCC = 'DCC' + ICD = 'ICD' + E_164 = 'E.164' + SNA = 'SNA' + OID_OSI = 'OID/OSI' + WWN = 'WWN' + NAA = 'NAA' + + class WakeUpType(object): + Reserved = pywbem.Uint16(0) + Other = pywbem.Uint16(1) + Unknown = pywbem.Uint16(2) + APM_Timer = pywbem.Uint16(3) + Modem_Ring = pywbem.Uint16(4) + LAN_Remote = pywbem.Uint16(5) + Power_Switch = pywbem.Uint16(6) + PCI_PME_ = pywbem.Uint16(7) + A_C_Power_Restored = pywbem.Uint16(8) + + class OperationalStatus(object): + Unknown = pywbem.Uint16(0) + Other = pywbem.Uint16(1) + OK = pywbem.Uint16(2) + Degraded = pywbem.Uint16(3) + Stressed = pywbem.Uint16(4) + Predictive_Failure = pywbem.Uint16(5) + Error = pywbem.Uint16(6) + Non_Recoverable_Error = pywbem.Uint16(7) + Starting = pywbem.Uint16(8) + Stopping = pywbem.Uint16(9) + Stopped = pywbem.Uint16(10) + In_Service = pywbem.Uint16(11) + No_Contact = pywbem.Uint16(12) + Lost_Communication = pywbem.Uint16(13) + Aborted = pywbem.Uint16(14) + Dormant = pywbem.Uint16(15) + Supporting_Entity_in_Error = pywbem.Uint16(16) + Completed = pywbem.Uint16(17) + Power_Mode = pywbem.Uint16(18) + # DMTF_Reserved = .. + # Vendor_Reserved = 0x8000.. + + class PowerManagementCapabilities(object): + Unknown = pywbem.Uint16(0) + Not_Supported = pywbem.Uint16(1) + Disabled = pywbem.Uint16(2) + Enabled = pywbem.Uint16(3) + Power_Saving_Modes_Entered_Automatically = pywbem.Uint16(4) + Power_State_Settable = pywbem.Uint16(5) + Power_Cycling_Supported = pywbem.Uint16(6) + Timed_Power_On_Supported = pywbem.Uint16(7) + + class RequestStateChange(object): + Completed_with_No_Error = pywbem.Uint32(0) + Not_Supported = pywbem.Uint32(1) + Unknown_or_Unspecified_Error = pywbem.Uint32(2) + Cannot_complete_within_Timeout_Period = pywbem.Uint32(3) + Failed = pywbem.Uint32(4) + Invalid_Parameter = pywbem.Uint32(5) + In_Use = pywbem.Uint32(6) + # DMTF_Reserved = .. + Method_Parameters_Checked___Job_Started = pywbem.Uint32(4096) + Invalid_State_Transition = pywbem.Uint32(4097) + Use_of_Timeout_Parameter_Not_Supported = pywbem.Uint32(4098) + Busy = pywbem.Uint32(4099) + # Method_Reserved = 4100..32767 + # Vendor_Specific = 32768..65535 + class RequestedState(object): + Enabled = pywbem.Uint16(2) + Disabled = pywbem.Uint16(3) + Shut_Down = pywbem.Uint16(4) + Offline = pywbem.Uint16(6) + Test = pywbem.Uint16(7) + Defer = pywbem.Uint16(8) + Quiesce = pywbem.Uint16(9) + Reboot = pywbem.Uint16(10) + Reset = pywbem.Uint16(11) + # DMTF_Reserved = .. + # Vendor_Reserved = 32768..65535 + +## end of class OMC_UnitaryComputerSystemProvider + + + +def get_providers(env): # register provider + omc_unitarycomputersystem_prov = OMC_UnitaryComputerSystemProvider() + return {'OMC_UnitaryComputerSystem': omc_unitarycomputersystem_prov} + + + + Property changes on: pybase/trunk/OMC_ComputerSystem.py ___________________________________________________________________ Added: svn:mergeinfo + Deleted: pybase/trunk/OMC_UnitaryComputerSystem-ow.reg =================================================================== --- pybase/trunk/OMC_UnitaryComputerSystem-ow.reg 2008-09-15 21:08:24 UTC (rev 974) +++ pybase/trunk/OMC_UnitaryComputerSystem-ow.reg 2008-09-15 21:30:47 UTC (rev 975) @@ -1,18 +0,0 @@ -// Provider registration for OMC_UnitaryComputerSystem -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_UnitaryComputerSystem:01"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_UnitaryComputerSystem"; - ProviderTypes = {1,6}; // Instance, Method - ModulePath = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; -}; - -instance of OpenWBEM_PyProviderRegistration -{ - InstanceID = "OMC:OMC_UnitaryComputerSystem:02"; - NamespaceNames = {"root/cimv2"}; - ClassName = "OMC_HostNameSettingData"; - ProviderTypes = {1}; // Instance - ModulePath = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; -}; Deleted: pybase/trunk/OMC_UnitaryComputerSystem-peg.reg =================================================================== --- pybase/trunk/OMC_UnitaryComputerSystem-peg.reg 2008-09-15 21:08:24 UTC (rev 974) +++ pybase/trunk/OMC_UnitaryComputerSystem-peg.reg 2008-09-15 21:30:47 UTC (rev 975) @@ -1,48 +0,0 @@ -//////// OMC_UnitaryComputerSystem -instance of PG_ProviderModule -{ - Name = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; - InterfaceType = "Python"; - InterfaceVersion = "1.0.0"; - Location = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; - UserContext = 2; // Requestor - Vendor = "OMC"; - Version = "0.1.0"; -}; - -instance of PG_Provider -{ - Name = "OMC_UnitaryComputerSystem"; - ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; -}; - -instance of PG_ProviderCapabilities -{ - CapabilityID = "OMC_UnitaryComputerSystem"; - ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; - ProviderName = "OMC_UnitaryComputerSystem"; - ClassName = "OMC_UnitaryComputerSystem"; - Namespaces = {"root/cimv2"}; - ProviderType = {2,5}; // Instance, Method -}; - -instance of PG_ProviderCapabilities -{ - CapabilityID = "OMC_HostNameSettingData"; - ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; - ProviderName = "OMC_UnitaryComputerSystem"; - ClassName = "OMC_HostNameSettingData"; - Namespaces = {"root/cimv2"}; - ProviderType = {2}; // Instance -}; - -instance of PG_ProviderCapabilities -{ - CapabilityID = "OMC_ComputerSystemHostNameSettingData"; - ProviderModuleName = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py"; - ProviderName = "OMC_UnitaryComputerSystem"; - ClassName = "OMC_ComputerSystemHostNameSettingData"; - Namespaces = {"root/cimv2"}; - ProviderType = {2,3}; // Instance, Associator -}; - Deleted: pybase/trunk/OMC_UnitaryComputerSystem.mof =================================================================== --- pybase/trunk/OMC_UnitaryComputerSystem.mof 2008-09-15 21:08:24 UTC (rev 974) +++ pybase/trunk/OMC_UnitaryComputerSystem.mof 2008-09-15 21:30:47 UTC (rev 975) @@ -1,9 +0,0 @@ -#pragma locale ("en_US") - - -////////////////////////////////////////////////////////////////////////////// -[ Description("OMC Unitary Computer System"), Version("0.0.1") ] -class OMC_UnitaryComputerSystem : CIM_UnitaryComputerSystem -{ -}; - Deleted: pybase/trunk/OMC_UnitaryComputerSystem.py =================================================================== --- pybase/trunk/OMC_UnitaryComputerSystem.py 2008-09-15 21:08:24 UTC (rev 974) +++ pybase/trunk/OMC_UnitaryComputerSystem.py 2008-09-15 21:30:47 UTC (rev 975) @@ -1,547 +0,0 @@ -#******************************************************************************* -# Copyright (C) 2007,2008 Novell, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# - Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# - Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# - Neither the name of Novell, Inc. nor the names of its -# contributors may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc. OR THE CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -#*****************************************************************************/ -"""Python Provider for OMC_UnitaryComputerSystem - -Instruments the CIM class OMC_UnitaryComputerSystem - -""" - -import pywbem -from pywbem import CIMProvider -from socket import getfqdn - -class OMC_UnitaryComputerSystemProvider(CIMProvider): - """Instrument the CIM class OMC_UnitaryComputerSystem - - OMC Unitary Computer System - - """ - - def get_instance(self, env, model, cim_class): - """Return an instance. - - Keyword arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - model -- A template of the pywbem.CIMInstance to be returned. The - key properties are set on this instance to correspond to the - instanceName that was requested. The properties of the model - are already filtered according to the PropertyList from the - request. Only properties present in the model need to be - given values. If you prefer, you can set all of the - values, and the instance will be filtered for you. - cim_class -- The pywbem.CIMClass - - Possible Errors: - CIM_ERR_ACCESS_DENIED - CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized - or otherwise incorrect parameters) - CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM - Instance does not exist in the specified namespace) - CIM_ERR_FAILED (some other unspecified error occurred) - - """ - - logger = env.get_logger() - logger.log_debug('Entering %s.get_instance()' \ - % self.__class__.__name__) - - #model['RequestedState'] = # TODO (type = pywbem.Uint16 self.Values.RequestedState) (default=12L) - #model['HealthState'] = # TODO (type = pywbem.Uint16 self.Values.HealthState) - #model['PowerState'] = # TODO (type = pywbem.Uint16 self.Values.PowerState) - #model['StatusDescriptions'] = # TODO (type = [unicode,]) - #model['Dedicated'] = # TODO (type = [pywbem.Uint16,] self.Values.Dedicated) - #model['OtherEnabledState'] = # TODO (type = unicode) - #model['PrimaryOwnerName'] = # TODO (type = unicode) - #model['OtherIdentifyingInfo'] = # TODO (type = [unicode,]) - #model['PowerManagementSupported'] = # TODO (type = bool) - #model['IdentifyingDescriptions'] = # TODO (type = [unicode,]) - #model['LastLoadInfo'] = # TODO (type = unicode) - #model['WakeUpType'] = # TODO (type = pywbem.Uint16 self.Values.WakeUpType) - #model['OperationalStatus'] = # TODO (type = [pywbem.Uint16,] self.Values.OperationalStatus) - #model['PrimaryOwnerContact'] = # TODO (type = unicode) - #model['OtherDedicatedDescriptions'] = # TODO (type = [unicode,]) - #model['Status'] = # TODO (type = unicode self.Values.Status) - #model['Description'] = # TODO (type = unicode) - #model['InstallDate'] = # TODO (type = pywbem.CIMDateTime) - #model['EnabledDefault'] = # TODO (type = pywbem.Uint16 self.Values.EnabledDefault) (default=2L) - #model['EnabledState'] = # TODO (type = pywbem.Uint16 self.Values.EnabledState) (default=5L) - #model['TimeOfLastStateChange'] = # TODO (type = pywbem.CIMDateTime) - #model['InitialLoadInfo'] = # TODO (type = [unicode,]) - #model['ElementName'] = # TODO (type = unicode) - #model['Roles'] = # TODO (type = [unicode,]) - #model['ResetCapability'] = # TODO (type = pywbem.Uint16 self.Values.ResetCapability) - model['NameFormat'] = self.Values.NameFormat.IP - #model['Caption'] = # TODO (type = unicode) - #model['PowerManagementCapabilities'] = # TODO (type = [pywbem.Uint16,] self.Values.PowerManagementCapabilities) - return model - - def enum_instances(self, env, model, cim_class, keys_only): - """Enumerate instances. - - The WBEM operations EnumerateInstances and EnumerateInstanceNames - are both mapped to this method. - This method is a python generator - - Keyword arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - model -- A template of the pywbem.CIMInstances to be generated. - The properties of the model are already filtered according to - the PropertyList from the request. Only properties present in - the model need to be given values. If you prefer, you can - always set all of the values, and the instance will be filtered - for you. - cim_class -- The pywbem.CIMClass - keys_only -- A boolean. True if only the key properties should be - set on the generated instances. - - Possible Errors: - CIM_ERR_FAILED (some other unspecified error occurred) - - """ - - logger = env.get_logger() - logger.log_debug('Entering %s.enum_instances()' \ - % self.__class__.__name__) - - # Key properties - model['CreationClassName'] = 'OMC_UnitaryComputerSystem' - model['Name'] = getfqdn() - if keys_only: - yield model - else: - try: - yield self.get_instance(env, model, cim_class) - except pywbem.CIMError, (num, msg): - if num not in (pywbem.CIM_ERR_NOT_FOUND, - pywbem.CIM_ERR_ACCESS_DENIED): - raise - - def set_instance(self, env, instance, previous_instance, cim_class): - """Return a newly created or modified instance. - - Keyword arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - instance -- The new pywbem.CIMInstance. If modifying an existing - instance, the properties on this instance have been filtered by - the PropertyList from the request. - previous_instance -- The previous pywbem.CIMInstance if modifying - an existing instance. None if creating a new instance. - cim_class -- The pywbem.CIMClass - - Return the new instance. The keys must be set on the new instance. - - Possible Errors: - CIM_ERR_ACCESS_DENIED - CIM_ERR_NOT_SUPPORTED - CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized - or otherwise incorrect parameters) - CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only - valid if previous_instance is None, indicating that the operation - was CreateInstance) - CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid - if previous_instance is not None, indicating that the operation - was ModifyInstance) - CIM_ERR_FAILED (some other unspecified error occurred) - - """ - - logger = env.get_logger() - logger.log_debug('Entering %s.set_instance()' \ - % self.__class__.__name__) - # TODO create or modify the instance - raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement - return instance - - def delete_instance(self, env, instance_name): - """Delete an instance. - - Keyword arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - instance_name -- A pywbem.CIMInstanceName specifying the instance - to delete. - - Possible Errors: - CIM_ERR_ACCESS_DENIED - CIM_ERR_NOT_SUPPORTED - CIM_ERR_INVALID_NAMESPACE - CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized - or otherwise incorrect parameters) - CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified - namespace) - CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM - Instance does not exist in the specified namespace) - CIM_ERR_FAILED (some other unspecified error occurred) - - """ - - logger = env.get_logger() - logger.log_debug('Entering %s.delete_instance()' \ - % self.__class__.__name__) - - # TODO delete the resource - raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement - - def cim_method_requeststatechange(self, env, object_name, method, - param_requestedstate, - param_timeoutperiod): - """Implements OMC_UnitaryComputerSystem.RequestStateChange() - - Requests that the state of the element be changed to the value - specified in the RequestedState parameter. When the requested - state change takes place, the EnabledState and RequestedState of - the element will be the same. Invoking the RequestStateChange - method multiple times could result in earlier requests being - overwritten or lost. If 0 is returned, then the task completed - successfully and the use of ConcreteJob was not required. If 4096 - (0x1000) is returned, then the task will take some time to - complete, ConcreteJob will be created, and its reference returned - in the output parameter Job. Any other return code indicates an - error condition. - - Keyword arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName - specifying the object on which the method RequestStateChange() - should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data - param_requestedstate -- The input parameter RequestedState (type pywbem.Uint16 self.Values.RequestStateChange.RequestedState) - The state requested for the element. This information will be - placed into the RequestedState property of the instance if the - return code of the RequestStateChange method is 0 ('Completed - with No Error'), 3 ('Timeout'), or 4096 (0x1000) ('Job - Started'). Refer to the description of the EnabledState and - RequestedState properties for the detailed explanations of the - RequestedState values. - - param_timeoutperiod -- The input parameter TimeoutPeriod (type pywbem.CIMDateTime) - A timeout period that specifies the maximum amount of time that - the client expects the transition to the new state to take. - The interval format must be used to specify the TimeoutPeriod. - A value of 0 or a null parameter indicates that the client has - no time requirements for the transition. If this property - does not contain 0 or null and the implementation does not - support this parameter, a return code of 'Use Of Timeout - Parameter Not Supported' must be returned. - - - Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.RequestStateChange) - and a dictionary with the out-parameters - - Output parameters: - Job -- (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) - Reference to the job (can be null if the task is completed). - - - """ - - logger = env.get_logger() - logger.log_debug('Entering %s.cim_method_requeststatechange()' \ - % self.__class__.__name__) - - # TODO do something - raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented - out_params = {} - #out_params['job'] = # TODO (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...)) - rval = None # TODO (type pywbem.Uint32 self.Values.RequestStateChange) - return (rval, out_params) - - def cim_method_setpowerstate(self, env, object_name, method, - param_powerstate, - param_time): - """Implements OMC_UnitaryComputerSystem.SetPowerState() - - Sets the power state of the computer. The use of this method has - been deprecated. Instead, use the SetPowerState method in the - associated PowerManagementService class. - - Keyword arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName - specifying the object on which the method SetPowerState() - should be invoked. - method -- A pywbem.CIMMethod representing the method meta-data - param_powerstate -- The input parameter PowerState (type pywbem.Uint32 self.Values.SetPowerState.PowerState) - The Desired state for the COmputerSystem. - - param_time -- The input parameter Time (type pywbem.CIMDateTime) - Time indicates when the power state should be set, either as a - regular date-time value or as an interval value (where the - interval begins when the method invocation is received. - - - Returns a two-tuple containing the return value (type pywbem.Uint32) - and a dictionary with the out-parameters - - Output parameters: none - - """ - - logger = env.get_logger() - logger.log_debug('Entering %s.cim_method_setpowerstate()' \ - % self.__class__.__name__) - - # TODO do something - raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented - out_params = {} - rval = None # TODO (type pywbem.Uint32) - return (rval, out_params) - - class Values(object): - class Status(object): - OK = 'OK' - Error = 'Error' - Degraded = 'Degraded' - Unknown = 'Unknown' - Pred_Fail = 'Pred Fail' - Starting = 'Starting' - Stopping = 'Stopping' - Service = 'Service' - Stressed = 'Stressed' - NonRecover = 'NonRecover' - No_Contact = 'No Contact' - Lost_Comm = 'Lost Comm' - Stopped = 'Stopped' - - class RequestedState(object): - Enabled = pywbem.Uint16(2) - Disabled = pywbem.Uint16(3) - Shut_Down = pywbem.Uint16(4) - No_Change = pywbem.Uint16(5) - Offline = pywbem.Uint16(6) - Test = pywbem.Uint16(7) - Deferred = pywbem.Uint16(8) - Quiesce = pywbem.Uint16(9) - Reboot = pywbem.Uint16(10) - Reset = pywbem.Uint16(11) - Not_Applicable = pywbem.Uint16(12) - # DMTF_Reserved = .. - # Vendor_Reserved = 32768..65535 - - class HealthState(object): - Unknown = pywbem.Uint16(0) - OK = pywbem.Uint16(5) - Degraded_Warning = pywbem.Uint16(10) - Minor_failure = pywbem.Uint16(15) - Major_failure = pywbem.Uint16(20) - Critical_failure = pywbem.Uint16(25) - Non_recoverable_error = pywbem.Uint16(30) - # DMTF_Reserved = .. - - class SetPowerState(object): - class PowerState(object): - Full_Power = pywbem.Uint32(1) - Power_Save___Low_Power_Mode = pywbem.Uint32(2) - Power_Save___Standby = pywbem.Uint32(3) - Power_Save___Other = pywbem.Uint32(4) - Power_Cycle = pywbem.Uint32(5) - Power_Off = pywbem.Uint32(6) - Hibernate = pywbem.Uint32(7) - Soft_Off = pywbem.Uint32(8) - - class PowerState(object): - Unknown = pywbem.Uint16(0) - Full_Power = pywbem.Uint16(1) - Power_Save___Low_Power_Mode = pywbem.Uint16(2) - Power_Save___Standby = pywbem.Uint16(3) - Power_Save___Unknown = pywbem.Uint16(4) - Power_Cycle = pywbem.Uint16(5) - Power_Off = pywbem.Uint16(6) - Power_Save___Warning = pywbem.Uint16(7) - Power_Save___Hibernate = pywbem.Uint16(8) - Power_Save___Soft_Off = pywbem.Uint16(9) - - class EnabledDefault(object): - Enabled = pywbem.Uint16(2) - Disabled = pywbem.Uint16(3) - Not_Applicable = pywbem.Uint16(5) - Enabled_but_Offline = pywbem.Uint16(6) - No_Default = pywbem.Uint16(7) - Quiesce = pywbem.Uint16(9) - # DMTF_Reserved = .. - # Vendor_Reserved = 32768..65535 - - class EnabledState(object): - Unknown = pywbem.Uint16(0) - Other = pywbem.Uint16(1) - Enabled = pywbem.Uint16(2) - Disabled = pywbem.Uint16(3) - Shutting_Down = pywbem.Uint16(4) - Not_Applicable = pywbem.Uint16(5) - Enabled_but_Offline = pywbem.Uint16(6) - In_Test = pywbem.Uint16(7) - Deferred = pywbem.Uint16(8) - Quiesce = pywbem.Uint16(9) - Starting = pywbem.Uint16(10) - # DMTF_Reserved = 11..32767 - # Vendor_Reserved = 32768..65535 - - class ResetCapability(object): - Other = pywbem.Uint16(1) - Unknown = pywbem.Uint16(2) - Disabled = pywbem.Uint16(3) - Enabled = pywbem.Uint16(4) - Not_Implemented = pywbem.Uint16(5) - - class Dedicated(object): - Not_Dedicated = pywbem.Uint16(0) - Unknown = pywbem.Uint16(1) - Other = pywbem.Uint16(2) - Storage = pywbem.Uint16(3) - Router = pywbem.Uint16(4) - Switch = pywbem.Uint16(5) - Layer_3_Switch = pywbem.Uint16(6) - Central_Office_Switch = pywbem.Uint16(7) - Hub = pywbem.Uint16(8) - Access_Server = pywbem.Uint16(9) - Firewall = pywbem.Uint16(10) - Print = pywbem.Uint16(11) - I_O = pywbem.Uint16(12) - Web_Caching = pywbem.Uint16(13) - Management = pywbem.Uint16(14) - Block_Server = pywbem.Uint16(15) - File_Server = pywbem.Uint16(16) - Mobile_User_Device = pywbem.Uint16(17) - Repeater = pywbem.Uint16(18) - Bridge_Extender = pywbem.Uint16(19) - Gateway = pywbem.Uint16(20) - Storage_Virtualizer = pywbem.Uint16(21) - Media_Library = pywbem.Uint16(22) - ExtenderNode = pywbem.Uint16(23) - NAS_Head = pywbem.Uint16(24) - Self_contained_NAS = pywbem.Uint16(25) - UPS = pywbem.Uint16(26) - IP_Phone = pywbem.Uint16(27) - Management_Controller = pywbem.Uint16(28) - Chassis_Manager = pywbem.Uint16(29) - # DMTF_Reserved = 30..32567 - # Vendor_Reserved = 32568..65535 - - class NameFormat(object): - Other = 'Other' - IP = 'IP' - Dial = 'Dial' - HID = 'HID' - NWA = 'NWA' - HWA = 'HWA' - X25 = 'X25' - ISDN = 'ISDN' - IPX = 'IPX' - DCC = 'DCC' - ICD = 'ICD' - E_164 = 'E.164' - SNA = 'SNA' - OID_OSI = 'OID/OSI' - WWN = 'WWN' - NAA = 'NAA' - - class WakeUpType(object): - Reserved = pywbem.Uint16(0) - Other = pywbem.Uint16(1) - Unknown = pywbem.Uint16(2) - APM_Timer = pywbem.Uint16(3) - Modem_Ring = pywbem.Uint16(4) - LAN_Remote = pywbem.Uint16(5) - Power_Switch = pywbem.Uint16(6) - PCI_PME_ = pywbem.Uint16(7) - A_C_Power_Restored = pywbem.Uint16(8) - - class OperationalStatus(object): - Unknown = pywbem.Uint16(0) - Other = pywbem.Uint16(1) - OK = pywbem.Uint16(2) - Degraded = pywbem.Uint16(3) - Stressed = pywbem.Uint16(4) - Predictive_Failure = pywbem.Uint16(5) - Error = pywbem.Uint16(6) - Non_Recoverable_Error = pywbem.Uint16(7) - Starting = pywbem.Uint16(8) - Stopping = pywbem.Uint16(9) - Stopped = pywbem.Uint16(10) - In_Service = pywbem.Uint16(11) - No_Contact = pywbem.Uint16(12) - Lost_Communication = pywbem.Uint16(13) - Aborted = pywbem.Uint16(14) - Dormant = pywbem.Uint16(15) - Supporting_Entity_in_Error = pywbem.Uint16(16) - Completed = pywbem.Uint16(17) - Power_Mode = pywbem.Uint16(18) - # DMTF_Reserved = .. - # Vendor_Reserved = 0x8000.. - - class PowerManagementCapabilities(object): - Unknown = pywbem.Uint16(0) - Not_Supported = pywbem.Uint16(1) - Disabled = pywbem.Uint16(2) - Enabled = pywbem.Uint16(3) - Power_Saving_Modes_Entered_Automatically = pywbem.Uint16(4) - Power_State_Settable = pywbem.Uint16(5) - Power_Cycling_Supported = pywbem.Uint16(6) - Timed_Power_On_Supported = pywbem.Uint16(7) - - class RequestStateChange(object): - Completed_with_No_Error = pywbem.Uint32(0) - Not_Supported = pywbem.Uint32(1) - Unknown_or_Unspecified_Error = pywbem.Uint32(2) - Cannot_complete_within_Timeout_Period = pywbem.Uint32(3) - Failed = pywbem.Uint32(4) - Invalid_Parameter = pywbem.Uint32(5) - In_Use = pywbem.Uint32(6) - # DMTF_Reserved = .. - Method_Parameters_Checked___Job_Started = pywbem.Uint32(4096) - Invalid_State_Transition = pywbem.Uint32(4097) - Use_of_Timeout_Parameter_Not_Supported = pywbem.Uint32(4098) - Busy = pywbem.Uint32(4099) - # Method_Reserved = 4100..32767 - # Vendor_Specific = 32768..65535 - class RequestedState(object): - Enabled = pywbem.Uint16(2) - Disabled = pywbem.Uint16(3) - Shut_Down = pywbem.Uint16(4) - Offline = pywbem.Uint16(6) - Test = pywbem.Uint16(7) - Defer = pywbem.Uint16(8) - Quiesce = pywbem.Uint16(9) - Reboot = pywbem.Uint16(10) - Reset = pywbem.Uint16(11) - # DMTF_Reserved = .. - # Vendor_Reserved = 32768..65535 - -## end of class OMC_UnitaryComputerSystemProvider - - - -def get_providers(env): # register provider - omc_unitarycomputersystem_prov = OMC_UnitaryComputerSystemProvider() - return {'OMC_UnitaryComputerSystem': omc_unitarycomputersystem_prov} - - - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-15 21:08:15
|
Revision: 974 http://omc.svn.sourceforge.net/omc/?rev=974&view=rev Author: bartw Date: 2008-09-15 21:08:24 +0000 (Mon, 15 Sep 2008) Log Message: ----------- OMC_UnitaryComputerSystem -> OMC_ComputerSystem Added Paths: ----------- test/trunk/OMC_ComputerSystem_Test.py Removed Paths: ------------- test/trunk/OMC_UnitaryComputerSystem_Test.py Copied: test/trunk/OMC_ComputerSystem_Test.py (from rev 973, test/trunk/OMC_UnitaryComputerSystem_Test.py) =================================================================== --- test/trunk/OMC_ComputerSystem_Test.py (rev 0) +++ test/trunk/OMC_ComputerSystem_Test.py 2008-09-15 21:08:24 UTC (rev 974) @@ -0,0 +1,291 @@ +#!/usr/bin/env python + +import pywbem +from socket import getfqdn +import unittest +import sys +import os +from time import sleep +sys.path.append(os.path.join(os.getcwd(), "lib")) + +import wbem_connection + +_globalNamespace = "root/cimv2" +_globalVerbose = True + +################################################################################ +# Test for the OMC_ComputerSystem +# +################################################################################ +class OMC_ComputerSystem_Test(unittest.TestCase): + + _supportedClasses = {} + _verbose = _globalVerbose + _orig_hostname = None + + def setUp(self): + unittest.TestCase.setUp(self) + wconn = wbem_connection.wbem_connection() + self._conn = wconn.get_wbem_connection() + self._orig_hostname = getfqdn() + + def tearDown(self): + unittest.TestCase.tearDown(self) + + def _dbgPrint(self, msg=''): + if self._verbose: + if len(msg): + print('\t -- %s --' % msg) + else: + print('') + + def _isClassSupported(self,classname): + try: + return self._supportedClasses[classname] + except KeyError: + try: + if self._conn.GetClass(classname, _globalNamespace) is not None: + self._supportedClasses[classname] = True + else: + self._supportedClasses[classname] = False + except: + self._supportedClasses[classname] = False + return self._supportedClasses[classname] + + def _sanity_check(self, type, classname): + try: + print self._conn.default_namespace + if type == 'instance': + PST.instance_sanity_check(self, self._conn, + classname, + self._verbose) + else: + PST.association_sanity_check(self, self._conn, + classname, + self._verbose) + except: + raise + + def _showMissingClassNotice(self, classname, testname): + self._dbgPrint("NOTICE: Skipping all %s tests for test %s: Class not loaded." % (classname, testname)) + + def _showUnsupportedAssnNotice(self, assnname, classname, testname): + self._dbgPrint('NOTICE: Skipping all %s tests for test %s: Associated class %s not loaded.' % (assnname, classname, testname)) + + def _isSupportedAssn(self, assnname, cname1, cname2, testname): + if not self._isClassSupported(cname1): + self._showUnsupportedAssnNotice(assnname, cname1, testname) + return False + elif not self._isClassSupported(cname2): + self._showUnsupportedAssnNotice(assnname, cname2, testname) + return False + return True + + def _showMissingClassNotice(self, classname, testname): + print "NOTICE: Skipping all %s tests for test %s: Class not loaded." % (str(classname), str(testname)) + + def _omc_computersystem_test(self): + hostname = getfqdn() + + insts = self._conn.EnumerateInstances('OMC_ComputerSystem', LocalOnly=False) + if 1 < len(insts): + self.fail('More than one OMC_ComputerSystem instance returned from EnumerateInstances') + if insts[0]['name'] != hostname: + self.fail('EnumerateInstances on OMC_ComputerSystem returned different instance than expected') + + insts = self._conn.EnumerateInstanceNames('OMC_ComputerSystem') + if 1 < len(insts): + self.fail('More than one OMC_ComputerSystem instance returned from EnumerateInstanceNames') + if insts[0]['name'] != hostname: + self.fail('EnumerateInstanceNames on OMC_ComputerSystem returned different instance name than expected') + + inst = self._conn.GetInstance(insts[0], LocalOnly=False) + if inst is None: + self.fail('Failed to GetInstance of OMC_ComputerSystem using %s' % insts[0]) + if inst['name'] != hostname: + self.fail('GetInstance on OMC_ComputerSystem returned different instance than expected') + + try: + self._conn.DeleteInstance(insts[0]) + self.fail('DeleteInstance of OMC_ComputerSystem succeeded when it should have failed') + except pywbem.CIMError, ce: + if ce[0] != 7: + self.fail('Exception on DeleteInstance of OMC_ComputerSystem was not "Not Supported" as expected') + pass + + try: + caption = 'Caption1' + if inst['Caption'] == caption: + caption = 'Caption2' + inst['Caption'] = caption + self._conn.ModifyInstance(inst) + insts = self._conn.EnumerateInstances('OMC_ComputerSystem', LocalOnly=False) + if insts[0]['Caption'] != caption: + self.fail('Attempt to ModifyInstance of OMC_ComputerSystem failed') + except pywbem.CIMError, ce: + self.failUnless(ce[0] == pywbem.CIM_ERR_NOT_SUPPORTED,\ + 'ModifyInstance of OMC_ComputerSystem failed') + + try: + inst = pywbem.CIMInstance('OMC_ComputerSystem', + properties={'CreationClassName' : 'OMC_ComputerSystem', + 'Name':getfqdn()}) + self._conn.CreateInstance(inst) + self.fail('CreateInstance of OMC_ComputerSystem succeeded when it should have failed') + except pywbem.CIMError, ce: + if ce[0] != 7: + # Should be 7, not supported. + self.fail('Exception on CreateInstance of OMC_ComputerSystem was not "Not Supported" as expected') + +# def _omc_hostnamesettingdata_test(self): +# hostname = getfqdn() +# +# insts = self._conn.EnumerateInstances('OMC_HostNameSettingData', LocalOnly=False) +# if 1 < len(insts): +# self.fail('More than one instance of OMC_HostNameSettingData returned from EnumerateInstances') +# if insts[0]['ComputerName'] != hostname: +# self.fail('EnumerateInstances on OMC_HostNameSettingData returned different instance than expected') +# +# insts = self._conn.EnumerateInstanceNames('OMC_HostNameSettingData') +# if 1 < len(insts): +# self.fail('More than one instance name of OMC_HostNameSettingData returned from EnumerateInstanceNames') +# if insts[0]['InstanceID'] != 'omc:computername': +# self.fail('EnumerateInstanceNames on OMC_HostNameSettingData returned different instance name than expected') +# +# inst = self._conn.GetInstance(insts[0], LocalOnly=False) +# if inst is None: +# self.fail('Failed to GetInstance of OMC_HostNameSettingData using %s' % insts[0]) +# if inst['ComputerName'] != hostname: +# self.fail('GetInstance of OMC_HostNameSettingData returned different instance than expected') +# +# try: +# self._conn.DeleteInstance(insts[0]) +# self.fail('DeleteInstance of OMC_HostNameSettingData succeeded when it should have failed') +# except pywbem.CIMError, ce: +# if ce[0] != 7: +# # Should be 7, not supported. +# self.fail('Exception on DeleteInstance of OMC_HostNameSettingData was not "Not Supported" as expected') +# +# try: +# elems = hostname.split('.') +# for elem in elems: +# if elem == elems[0]: +# newhostname = 'fakehostname' +# else: +# newhostname = newhostname + '.' + elem +# inst['ComputerName'] = newhostname +# self._conn.ModifyInstance(inst) +# insts = self._conn.EnumerateInstances('OMC_HostNameSettingData', LocalOnly=False) +# failmsg = None +# if insts[0]['ComputerName'] != newhostname: +# failmsg = 'Attempt to ModifyInstance of OMC_HostNameSettingData failed' +# self._dbgPrint('Modified ComputerName of OMC_HostNameSettingData instance, awaiting serialization') +# ctr = 0 +# while ctr < 100 and newhostname != getfqdn(): +# sleep(1) +# ctr = ctr + 1 +# if newhostname != getfqdn(): +# failmsg = 'ModifyInstance of OMC_HostNameSettingData successful but hostname not modified on system' +# else: +# # Should get here always; try to set the name back to the original +# self._dbgPrint('New host name setting now applied: %s' % getfqdn()) +# inst['ComputerName'] = hostname +# self._conn.ModifyInstance(inst) +# ctr = 0 +# self._dbgPrint('Restored ComputerName of OMC_HostNameSettingData instance, awaiting serialization') +# while ctr < 100 and hostname != getfqdn(): +# sleep(1) +# ctr = ctr + 1 +# self._dbgPrint('Previous host name setting now applied: %s' % getfqdn()) +# if failmsg is not None: +# self.fail(failmsg) +# except pywbem.CIMError: +# self.fail('ModifyInstance of OMC_HostNameSettingData failed') +# +# try: +# inst = pywbem.CIMInstance('OMC_HostNameSettingData', +# properties={'InstanceID' : 'omc:computername2', +# 'ComputerName':getfqdn()}) +# self._conn.CreateInstance(inst) +# self.fail('CreateInstance of OMC_HostNameSettingData succeeded when it should have failed') +# except pywbem.CIMError, ce: +# if ce[0] != 7: +# # Should be 7, not supported. +# self.fail('Exception on CreateInstance of OMC_HostNameSettingData was not "Not Supported" as expected') +# +# def _omc_computersystemhostnamesettingdata_test(self): +# ucs_op = self._conn.EnumerateInstanceNames('OMC_ComputerSystem')[0] +# hnsd_op = self._conn.EnumerateInstanceNames('OMC_HostNameSettingData')[0] +# insts = self._conn.EnumerateInstances('OMC_ComputerSystemHostNameSettingData', LocalOnly=False) +# if 1 < len(insts): +# self.fail('EnumerateInstances of OMC_ComputerSystemHostNameSettingData returned multiple instances when only one was expected') +# if insts[0]['ManagedElement'] != ucs_op: +# self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid') +# if insts[0]['SettingData'] != hnsd_op: +# self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid') +# +# insts = self._conn.EnumerateInstanceNames('OMC_ComputerSystemHostNameSettingData') +# if 1 < len(insts): +# self.fail('EnumerateInstanceNames of OMC_ComputerSystemHostNameSettingData returned multiple instance names when only one was expected') +# if insts[0]['ManagedElement'] != ucs_op: +# self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid') +# if insts[0]['SettingData'] != hnsd_op: +# self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid') +# +# refs = self._conn.References(ucs_op, ResultClass='OMC_ComputerSystemHostNameSettingData') +# if 1 < len(refs): +# self.fail('References of OMC_Computersystem returned multiple instances when only one was expected') +# if refs[0]['ManagedElement'] != ucs_op: +# self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid') +# if refs[0]['SettingData'] != hnsd_op: +# self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid') +# +# refs = self._conn.References(hnsd_op, ResultClass='OMC_ComputerSystemHostNameSettingData') +# if 1 < len(refs): +# self.fail('References of OMC_HostNameSettingData returned multiple instances when only one was expected') +# if refs[0]['ManagedElement'] != ucs_op: +# self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid') +# if refs[0]['SettingData'] != hnsd_op: +# self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid') +# +# assocs = self._conn.AssociatorNames(ucs_op, AssocClass='OMC_ComputerSystemHostNameSettingData') +# if 1 < len(assocs): +# self.fail('AssociatorNames of OMC_ComputerSystem returned multiple instances when only one was expected') +# qualified_hnsd_op = str(hnsd_op) +# if not qualified_hnsd_op.startswith('//%s/' % getfqdn()): +# qualified_hnsd_op = str(hnsd_op) +# assocs[0].host = None +# if str(assocs[0]) != qualified_hnsd_op: +# self.fail('AssociatorNames for %s is not valid' % ucs_op) +# +# assocs = self._conn.AssociatorNames(hnsd_op, AssocClass='OMC_ComputerSystemHostNameSettingData') +# if 1 < len(assocs): +# self.fail('AssociatorNames of OMC_HostNameSettingData returned multiple instances when only one was expected') +# qualified_ucs_op = str(ucs_op) +# if not qualified_ucs_op.startswith('//%s/' % getfqdn()): +# qualified_ucs_op = str(ucs_op) +# assocs[0].host = None +# if str(assocs[0]) != qualified_ucs_op: +# self.fail('AssociatorNames for %s is not valid' % hnsd_op) + + def _run_omcbase_component_tests(self, testname, testmap): + for classname in testmap.keys(): + if not self._isClassSupported(classname): + self._showMissingClassNotice(classname, testname) + else: + testmap[classname]() + + def test_computer_system(self): + ucsClasses = {'OMC_ComputerSystem' : self._omc_computersystem_test} +#'OMC_HostNameSettingData' : self._omc_hostnamesettingdata_test, +#'OMC_ComputerSystemHostNameSettingData' : self._omc_computersystemhostnamesettingdata_test} + self._run_omcbase_component_tests('computer_system', ucsClasses) + + + +def get_unit_test(): + return (OMC_ComputerSystem_Test) + +if __name__ == '__main__': + suite = unittest.makeSuite(OMC_ComputerSystem_Test) + unittest.TextTestRunner(verbosity=2).run(suite) Property changes on: test/trunk/OMC_ComputerSystem_Test.py ___________________________________________________________________ Added: svn:executable + * Added: svn:mergeinfo + Deleted: test/trunk/OMC_UnitaryComputerSystem_Test.py =================================================================== --- test/trunk/OMC_UnitaryComputerSystem_Test.py 2008-09-15 21:07:57 UTC (rev 973) +++ test/trunk/OMC_UnitaryComputerSystem_Test.py 2008-09-15 21:08:24 UTC (rev 974) @@ -1,291 +0,0 @@ -#!/usr/bin/env python - -import pywbem -from socket import getfqdn -import unittest -import sys -import os -from time import sleep -sys.path.append(os.path.join(os.getcwd(), "lib")) - -import wbem_connection - -_globalNamespace = "root/cimv2" -_globalVerbose = True - -################################################################################ -# Test for the OMC_ComputerSystem -# -################################################################################ -class OMC_ComputerSystem_Test(unittest.TestCase): - - _supportedClasses = {} - _verbose = _globalVerbose - _orig_hostname = None - - def setUp(self): - unittest.TestCase.setUp(self) - wconn = wbem_connection.wbem_connection() - self._conn = wconn.get_wbem_connection() - self._orig_hostname = getfqdn() - - def tearDown(self): - unittest.TestCase.tearDown(self) - - def _dbgPrint(self, msg=''): - if self._verbose: - if len(msg): - print('\t -- %s --' % msg) - else: - print('') - - def _isClassSupported(self,classname): - try: - return self._supportedClasses[classname] - except KeyError: - try: - if self._conn.GetClass(classname, _globalNamespace) is not None: - self._supportedClasses[classname] = True - else: - self._supportedClasses[classname] = False - except: - self._supportedClasses[classname] = False - return self._supportedClasses[classname] - - def _sanity_check(self, type, classname): - try: - print self._conn.default_namespace - if type == 'instance': - PST.instance_sanity_check(self, self._conn, - classname, - self._verbose) - else: - PST.association_sanity_check(self, self._conn, - classname, - self._verbose) - except: - raise - - def _showMissingClassNotice(self, classname, testname): - self._dbgPrint("NOTICE: Skipping all %s tests for test %s: Class not loaded." % (classname, testname)) - - def _showUnsupportedAssnNotice(self, assnname, classname, testname): - self._dbgPrint('NOTICE: Skipping all %s tests for test %s: Associated class %s not loaded.' % (assnname, classname, testname)) - - def _isSupportedAssn(self, assnname, cname1, cname2, testname): - if not self._isClassSupported(cname1): - self._showUnsupportedAssnNotice(assnname, cname1, testname) - return False - elif not self._isClassSupported(cname2): - self._showUnsupportedAssnNotice(assnname, cname2, testname) - return False - return True - - def _showMissingClassNotice(self, classname, testname): - print "NOTICE: Skipping all %s tests for test %s: Class not loaded." % (str(classname), str(testname)) - - def _omc_computersystem_test(self): - hostname = getfqdn() - - insts = self._conn.EnumerateInstances('OMC_ComputerSystem', LocalOnly=False) - if 1 < len(insts): - self.fail('More than one OMC_ComputerSystem instance returned from EnumerateInstances') - if insts[0]['name'] != hostname: - self.fail('EnumerateInstances on OMC_ComputerSystem returned different instance than expected') - - insts = self._conn.EnumerateInstanceNames('OMC_ComputerSystem') - if 1 < len(insts): - self.fail('More than one OMC_ComputerSystem instance returned from EnumerateInstanceNames') - if insts[0]['name'] != hostname: - self.fail('EnumerateInstanceNames on OMC_ComputerSystem returned different instance name than expected') - - inst = self._conn.GetInstance(insts[0], LocalOnly=False) - if inst is None: - self.fail('Failed to GetInstance of OMC_ComputerSystem using %s' % insts[0]) - if inst['name'] != hostname: - self.fail('GetInstance on OMC_ComputerSystem returned different instance than expected') - - try: - self._conn.DeleteInstance(insts[0]) - self.fail('DeleteInstance of OMC_ComputerSystem succeeded when it should have failed') - except pywbem.CIMError, ce: - if ce[0] != 7: - self.fail('Exception on DeleteInstance of OMC_ComputerSystem was not "Not Supported" as expected') - pass - - try: - caption = 'Caption1' - if inst['Caption'] == caption: - caption = 'Caption2' - inst['Caption'] = caption - self._conn.ModifyInstance(inst) - insts = self._conn.EnumerateInstances('OMC_ComputerSystem', LocalOnly=False) - if insts[0]['Caption'] != caption: - self.fail('Attempt to ModifyInstance of OMC_ComputerSystem failed') - except pywbem.CIMError, ce: - self.failUnless(ce[0] == pywbem.CIM_ERR_NOT_SUPPORTED,\ - 'ModifyInstance of OMC_ComputerSystem failed') - - try: - inst = pywbem.CIMInstance('OMC_ComputerSystem', - properties={'CreationClassName' : 'OMC_ComputerSystem', - 'Name':getfqdn()}) - self._conn.CreateInstance(inst) - self.fail('CreateInstance of OMC_ComputerSystem succeeded when it should have failed') - except pywbem.CIMError, ce: - if ce[0] != 7: - # Should be 7, not supported. - self.fail('Exception on CreateInstance of OMC_ComputerSystem was not "Not Supported" as expected') - -# def _omc_hostnamesettingdata_test(self): -# hostname = getfqdn() -# -# insts = self._conn.EnumerateInstances('OMC_HostNameSettingData', LocalOnly=False) -# if 1 < len(insts): -# self.fail('More than one instance of OMC_HostNameSettingData returned from EnumerateInstances') -# if insts[0]['ComputerName'] != hostname: -# self.fail('EnumerateInstances on OMC_HostNameSettingData returned different instance than expected') -# -# insts = self._conn.EnumerateInstanceNames('OMC_HostNameSettingData') -# if 1 < len(insts): -# self.fail('More than one instance name of OMC_HostNameSettingData returned from EnumerateInstanceNames') -# if insts[0]['InstanceID'] != 'omc:computername': -# self.fail('EnumerateInstanceNames on OMC_HostNameSettingData returned different instance name than expected') -# -# inst = self._conn.GetInstance(insts[0], LocalOnly=False) -# if inst is None: -# self.fail('Failed to GetInstance of OMC_HostNameSettingData using %s' % insts[0]) -# if inst['ComputerName'] != hostname: -# self.fail('GetInstance of OMC_HostNameSettingData returned different instance than expected') -# -# try: -# self._conn.DeleteInstance(insts[0]) -# self.fail('DeleteInstance of OMC_HostNameSettingData succeeded when it should have failed') -# except pywbem.CIMError, ce: -# if ce[0] != 7: -# # Should be 7, not supported. -# self.fail('Exception on DeleteInstance of OMC_HostNameSettingData was not "Not Supported" as expected') -# -# try: -# elems = hostname.split('.') -# for elem in elems: -# if elem == elems[0]: -# newhostname = 'fakehostname' -# else: -# newhostname = newhostname + '.' + elem -# inst['ComputerName'] = newhostname -# self._conn.ModifyInstance(inst) -# insts = self._conn.EnumerateInstances('OMC_HostNameSettingData', LocalOnly=False) -# failmsg = None -# if insts[0]['ComputerName'] != newhostname: -# failmsg = 'Attempt to ModifyInstance of OMC_HostNameSettingData failed' -# self._dbgPrint('Modified ComputerName of OMC_HostNameSettingData instance, awaiting serialization') -# ctr = 0 -# while ctr < 100 and newhostname != getfqdn(): -# sleep(1) -# ctr = ctr + 1 -# if newhostname != getfqdn(): -# failmsg = 'ModifyInstance of OMC_HostNameSettingData successful but hostname not modified on system' -# else: -# # Should get here always; try to set the name back to the original -# self._dbgPrint('New host name setting now applied: %s' % getfqdn()) -# inst['ComputerName'] = hostname -# self._conn.ModifyInstance(inst) -# ctr = 0 -# self._dbgPrint('Restored ComputerName of OMC_HostNameSettingData instance, awaiting serialization') -# while ctr < 100 and hostname != getfqdn(): -# sleep(1) -# ctr = ctr + 1 -# self._dbgPrint('Previous host name setting now applied: %s' % getfqdn()) -# if failmsg is not None: -# self.fail(failmsg) -# except pywbem.CIMError: -# self.fail('ModifyInstance of OMC_HostNameSettingData failed') -# -# try: -# inst = pywbem.CIMInstance('OMC_HostNameSettingData', -# properties={'InstanceID' : 'omc:computername2', -# 'ComputerName':getfqdn()}) -# self._conn.CreateInstance(inst) -# self.fail('CreateInstance of OMC_HostNameSettingData succeeded when it should have failed') -# except pywbem.CIMError, ce: -# if ce[0] != 7: -# # Should be 7, not supported. -# self.fail('Exception on CreateInstance of OMC_HostNameSettingData was not "Not Supported" as expected') -# -# def _omc_computersystemhostnamesettingdata_test(self): -# ucs_op = self._conn.EnumerateInstanceNames('OMC_ComputerSystem')[0] -# hnsd_op = self._conn.EnumerateInstanceNames('OMC_HostNameSettingData')[0] -# insts = self._conn.EnumerateInstances('OMC_ComputerSystemHostNameSettingData', LocalOnly=False) -# if 1 < len(insts): -# self.fail('EnumerateInstances of OMC_ComputerSystemHostNameSettingData returned multiple instances when only one was expected') -# if insts[0]['ManagedElement'] != ucs_op: -# self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid') -# if insts[0]['SettingData'] != hnsd_op: -# self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid') -# -# insts = self._conn.EnumerateInstanceNames('OMC_ComputerSystemHostNameSettingData') -# if 1 < len(insts): -# self.fail('EnumerateInstanceNames of OMC_ComputerSystemHostNameSettingData returned multiple instance names when only one was expected') -# if insts[0]['ManagedElement'] != ucs_op: -# self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid') -# if insts[0]['SettingData'] != hnsd_op: -# self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid') -# -# refs = self._conn.References(ucs_op, ResultClass='OMC_ComputerSystemHostNameSettingData') -# if 1 < len(refs): -# self.fail('References of OMC_Computersystem returned multiple instances when only one was expected') -# if refs[0]['ManagedElement'] != ucs_op: -# self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid') -# if refs[0]['SettingData'] != hnsd_op: -# self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid') -# -# refs = self._conn.References(hnsd_op, ResultClass='OMC_ComputerSystemHostNameSettingData') -# if 1 < len(refs): -# self.fail('References of OMC_HostNameSettingData returned multiple instances when only one was expected') -# if refs[0]['ManagedElement'] != ucs_op: -# self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid') -# if refs[0]['SettingData'] != hnsd_op: -# self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid') -# -# assocs = self._conn.AssociatorNames(ucs_op, AssocClass='OMC_ComputerSystemHostNameSettingData') -# if 1 < len(assocs): -# self.fail('AssociatorNames of OMC_ComputerSystem returned multiple instances when only one was expected') -# qualified_hnsd_op = str(hnsd_op) -# if not qualified_hnsd_op.startswith('//%s/' % getfqdn()): -# qualified_hnsd_op = str(hnsd_op) -# assocs[0].host = None -# if str(assocs[0]) != qualified_hnsd_op: -# self.fail('AssociatorNames for %s is not valid' % ucs_op) -# -# assocs = self._conn.AssociatorNames(hnsd_op, AssocClass='OMC_ComputerSystemHostNameSettingData') -# if 1 < len(assocs): -# self.fail('AssociatorNames of OMC_HostNameSettingData returned multiple instances when only one was expected') -# qualified_ucs_op = str(ucs_op) -# if not qualified_ucs_op.startswith('//%s/' % getfqdn()): -# qualified_ucs_op = str(ucs_op) -# assocs[0].host = None -# if str(assocs[0]) != qualified_ucs_op: -# self.fail('AssociatorNames for %s is not valid' % hnsd_op) - - def _run_omcbase_component_tests(self, testname, testmap): - for classname in testmap.keys(): - if not self._isClassSupported(classname): - self._showMissingClassNotice(classname, testname) - else: - testmap[classname]() - - def test_computer_system(self): - ucsClasses = {'OMC_ComputerSystem' : self._omc_computersystem_test} -#'OMC_HostNameSettingData' : self._omc_hostnamesettingdata_test, -#'OMC_ComputerSystemHostNameSettingData' : self._omc_computersystemhostnamesettingdata_test} - self._run_omcbase_component_tests('computer_system', ucsClasses) - - - -def get_unit_test(): - return (OMC_ComputerSystem_Test) - -if __name__ == '__main__': - suite = unittest.makeSuite(OMC_ComputerSystem_Test) - unittest.TextTestRunner(verbosity=2).run(suite) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-15 21:07:49
|
Revision: 973 http://omc.svn.sourceforge.net/omc/?rev=973&view=rev Author: bartw Date: 2008-09-15 21:07:57 +0000 (Mon, 15 Sep 2008) Log Message: ----------- OMC_UnitaryComputerSystem -> OMC_ComputerSystem Modified Paths: -------------- test/trunk/OMC_OperatingSystem_Test.py test/trunk/OMC_UnitaryComputerSystem_Test.py test/trunk/OMC_UnixProcess_Test.py test/trunk/omcbase_test.py Modified: test/trunk/OMC_OperatingSystem_Test.py =================================================================== --- test/trunk/OMC_OperatingSystem_Test.py 2008-09-15 21:05:04 UTC (rev 972) +++ test/trunk/OMC_OperatingSystem_Test.py 2008-09-15 21:07:57 UTC (rev 973) @@ -72,9 +72,9 @@ "Incorrect number of OperatingSystem Instances returned") os = os_list[0] #Check OperatingSystem Properties - if os['CSCreationClassName'].lower() != "omc_unitarycomputersystem": + if os['CSCreationClassName'].lower() != "omc_computersystem": self.add_Error("CSCreationClassName incorrect") - if os['CSCreationClassName'].lower() != "omc_unitarycomputersystem": + if os['CSCreationClassName'].lower() != "omc_computersystem": self.add_Error("CSCreationClassName incorrect") if os['CreationClassName'].lower() != "omc_operatingsystem": self.add_Error("CreationClassName incorrect") @@ -216,10 +216,10 @@ os_list = self._conn.EnumerateInstances("OMC_OperatingSystem") self.failUnless(len(os_list) > 0,\ "No OperatingSystem instance returned") - #Compare inst_os_assoc with UnitaryComputerSystem + #Compare inst_os_assoc with ComputerSystem inst_os_assoc = self._conn.Associators(os_list[0].path, AssocClass="OMC_InstalledOS") - ucs = self._conn.EnumerateInstances("OMC_UnitaryComputerSystem") + ucs = self._conn.EnumerateInstances("OMC_ComputerSystem") if inst_os_assoc[0]['Name'] != ucs[0]['Name']: self.add_Error("OMC_InstalledOS association failed") Modified: test/trunk/OMC_UnitaryComputerSystem_Test.py =================================================================== --- test/trunk/OMC_UnitaryComputerSystem_Test.py 2008-09-15 21:05:04 UTC (rev 972) +++ test/trunk/OMC_UnitaryComputerSystem_Test.py 2008-09-15 21:07:57 UTC (rev 973) @@ -14,10 +14,10 @@ _globalVerbose = True ################################################################################ -# Test for the OMC_UnitaryComputerSystem +# Test for the OMC_ComputerSystem # ################################################################################ -class OMC_UnitaryComputerSystem_Test(unittest.TestCase): +class OMC_ComputerSystem_Test(unittest.TestCase): _supportedClasses = {} _verbose = _globalVerbose @@ -84,33 +84,33 @@ def _showMissingClassNotice(self, classname, testname): print "NOTICE: Skipping all %s tests for test %s: Class not loaded." % (str(classname), str(testname)) - def _omc_unitarycomputersystem_test(self): + def _omc_computersystem_test(self): hostname = getfqdn() - insts = self._conn.EnumerateInstances('OMC_UnitaryComputerSystem', LocalOnly=False) + insts = self._conn.EnumerateInstances('OMC_ComputerSystem', LocalOnly=False) if 1 < len(insts): - self.fail('More than one OMC_UnitaryComputerSystem instance returned from EnumerateInstances') + self.fail('More than one OMC_ComputerSystem instance returned from EnumerateInstances') if insts[0]['name'] != hostname: - self.fail('EnumerateInstances on OMC_UnitaryComputerSystem returned different instance than expected') + self.fail('EnumerateInstances on OMC_ComputerSystem returned different instance than expected') - insts = self._conn.EnumerateInstanceNames('OMC_UnitaryComputerSystem') + insts = self._conn.EnumerateInstanceNames('OMC_ComputerSystem') if 1 < len(insts): - self.fail('More than one OMC_UnitaryComputerSystem instance returned from EnumerateInstanceNames') + self.fail('More than one OMC_ComputerSystem instance returned from EnumerateInstanceNames') if insts[0]['name'] != hostname: - self.fail('EnumerateInstanceNames on OMC_UnitaryComputerSystem returned different instance name than expected') + self.fail('EnumerateInstanceNames on OMC_ComputerSystem returned different instance name than expected') inst = self._conn.GetInstance(insts[0], LocalOnly=False) if inst is None: - self.fail('Failed to GetInstance of OMC_UnitaryComputerSystem using %s' % insts[0]) + self.fail('Failed to GetInstance of OMC_ComputerSystem using %s' % insts[0]) if inst['name'] != hostname: - self.fail('GetInstance on OMC_UnitaryComputerSystem returned different instance than expected') + self.fail('GetInstance on OMC_ComputerSystem returned different instance than expected') try: self._conn.DeleteInstance(insts[0]) - self.fail('DeleteInstance of OMC_UnitaryComputerSystem succeeded when it should have failed') + self.fail('DeleteInstance of OMC_ComputerSystem succeeded when it should have failed') except pywbem.CIMError, ce: if ce[0] != 7: - self.fail('Exception on DeleteInstance of OMC_UnitaryComputerSystem was not "Not Supported" as expected') + self.fail('Exception on DeleteInstance of OMC_ComputerSystem was not "Not Supported" as expected') pass try: @@ -119,23 +119,23 @@ caption = 'Caption2' inst['Caption'] = caption self._conn.ModifyInstance(inst) - insts = self._conn.EnumerateInstances('OMC_UnitaryComputerSystem', LocalOnly=False) + insts = self._conn.EnumerateInstances('OMC_ComputerSystem', LocalOnly=False) if insts[0]['Caption'] != caption: - self.fail('Attempt to ModifyInstance of OMC_UnitaryComputerSystem failed') + self.fail('Attempt to ModifyInstance of OMC_ComputerSystem failed') except pywbem.CIMError, ce: self.failUnless(ce[0] == pywbem.CIM_ERR_NOT_SUPPORTED,\ - 'ModifyInstance of OMC_UnitaryComputerSystem failed') + 'ModifyInstance of OMC_ComputerSystem failed') try: - inst = pywbem.CIMInstance('OMC_UnitaryComputerSystem', - properties={'CreationClassName' : 'OMC_UnitaryComputerSystem', + inst = pywbem.CIMInstance('OMC_ComputerSystem', + properties={'CreationClassName' : 'OMC_ComputerSystem', 'Name':getfqdn()}) self._conn.CreateInstance(inst) - self.fail('CreateInstance of OMC_UnitaryComputerSystem succeeded when it should have failed') + self.fail('CreateInstance of OMC_ComputerSystem succeeded when it should have failed') except pywbem.CIMError, ce: if ce[0] != 7: # Should be 7, not supported. - self.fail('Exception on CreateInstance of OMC_UnitaryComputerSystem was not "Not Supported" as expected') + self.fail('Exception on CreateInstance of OMC_ComputerSystem was not "Not Supported" as expected') # def _omc_hostnamesettingdata_test(self): # hostname = getfqdn() @@ -214,7 +214,7 @@ # self.fail('Exception on CreateInstance of OMC_HostNameSettingData was not "Not Supported" as expected') # # def _omc_computersystemhostnamesettingdata_test(self): -# ucs_op = self._conn.EnumerateInstanceNames('OMC_UnitaryComputerSystem')[0] +# ucs_op = self._conn.EnumerateInstanceNames('OMC_ComputerSystem')[0] # hnsd_op = self._conn.EnumerateInstanceNames('OMC_HostNameSettingData')[0] # insts = self._conn.EnumerateInstances('OMC_ComputerSystemHostNameSettingData', LocalOnly=False) # if 1 < len(insts): @@ -234,7 +234,7 @@ # # refs = self._conn.References(ucs_op, ResultClass='OMC_ComputerSystemHostNameSettingData') # if 1 < len(refs): -# self.fail('References of OMC_UnitaryComputersystem returned multiple instances when only one was expected') +# self.fail('References of OMC_Computersystem returned multiple instances when only one was expected') # if refs[0]['ManagedElement'] != ucs_op: # self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid') # if refs[0]['SettingData'] != hnsd_op: @@ -250,7 +250,7 @@ # # assocs = self._conn.AssociatorNames(ucs_op, AssocClass='OMC_ComputerSystemHostNameSettingData') # if 1 < len(assocs): -# self.fail('AssociatorNames of OMC_UnitaryComputerSystem returned multiple instances when only one was expected') +# self.fail('AssociatorNames of OMC_ComputerSystem returned multiple instances when only one was expected') # qualified_hnsd_op = str(hnsd_op) # if not qualified_hnsd_op.startswith('//%s/' % getfqdn()): # qualified_hnsd_op = str(hnsd_op) @@ -275,17 +275,17 @@ else: testmap[classname]() - def test_unitary_computer_system(self): - ucsClasses = {'OMC_UnitaryComputerSystem' : self._omc_unitarycomputersystem_test} + def test_computer_system(self): + ucsClasses = {'OMC_ComputerSystem' : self._omc_computersystem_test} #'OMC_HostNameSettingData' : self._omc_hostnamesettingdata_test, #'OMC_ComputerSystemHostNameSettingData' : self._omc_computersystemhostnamesettingdata_test} - self._run_omcbase_component_tests('unitary_computer_system', ucsClasses) + self._run_omcbase_component_tests('computer_system', ucsClasses) def get_unit_test(): - return (OMC_UnitaryComputerSystem_Test) + return (OMC_ComputerSystem_Test) if __name__ == '__main__': - suite = unittest.makeSuite(OMC_UnitaryComputerSystem_Test) + suite = unittest.makeSuite(OMC_ComputerSystem_Test) unittest.TextTestRunner(verbosity=2).run(suite) Modified: test/trunk/OMC_UnixProcess_Test.py =================================================================== --- test/trunk/OMC_UnixProcess_Test.py 2008-09-15 21:05:04 UTC (rev 972) +++ test/trunk/OMC_UnixProcess_Test.py 2008-09-15 21:07:57 UTC (rev 973) @@ -305,7 +305,7 @@ if proc['handle'] == str(os.getpid()) or proc['ParentProcessID'] == str(os.getpid()): break if prop.lower() == "cscreationclassname": - if proc[prop].lower() != "omc_unitarycomputersystem": + if proc[prop].lower() != "omc_computersystem": self.add_Error("PID: %s: %s does not match"% \ (str(proc['Handle'],str(prop)))) if prop.lower() == "csname": Modified: test/trunk/omcbase_test.py =================================================================== --- test/trunk/omcbase_test.py 2008-09-15 21:05:04 UTC (rev 972) +++ test/trunk/omcbase_test.py 2008-09-15 21:07:57 UTC (rev 973) @@ -124,7 +124,7 @@ def _omc_hostedinitdservice_test(self): if self._isSupportedAssn('OMC_HostedInitdService', - 'OMC_UnitaryComputerSystem', + 'OMC_ComputerSystem', 'OMC_InitdService', 'initd'): # Test the assn @@ -136,33 +136,33 @@ def _omc_initdservicerunlevel_test(self): pass - def _omc_unitarycomputersystem_test(self): + def _omc_computersystem_test(self): hostname = getfqdn() - insts = self._conn.EnumerateInstances('OMC_UnitaryComputerSystem', LocalOnly=False) + insts = self._conn.EnumerateInstances('OMC_ComputerSystem', LocalOnly=False) if 1 < len(insts): - self.fail('More than one OMC_UnitaryComputerSystem instance returned from EnumerateInstances') + self.fail('More than one OMC_ComputerSystem instance returned from EnumerateInstances') if insts[0]['name'] != hostname: - self.fail('EnumerateInstances on OMC_UnitaryComputerSystem returned different instance than expected') + self.fail('EnumerateInstances on OMC_ComputerSystem returned different instance than expected') - insts = self._conn.EnumerateInstanceNames('OMC_UnitaryComputerSystem') + insts = self._conn.EnumerateInstanceNames('OMC_ComputerSystem') if 1 < len(insts): - self.fail('More than one OMC_UnitaryComputerSystem instance returned from EnumerateInstanceNames') + self.fail('More than one OMC_ComputerSystem instance returned from EnumerateInstanceNames') if insts[0]['name'] != hostname: - self.fail('EnumerateInstanceNames on OMC_UnitaryComputerSystem returned different instance name than expected') + self.fail('EnumerateInstanceNames on OMC_ComputerSystem returned different instance name than expected') inst = self._conn.GetInstance(insts[0], LocalOnly=False) if inst is None: - self.fail('Failed to GetInstance of OMC_UnitaryComputerSystem using %s' % insts[0]) + self.fail('Failed to GetInstance of OMC_ComputerSystem using %s' % insts[0]) if inst['name'] != hostname: - self.fail('GetInstance on OMC_UnitaryComputerSystem returned different instance than expected') + self.fail('GetInstance on OMC_ComputerSystem returned different instance than expected') try: self._conn.DeleteInstance(insts[0]) - self.fail('DeleteInstance of OMC_UnitaryComputerSystem succeeded when it should have failed') + self.fail('DeleteInstance of OMC_ComputerSystem succeeded when it should have failed') except pywbem.CIMError, ce: if ce[0] != 7: - self.fail('Exception on DeleteInstance of OMC_UnitaryComputerSystem was not "Not Supported" as expected') + self.fail('Exception on DeleteInstance of OMC_ComputerSystem was not "Not Supported" as expected') pass try: @@ -171,22 +171,22 @@ caption = 'Caption2' inst['Caption'] = caption self._conn.ModifyInstance(inst) - insts = self._conn.EnumerateInstances('OMC_UnitaryComputerSystem', LocalOnly=False) + insts = self._conn.EnumerateInstances('OMC_ComputerSystem', LocalOnly=False) if insts[0]['Caption'] != caption: - self.fail('Attempt to ModifyInstance of OMC_UnitaryComputerSystem failed') + self.fail('Attempt to ModifyInstance of OMC_ComputerSystem failed') except pywbem.CIMError, ce: - self.fail('ModifyInstance of OMC_UnitaryComputerSystem failed') + self.fail('ModifyInstance of OMC_ComputerSystem failed') try: - inst = pywbem.CIMInstance('OMC_UnitaryComputerSystem', - properties={'CreationClassName' : 'OMC_UnitaryComputerSystem', + inst = pywbem.CIMInstance('OMC_ComputerSystem', + properties={'CreationClassName' : 'OMC_ComputerSystem', 'Name':getfqdn()}) self._conn.CreateInstance(inst) - self.fail('CreateInstance of OMC_UnitaryComputerSystem succeeded when it should have failed') + self.fail('CreateInstance of OMC_ComputerSystem succeeded when it should have failed') except pywbem.CIMError, ce: if ce[0] != 7: # Should be 7, not supported. - self.fail('Exception on CreateInstance of OMC_UnitaryComputerSystem was not "Not Supported" as expected') + self.fail('Exception on CreateInstance of OMC_ComputerSystem was not "Not Supported" as expected') def _omc_hostnamesettingdata_test(self): hostname = getfqdn() @@ -265,7 +265,7 @@ self.fail('Exception on CreateInstance of OMC_HostNameSettingData was not "Not Supported" as expected') # def _omc_computersystemhostnamesettingdata_test(self): -# ucs_op = self._conn.EnumerateInstanceNames('OMC_UnitaryComputerSystem')[0] +# ucs_op = self._conn.EnumerateInstanceNames('OMC_ComputerSystem')[0] # hnsd_op = self._conn.EnumerateInstanceNames('OMC_HostNameSettingData')[0] # insts = self._conn.EnumerateInstances('OMC_ComputerSystemHostNameSettingData', LocalOnly=False) # if 1 < len(insts): @@ -285,7 +285,7 @@ # # refs = self._conn.References(ucs_op, ResultClass='OMC_ComputerSystemHostNameSettingData') # if 1 < len(refs): -# self.fail('References of OMC_UnitaryComputersystem returned multiple instances when only one was expected') +# self.fail('References of OMC_Computersystem returned multiple instances when only one was expected') # if refs[0]['ManagedElement'] != ucs_op: # self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid') # if refs[0]['SettingData'] != hnsd_op: @@ -301,7 +301,7 @@ # # assocs = self._conn.AssociatorNames(ucs_op, AssocClass='OMC_ComputerSystemHostNameSettingData') # if 1 < len(assocs): -# self.fail('AssociatorNames of OMC_UnitaryComputerSystem returned multiple instances when only one was expected') +# self.fail('AssociatorNames of OMC_ComputerSystem returned multiple instances when only one was expected') # qualified_hnsd_op = str(hnsd_op) # if not qualified_hnsd_op.startswith('//%s/' % getfqdn()): # qualified_hnsd_op = '//%s/%s' % (getfqdn(), str(hnsd_op)) @@ -467,11 +467,11 @@ # else: # self.fail("OMC_OperatingSystem _isSupportedAssn failed") - def test_unitary_computer_system(self): - ucsClasses = {'OMC_UnitaryComputerSystem' : self._omc_unitarycomputersystem_test, + def test_computer_system(self): + ucsClasses = {'OMC_ComputerSystem' : self._omc_computersystem_test, 'OMC_HostNameSettingData' : self._omc_hostnamesettingdata_test, 'OMC_ComputerSystemHostNameSettingData' : self._omc_computersystemhostnamesettingdata_test} - self._run_omcbase_component_tests('unitary_computer_system', ucsClasses) + self._run_omcbase_component_tests('computer_system', ucsClasses) # # def _omc_process_executable(self): # '''OMC_ProcessExecutable''' @@ -569,7 +569,7 @@ # ci = pywbem.CIMInstance("OMC_SystemTimeService") # ci['CreationClassName'] = "OMC_SystemTimeService" # ci['Name'] = "timeservice_test" -# ci['SystemCreationClassName'] = "OMC_UnitaryComputerSystem" +# ci['SystemCreationClassName'] = "OMC_ComputerSystem" # ci['SystemName'] = "c119.cim.lab.novell.com" # ci['AvailableRequestedState'] = [ pywbem.Uint16(2) ] # ci['Caption'] = 'test' @@ -647,7 +647,7 @@ # # def _omc_hosted_time_service(self): # if self._isSupportedAssn('OMC_HostedTimeService', -# 'OMC_UnitaryComputerSystem', +# 'OMC_ComputerSystem', # 'OMC_SystemTimeService', # 'h_time_test'): # try: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-15 21:04:54
|
Revision: 972 http://omc.svn.sourceforge.net/omc/?rev=972&view=rev Author: bartw Date: 2008-09-15 21:05:04 +0000 (Mon, 15 Sep 2008) Log Message: ----------- try a few unix sockets Modified Paths: -------------- test/trunk/lib/wbem_connection.py Modified: test/trunk/lib/wbem_connection.py =================================================================== --- test/trunk/lib/wbem_connection.py 2008-09-15 20:50:11 UTC (rev 971) +++ test/trunk/lib/wbem_connection.py 2008-09-15 21:05:04 UTC (rev 972) @@ -20,9 +20,21 @@ #def get_wbem_connection(url=none): def get_wbem_connection(self): """Return a wbem connection to ZOS_SERVER""" - conn = pywbem.WBEMConnection('https://localhost', ('root', 'novell')) -#conn.default_namespace = 'root/ZENworks' - return conn + for args in ( + ('https://localhost', ('root','novell')), + ('/var/run/tog-pegasus/cimxml.socket',), + ('/tmp/OW@LCL@APIIPC_72859_Xq47Bf_P9r761-5_J-7_Q',), + ): + try: + conn = pywbem.WBEMConnection(*args) + conn.GetClass('CIM_ManagedElement') + return conn + except pywbem.CIMError, ce: + continue + except pywbem.cim_http.AuthError, ce: + continue + else: + raise ce def get_default_namespace(self): return self.namespace This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-15 20:50:01
|
Revision: 971 http://omc.svn.sourceforge.net/omc/?rev=971&view=rev Author: bartw Date: 2008-09-15 20:50:11 +0000 (Mon, 15 Sep 2008) Log Message: ----------- Branched old code to port to new python provider interface. Added Paths: ----------- pybase/branches/old-style_prov_ifc/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-15 20:44:12
|
Revision: 970 http://omc.svn.sourceforge.net/omc/?rev=970&view=rev Author: bartw Date: 2008-09-15 20:44:20 +0000 (Mon, 15 Sep 2008) Log Message: ----------- bug fixes Modified Paths: -------------- pybase/trunk/OMC_Base.mof pybase/trunk/OMC_LogicalFile.py pybase/trunk/OMC_SyslogNG.py Added Paths: ----------- pybase/branches/ Modified: pybase/trunk/OMC_Base.mof =================================================================== --- pybase/trunk/OMC_Base.mof 2008-09-15 15:48:57 UTC (rev 969) +++ pybase/trunk/OMC_Base.mof 2008-09-15 20:44:20 UTC (rev 970) @@ -3,6 +3,5 @@ #pragma include ("OMC_LogicalFile.mof") #pragma include ("OMC_UnixProcess.mof") #pragma include ("OMC_InitdService.mof") -#pragma include ("OMC_InitdService.mof") #pragma include ("OMC_TimeService.mof") #pragma include ("OMC_SyslogNG.mof") Modified: pybase/trunk/OMC_LogicalFile.py =================================================================== --- pybase/trunk/OMC_LogicalFile.py 2008-09-15 15:48:57 UTC (rev 969) +++ pybase/trunk/OMC_LogicalFile.py 2008-09-15 20:44:20 UTC (rev 970) @@ -76,7 +76,10 @@ if target[0] != '/': target = os.path.dirname(dev)+'/'+target dev = os.path.abspath(target) - _mounts[os.stat(line[1])[ST_DEV]] = dev + try: + _mounts[os.stat(line[1])[ST_DEV]] = dev + except OSError: + pass _guard.release() mfile.close() Modified: pybase/trunk/OMC_SyslogNG.py =================================================================== --- pybase/trunk/OMC_SyslogNG.py 2008-09-15 15:48:57 UTC (rev 969) +++ pybase/trunk/OMC_SyslogNG.py 2008-09-15 20:44:20 UTC (rev 970) @@ -569,7 +569,8 @@ break else: raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) - ux(RecordData=line.strip()) + ux(RecordData=line.strip().decode('latin_1', 'xmlcharrefreplace')) + #ux(RecordData=line.strip()) ux(ElementName=fname) #ux(Caption='') # TODO This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-15 15:48:52
|
Revision: 969 http://omc.svn.sourceforge.net/omc/?rev=969&view=rev Author: bartw Date: 2008-09-15 15:48:57 +0000 (Mon, 15 Sep 2008) Log Message: ----------- added some TODO items Modified Paths: -------------- cmpi-bindings/trunk/TODO Modified: cmpi-bindings/trunk/TODO =================================================================== --- cmpi-bindings/trunk/TODO 2008-09-14 04:09:52 UTC (rev 968) +++ cmpi-bindings/trunk/TODO 2008-09-15 15:48:57 UTC (rev 969) @@ -17,3 +17,9 @@ Wrap CMPIEnumeration and CMPIArray in typemaps. +Indication providers + +Port omc/pybase and omc/pyprofiles to new interface. + +Update docs on pywbem wiki, starting with quickstart guide. + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-13 20:19:44
|
Revision: 967 http://omc.svn.sourceforge.net/omc/?rev=967&view=rev Author: bartw Date: 2008-09-13 20:19:55 +0000 (Sat, 13 Sep 2008) Log Message: ----------- Provided an alternative to references, where associations can be had for free based on enum_instances. Modified Paths: -------------- cmpi-bindings/trunk/swig/python/cim_provider.py Modified: cmpi-bindings/trunk/swig/python/cim_provider.py =================================================================== --- cmpi-bindings/trunk/swig/python/cim_provider.py 2008-09-13 05:46:27 UTC (rev 966) +++ cmpi-bindings/trunk/swig/python/cim_provider.py 2008-09-13 20:19:55 UTC (rev 967) @@ -199,10 +199,8 @@ 'is_subclass', 'codegen'] -class _NotImplemented(Exception): - pass -def _path_equals_ignore_host(lhs, rhs): +def _paths_equal(lhs, rhs): """If one object path doesn't inlcude a host, don't include the hosts in the comparison @@ -417,8 +415,8 @@ | ~~~~~~~~~~~~~~~~~~~~~ | | ~~~~~~~~~~~~~~~~~ | +------------------------+ +-------------------+ | +-----------------------------------+ | - | | [Association] assoc_class | | - | object_name | ~~~~~~~~~~~~~~~~~~~~~~~~~ | | + | | [Association] model.classname | | + | object_name | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | +--------------+ object_name.classname REF role | | (CIMInstanceName) | result_class_name REF result_role +------+ | |(CIMInstanceName) @@ -433,8 +431,39 @@ CIM_ERR_FAILED (some other unspecified error occurred) """ - raise _NotImplemented() + # Don't change this return value. If affects the behavior + # of the MI_* methods. + return None + def simple_refs(self, env, object_name, model, + result_class_name, role, result_role, keys_only): + + gen = self.enum_instances(env, model, model.property_list, keys_only) + for inst in gen: + for prop in inst.properties.values(): + if prop.type != 'reference': + continue + if role and prop.name.lower() != role: + continue + if self.paths_equal(object_name, prop.value): + yield inst + + + def paths_equal(self, lhs, rhs): + """If one object path doesn't inlcude a host, don't include the hosts + in the comparison + + """ + + if lhs is rhs: + return True + if lhs.host is not None and rhs.host is not None and lhs.host != rhs.host: + return False + # need to make sure this stays in sync with CIMInstanceName.__cmp__() + return not (pywbem.cmpname(rhs.classname, lhs.classname) or + cmp(rhs.keybindings, lhs.keybindings) or + pywbem.cmpname(rhs.namespace, lhs.namespace)) + def _set_filter_results(self, value): self._filter_results = value def _get_filter_results(self): @@ -653,13 +682,17 @@ model = pywbem.CIMInstance(classname=assocClassName) model.path = pywbem.CIMInstanceName(classname=assocClassName, namespace=objectName.namespace) - for inst in self.references(env=env, + gen = self.references(env=env, object_name=objectName, model=model, result_class_name=resultClassName, role=role, result_role=None, - keys_only=False): + keys_only=False) + if gen is None: + logger.log_debug('references() returned None instead of generator object') + return + for inst in gen: for prop in inst.properties.values(): lpname = prop.name.lower() if prop.type != 'reference': @@ -668,7 +701,7 @@ continue if resultRole and resultRole.lower() != lpname: continue - if _path_equals_ignore_host(prop.value, objectName): + if self.paths_equal(prop.value, objectName): continue if resultClassName and self.filter_results and \ resultClassName.lower() != prop.value.classname.lower(): @@ -710,13 +743,17 @@ model = pywbem.CIMInstance(classname=assocClassName) model.path = pywbem.CIMInstanceName(classname=assocClassName, namespace=objectName.namespace) - for inst in self.references(env=env, + gen = self.references(env=env, object_name=objectName, model=model, result_class_name=resultClassName, role=role, result_role=None, - keys_only=False): + keys_only=False) + if gen is None: + logger.log_debug('references() returned None instead of generator object') + return + for inst in gen: for prop in inst.properties.values(): lpname = prop.name.lower() if prop.type != 'reference': @@ -725,7 +762,7 @@ continue if resultRole and resultRole.lower() != lpname: continue - if _path_equals_ignore_host(prop.value, objectName): + if self.paths_equal(prop.value, objectName): continue if resultClassName and self.filter_results and \ resultClassName.lower() != prop.value.classname.lower(): @@ -766,13 +803,17 @@ "** this shouldn't happen") model[role] = objectName - for inst in self.references(env=env, + gen = self.references(env=env, object_name=objectName, model=model, result_class_name='', role=role, result_role=None, - keys_only=False): + keys_only=False) + if gen is None: + logger.log_debug('references() returned None instead of generator object') + return + for inst in gen: if self.filter_results and plist is not None: inst = inst.copy() filter_instance(inst, plist) @@ -810,13 +851,17 @@ raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, "** this shouldn't happen") model[role] = objectName - for inst in self.references(env=env, + gen = self.references(env=env, object_name=objectName, model=model, result_class_name='', role=role, result_role=None, - keys_only=True): + keys_only=True) + if gen is None: + logger.log_debug('references() returned None instead of generator object') + return + for inst in gen: for prop in inst.properties.values(): if hasattr(prop.value, 'namespace') and prop.value.namespace is None: prop.value.namespace = objectName.namespace @@ -1382,20 +1427,48 @@ %% self.__class__.__name__) ch = env.get_cimom_handle()''' % \ (args, CIMProvider.references.__doc__) + + refprops = [] + for prop in cc.properties.values(): + if prop.reference_class is not None: + refprops.append((prop.name, prop.reference_class)) + + code+= '''\n + # If you want to get references for free, implemented in terms + # of enum_instances, just leave the code below unaltered.''' + + for i, refprop in enumerate(refprops): + if i == 0: + code+= ''' + if ch.is_subclass(object_name.namespace, + sub=object_name.classname, + super='%s')''' % refprop[1] + + else: + code+= ''' or \\ + ch.is_subclass(object_name.namespace, + sub=object_name.classname, + super='%s')''' % refprop[1] + code+=''': + return self.simple_refs(env, object_name, model, + result_class_name, role, result_role, keys_only) + ''' + + code+=''' + # If you are doing simple refs with the code above, remove the + # remainder of this method. Or, remove the stuff above and + # implement references below. + # # Prime model.path with knowledge of the keys, so key values on # the CIMInstanceName (model.path) will automatically be set when # we set property values on the model. model.path.update(%s) - ''' % str(keydict) - refprops = [] - for prop in cc.properties.values(): - if prop.reference_class is not None: - refprops.append((prop.name, prop.reference_class)) + # This is a common pattern. YMMV''' % str(keydict) + for refprop in refprops: code+= ''' - # This is a common pattern. YMMV if (not role or role.lower() == '%(refpropnamel)s') and \\ ch.is_subclass(object_name.namespace, sub=object_name.classname, @@ -1721,17 +1794,14 @@ for lcname in lcnames: fn = self._get_callable(lcname, 'MI_associators', is_assoc) if fn is not None: - try: - for i in fn(env, - objectName, - lcname, - resultClassName, - role, - resultRole, - propertyList): - yield i - except _NotImplemented: - continue + for i in fn(env, + objectName, + lcname, + resultClassName, + role, + resultRole, + propertyList): + yield i logger.log_debug('CIMProvider MI_associators returning') ############################################################################## @@ -1769,16 +1839,13 @@ for lcname in lcnames: fn = self._get_callable(lcname, 'MI_associatorNames', is_assoc) if fn is not None: - try: - for i in fn(env, - objectName, - lcname, - resultClassName, - role, - resultRole): - yield i - except _NotImplemented: - continue + for i in fn(env, + objectName, + lcname, + resultClassName, + role, + resultRole): + yield i logger.log_debug('CIMProvider MI_associatorNames returning') @@ -1811,15 +1878,12 @@ for lcname in lcnames: fn = self._get_callable(lcname, 'MI_references', is_assoc) if fn is not None: - try: - for i in fn(env, - objectName, - lcname, - role, - propertyList): - yield i - except _NotImplemented: - continue + for i in fn(env, + objectName, + lcname, + role, + propertyList): + yield i logger.log_debug('CIMProvider MI_references returning') @@ -1852,14 +1916,11 @@ for lcname in lcnames: fn = self._get_callable(lcname, 'MI_referenceNames', is_assoc) if fn is not None: - try: - for i in fn(env, - objectName, - lcname, - role): - yield i - except _NotImplemented: - continue + for i in fn(env, + objectName, + lcname, + role): + yield i logger.log_debug('CIMProvider MI_referenceNames returning') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-13 05:46:18
|
Revision: 966 http://omc.svn.sourceforge.net/omc/?rev=966&view=rev Author: bartw Date: 2008-09-13 05:46:27 +0000 (Sat, 13 Sep 2008) Log Message: ----------- some codegen fixes, switch to new upcall CIMOM handle Modified Paths: -------------- cmpi-bindings/trunk/swig/python/cim_provider.py cmpi-bindings/trunk/swig/python/cmpi_bindings.py Modified: cmpi-bindings/trunk/swig/python/cim_provider.py =================================================================== --- cmpi-bindings/trunk/swig/python/cim_provider.py 2008-09-12 21:07:21 UTC (rev 965) +++ cmpi-bindings/trunk/swig/python/cim_provider.py 2008-09-13 05:46:27 UTC (rev 966) @@ -649,7 +649,7 @@ if not assocClassName: raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, "Empty assocClassName passed to Associators") - ch = env.get_cimom_handle2() + ch = env.get_cimom_handle() model = pywbem.CIMInstance(classname=assocClassName) model.path = pywbem.CIMInstanceName(classname=assocClassName, namespace=objectName.namespace) @@ -1197,6 +1197,13 @@ ''' % (args, CIMProvider.get_instance.__doc__ ) keyProps = [p for p in cc.properties.values() \ if 'key' in p.qualifiers] + if not keyProps and 'association' in cc.qualifiers: + # SFCB has problems with qualifiers on REF properties. + # http://sourceforge.net/tracker/index.php?func=detail&aid=2104565&group_id=128809&atid=712784 + keyProps = [p for p in cc.properties.values() \ + if p.type == 'reference'] + for prop in keyProps: + prop.qualifiers['KEY'] = True code+= ''' # TODO fetch system resource matching the following keys:''' @@ -1226,13 +1233,13 @@ logger.log_debug('Entering %%s.enum_instances()' \\ %% self.__class__.__name__) ''' % (args, CIMProvider.enum_instances.__doc__) - kd = dict([(kp.name, None) for kp in keyProps]) + keydict = dict([(kp.name, None) for kp in keyProps]) code+= ''' # Prime model.path with knowledge of the keys, so key values on # the CIMInstanceName (model.path) will automatically be set when # we set property values on the model. model.path.update(%s) - ''' % str(kd) + ''' % str(keydict) code+= ''' while False: # TODO more instances? @@ -1373,15 +1380,22 @@ logger = env.get_logger() logger.log_debug('Entering %%s.references()' \\ %% self.__class__.__name__) - ch = env.get_cimom_handle() - # This is a common pattern. YMMV''' % \ + ch = env.get_cimom_handle()''' % \ (args, CIMProvider.references.__doc__) + code+=''' + # Prime model.path with knowledge of the keys, so key values on + # the CIMInstanceName (model.path) will automatically be set when + # we set property values on the model. + model.path.update(%s) + ''' % str(keydict) + refprops = [] for prop in cc.properties.values(): if prop.reference_class is not None: refprops.append((prop.name, prop.reference_class)) for refprop in refprops: code+= ''' + # This is a common pattern. YMMV if (not role or role.lower() == '%(refpropnamel)s') and \\ ch.is_subclass(object_name.namespace, sub=object_name.classname, @@ -1456,7 +1470,7 @@ mof =''' // SFCB Provider registration for %(classname)s [%(classname)s] - provider: %(classname)sProvider + provider: %(classname)s location: pyCmpiProvider type: %(sfcbtypes)s namespace: root/cimv2 // TODO @@ -1474,14 +1488,14 @@ }; instance of PG_Provider { - Name = "%(classname)sProvider"; + Name = "%(classname)s"; ProviderModuleName = "pyCmpiProvider_%(classname)s"; }; instance of PG_ProviderCapabilities { CapabilityID = "%(classname)s"; ProviderModuleName = "pyCmpiProvider_%(classname)s"; - ProviderName = "%(classname)sProvider"; + ProviderName = "%(classname)s"; ClassName = "%(classname)s"; Namespaces = {"root/cimv2"}; // TODO ProviderType = {%(pegtypeNum)s}; // %(pegtypeStr)s Modified: cmpi-bindings/trunk/swig/python/cmpi_bindings.py =================================================================== --- cmpi-bindings/trunk/swig/python/cmpi_bindings.py 2008-09-12 21:07:21 UTC (rev 965) +++ cmpi-bindings/trunk/swig/python/cmpi_bindings.py 2008-09-13 05:46:27 UTC (rev 966) @@ -149,9 +149,9 @@ self.ctx = None def get_logger(self): return Logger(self.proxy.broker) + #def get_cimom_handle(self): + # return SFCBUDSConnection() def get_cimom_handle(self): - return SFCBUDSConnection() - def get_cimom_handle2(self): return BrokerCIMOMHandle(self.proxy, self.ctx) def get_user_name(self): pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <np...@us...> - 2008-09-12 22:48:39
|
Revision: 962 http://omc.svn.sourceforge.net/omc/?rev=962&view=rev Author: npaxton Date: 2008-09-12 20:12:12 +0000 (Fri, 12 Sep 2008) Log Message: ----------- remove 'memory leak' TODO Modified Paths: -------------- cmpi-bindings/trunk/TODO Modified: cmpi-bindings/trunk/TODO =================================================================== --- cmpi-bindings/trunk/TODO 2008-09-12 17:36:49 UTC (rev 961) +++ cmpi-bindings/trunk/TODO 2008-09-12 20:12:12 UTC (rev 962) @@ -2,8 +2,6 @@ brokerEncFT, and which are created with clone(). We have to release the later, not the former. -Fix memory leaks related to cloning of CMPIData structs. - Items marked as "TODO" in the code. Finish wrapping broker FTs, such as upcalls. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-12 22:19:30
|
Revision: 964 http://omc.svn.sourceforge.net/omc/?rev=964&view=rev Author: bartw Date: 2008-09-12 21:04:22 +0000 (Fri, 12 Sep 2008) Log Message: ----------- removed old code Modified Paths: -------------- cmpi-bindings/trunk/swig/cmpi_callbacks.i Modified: cmpi-bindings/trunk/swig/cmpi_callbacks.i =================================================================== --- cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-09-12 20:48:21 UTC (rev 963) +++ cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-09-12 21:04:22 UTC (rev 964) @@ -9,7 +9,6 @@ %extend CMPIBroker { - /* TODO remove CMPIBroker() { return _BROKER; } */ void LogMessage(int severity, const char *id, const char *text) { CMLogMessage($self, severity, id, text, NULL); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-12 22:19:27
|
Revision: 965 http://omc.svn.sourceforge.net/omc/?rev=965&view=rev Author: bartw Date: 2008-09-12 21:07:21 +0000 (Fri, 12 Sep 2008) Log Message: ----------- some code cleanup Modified Paths: -------------- cmpi-bindings/trunk/src/cmpi_provider_python.c Modified: cmpi-bindings/trunk/src/cmpi_provider_python.c =================================================================== --- cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-12 21:04:22 UTC (rev 964) +++ cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-12 21:07:21 UTC (rev 965) @@ -497,8 +497,6 @@ } pthread_mutex_unlock(&_CMPI_INIT_MUTEX); - /* Finished. */ -exit: _SBLIM_TRACE(1,("Cleanup() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -580,7 +578,6 @@ pyresult, pyreference); -exit: _SBLIM_TRACE(1,("EnumInstanceNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -617,7 +614,6 @@ pyreference, pyproperties); -exit: _SBLIM_TRACE(1,("EnumInstances() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -653,7 +649,6 @@ pyreference, pyproperties); -exit: _SBLIM_TRACE(1,("GetInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -691,8 +686,6 @@ pyreference, pynewinst); - /* Finished. */ -exit: _SBLIM_TRACE(1,("CreateInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -736,8 +729,6 @@ pynewinst, plist); - /* Finished. */ -exit: _SBLIM_TRACE(1,("SetInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -769,8 +760,6 @@ pyresult, pyreference); - /* Finished. */ -exit: _SBLIM_TRACE(1,("DeleteInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -810,8 +799,6 @@ /* Query filtering is not supported for this class. */ - /* Finished. */ -exit: _SBLIM_TRACE(1,("ExecQuery() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -873,10 +860,7 @@ pyrole, pyresultRole); - /* Query filtering is not supported for this class. */ - /* Finished. */ -exit: _SBLIM_TRACE(1,("associatorNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -936,10 +920,7 @@ pyresultRole, pyprops); - /* Query filtering is not supported for this class. */ - /* Finished. */ -exit: _SBLIM_TRACE(1,("associators() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -982,10 +963,7 @@ pyresultClass, pyrole); - /* Query filtering is not supported for this class. */ - /* Finished. */ -exit: _SBLIM_TRACE(1,("referenceNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -1032,8 +1010,6 @@ pyrole, pyprops); - /* Finished. */ -exit: _SBLIM_TRACE(1,("references() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -1071,8 +1047,6 @@ pyin, pyout); - /* Finished. */ -exit: _SBLIM_TRACE(1,("invokeMethod() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -1107,8 +1081,6 @@ pyclassPath, pyowner); - /* Finished. */ -exit: _SBLIM_TRACE(1,("authorizeFilter() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -1143,8 +1115,6 @@ pyclassPath, pyfirstActivation); - /* Finished. */ -exit: _SBLIM_TRACE(1,("activateFilter() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -1179,8 +1149,6 @@ pyclassPath, pylastActivation); - /* Finished. */ -exit: _SBLIM_TRACE(1,("deActivateFilter() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -1219,8 +1187,6 @@ pyclassName, pyclassPath); - /* Finished. */ -exit: _SBLIM_TRACE(1,("mustPoll() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -1243,8 +1209,6 @@ call_py_provider((PyProviderMIHandle*)self->hdl, &status, "enable_indications", 1, pyctx); - /* Finished. */ -exit: _SBLIM_TRACE(1,("enableIndications() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; @@ -1267,8 +1231,6 @@ call_py_provider((PyProviderMIHandle*)self->hdl, &status, "disable_indications", 1, pyctx); - /* Finished. */ -exit: _SBLIM_TRACE(1,("disableIndications() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-12 17:36:39
|
Revision: 961 http://omc.svn.sourceforge.net/omc/?rev=961&view=rev Author: bartw Date: 2008-09-12 17:36:49 +0000 (Fri, 12 Sep 2008) Log Message: ----------- start on _BROKER refactor Modified Paths: -------------- cmpi-bindings/trunk/src/cmpi_provider_python.c cmpi-bindings/trunk/swig/cmpi.i Modified: cmpi-bindings/trunk/src/cmpi_provider_python.c =================================================================== --- cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-12 17:23:18 UTC (rev 960) +++ cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-12 17:36:49 UTC (rev 961) @@ -198,7 +198,7 @@ #define TB_ERROR(str) {tbstr = str; goto cleanup;} static CMPIString* -get_exc_trace() +get_exc_trace(const CMPIBroker* broker) { char *tbstr = NULL; @@ -267,7 +267,7 @@ tbstr = PyString_AsString(newstr); char* tmp = fmtstr("cmpi:%s", tbstr); - rv = _BROKER->eft->newString(_BROKER, tmp, NULL); + rv = broker->eft->newString(broker, tmp, NULL); free(tmp); cleanup: @@ -275,7 +275,7 @@ if (rv == NULL) { - rv = _BROKER->eft->newString(_BROKER, tbstr ? tbstr : "", NULL); + rv = broker->eft->newString(broker, tbstr ? tbstr : "", NULL); } Py_DecRef(func); @@ -294,7 +294,7 @@ SWIGEXPORT void SWIG_init(void); #define PY_CMPI_SETFAIL(msgstr) {if (st != NULL) st->rc = CMPI_RC_ERR_FAILED; st->msg = msgstr; } -static int PyGlobalInitialize(CMPIStatus* st) +static int PyGlobalInitialize(const CMPIBroker* broker, CMPIStatus* st) { int rc = 0; @@ -321,7 +321,7 @@ { SWIG_PYTHON_THREAD_END_BLOCK; _SBLIM_TRACE(1,("<%d/0x%x> Python: import cmpi_bindings failed", getpid(), pthread_self())); - PY_CMPI_SETFAIL(get_exc_trace()); + PY_CMPI_SETFAIL(get_exc_trace(broker)); abort(); return -1; } @@ -344,7 +344,7 @@ perror("Can't lock _CMPI_INIT_MUTEX"); abort(); } - rc = PyGlobalInitialize(st); + rc = PyGlobalInitialize(hdl->broker, st); pthread_mutex_unlock(&_CMPI_INIT_MUTEX); if (rc != 0) { @@ -359,10 +359,10 @@ if (provclass == NULL) { SWIG_PYTHON_THREAD_END_BLOCK; - PY_CMPI_SETFAIL(get_exc_trace()); + PY_CMPI_SETFAIL(get_exc_trace(hdl->broker)); return -1; } - PyObject* broker = SWIG_NewPointerObj((void*) _BROKER, SWIGTYPE_p__CMPIBroker, 0); + PyObject* broker = SWIG_NewPointerObj((void*) hdl->broker, SWIGTYPE_p__CMPIBroker, 0); PyObject* args = PyTuple_New(2); _SBLIM_TRACE(1,("\n<%d/0x%x> >>>>> PyInitialize(Python) called, MINAME=%s\n", getpid(), pthread_self(), hdl->miName)); @@ -374,7 +374,7 @@ if (provinst == NULL) { SWIG_PYTHON_THREAD_END_BLOCK; - PY_CMPI_SETFAIL(get_exc_trace()); + PY_CMPI_SETFAIL(get_exc_trace(hdl->broker)); return -1; } @@ -431,7 +431,7 @@ char* str = fmtstr("Python module does not contain \"%s\"", opname); _SBLIM_TRACE(1,(str)); st->rc = CMPI_RC_ERR_FAILED; - st->msg = _BROKER->eft->newString(_BROKER, str, NULL); + st->msg = hdl->broker->eft->newString(hdl->broker, str, NULL); free(str); rc = 1; goto cleanup; @@ -442,7 +442,7 @@ opname); _SBLIM_TRACE(1,(str)); st->rc = CMPI_RC_ERR_FAILED; - st->msg = _BROKER->eft->newString(_BROKER, str, NULL); + st->msg = hdl->broker->eft->newString(hdl->broker, str, NULL); free(str); rc = 1; goto cleanup; @@ -465,7 +465,7 @@ if (PyErr_Occurred()) { st->rc = CMPI_RC_ERR_FAILED; - st->msg = get_exc_trace(); + st->msg = get_exc_trace(hdl->broker); PyErr_Clear(); rc = 1; goto cleanup; @@ -479,7 +479,7 @@ opname); _SBLIM_TRACE(1,(str)); st->rc = CMPI_RC_ERR_FAILED; - st->msg = _BROKER->eft->newString(_BROKER, str, NULL); + st->msg = hdl->broker->eft->newString(hdl->broker, str, NULL); free(str); rc = 1; SWIG_PYTHON_THREAD_END_ALLOW; @@ -498,7 +498,7 @@ char* str = fmtstr("Python function \"%s\" didn't return a {<int>, <str>) two-tuple", opname); _SBLIM_TRACE(1,(str)); st->rc = CMPI_RC_ERR_FAILED; - st->msg = _BROKER->eft->newString(_BROKER, str, NULL); + st->msg = hdl->broker->eft->newString(hdl->broker, str, NULL); free(str); rc = 1; SWIG_PYTHON_THREAD_END_ALLOW; @@ -509,12 +509,13 @@ if (prstr == Py_None) { SWIG_PYTHON_THREAD_BEGIN_ALLOW; - st->msg = _BROKER->eft->newString(_BROKER, "", NULL); + st->msg = hdl->broker->eft->newString(hdl->broker, "", NULL); SWIG_PYTHON_THREAD_END_ALLOW; } else { - st->msg = _BROKER->eft->newString(_BROKER, PyString_AsString(prstr), NULL); + st->msg = hdl->broker->eft->newString(hdl->broker, + PyString_AsString(prstr), NULL); } rc = pi != 0; cleanup: @@ -748,10 +749,6 @@ PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; - { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - SWIG_PYTHON_THREAD_END_BLOCK; - } PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); PyObject *pyresult = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); @@ -1489,7 +1486,6 @@ { _SBLIM_TRACE(1,("\n>>>>> createInit(Python) called, miname= %s (ctx=%p)\n", miname, context)); - //_MINAME = strdup(miname); /* * We can't initialize Python here and load Python modules, because * SFCB passes a NULL CMPIStatus* st, which means we can't report Modified: cmpi-bindings/trunk/swig/cmpi.i =================================================================== --- cmpi-bindings/trunk/swig/cmpi.i 2008-09-12 17:23:18 UTC (rev 960) +++ cmpi-bindings/trunk/swig/cmpi.i 2008-09-12 17:36:49 UTC (rev 961) @@ -43,6 +43,6 @@ # Data types %include "cmpi_types.i" -# _BROKER callbacks +# Broker callbacks %include "cmpi_callbacks.i" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <np...@us...> - 2008-09-12 17:23:11
|
Revision: 960 http://omc.svn.sourceforge.net/omc/?rev=960&view=rev Author: npaxton Date: 2008-09-12 17:23:18 +0000 (Fri, 12 Sep 2008) Log Message: ----------- change ownership flag on cloned data, validate that memory leak potential is gone... note this is for python only... ruby may still need ownership flag changed from 0 to 1 Modified Paths: -------------- cmpi-bindings/trunk/swig/cmpi_types.i Modified: cmpi-bindings/trunk/swig/cmpi_types.i =================================================================== --- cmpi-bindings/trunk/swig/cmpi_types.i 2008-09-12 01:51:38 UTC (rev 959) +++ cmpi-bindings/trunk/swig/cmpi_types.i 2008-09-12 17:23:18 UTC (rev 960) @@ -410,9 +410,8 @@ return rb_ary_push( rb_ary_push( rl, rbdata ), rb_str_new2(CMGetCharPtr(s) ) ); #endif #if defined (SWIGPYTHON) - #TODO memory leak alert (clone_data) SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0); + PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 1); PyObject* pl = PyTuple_New(2); PyTuple_SetItem(pl, 0, pydata); @@ -627,9 +626,8 @@ return rb_ary_push( rb_ary_push( rl, rbdata ), rb_str_new2(CMGetCharPtr(s) ) ); #endif #if defined (SWIGPYTHON) - #TODO memory leak alert (clone_data) SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0); + PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 1); PyObject* pl = PyTuple_New(2); PyTuple_SetItem(pl, 0, pydata); @@ -725,9 +723,8 @@ return rb_ary_push( rb_ary_push( rl, rbdata ), rb_str_new2(CMGetCharPtr(s) ) ); #endif #if defined (SWIGPYTHON) - #TODO memory leak alert (clone_data) SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0); + PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 1); PyObject* pl = PyTuple_New(2); PyTuple_SetItem(pl, 0, pydata); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mik...@us...> - 2008-09-12 01:51:28
|
Revision: 959 http://omc.svn.sourceforge.net/omc/?rev=959&view=rev Author: mike-brasher Date: 2008-09-12 01:51:38 +0000 (Fri, 12 Sep 2008) Log Message: ----------- Implemented thread-specific-data broker stacks and push/pop/top operations. _BROKER is now a #define to "_get_broker()". Modified Paths: -------------- cmpi-bindings/trunk/src/cmpi_provider_python.c Modified: cmpi-bindings/trunk/src/cmpi_provider_python.c =================================================================== --- cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-11 22:38:15 UTC (rev 958) +++ cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-12 01:51:38 UTC (rev 959) @@ -59,8 +59,92 @@ } #endif -/* Global handle to the CIM broker. This is initialized by the CIMOM when the provider is loaded */ -static const CMPIBroker * _BROKER = NULL; +/* +**============================================================================== +** +** _get_broker() +** +**============================================================================== +*/ + +pthread_key_t _cmpi_broker_key; +pthread_once_t _cmpi_broker_key_once = PTHREAD_ONCE_INIT; + +typedef struct _CMPIBrokerElem +{ + const CMPIBroker* broker; + struct _CMPIBrokerElem* next; +} +CMPIBrokerElem; + +static void _once() +{ + pthread_key_create(&_cmpi_broker_key, NULL); +} + +static const CMPIBroker* _get_broker() +{ + CMPIBrokerElem* e; + + pthread_once(&_cmpi_broker_key_once, _once); + + if (!(e = (CMPIBrokerElem*)pthread_getspecific(_cmpi_broker_key))) + return NULL; + + return e->broker; +} + +static void _push_broker(const CMPIBroker* broker) +{ + CMPIBrokerElem* e; + + printf("****** PUSH(%p)\n", broker); + + if (!broker) + { + assert("_push_broker() failed" == NULL); + return; + } + + pthread_once(&_cmpi_broker_key_once, _once); + e = (CMPIBrokerElem*)malloc(sizeof(CMPIBrokerElem)); + e->broker = broker; + e->next = (CMPIBrokerElem*)pthread_getspecific(_cmpi_broker_key); + pthread_setspecific(_cmpi_broker_key, e); +} + +static const CMPIBroker* _pop_broker() +{ + CMPIBrokerElem* e; + const CMPIBroker* broker; + pthread_once(&_cmpi_broker_key_once, _once); + + if (!(e = (CMPIBrokerElem*)pthread_getspecific(_cmpi_broker_key))) + { + assert("_pop_broker() failed" == NULL); + return NULL; + } + + pthread_setspecific(_cmpi_broker_key, e->next); + + broker = e->broker; + free(e); + + printf("****** POP(%p)\n", broker); + + return broker; +} + +#define _BROKER _get_broker() + +/* +**============================================================================== +** +** Local definitions: +** +**============================================================================== +*/ + static pthread_mutex_t _CMPI_INIT_MUTEX = PTHREAD_MUTEX_INITIALIZER; static int _PY_INIT = 0; // acts as a boolean - is Python Initialized static int _MI_COUNT = 0; @@ -72,28 +156,29 @@ { char *miName; PyObject *pyMod; + const CMPIBroker* broker; } PyProviderMIHandle; static char* fmtstr(const char* fmt, ...) { va_list ap; int len; - va_start(ap, fmt); + va_start(ap, fmt); len = vsnprintf(NULL, 0, fmt, ap); - va_end(ap); + va_end(ap); if (len <= 0) { - return NULL; - } - char* str = (char*)malloc(len+1); - if (str == NULL) - { - return NULL; - } - va_start(ap, fmt); - vsnprintf(str, len+1, fmt, ap); - va_end(ap); - return str; + return NULL; + } + char* str = (char*)malloc(len+1); + if (str == NULL) + { + return NULL; + } + va_start(ap, fmt); + vsnprintf(str, len+1, fmt, ap); + va_end(ap); + return str; } @@ -115,95 +200,95 @@ static CMPIString* get_exc_trace() { - char *tbstr = NULL; + char *tbstr = NULL; - PyObject *iostrmod = NULL; - PyObject *tbmod = NULL; - PyObject *iostr = NULL; - PyObject *obstr = NULL; - PyObject *args = NULL; - PyObject *newstr = NULL; - PyObject *func = NULL; - CMPIString* rv = NULL; + PyObject *iostrmod = NULL; + PyObject *tbmod = NULL; + PyObject *iostr = NULL; + PyObject *obstr = NULL; + PyObject *args = NULL; + PyObject *newstr = NULL; + PyObject *func = NULL; + CMPIString* rv = NULL; - PyObject *type, *value, *traceback; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_Fetch(&type, &value, &traceback); + PyObject *type, *value, *traceback; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_Fetch(&type, &value, &traceback); _SBLIM_TRACE(1,("** type %p, value %p, traceback %p", type, value, traceback)); - PyErr_Print(); - PyErr_Clear(); - PyErr_NormalizeException(&type, &value, &traceback); + PyErr_Print(); + PyErr_Clear(); + PyErr_NormalizeException(&type, &value, &traceback); _SBLIM_TRACE(1,("** type %p, value %p, traceback %p", type, value, traceback)); - iostrmod = PyImport_ImportModule("StringIO"); - if (iostrmod==NULL) - TB_ERROR("can't import StringIO"); + iostrmod = PyImport_ImportModule("StringIO"); + if (iostrmod==NULL) + TB_ERROR("can't import StringIO"); - iostr = PyObject_CallMethod(iostrmod, "StringIO", NULL); + iostr = PyObject_CallMethod(iostrmod, "StringIO", NULL); - if (iostr==NULL) - TB_ERROR("cStringIO.StringIO() failed"); + if (iostr==NULL) + TB_ERROR("cStringIO.StringIO() failed"); - tbmod = PyImport_ImportModule("traceback"); - if (tbmod==NULL) - TB_ERROR("can't import traceback"); + tbmod = PyImport_ImportModule("traceback"); + if (tbmod==NULL) + TB_ERROR("can't import traceback"); - obstr = PyObject_CallMethod(tbmod, "print_exception", - "(OOOOO)", - type ? type : Py_None, - value ? value : Py_None, - traceback ? traceback : Py_None, - Py_None, - iostr); + obstr = PyObject_CallMethod(tbmod, "print_exception", + "(OOOOO)", + type ? type : Py_None, + value ? value : Py_None, + traceback ? traceback : Py_None, + Py_None, + iostr); - if (obstr==NULL) - { - PyErr_Print(); - TB_ERROR("traceback.print_exception() failed"); - } + if (obstr==NULL) + { + PyErr_Print(); + TB_ERROR("traceback.print_exception() failed"); + } - Py_DecRef(obstr); + Py_DecRef(obstr); - obstr = PyObject_CallMethod(iostr, "getvalue", NULL); - if (obstr==NULL) - TB_ERROR("getvalue() failed."); + obstr = PyObject_CallMethod(iostr, "getvalue", NULL); + if (obstr==NULL) + TB_ERROR("getvalue() failed."); - if (!PyString_Check(obstr)) - TB_ERROR("getvalue() did not return a string"); + if (!PyString_Check(obstr)) + TB_ERROR("getvalue() did not return a string"); - args = PyTuple_New(2); - PyTuple_SetItem(args, 0, string2py("\n")); - PyTuple_SetItem(args, 1, string2py("<br>")); - - func = PyObject_GetAttrString(obstr, "replace"); - //newstr = PyObject_CallMethod(obstr, "replace", args); - newstr = PyObject_CallObject(func, args); + args = PyTuple_New(2); + PyTuple_SetItem(args, 0, string2py("\n")); + PyTuple_SetItem(args, 1, string2py("<br>")); + + func = PyObject_GetAttrString(obstr, "replace"); + //newstr = PyObject_CallMethod(obstr, "replace", args); + newstr = PyObject_CallObject(func, args); - tbstr = PyString_AsString(newstr); + tbstr = PyString_AsString(newstr); - char* tmp = fmtstr("cmpi:%s", tbstr); - rv = _BROKER->eft->newString(_BROKER, tmp, NULL); - free(tmp); + char* tmp = fmtstr("cmpi:%s", tbstr); + rv = _BROKER->eft->newString(_BROKER, tmp, NULL); + free(tmp); cleanup: - PyErr_Restore(type, value, traceback); + PyErr_Restore(type, value, traceback); - if (rv == NULL) - { - rv = _BROKER->eft->newString(_BROKER, tbstr ? tbstr : "", NULL); - } + if (rv == NULL) + { + rv = _BROKER->eft->newString(_BROKER, tbstr ? tbstr : "", NULL); + } - Py_DecRef(func); - Py_DecRef(args); - Py_DecRef(newstr); - Py_DecRef(iostr); - Py_DecRef(obstr); - Py_DecRef(iostrmod); - Py_DecRef(tbmod); + Py_DecRef(func); + Py_DecRef(args); + Py_DecRef(newstr); + Py_DecRef(iostr); + Py_DecRef(obstr); + Py_DecRef(iostrmod); + Py_DecRef(tbmod); - SWIG_PYTHON_THREAD_END_BLOCK; - return rv; + SWIG_PYTHON_THREAD_END_BLOCK; + return rv; } @@ -216,10 +301,10 @@ _SBLIM_TRACE(1,("<%d/0x%x> PyGlobalInitialize() called", getpid(), pthread_self())); if (_PY_INIT) - { - _SBLIM_TRACE(1,("<%d/0x%x> PyGlobalInitialize() returning: already initialized", getpid(), pthread_self())); - return 0; - } + { + _SBLIM_TRACE(1,("<%d/0x%x> PyGlobalInitialize() returning: already initialized", getpid(), pthread_self())); + return 0; + } _PY_INIT=1;//true _SBLIM_TRACE(1,("<%d/0x%x> Python: Loading", getpid(), pthread_self())); @@ -270,7 +355,7 @@ SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject* provclass = PyObject_GetAttrString(_PYPROVMOD, - "CMPIProvider"); + "CMPIProvider"); if (provclass == NULL) { SWIG_PYTHON_THREAD_END_BLOCK; @@ -309,16 +394,16 @@ SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (cplist == NULL) { - Py_INCREF(Py_None); - SWIG_PYTHON_THREAD_END_BLOCK; - return Py_None; + Py_INCREF(Py_None); + SWIG_PYTHON_THREAD_END_BLOCK; + return Py_None; } PyObject* pl; pl = PyList_New(0); for (; *cplist != NULL; ++cplist) { - PyList_Append(pl, PyString_FromString(*cplist)); + PyList_Append(pl, PyString_FromString(*cplist)); } SWIG_PYTHON_THREAD_END_BLOCK; @@ -341,8 +426,8 @@ pyfunc = PyObject_GetAttrString(hdl->pyMod, opname); if (pyfunc == NULL) { - PyErr_Print(); - PyErr_Clear(); + PyErr_Print(); + PyErr_Clear(); char* str = fmtstr("Python module does not contain \"%s\"", opname); _SBLIM_TRACE(1,(str)); st->rc = CMPI_RC_ERR_FAILED; @@ -368,28 +453,28 @@ for (i = 0; i < nargs; ++i) { PyObject* arg = va_arg(vargs, PyObject*); - if (arg == NULL) - { - arg = Py_None; - Py_IncRef(arg); - } + if (arg == NULL) + { + arg = Py_None; + Py_IncRef(arg); + } PyTuple_SET_ITEM(pyargs, i, arg); } va_end(vargs); prv = PyObject_CallObject(pyfunc, pyargs); - if (PyErr_Occurred()) - { - st->rc = CMPI_RC_ERR_FAILED; - st->msg = get_exc_trace(); - PyErr_Clear(); - rc = 1; - goto cleanup; - } + if (PyErr_Occurred()) + { + st->rc = CMPI_RC_ERR_FAILED; + st->msg = get_exc_trace(); + PyErr_Clear(); + rc = 1; + goto cleanup; + } - if (! PyTuple_Check(prv) || - (PyTuple_Size(prv) != 2 && PyTuple_Size(prv) != 1)) - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; + if (! PyTuple_Check(prv) || + (PyTuple_Size(prv) != 2 && PyTuple_Size(prv) != 1)) + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; char* str = fmtstr("Python function \"%s\" didn't return a two-tuple", opname); _SBLIM_TRACE(1,(str)); @@ -397,40 +482,40 @@ st->msg = _BROKER->eft->newString(_BROKER, str, NULL); free(str); rc = 1; - SWIG_PYTHON_THREAD_END_ALLOW; + SWIG_PYTHON_THREAD_END_ALLOW; goto cleanup; - } - PyObject* prc = PyTuple_GetItem(prv, 0); - PyObject* prstr = Py_None; - if (PyTuple_Size(prv) == 2) - { - prstr = PyTuple_GetItem(prv, 1); - } + } + PyObject* prc = PyTuple_GetItem(prv, 0); + PyObject* prstr = Py_None; + if (PyTuple_Size(prv) == 2) + { + prstr = PyTuple_GetItem(prv, 1); + } - if (! PyInt_Check(prc) || (! PyString_Check(prstr) && prstr != Py_None)) - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; + if (! PyInt_Check(prc) || (! PyString_Check(prstr) && prstr != Py_None)) + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; char* str = fmtstr("Python function \"%s\" didn't return a {<int>, <str>) two-tuple", opname); _SBLIM_TRACE(1,(str)); st->rc = CMPI_RC_ERR_FAILED; st->msg = _BROKER->eft->newString(_BROKER, str, NULL); free(str); rc = 1; - SWIG_PYTHON_THREAD_END_ALLOW; + SWIG_PYTHON_THREAD_END_ALLOW; goto cleanup; - } - long pi = PyInt_AsLong(prc); - st->rc = (CMPIrc)pi; - if (prstr == Py_None) - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - st->msg = _BROKER->eft->newString(_BROKER, "", NULL); - SWIG_PYTHON_THREAD_END_ALLOW; - } - else - { - st->msg = _BROKER->eft->newString(_BROKER, PyString_AsString(prstr), NULL); - } + } + long pi = PyInt_AsLong(prc); + st->rc = (CMPIrc)pi; + if (prstr == Py_None) + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + st->msg = _BROKER->eft->newString(_BROKER, "", NULL); + SWIG_PYTHON_THREAD_END_ALLOW; + } + else + { + st->msg = _BROKER->eft->newString(_BROKER, PyString_AsString(prstr), NULL); + } rc = pi != 0; cleanup: Py_DecRef(pyargs); @@ -445,10 +530,10 @@ static CMPIStatus Cleanup( PyProviderMIHandle * miHdl, - const CMPIContext * context, - CMPIBoolean terminating) + const CMPIContext * context, + CMPIBoolean terminating) { - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ if (miHdl != NULL) { @@ -495,40 +580,74 @@ return status; } +static const CMPIBroker* _broker_of(const void* hdl) +{ + const PyProviderMIHandle* ptr = (const PyProviderMIHandle*)hdl; + return ptr->broker; +} + +/* +**============================================================================== +** +** Provider Interface functions +** +**============================================================================== +*/ + static CMPIStatus InstCleanup( - CMPIInstanceMI * self, - const CMPIContext * context, - CMPIBoolean terminating) + CMPIInstanceMI * self, + const CMPIContext * context, + CMPIBoolean terminating) { + const CMPIBroker* cb = _broker_of(self->hdl); + _push_broker(cb); + _SBLIM_TRACE(1,("Cleanup(Python) called for Instance provider %s", ((PyProviderMIHandle *)self->hdl)->miName)); - return Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); + CMPIStatus st = Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); + _pop_broker(); + return st; } static CMPIStatus AssocCleanup( - CMPIAssociationMI * self, - const CMPIContext * context, - CMPIBoolean terminating) + CMPIAssociationMI * self, + const CMPIContext * context, + CMPIBoolean terminating) { + const CMPIBroker* cb = _broker_of(self->hdl); + _push_broker(cb); + _SBLIM_TRACE(1,("Cleanup(Python) called for Association provider %s", ((PyProviderMIHandle *)self->hdl)->miName)); - return Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); + CMPIStatus st = Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); + _pop_broker(); + return st; } static CMPIStatus MethodCleanup( - CMPIMethodMI * self, - const CMPIContext * context, - CMPIBoolean terminating) + CMPIMethodMI * self, + const CMPIContext * context, + CMPIBoolean terminating) { + const CMPIBroker* cb = _broker_of(self->hdl); + _push_broker(cb); + _SBLIM_TRACE(1,("Cleanup(Python) called for Method provider %s", ((PyProviderMIHandle *)self->hdl)->miName)); - return Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); + CMPIStatus st = Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); + _pop_broker(); + return st; } static CMPIStatus IndicationCleanup( - CMPIIndicationMI * self, - const CMPIContext * context, - CMPIBoolean terminating) + CMPIIndicationMI * self, + const CMPIContext * context, + CMPIBoolean terminating) { + const CMPIBroker* cb = _broker_of(self->hdl); + _push_broker(cb); + _SBLIM_TRACE(1,("Cleanup(Python) called for Indication provider %s", ((PyProviderMIHandle *)self->hdl)->miName)); - return Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); + CMPIStatus st = Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); + _pop_broker(); + return st; } // ---------------------------------------------------------------------------- @@ -536,18 +655,20 @@ /* EnumInstanceNames() - return a list of all the instances names (i.e. return their object paths only) */ static CMPIStatus EnumInstanceNames( - CMPIInstanceMI * self, - const CMPIContext * context, - const CMPIResult * result, - const CMPIObjectPath * reference) + CMPIInstanceMI * self, + const CMPIContext * context, + const CMPIResult * result, + const CMPIObjectPath * reference) { + const CMPIBroker* cb = _broker_of(self->hdl); CMPIStatus status = {CMPI_RC_OK, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("EnumInstanceNames() called")); _SBLIM_TRACE(1,("EnumInstancesNames(Python) called, context %p, result %p, reference %p", context, result, reference)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); @@ -562,6 +683,7 @@ exit: _SBLIM_TRACE(1,("EnumInstanceNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } @@ -571,18 +693,20 @@ /* EnumInstances() - return a list of all the instances (i.e. return all the instance data) */ static CMPIStatus EnumInstances( - CMPIInstanceMI * self, - const CMPIContext * context, - const CMPIResult * result, - const CMPIObjectPath * reference, - const char ** properties) + CMPIInstanceMI * self, + const CMPIContext * context, + const CMPIResult * result, + const CMPIObjectPath * reference, + const char ** properties) { - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ -/* char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); Our current CIM namespace */ + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ + /* char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); Our current CIM namespace */ + _push_broker(cb); _SBLIM_TRACE(1,("EnumInstances(Python) called, context %p, result %p, reference %p, properties %p", context, result, reference, properties)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); @@ -599,6 +723,7 @@ exit: _SBLIM_TRACE(1,("EnumInstances() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } @@ -608,23 +733,25 @@ /* GetInstance() - return the instance data for the specified instance only */ static CMPIStatus GetInstance( - CMPIInstanceMI * self, - const CMPIContext * context, - const CMPIResult * results, - const CMPIObjectPath * reference, - const char ** properties) + CMPIInstanceMI * self, + const CMPIContext * context, + const CMPIResult * results, + const CMPIObjectPath * reference, + const char ** properties) { - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ + _push_broker(cb); _SBLIM_TRACE(1,("GetInstance(Python) called, context %p, results %p, reference %p, properties %p", context, results, reference, properties)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; - { + { SWIG_PYTHON_THREAD_BEGIN_BLOCK; SWIG_PYTHON_THREAD_END_BLOCK; - } + } PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); PyObject *pyresult = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); @@ -639,6 +766,7 @@ exit: _SBLIM_TRACE(1,("GetInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } @@ -648,19 +776,21 @@ /* CreateInstance() - create a new instance from the specified instance data. */ static CMPIStatus CreateInstance( - CMPIInstanceMI * self, - const CMPIContext * context, - const CMPIResult * results, - const CMPIObjectPath * reference, - const CMPIInstance * newinstance) + CMPIInstanceMI * self, + const CMPIContext * context, + const CMPIResult * results, + const CMPIObjectPath * reference, + const CMPIInstance * newinstance) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + _push_broker(cb); /* Creating new instances is not supported for this class. */ _SBLIM_TRACE(1,("CreateInstance(Python) called, context %p, results %p, reference %p, newinstance %p", context, results, reference, newinstance)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); @@ -678,6 +808,7 @@ /* Finished. */ exit: _SBLIM_TRACE(1,("CreateInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } @@ -690,14 +821,16 @@ /* SetInstance() - save modified instance data for the specified instance. */ static CMPIStatus SetInstance( - CMPIInstanceMI * self, - const CMPIContext * context, - const CMPIResult * results, - const CMPIObjectPath * reference, - const CMPIInstance * newinstance, - const char ** properties) + CMPIInstanceMI * self, + const CMPIContext * context, + const CMPIResult * results, + const CMPIObjectPath * reference, + const CMPIInstance * newinstance, + const char ** properties) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + _push_broker(cb); /* Modifying existing instances is not supported for this class. */ @@ -718,11 +851,12 @@ pyresult, pyreference, pynewinst, - plist); + plist); /* Finished. */ exit: _SBLIM_TRACE(1,("SetInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } @@ -731,16 +865,18 @@ /* DeleteInstance() - delete/remove the specified instance. */ static CMPIStatus DeleteInstance( - CMPIInstanceMI * self, - const CMPIContext * context, - const CMPIResult * results, - const CMPIObjectPath * reference) + CMPIInstanceMI * self, + const CMPIContext * context, + const CMPIResult * results, + const CMPIObjectPath * reference) { - CMPIStatus status = {CMPI_RC_OK, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_OK, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("DeleteInstance(Python) called, context %p, results %p, reference %p", context, results, reference)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); @@ -756,6 +892,7 @@ /* Finished. */ exit: _SBLIM_TRACE(1,("DeleteInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } @@ -764,18 +901,20 @@ /* ExecQuery() - return a list of all the instances that satisfy the desired query filter. */ static CMPIStatus ExecQuery( - CMPIInstanceMI * self, - const CMPIContext * context, - const CMPIResult * results, - const CMPIObjectPath * reference, - const char * query, - const char * language) + CMPIInstanceMI * self, + const CMPIContext * context, + const CMPIResult * results, + const CMPIObjectPath * reference, + const char * query, + const char * language) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + _push_broker(cb); _SBLIM_TRACE(1,("ExecQuery(Python) called, context %p, results %p, reference %p, query %s, language %s", context, results, reference, query, language)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); @@ -789,14 +928,15 @@ pycontext, pyresult, pyreference, - pyquery, - pylang); + pyquery, + pylang); /* Query filtering is not supported for this class. */ /* Finished. */ exit: _SBLIM_TRACE(1,("ExecQuery() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } @@ -807,236 +947,250 @@ // CMPIStatus associatorNames( - CMPIAssociationMI* self, - const CMPIContext* ctx, - const CMPIResult* rslt, - const CMPIObjectPath* objName, - const char* assocClass, - const char* resultClass, - const char* role, - const char* resultRole) + CMPIAssociationMI* self, + const CMPIContext* ctx, + const CMPIResult* rslt, + const CMPIObjectPath* objName, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("associatorNames(Python) called, ctx %p, rslt %p, objName %p, assocClass %s, resultClass %s, role %s, resultRole %s", ctx, rslt, objName, assocClass, resultClass, role, resultRole)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); PyObject *pyobjName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); SWIG_PYTHON_THREAD_END_BLOCK; - PyObject *pyassocClass = NULL; - PyObject *pyresultClass = NULL; - PyObject* pyrole = NULL; - PyObject* pyresultRole = NULL; - if (assocClass != NULL) - { - pyassocClass = string2py(assocClass); - } - if (resultClass != NULL) - { - pyresultClass = string2py(resultClass); - } - if (role != NULL) - { - pyrole = string2py(role); - } - if (resultRole != NULL) - { - pyresultRole = string2py(resultRole); - } + PyObject *pyassocClass = NULL; + PyObject *pyresultClass = NULL; + PyObject* pyrole = NULL; + PyObject* pyresultRole = NULL; + if (assocClass != NULL) + { + pyassocClass = string2py(assocClass); + } + if (resultClass != NULL) + { + pyresultClass = string2py(resultClass); + } + if (role != NULL) + { + pyrole = string2py(role); + } + if (resultRole != NULL) + { + pyresultRole = string2py(resultRole); + } call_py_provider((PyProviderMIHandle*)self->hdl, &status, "associator_names", 7, pyctx, pyrslt, pyobjName, - pyassocClass, - pyresultClass, - pyrole, - pyresultRole); + pyassocClass, + pyresultClass, + pyrole, + pyresultRole); /* Query filtering is not supported for this class. */ /* Finished. */ exit: _SBLIM_TRACE(1,("associatorNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } /***************************************************************************/ CMPIStatus associators( - CMPIAssociationMI* self, - const CMPIContext* ctx, - const CMPIResult* rslt, - const CMPIObjectPath* objName, - const char* assocClass, - const char* resultClass, - const char* role, - const char* resultRole, - const char** properties) + CMPIAssociationMI* self, + const CMPIContext* ctx, + const CMPIResult* rslt, + const CMPIObjectPath* objName, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole, + const char** properties) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("associators(Python) called, ctx %p, rslt %p, objName %p, assocClass %s, resultClass %s, role %s, resultRole %s", ctx, rslt, objName, assocClass, resultClass, role, resultRole)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); PyObject *pyobjName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); SWIG_PYTHON_THREAD_END_BLOCK; - PyObject *pyprops = proplist2py(properties); - PyObject *pyassocClass = NULL; - PyObject *pyresultClass = NULL; - PyObject* pyrole = NULL; - PyObject* pyresultRole = NULL; - if (assocClass != NULL) - { - pyassocClass = string2py(assocClass); - } - if (resultClass != NULL) - { - pyresultClass = string2py(resultClass); - } - if (role != NULL) - { - pyrole = string2py(role); - } - if (resultRole != NULL) - { - pyresultRole = string2py(resultRole); - } + PyObject *pyprops = proplist2py(properties); + PyObject *pyassocClass = NULL; + PyObject *pyresultClass = NULL; + PyObject* pyrole = NULL; + PyObject* pyresultRole = NULL; + if (assocClass != NULL) + { + pyassocClass = string2py(assocClass); + } + if (resultClass != NULL) + { + pyresultClass = string2py(resultClass); + } + if (role != NULL) + { + pyrole = string2py(role); + } + if (resultRole != NULL) + { + pyresultRole = string2py(resultRole); + } call_py_provider((PyProviderMIHandle*)self->hdl, &status, "associators", 8, pyctx, pyrslt, pyobjName, - pyassocClass, - pyresultClass, - pyrole, - pyresultRole, - pyprops); + pyassocClass, + pyresultClass, + pyrole, + pyresultRole, + pyprops); /* Query filtering is not supported for this class. */ /* Finished. */ exit: _SBLIM_TRACE(1,("associators() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } /***************************************************************************/ CMPIStatus referenceNames( - CMPIAssociationMI* self, - const CMPIContext* ctx, - const CMPIResult* rslt, - const CMPIObjectPath* objName, - const char* resultClass, - const char* role) + CMPIAssociationMI* self, + const CMPIContext* ctx, + const CMPIResult* rslt, + const CMPIObjectPath* objName, + const char* resultClass, + const char* role) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("referenceNames(Python) called, ctx %p, rslt %p, objName %p, resultClass %s, role %s", ctx, rslt, objName, resultClass, role)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); PyObject *pyobjName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); SWIG_PYTHON_THREAD_END_BLOCK; - PyObject* pyresultClass = NULL; - PyObject* pyrole = NULL; - if (role != NULL) - { - pyrole = string2py(role); - } - if (resultClass != NULL) - { - pyresultClass = string2py(resultClass); - } + PyObject* pyresultClass = NULL; + PyObject* pyrole = NULL; + if (role != NULL) + { + pyrole = string2py(role); + } + if (resultClass != NULL) + { + pyresultClass = string2py(resultClass); + } call_py_provider((PyProviderMIHandle*)self->hdl, &status, "reference_names", 5, pyctx, pyrslt, pyobjName, - pyresultClass, - pyrole); + pyresultClass, + pyrole); /* Query filtering is not supported for this class. */ /* Finished. */ exit: _SBLIM_TRACE(1,("referenceNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } /***************************************************************************/ CMPIStatus references( - CMPIAssociationMI* self, - const CMPIContext* ctx, - const CMPIResult* rslt, - const CMPIObjectPath* objName, - const char* resultClass, - const char* role, - const char** properties) + CMPIAssociationMI* self, + const CMPIContext* ctx, + const CMPIResult* rslt, + const CMPIObjectPath* objName, + const char* resultClass, + const char* role, + const char** properties) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("references(Python) called, ctx %p, rslt %p, objName %p, resultClass %s, role %s, properties %p", ctx, rslt, objName, resultClass, role, properties)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); PyObject *pyobjName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); SWIG_PYTHON_THREAD_END_BLOCK; - PyObject* pyrole = NULL; - PyObject* pyresultClass = NULL; - if (role != NULL) - { - pyrole = string2py(role); - } - if (resultClass != NULL) - { - pyresultClass = string2py(resultClass); - } - PyObject *pyprops = proplist2py(properties); + PyObject* pyrole = NULL; + PyObject* pyresultClass = NULL; + if (role != NULL) + { + pyrole = string2py(role); + } + if (resultClass != NULL) + { + pyresultClass = string2py(resultClass); + } + PyObject *pyprops = proplist2py(properties); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "references", 6, pyctx, pyrslt, pyobjName, - pyresultClass, - pyrole, - pyprops); + pyresultClass, + pyrole, + pyprops); /* Finished. */ exit: _SBLIM_TRACE(1,("references() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } /***************************************************************************/ CMPIStatus invokeMethod( - CMPIMethodMI* self, - const CMPIContext* ctx, - const CMPIResult* rslt, - const CMPIObjectPath* objName, - const char* method, - const CMPIArgs* in, - CMPIArgs* out) + CMPIMethodMI* self, + const CMPIContext* ctx, + const CMPIResult* rslt, + const CMPIObjectPath* objName, + const char* method, + const CMPIArgs* in, + CMPIArgs* out) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("invokeMethod(Python) called, ctx %p, rslt %p, objName %p, method %s, in %p, out %p", ctx, rslt, objName, method, in, out)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); @@ -1045,72 +1199,78 @@ PyObject *pyin = SWIG_NewPointerObj((void*) in, SWIGTYPE_p__CMPIArgs, 0); PyObject *pyout = SWIG_NewPointerObj((void*) out, SWIGTYPE_p__CMPIArgs, 0); SWIG_PYTHON_THREAD_END_BLOCK; - PyObject *pymethod = string2py(method); + PyObject *pymethod = string2py(method); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "invoke_method", 6, pyctx, pyrslt, pyobjName, - pymethod, - pyin, - pyout); + pymethod, + pyin, + pyout); /* Finished. */ exit: _SBLIM_TRACE(1,("invokeMethod() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } /***************************************************************************/ CMPIStatus authorizeFilter( - CMPIIndicationMI* self, - const CMPIContext* ctx, - const CMPISelectExp* filter, - const char* className, - const CMPIObjectPath* classPath, - const char* owner) + CMPIIndicationMI* self, + const CMPIContext* ctx, + const CMPISelectExp* filter, + const char* className, + const CMPIObjectPath* classPath, + const char* owner) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("authorizeFilter(Python) called, ctx %p, filter %p, className %s, classPath %p, owner %s", ctx, filter, className, classPath, owner)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); PyObject *pyfilter = SWIG_NewPointerObj((void*) filter, SWIGTYPE_p__CMPISelectExp, 0); PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); SWIG_PYTHON_THREAD_END_BLOCK; - PyObject *pyclassName = string2py(className); - PyObject *pyowner = string2py(owner); + PyObject *pyclassName = string2py(className); + PyObject *pyowner = string2py(owner); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "authorize_filter", 5, pyctx, pyfilter, pyclassName, - pyclassPath, - pyowner); + pyclassPath, + pyowner); /* Finished. */ exit: _SBLIM_TRACE(1,("authorizeFilter() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } /***************************************************************************/ CMPIStatus activateFilter( - CMPIIndicationMI* self, - const CMPIContext* ctx, - const CMPISelectExp* filter, - const char* className, - const CMPIObjectPath* classPath, - CMPIBoolean firstActivation) + CMPIIndicationMI* self, + const CMPIContext* ctx, + const CMPISelectExp* filter, + const char* className, + const CMPIObjectPath* classPath, + CMPIBoolean firstActivation) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("activateFilter(Python) called, ctx %p, filter %p, className %s, classPath %p, firstActivation %d", ctx, filter, className, classPath, firstActivation)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); @@ -1118,35 +1278,38 @@ PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); PyObject *pyfirstActivation = PyBool_FromLong(firstActivation); SWIG_PYTHON_THREAD_END_BLOCK; - PyObject *pyclassName = string2py(className); + PyObject *pyclassName = string2py(className); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "activate_filter", 5, pyctx, pyfilter, pyclassName, - pyclassPath, - pyfirstActivation); + pyclassPath, + pyfirstActivation); /* Finished. */ exit: _SBLIM_TRACE(1,("activateFilter() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } /***************************************************************************/ CMPIStatus deActivateFilter( - CMPIIndicationMI* self, - const CMPIContext* ctx, - const CMPISelectExp* filter, - const char* className, - const CMPIObjectPath* classPath, - CMPIBoolean lastActivation) + CMPIIndicationMI* self, + const CMPIContext* ctx, + const CMPISelectExp* filter, + const char* className, + const CMPIObjectPath* classPath, + CMPIBoolean lastActivation) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("deActivateFilter(Python) called, ctx %p, filter %p, className %s, classPath %p, lastActivation %d", ctx, filter, className, classPath, lastActivation)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); @@ -1154,18 +1317,19 @@ PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); PyObject *pylastActivation = PyBool_FromLong(lastActivation); SWIG_PYTHON_THREAD_END_BLOCK; - PyObject *pyclassName = string2py(className); + PyObject *pyclassName = string2py(className); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "deactivate_filter", 5, pyctx, pyfilter, pyclassName, - pyclassPath, - pylastActivation); + pyclassPath, + pylastActivation); /* Finished. */ exit: _SBLIM_TRACE(1,("deActivateFilter() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } @@ -1174,19 +1338,21 @@ // Note: sfcb doesn't support mustPoll. :( // http://sourceforge.net/mailarchive/message.php?msg_id=OFF38FF3F9.39FD2E1F-ONC1257385.004A7122-C1257385.004BB0AF%40de.ibm.com CMPIStatus mustPoll( - CMPIIndicationMI* self, - const CMPIContext* ctx, - //const CMPIResult* rslt, TODO: figure out who is right: spec. vs. sblim - const CMPISelectExp* filter, - const char* className, - const CMPIObjectPath* classPath) + CMPIIndicationMI* self, + const CMPIContext* ctx, + //const CMPIResult* rslt, TODO: figure out who is right: spec. vs. sblim + const CMPISelectExp* filter, + const char* className, + const CMPIObjectPath* classPath) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); //_SBLIM_TRACE(1,("mustPoll(Python) called, ctx %p, rslt %p, filter %p, className %s, classPath %p", ctx, rslt, filter, className, classPath)); _SBLIM_TRACE(1,("mustPoll(Python) called, ctx %p, filter %p, className %s, classPath %p", ctx, filter, className, classPath)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); @@ -1198,28 +1364,31 @@ call_py_provider((PyProviderMIHandle*)self->hdl, &status, "must_poll", 4, pyctx, - //pyrslt, + //pyrslt, pyfilter, pyclassName, - pyclassPath); + pyclassPath); /* Finished. */ exit: _SBLIM_TRACE(1,("mustPoll() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } /***************************************************************************/ CMPIStatus enableIndications( - CMPIIndicationMI* self, - const CMPIContext* ctx) + CMPIIndicationMI* self, + const CMPIContext* ctx) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("enableIndications(Python) called, ctx %p", ctx)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); @@ -1230,20 +1399,23 @@ /* Finished. */ exit: _SBLIM_TRACE(1,("enableIndications() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } /***************************************************************************/ CMPIStatus disableIndications( - CMPIIndicationMI* self, - const CMPIContext* ctx) + CMPIIndicationMI* self, + const CMPIContext* ctx) { - CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + const CMPIBroker* cb = _broker_of(self->hdl); + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + _push_broker(cb); _SBLIM_TRACE(1,("disableIndications(Python) called, ctx %p", ctx)); - PY_CMPI_INIT + PY_CMPI_INIT SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); @@ -1254,6 +1426,7 @@ /* Finished. */ exit: _SBLIM_TRACE(1,("disableIndications() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + _pop_broker(); return status; } @@ -1263,97 +1436,88 @@ static CMPIMethodMIFT MethodMIFT__={ - CMPICurrentVersion, - CMPICurrentVersion, - "methodCmpi_Swig", // miName - MethodCleanup, - invokeMethod, + CMPICurrentVersion, + CMPICurrentVersion, + "methodCmpi_Swig", // miName + MethodCleanup, + invokeMethod, }; static CMPIIndicationMIFT IndicationMIFT__={ - CMPICurrentVersion, - CMPICurrentVersion, - "indicationCmpi_Swig", // miName - IndicationCleanup, - authorizeFilter, - mustPoll, - activateFilter, - deActivateFilter, - enableIndications, - disableIndications, + CMPICurrentVersion, + CMPICurrentVersion, + "indicationCmpi_Swig", // miName + IndicationCleanup, + authorizeFilter, + mustPoll, + activateFilter, + deActivateFilter, + enableIndications, + disableIndications, }; static CMPIAssociationMIFT AssociationMIFT__={ - CMPICurrentVersion, - CMPICurrentVersion, - "instanceCmpi_Swig", // miName - AssocCleanup, - associators, - associatorNames, - references, - referenceNames, + CMPICurrentVersion, + CMPICurrentVersion, + "instanceCmpi_Swig", // miName + AssocCleanup, + associators, + associatorNames, + references, + referenceNames, }; static CMPIInstanceMIFT InstanceMIFT__={ - CMPICurrentVersion, - CMPICurrentVersion, - "associatorCmpi_Swig", // miName - InstCleanup, - EnumInstanceNames, - EnumInstances, - GetInstance, - CreateInstance, - SetInstance, - DeleteInstance, - ExecQuery, + CMPICurrentVersion, + CMPICurrentVersion, + "associatorCmpi_Swig", // miName + InstCleanup, + EnumInstanceNames, + EnumInstances, + GetInstance, + CreateInstance, + SetInstance, + DeleteInstance, + ExecQuery, }; static void createInit(const CMPIBroker* broker, - const CMPIContext* context, const char* miname, CMPIStatus* st) + const CMPIContext* context, const char* miname, CMPIStatus* st) { _SBLIM_TRACE(1,("\n>>>>> createInit(Python) called, miname= %s (ctx=%p)\n", miname, context)); - if (!_BROKER) - { - _BROKER = broker; - } - else if (_BROKER != broker) - { - fprintf(stderr, "createInit broker %p, _BROKER %p\n", broker, _BROKER); - fprintf(stderr, "aborting\n"); - abort(); - } //_MINAME = strdup(miname); /* - * We can't initialize Python here and load Python modules, because - * SFCB passes a NULL CMPIStatus* st, which means we can't report - * back error strings. Instead, we'll check and initialize in each - * MIFT function - */ + * We can't initialize Python here and load Python modules, because + * SFCB passes a NULL CMPIStatus* st, which means we can't report + * back error strings. Instead, we'll check and initialize in each + * MIFT function + */ } #define SWIG_CMPI_MI_FACTORY(ptype) \ CMPI##ptype##MI* _Generic_Create_##ptype##MI(const CMPIBroker* broker, \ - const CMPIContext* context, const char* miname, CMPIStatus* st)\ + const CMPIContext* context, const char* miname, CMPIStatus* st)\ { \ /*_SBLIM_TRACE(1, ("\n>>>>> in FACTORY: CMPI"#ptype"MI* _Generic_Create_"#ptype"MI... miname=%s", miname));*/ \ PyProviderMIHandle *hdl = (PyProviderMIHandle*)malloc(sizeof(PyProviderMIHandle)); \ if (hdl) { \ hdl->pyMod = NULL; \ hdl->miName = strdup(miname); \ + hdl->broker = broker; \ } \ - CMPI##ptype##MI *mi= (CMPI##ptype##MI*)malloc(sizeof(CMPI##ptype##MI)); \ + CMPI##ptype##MI *mi= (CMPI##ptype##MI*)malloc(sizeof(CMPI##ptype##MI)); \ if (mi) { \ - mi->hdl = hdl; \ - mi->ft = &ptype##MIFT__; \ - } \ - createInit(broker, context, miname, st); \ + mi->hdl = hdl; \ + mi->ft = &ptype##MIFT__; \ + } \ + createInit(broker, context, miname, st); \ /*_SBLIM_TRACE(1, ("\n>>>>> returning mi=0x%08x mi->hdl=0x%08x mi->ft=0x%08x", mi, mi->hdl, mi->ft));*/ \ ++_MI_COUNT; \ - return mi; \ + return mi; \ } SWIG_CMPI_MI_FACTORY(Instance) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-09-11 22:38:06
|
Revision: 958 http://omc.svn.sourceforge.net/omc/?rev=958&view=rev Author: bartw Date: 2008-09-11 22:38:15 +0000 (Thu, 11 Sep 2008) Log Message: ----------- more method tests, rigged test scripts to honor command line options Modified Paths: -------------- cmpi-bindings/trunk/test/python/TestAtomProvider_Test.py cmpi-bindings/trunk/test/python/TestMethod.mof cmpi-bindings/trunk/test/python/TestMethod.py cmpi-bindings/trunk/test/python/TestMethod_Test.py cmpi-bindings/trunk/test/python/lib/wbem_connection.py cmpi-bindings/trunk/test/python/test_assoc.py Modified: cmpi-bindings/trunk/test/python/TestAtomProvider_Test.py =================================================================== --- cmpi-bindings/trunk/test/python/TestAtomProvider_Test.py 2008-09-11 22:16:48 UTC (rev 957) +++ cmpi-bindings/trunk/test/python/TestAtomProvider_Test.py 2008-09-11 22:38:15 UTC (rev 958) @@ -15,7 +15,11 @@ import unittest import math from lib import wbem_connection +from optparse import OptionParser +conn = None +globalParser = None + _tolerance = .04 _atoms = {'Hydrogen': 1, @@ -200,17 +204,17 @@ time = pywbem.CIMDateTime.now() def setUp(self): + global conn self.inst_paths = [] self.instance = None - #wconn = wbem_connection.wbem_connection() - self.conn = pywbem.PegasusUDSConnection() - self.conn = pywbem.SFCBUDSConnection() + if conn is None: + conn = wbem_connection.WBEMConnFromOptions(globalParser) unittest.TestCase.setUp(self) def tearDown(self): for ipath in self.inst_paths: try: - self.conn.DeleteInstance(ipath) + conn.DeleteInstance(ipath) except pywbem.CIMError,arg: pass unittest.TestCase.tearDown(self) @@ -231,7 +235,7 @@ # namespace='Interop')) # # try: - # self.conn.CreateInstance(reginst) + # conn.CreateInstance(reginst) # except pywbem.CIMError, arg: # self.fail("Could not REGISTER %s:%s" % (reginst.classname, str(arg))) # restart_gmond() @@ -241,19 +245,19 @@ #def test_7_deregister(self): # """ Test Deregister Provider """ - # self.conn.default_namespace = 'Interop' - # reglist = self.conn.EnumerateInstanceNames('OpenWBEM_PyProviderRegistration') + # conn.default_namespace = 'Interop' + # reglist = conn.EnumerateInstanceNames('OpenWBEM_PyProviderRegistration') # for inst_name in reglist: # if inst_name['InstanceID'] == 'TestAtomProvider': # try: - # self.conn.DeleteInstance(inst_name) + # conn.DeleteInstance(inst_name) # except pywbem.CIMError, arg: # self.fail("Could not DEREGISTER Class") # restart_gmond() # try: - # self.conn.GetInstance(inst_name) + # conn.GetInstance(inst_name) # except pywbem.CIMError, arg: # self.failUnlessEqual(arg[0], pywbem.CIM_ERR_NOT_FOUND, # 'Unexpected exception on GetInstance: %s' % str(arg)) @@ -314,7 +318,7 @@ pywbem.Uint8(number)] try: - cipath = self.conn.CreateInstance(new_instance) + cipath = conn.CreateInstance(new_instance) new_instance.path = cipath self.inst_paths.append(cipath) @@ -332,12 +336,12 @@ self.fail('%s: CreateInstance Failed.' % str(msg)) continue try: - ci = self.conn.GetInstance(rval.path) + ci = conn.GetInstance(rval.path) except pywbem.CIMError,arg: self.fail('GetInstance failed for instance just created') continue - _compare_values(self.conn, ci, self.time) + _compare_values(conn, ci, self.time) def test_3_enum_instances(self): @@ -349,20 +353,20 @@ self.fail('%s: CreateInstance Failed.' % str(msg)) continue try: - ci = self.conn.GetInstance(rval.path) + ci = conn.GetInstance(rval.path) insts.append(ci) except pywbem.CIMError,arg: self.fail('GetInstance failed for instance just created') continue try: - ta_list = self.conn.EnumerateInstances('Test_Atom') + ta_list = conn.EnumerateInstances('Test_Atom') except pywbem.CIMError, arg: self.fail('EnumerateInstances Failed: %s' % str(arg)) raise try: - paths = self.conn.EnumerateInstanceNames('Test_Atom') + paths = conn.EnumerateInstanceNames('Test_Atom') except pywbem.CIMError, arg: self.fail('EnumerateInstanceNames Failed: %s' % str(arg)) @@ -374,7 +378,7 @@ for rci in ta_list: rci.path.host = None if rci.path == ci.path: - _compare_values(self.conn, rci, self.time) + _compare_values(conn, rci, self.time) break else: self.fail('Did not get a created instance back from EnumerateInstance') @@ -390,20 +394,20 @@ self.fail('%s: CreateInstance Failed.' % str(msg)) continue try: - ci = self.conn.GetInstance(rval.path) + ci = conn.GetInstance(rval.path) insts.append(ci) except pywbem.CIMError,arg: self.fail('GetInstance failed for instance just created') continue try: - ta_list = self.conn.EnumerateInstanceNames('Test_Atom') + ta_list = conn.EnumerateInstanceNames('Test_Atom') except pywbem.CIMError, arg: self.fail('EnumerateInstanceNames Failed: %s' % str(arg)) raise try: - instances = self.conn.EnumerateInstances('Test_Atom') + instances = conn.EnumerateInstances('Test_Atom') except pywbem.CIMError, arg: self.fail('EnumerateInstances Failed: %s' % str(arg)) @@ -428,7 +432,7 @@ 'sint32Propa', 'sint32Prop'] keybindings = {'Name': 'Carbon'} try: - inst = get_instance(self.conn, keybindings, propertylist) + inst = get_instance(conn, keybindings, propertylist) except pywbem.CIMError, arg: raise arg @@ -449,7 +453,7 @@ 'sint64Propa', 'sint64prop', 'boolProp'] keybindings = {'Name': 'Boron'} - mod_instance = get_instance(self.conn, keybindings, propertylist) + mod_instance = get_instance(conn, keybindings, propertylist) weight = _atomic_weights['Boron'] new_time = pywbem.CIMDateTime.now() @@ -468,11 +472,11 @@ mod_instance['Name'] = 'Boron' try: - self.conn.ModifyInstance(mod_instance, PropertyList=propertylist) + conn.ModifyInstance(mod_instance, PropertyList=propertylist) except pywbem.CIMError, arg: self.fail(arg) - mod_instance = get_instance(self.conn, keybindings, propertylist) + mod_instance = get_instance(conn, keybindings, propertylist) for prop in mod_instance.properties.keys(): if prop == 'uint64Prop' or prop == 'sint64Prop': self.assertEqual(mod_instance[prop],2,"Values NOT EQUAL") @@ -504,23 +508,23 @@ self.fail('%s: CreateInstance Failed.' % str(msg)) continue try: - ci = self.conn.GetInstance(rval.path) + ci = conn.GetInstance(rval.path) insts.append(ci) except pywbem.CIMError,arg: self.fail('GetInstance failed for instance just created') continue - del_instances = get_instance_names(self.conn) + del_instances = get_instance_names(conn) for inst in del_instances: try: - self.conn.DeleteInstance(inst) + conn.DeleteInstance(inst) except pywbem.CIMError, arg: self.fail('DeleteInstance Failed: %s' % str(arg)) break else: for inst in del_instances: try: - self.conn.DeleteInstance(inst) + conn.DeleteInstance(inst) except pywbem.CIMError, arg: self.failUnlessEqual(arg[0], pywbem.CIM_ERR_NOT_FOUND, 'Unexpected exception on delete: %s' % str(arg)) @@ -531,5 +535,11 @@ return TestAtomProvider if __name__ == "__main__": + p = OptionParser() + wbem_connection.getWBEMConnParserOptions(p) + options, arguments = p.parse_args() + globalParser = p + suite = unittest.makeSuite(TestAtomProvider) unittest.TextTestRunner(verbosity=2).run(suite) + Modified: cmpi-bindings/trunk/test/python/TestMethod.mof =================================================================== --- cmpi-bindings/trunk/test/python/TestMethod.mof 2008-09-11 22:16:48 UTC (rev 957) +++ cmpi-bindings/trunk/test/python/TestMethod.mof 2008-09-11 22:38:15 UTC (rev 958) @@ -260,5 +260,9 @@ [in, required, EmbeddedInstance("Test_Method")] string insts[] ); + [ Description("Retrieve instances of Test_Method as an instance list output parameter") ] + sint32 getObjects( + [in(false), out, required, EmbeddedInstance("Test_Method")] string insts[] + ); }; Modified: cmpi-bindings/trunk/test/python/TestMethod.py =================================================================== --- cmpi-bindings/trunk/test/python/TestMethod.py 2008-09-11 22:16:48 UTC (rev 957) +++ cmpi-bindings/trunk/test/python/TestMethod.py 2008-09-11 22:38:15 UTC (rev 958) @@ -720,6 +720,20 @@ rval = pywbem.Sint32(0) return (rval, out_params) + def cim_method_getobjects(self, env, object_name): + logger = env.get_logger() + logger.log_debug('Entering %s.cim_method_getobjects()' \ + % self.__class__.__name__) + + insts = [] + for kn, val in g_insts.items(): + inst = pywbem.CIMInstance('TestMethod', + properties={'id':kn, 'p_str':val[0], 'p_sint32':val[1]}) + insts.append(inst) + + out_params = [pywbem.CIMParameter('insts', 'instance', value=insts)] + rval = pywbem.Sint32(0) + return (rval, out_params) ## end of class TestMethodProvider Modified: cmpi-bindings/trunk/test/python/TestMethod_Test.py =================================================================== --- cmpi-bindings/trunk/test/python/TestMethod_Test.py 2008-09-11 22:16:48 UTC (rev 957) +++ cmpi-bindings/trunk/test/python/TestMethod_Test.py 2008-09-11 22:38:15 UTC (rev 958) @@ -15,6 +15,7 @@ import sys real_tolerance = 0.01 +conn = None #This test requires the usage of elementtree @@ -157,11 +158,8 @@ def setUp(self): unittest.TestCase.setUp(self) - #wconn = wbem_connection.wbem_connection() - #self.conn = wconn._WBEMConnFromOptions(_g_opts) - self.conn = pywbem.PegasusUDSConnection() - self.conn = pywbem.SFCBUDSConnection() - self.conn.debug = True + self.conn = conn + self.conn.debug = True for iname in self.conn.EnumerateInstanceNames('Test_Method'): self.conn.DeleteInstance(iname) self._verbose = _g_opts.verbose @@ -510,6 +508,7 @@ properties={'p_str':'str2', 'p_sint32':pywbem.Sint32(2)}) inst2.update(iname2) + self.conn.DeleteInstance(iname) rv, outs = self.conn.InvokeMethod('createObjects', 'Test_Method', insts=[inst, inst2]) @@ -518,6 +517,14 @@ ninst = self.conn.GetInstance(iname2) self.assertEquals(ninst['p_str'], 'str2') self.assertEquals(ninst['p_sint32'], 2) + + try: + rv, outs = self.conn.InvokeMethod('getObjects', 'Test_Method') + except: + raise + insts = outs['insts'] + self.assertEquals(len(insts), 2) + def get_unit_test(): @@ -537,6 +544,7 @@ help='Indicate the level of debugging statements to display (default=2)', default=2) _g_opts, _g_args = parser.parse_args() + conn = wbem_connection.WBEMConnFromOptions(parser) suite = unittest.makeSuite(TestMethods) unittest.TextTestRunner(verbosity=_g_opts.dbglevel).run(suite) Modified: cmpi-bindings/trunk/test/python/lib/wbem_connection.py =================================================================== --- cmpi-bindings/trunk/test/python/lib/wbem_connection.py 2008-09-11 22:16:48 UTC (rev 957) +++ cmpi-bindings/trunk/test/python/lib/wbem_connection.py 2008-09-11 22:38:15 UTC (rev 958) @@ -4,10 +4,10 @@ from getpass import getpass def getWBEMConnParserOptions(parser): - parser.add_option('-u', '--url', default='https://localhost', help='Specify the URL to the CIMOM') + parser.add_option('-u', '--url', default='/tmp/sfcbHttpSocket', help='Specify the URL to the CIMOM') parser.add_option('-n', '--namespace', default='root/cimv2', help='Specify the namespace the test runs against') - parser.add_option('', '--user', default='', help='Specify the user name used when connection to the CIMOM') - parser.add_option('', '--password', default='', help='Specify the password for the user') + parser.add_option('', '--user', default=None, help='Specify the user name used when connection to the CIMOM') + parser.add_option('', '--password', default=None, help='Specify the password for the user') @@ -19,7 +19,11 @@ pw = options.password if options.user and not pw: pw = getpass('\nEnter password for %s: ' % options.user) - wconn = pywbem.WBEMConnection(options.url, (options.user, pw)) + options.password = pw + creds = None + if options.user: + creds = (options.user, pw) + wconn = pywbem.WBEMConnection(options.url, creds) if options.namespace: wconn.default_namespace = options.namespace return wconn Modified: cmpi-bindings/trunk/test/python/test_assoc.py =================================================================== --- cmpi-bindings/trunk/test/python/test_assoc.py 2008-09-11 22:16:48 UTC (rev 957) +++ cmpi-bindings/trunk/test/python/test_assoc.py 2008-09-11 22:38:15 UTC (rev 958) @@ -14,10 +14,12 @@ import grp from lib import ProviderSanityTest as PST +from lib import wbem_connection from socket import getfqdn _globalVerbose = False +conn = None def isObjPathMatch( op1, op2 ): op1.host = None @@ -47,28 +49,7 @@ return _local_op1_str == _local_op2_str -class WBEMConn: - - # Borgness - _shared_state = {} - conn = None - - def __init__(self, options=None): - # Borgness - self.__dict__ = WBEMConn._shared_state - if options: - proto = 'http' - if options.secure: - proto = 'https' - url = '%s://%s' % (proto, options.host) - self.conn = pywbem.WBEMConnection( - url, - (options.user, options.password), - default_namespace = options.namespace) - self.conn = pywbem.PegasusUDSConnection() - self.conn = pywbem.SFCBUDSConnection() - class TestAssociations(unittest.TestCase): @@ -81,8 +62,8 @@ def setUp(self): unittest.TestCase.setUp(self) - self._conn = WBEMConn().conn self._verbose = _globalVerbose + self._conn = conn self._dbgPrint() def tearDown(self): @@ -1177,6 +1158,7 @@ if __name__ == '__main__': parser = optparse.OptionParser() + wbem_connection.getWBEMConnParserOptions(parser) parser.add_option('--level', '-l', action='store', @@ -1184,22 +1166,12 @@ dest='dbglevel', help='Indicate the level of debugging statements to display (default=2)', default=2) - parser.add_option('', '--host', default='localhost', - help='Specify the hosting machine of the CIMOM (default=localhost)') - parser.add_option('-s', '--secure', action='store_true', default=False, - help='Use the HTTPS protocol. Default is HTTP') - parser.add_option('-n', '--namespace', default='root/cimv2', - help='Specify the namespace the test runs against (default=root/cimv2)') - parser.add_option('', '--user', default='', - help='Specify the user name used when connection to the CIMOM') - parser.add_option('', '--password', default='', - help='Specify the password for the user') parser.add_option('--verbose', '', action='store_true', default=False, help='Show verbose output') options, arguments = parser.parse_args() _globalVerbose = options.verbose - wconn = WBEMConn(options) + conn = wbem_connection.WBEMConnFromOptions(parser) suite = unittest.makeSuite(TestAssociations) unittest.TextTestRunner(verbosity=options.dbglevel).run(suite) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |