From: <mik...@us...> - 2008-10-24 19:30:01
|
Revision: 1130 http://omc.svn.sourceforge.net/omc/?rev=1130&view=rev Author: mike-brasher Date: 2008-10-24 19:29:58 +0000 (Fri, 24 Oct 2008) Log Message: ----------- New test provider Modified Paths: -------------- cmpi-bindings/trunk/test/python/install.sh Added Paths: ----------- cmpi-bindings/trunk/test/python/TestExcept.mof cmpi-bindings/trunk/test/python/TestExcept.peg.reg cmpi-bindings/trunk/test/python/TestExcept.py cmpi-bindings/trunk/test/python/TestExcept.sfcb.reg Added: cmpi-bindings/trunk/test/python/TestExcept.mof =================================================================== --- cmpi-bindings/trunk/test/python/TestExcept.mof (rev 0) +++ cmpi-bindings/trunk/test/python/TestExcept.mof 2008-10-24 19:29:58 UTC (rev 1130) @@ -0,0 +1,11 @@ +[ Description("Instance provider used to test exceptions by causing them")] +class Test_Except +{ + [Key] string id; + uint32 count; + boolean flag; + string message; + uint32 counts[]; + boolean flags[]; + string messages[]; +}; Added: cmpi-bindings/trunk/test/python/TestExcept.peg.reg =================================================================== --- cmpi-bindings/trunk/test/python/TestExcept.peg.reg (rev 0) +++ cmpi-bindings/trunk/test/python/TestExcept.peg.reg 2008-10-24 19:29:58 UTC (rev 1130) @@ -0,0 +1,25 @@ +// Pegasus Provider registration for Test_Except +instance of PG_ProviderModule +{ + Name = "pyCmpiProvider_Test_Except"; + InterfaceType = "CMPI"; + InterfaceVersion = "2.0.0"; + Location = "pyCmpiProvider"; + UserContext = 2; // Requestor + Vendor = "TODO"; // TODO + Version = "1.0"; +}; +instance of PG_Provider +{ + Name = "Test_Except"; + ProviderModuleName = "pyCmpiProvider_Test_Except"; +}; +instance of PG_ProviderCapabilities +{ + CapabilityID = "Test_Except"; + ProviderModuleName = "pyCmpiProvider_Test_Except"; + ProviderName = "Test_Except"; + ClassName = "Test_Except"; + Namespaces = {"root/cimv2"}; + ProviderType = {2}; // Instance +}; Added: cmpi-bindings/trunk/test/python/TestExcept.py =================================================================== --- cmpi-bindings/trunk/test/python/TestExcept.py (rev 0) +++ cmpi-bindings/trunk/test/python/TestExcept.py 2008-10-24 19:29:58 UTC (rev 1130) @@ -0,0 +1,183 @@ +"""Python Provider for Test_Except + +Instruments the CIM class Test_Except + +""" + +import pywbem +from pywbem.cim_provider2 import CIMProvider2 + +class Test_Except(CIMProvider2): + """Instrument the CIM class Test_Except + + Instance provider used to test exceptions by causing them + + """ + + def __init__ (self, env): + logger = env.get_logger() + logger.log_debug('Initializing provider %s from %s' \ + % (self.__class__.__name__, __file__)) + + def get_instance(self, env, model): + """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. + + 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__) + + + # TODO fetch system resource matching the following keys: + # model['id'] + + #model['count'] = pywbem.Uint32() # TODO + #model['counts'] = [pywbem.Uint32(),] # TODO + #model['flag'] = bool() # TODO + #model['flags'] = [bool(),] # TODO + #model['message'] = '' # TODO + #model['messages'] = ['',] # TODO + return model + + def enum_instances(self, env, model, 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. + 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__) + + # 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({'id': None}) + + model['id'] = 'RED' + + # ATTN: this next line trashes memory in sfcb (invalid write). + #model['id'] = pywbem.Uint32(99) + + # ATTN: this next line trashes memory and client hangs forever. + #model['id'] = ['RED', 'GREEN', 'BLUE' ] + + model['count'] = pywbem.Uint32(99) + model['flag'] = bool(0) + model['message'] = 'hello world' + # ATTN: this next line trashes memory and client hangs forever. + #model['message'] = ['RED', 'GREEN', 'BLUE' ] + model['counts'] = [pywbem.Uint32(10), pywbem.Uint32(20)] + model['flags'] = [bool(1), bool(2), bool(3)] + model['messages'] = ['RED', 'GREEN', 'BLUE' ] + + # ATTN: sfcb accepts this and sends it to the client. + #model['illegal property name'] = 'oops' + yield model + + def set_instance(self, env, instance, modify_existing): + """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. + modify_existing -- True if ModifyInstance, False if CreateInstance + + 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 modify_existing is False, indicating that the operation + was CreateInstance) + CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid + if modify_existing is True, 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 + +## end of class Test_ExceptProvider + +## get_providers() for associating CIM Class Name to python provider class name + +def get_providers(env): + test_except_prov = Test_Except(env) + return {'Test_Except': test_except_prov} Added: cmpi-bindings/trunk/test/python/TestExcept.sfcb.reg =================================================================== --- cmpi-bindings/trunk/test/python/TestExcept.sfcb.reg (rev 0) +++ cmpi-bindings/trunk/test/python/TestExcept.sfcb.reg 2008-10-24 19:29:58 UTC (rev 1130) @@ -0,0 +1,5 @@ +[Test_Except] + provider: TestExcept + location: pyCmpiProvider + type: instance + namespace: root/cimv2 Modified: cmpi-bindings/trunk/test/python/install.sh =================================================================== --- cmpi-bindings/trunk/test/python/install.sh 2008-10-24 10:21:03 UTC (rev 1129) +++ cmpi-bindings/trunk/test/python/install.sh 2008-10-24 19:29:58 UTC (rev 1130) @@ -43,6 +43,7 @@ __install TestAssocProvider.py /usr/lib/pycim __install TestAtomProvider.py /usr/lib/pycim __install UpcallAtomProvider.py /usr/lib/pycim +__install TestExcept.py /usr/lib/pycim if [ "$1" = "op" ]; then cimmof TestMethodPegasus.mof @@ -53,15 +54,20 @@ cimmof -n root/PG_InterOp TestAtomProvider.peg.reg cimmof UpcallAtom.mof cimmof -n root/PG_Interop UpcallAtom.peg.reg + cimmof TestExcept.mof + cimmof -n root/PG_InterOp TestExcept.peg.reg + else __install TestMethod.mof /var/lib/sfcb/stage/mofs/root/cimv2 __install TestAssoc.mof /var/lib/sfcb/stage/mofs/root/cimv2 __install TestAtom.mof /var/lib/sfcb/stage/mofs/root/cimv2 __install UpcallAtom.mof /var/lib/sfcb/stage/mofs/root/cimv2 + __install TestExcept.mof /var/lib/sfcb/stage/mofs/root/cimv2 __install TestAssocProvider.sfcb.reg /var/lib/sfcb/stage/regs __install TestMethod.sfcb.reg /var/lib/sfcb/stage/regs __install TestAtomProvider.sfcb.reg /var/lib/sfcb/stage/regs __install UpcallAtom.sfcb.reg /var/lib/sfcb/stage/regs + __install TestExcept.sfcb.reg /var/lib/sfcb/stage/regs sfcbrepos -f fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |