void ComputerSystemProvider::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath &ref, ObjectPathResponseHandler& handler) { CIMName className = ref.getClassName(); _checkClass(className); handler.processing(); // Deliver instance only if request was for leaf class if (className.equal(CLASS_EXTENDED_COMPUTER_SYSTEM)) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_CREATION_CLASS_NAME, CLASS_EXTENDED_COMPUTER_SYSTEM, CIMKeyBinding::STRING)); keys.append(CIMKeyBinding( PROPERTY_NAME, _cs.getHostName(), CIMKeyBinding::STRING)); handler.deliver(CIMObjectPath( _cs.getHostName(), ref.getNameSpace(), CLASS_EXTENDED_COMPUTER_SYSTEM, keys)); } handler.complete(); return; }
void ComputerSystemProvider::getInstance( const OperationContext& context, const CIMObjectPath& ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler &handler) { CIMName className = ref.getClassName(); _checkClass(className); Array<CIMKeyBinding> keys = ref.getKeyBindings(); //-- make sure we're the right instance unsigned int keyCount = NUMKEYS_COMPUTER_SYSTEM; CIMName keyName; String keyValue; if (keys.size() != keyCount) { throw CIMInvalidParameterException("Wrong number of keys"); } for (unsigned int ii = 0; ii < keys.size(); ii++) { keyName = keys[ii].getName(); keyValue = keys[ii].getValue(); //Put CLASS_EXTENDED_COMPUTER_SYSTEM in front CLASS_CIM_COMPUTER_SYSTEM //to prefer CLASS_EXTENDED_COMPUTER_SYSTEM as class being served first //followed by CLASS_CIM_UNITARY_COMPUTER_SYSTEM if (keyName.equal(PROPERTY_CREATION_CLASS_NAME) && (String::equalNoCase(keyValue,CLASS_EXTENDED_COMPUTER_SYSTEM) || String::equalNoCase(keyValue,CLASS_CIM_UNITARY_COMPUTER_SYSTEM) || String::equalNoCase(keyValue,CLASS_CIM_COMPUTER_SYSTEM) || String::equalNoCase(keyValue,String::EMPTY))) { keyCount--; } else if (keyName.equal("Name") && String::equalNoCase(keyValue,_cs.getHostName())) { keyCount--; } } if (keyCount) { throw CIMInvalidParameterException(String::EMPTY); } // return instance of specified class CIMInstance instance = _cs.buildInstance(ref.getClassName()); handler.processing(); handler.deliver(instance); handler.complete(); return; }
gridfs* _checkGridfs(SEXP gfs) { _checkClass(gfs, "mongo.gridfs"); SEXP ptr = getAttrib(gfs, sym_mongo_gridfs); if (ptr == R_NilValue) error("Attribute \"mongo.gridfs\" is missing from mongo.gridfs class object\n"); gridfs* _gfs = (gridfs*)R_ExternalPtrAddr(ptr); if (!_gfs) error("mongo.gridfs object appears to have been destroyed.\n"); return _gfs; }
gridfile* _checkGridfile(SEXP gfile) { _checkClass(gfile, "mongo.gridfile"); SEXP ptr = getAttrib(gfile, sym_mongo_gridfile); if (ptr == R_NilValue) error("Attribute \"mongo.gridfile\" is missing from mongo.gridfile class object\n"); gridfile* _gfile = (gridfile*)R_ExternalPtrAddr(ptr); if (!_gfile) error("mongo.gridfile object appears to have been destroyed.\n"); return _gfile; }
gridfile* _checkGridfileWriter(SEXP gfw) { _checkClass(gfw, "mongo.gridfile.writer"); SEXP ptr = getAttrib(gfw, sym_mongo_gridfile); if (ptr == R_NilValue) error("Expected a \"mongo.gridfile\" attribute in object\n"); gridfile* _gfile = (gridfile*)R_ExternalPtrAddr(ptr); if (!_gfile) error("mongo.grdfile.writer object appears to have been finished.\n"); return _gfile; }
mongo_cursor* _checkCursor(SEXP cursor) { _checkClass(cursor, "mongo.cursor"); SEXP ptr = getAttrib(cursor, sym_mongo_cursor); if (ptr == R_NilValue) error("Attribute \"mongo.cursor\" is missing from mongo.cursor class object\n"); mongo_cursor* _cursor = (mongo_cursor*)R_ExternalPtrAddr(ptr); /* NULL cursor value indicates no records returned from find if (!_cursor) error("mongo.cursor object appears to have been destroyed.\n"); */ return _cursor; }
/* ================================================================================ NAME : enumerateInstanceNames DESCRIPTION : Enumerates all of the IPProtocolEndpoint instance names. : An array of instance references is returned. ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : Localization is not supported by this provider. PARAMETERS : ================================================================================ */ void BIPTLEpProvider::enumerateInstanceNames(const OperationContext &ctx, const CIMObjectPath &ref, ObjectPathResponseHandler &handler) { #ifdef DEBUG cout << "BIPTLEpProvider::enumerateInstanceNames()" << endl; #endif CIMName className = ref.getClassName(); CIMNamespaceName nameSpace = ref.getNameSpace(); // Validate the classname _checkClass(className); // Notify processing is starting handler.processing(); int i; InterfaceList _ifList; #ifdef DEBUG cout << "BIPTLEpProvider::enumerateInstanceNames() _ifList Initialized" << endl; #endif for (i = 0; i < _ifList.size(); i++) { IPInterface _ipif = _ifList.getInterface(i); if (_ipif.bindsToLANInterface()) { // Deliver the names handler.deliver( CIMObjectPath(String::EMPTY, // hostname nameSpace, CLASS_PG_BINDS_IP_TO_LAN_ENDPOINT, _constructKeyBindings(nameSpace, _ipif) ) ); } } // Notify processing is complete handler.complete(); return; } // enumerateInstanceNames
void UNIX_PROVIDER::enumerateInstanceNames(const OperationContext &ctx, const CIMObjectPath &ref, ObjectPathResponseHandler &handler) { int pIndex; CLASS_IMPLEMENTATION _p; CIMName className = ref.getClassName(); CIMNamespaceName nameSpace = ref.getNameSpace(); // Validate the classname _checkClass(className); // Notify processing is starting handler.processing(); // We are only going to respond to enumeration requests on // CLASS_UNIX_PROCESS if (className.equal (_getBaseClassCimName()) || className.equal(_getClassCimName())) { // Get the process information and deliver an ObjectPath for // each process // Note that loadProcessInfo modifies pIndex to point to the // next process structure before the loop increments it! _p.initialize(); for (pIndex = 0; _p.load(pIndex); pIndex++) { // Deliver the names handler.deliver(CIMObjectPath(String(""), // hostname nameSpace, _getClassCimName(), _constructKeyBindings(_p))); } _p.finalize(); } // Notify processing is complete handler.complete(); return; } // enumerateInstanceNames
/* ================================================================================ NAME : enumerateInstances DESCRIPTION : Enumerates all of the IPProtocolEndpoint instances. : An array of instance references is returned. ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : LocalOnly, DeepInheritance and propertyList are not : respected by this provider. Localization is not supported PARAMETERS : ================================================================================ */ void BIPTLEpProvider::enumerateInstances( const OperationContext & context, const CIMObjectPath & classReference, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & propertyList, InstanceResponseHandler & handler) { #ifdef DEBUG cout << "BIPTLEpProvider::enumerateInstances()" << endl; #endif CIMName className = classReference.getClassName(); CIMNamespaceName nameSpace = classReference.getNameSpace(); // Validate the classname _checkClass(className); // Notify processing is starting handler.processing(); int i; InterfaceList _ifList; for (i = 0; i < _ifList.size(); i++) { IPInterface _ipif = _ifList.getInterface(i); if (_ipif.bindsToLANInterface()) { handler.deliver( _constructInstance(CLASS_PG_BINDS_IP_TO_LAN_ENDPOINT, nameSpace, _ipif ) ); } } // Notify processing is complete handler.complete(); return; } // enumerateInstances
void ComputerSystemProvider::enumerateInstances( const OperationContext& context, const CIMObjectPath& ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler& handler) { CIMName className = ref.getClassName(); _checkClass(className); handler.processing(); // Deliver instance only if request was for leaf class if (className.equal (CLASS_EXTENDED_COMPUTER_SYSTEM)) { Array<CIMKeyBinding> keys; keys.append(CIMKeyBinding( PROPERTY_CREATION_CLASS_NAME, CLASS_EXTENDED_COMPUTER_SYSTEM, CIMKeyBinding::STRING)); keys.append(CIMKeyBinding( PROPERTY_NAME, _cs.getHostName(), CIMKeyBinding::STRING)); CIMObjectPath instanceName( String::EMPTY, // Hostname not required CIMNamespaceName(), // Namespace not required CLASS_EXTENDED_COMPUTER_SYSTEM, keys); CIMInstance instance = _cs.buildInstance(CLASS_EXTENDED_COMPUTER_SYSTEM); instance.setPath(instanceName); handler.deliver(instance); } handler.complete(); return; }
/* ================================================================================ NAME : getInstance DESCRIPTION : Returns a single instance. ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : LocalOnly, DeepInheritance and propertyList are not : respected by this provider. Localization is not supported PARAMETERS : ================================================================================ */ void BIPTLEpProvider::getInstance(const OperationContext &ctx, const CIMObjectPath &instanceName, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList &propertyList, InstanceResponseHandler &handler) { #ifdef DEBUG cout << "BIPTLEpProvider::getInstance(" << instanceName.toString() << ")" << endl; #endif CIMKeyBinding kb; CIMName className = instanceName.getClassName(); CIMNamespaceName nameSpace = instanceName.getNameSpace(); int i; int keysFound; // this will be used as a bit array String sn; // system name String lepName, // LAN Endpoint Name ipeName, // IP Protocol Endpoint Name refCCN, // Reference's Creation Class Name refName; // Reference's Name // Grab the system name if (IPInterface::getSystemName(sn) == false) sn = String::EMPTY; // Validate the classname _checkClass(className); // Extract the key values Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings(); // Leave immediately if wrong number of keys if ( kbArray.size() != NUMKEYS_PG_BINDS_IP_TO_LAN_ENDPOINT ) throw CIMInvalidParameterException("Wrong number of keys"); // Validate the keys. // Each loop iteration will set a bit in keysFound when a valid // key is found. If the expected bits aren't all set when // the loop finishes, it's a problem for (i=0, keysFound=0; i < NUMKEYS_PG_BINDS_IP_TO_LAN_ENDPOINT; i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); String keyValue = kb.getValue(); // Antecedent must match if (keyName.equal (PROPERTY_ANTECEDENT)) { if (_goodPERefKeys(keyValue, refCCN, refName) && String::equalNoCase(refCCN, CLASS_CIM_LAN_ENDPOINT.getString())) { keysFound |= 1; lepName = refName; } else throw CIMInvalidParameterException(keyValue+": bad value for key "+ keyName.getString()); } // Dependent must match else if (keyName.equal (PROPERTY_DEPENDENT)) { if (_goodPERefKeys(keyValue, refCCN, refName) && String::equalNoCase(refCCN, CLASS_CIM_IP_PROTOCOL_ENDPOINT.getString())) { keysFound |= 2; ipeName = refName; } else throw CIMInvalidParameterException(keyValue+": bad value for key "+ keyName.getString()); } // Key name was not recognized by any of the above tests else throw CIMInvalidParameterException(keyName.getString()+ ": Unrecognized key"); } // for // We could get here if we didn't get all the keys, which // could happen if the right number of keys were supplied, // and they all had valid names and values, but there were // any duplicates (e.g., two Names, no SystemName) if (keysFound != (1<<NUMKEYS_PG_BINDS_IP_TO_LAN_ENDPOINT)-1) throw CIMInvalidParameterException("Bad object name"); // Get the Interface List InterfaceList _ifList; IPInterface _ipif; // Make sure the LAN Endpoint name is embedded in the IP Protocol Endpoint // name. If we can find the request interface and if it's one that // binds to a LAN Interface, then we've found the right one, so // return it to the client. if (ipeName.find(lepName) != PEG_NOT_FOUND && _ifList.findInterface(ipeName, _ipif) && _ipif.bindsToLANInterface()) { /* Notify processing is starting. */ handler.processing(); /* Return the instance. */ handler.deliver(_constructInstance(className, nameSpace, _ipif)); /* Notify processing is complete. */ handler.complete(); return; } throw CIMObjectNotFoundException(ipeName+": No such IP Interface"); return; // can never execute, but required to keep compiler happy }
void UNIX_PROVIDER::getInstance(const OperationContext &ctx, const CIMObjectPath &instanceName, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList &propertyList, InstanceResponseHandler &handler) { CIMKeyBinding kb; CIMName className = instanceName.getClassName(); CIMNamespaceName nameSpace = instanceName.getNameSpace(); String handle; int i; int keysFound = 0; // this will be used as a bit array CLASS_IMPLEMENTATION _p; // Validate the classname _checkClass(className); // Extract the key values Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings(); // Leave immediately if wrong number of keys if ( kbArray.size() != NUMKEYS_CLASS_IMPLEMENTATION ) throw CIMInvalidParameterException("Wrong number of keys"); // Validate the keys. // Each loop iteration will set a bit in keysFound when a valid // key is found. If the expected bits aren't all set when // the loop finishes, it's a problem for(i=0, keysFound=0; i<NUMKEYS_CLASS_IMPLEMENTATION; i++) { kb = kbArray[i]; if (_p.validateKey(kb)) { keysFound++; _p.buildKeyHandle(kb, handle); } // Key name was not recognized by any of the above tests else throw CIMInvalidParameterException(kb.getName().getString() + ": Unrecognized key"); } // for // We could get here if we didn't get all the keys, which // could happen if the right number of keys were supplied, // and they all had valid names and values, but there were // any duplicates (e.g., two Handles, no OSName) if(keysFound != NUMKEYS_CLASS_IMPLEMENTATION) throw CIMInvalidParameterException("Bad object name"); /* Find the instance. First convert the instance id which is the */ /* process handle to an integer. This is necessary because the */ /* handle is the process id on HP-UX which must be passed to */ /* pstat_getproc() as an integer. */ /* Get the process information. */ if (_p.find(handle)) { /* Notify processing is starting. */ handler.processing(); /* Return the instance. */ handler.deliver(_constructInstance(className, nameSpace, _p)); /* Notify processing is complete. */ handler.complete(); return; } throw CIMObjectNotFoundException(handle+": No such process"); return; // can never execute, but required to keep compiler happy }
/* ================================================================================ NAME : getInstance DESCRIPTION : Returns a single instance. ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : LocalOnly, DeepInheritance and propertyList are not : respected by this provider. Localization is not supported PARAMETERS : ================================================================================ */ void IPPEpProvider::getInstance(const OperationContext &ctx, const CIMObjectPath &instanceName, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList &propertyList, InstanceResponseHandler &handler) { #ifdef DEBUG cout << "IPPEpProvider::getInstance(" << instanceName.toString() << ")" << endl; #endif CIMKeyBinding kb; CIMName className = instanceName.getClassName(); CIMNamespaceName nameSpace = instanceName.getNameSpace(); int i; int keysFound; // this will be used as a bit array String sn; // system name String ifName; // Grab the system name if (IPInterface::getSystemName(sn) == false) sn = String::EMPTY; // Validate the classname _checkClass(className); // Extract the key values Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings(); // Leave immediately if wrong number of keys if ( kbArray.size() != NUMKEYS_IP_PROTOCOL_ENDPOINT ) throw CIMInvalidParameterException("Wrong number of keys"); // Validate the keys. // Each loop iteration will set a bit in keysFound when a valid // key is found. If the expected bits aren't all set when // the loop finishes, it's a problem for (i=0, keysFound=0; i < NUMKEYS_IP_PROTOCOL_ENDPOINT; i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); String keyValue = kb.getValue(); // SystemCreationClassName can be empty or must match if (keyName.equal (PROPERTY_SYSTEM_CREATION_CLASS_NAME)) { if (String::equal(keyValue, String::EMPTY) || String::equalNoCase(keyValue, CLASS_CIM_UNITARY_COMPUTER_SYSTEM.getString())) keysFound |= 1; else throw CIMInvalidParameterException(keyValue+": bad value for key "+ keyName.getString()); } // SystemName can be empty or must match else if (keyName.equal (PROPERTY_SYSTEM_NAME)) { if (String::equal(keyValue, String::EMPTY) || String::equalNoCase(keyValue, sn) ) keysFound |= 2; else throw CIMInvalidParameterException(keyValue+": bad value for key "+ keyName.getString()); } // CreationClassName can be empty or must match else if (keyName.equal (PROPERTY_CREATION_CLASS_NAME)) { if (String::equal(keyValue, String::EMPTY) || String::equalNoCase(keyValue, CLASS_CIM_IP_PROTOCOL_ENDPOINT.getString())) keysFound |= 4; else throw CIMInvalidParameterException(keyValue+": bad value for key "+ keyName.getString()); } // Name must be a valid IP interface, but we will know that later // For now, just verify that it's present else if (keyName.equal (PROPERTY_NAME)) { ifName = keyValue; keysFound |= 8; } // Key name was not recognized by any of the above tests else throw CIMInvalidParameterException(keyName.getString() + ": Unrecognized key"); } // for // We could get here if we didn't get all the keys, which // could happen if the right number of keys were supplied, // and they all had valid names and values, but there were // any duplicates (e.g., two Names, no SystemName) if (keysFound != (1<<NUMKEYS_IP_PROTOCOL_ENDPOINT)-1) throw CIMInvalidParameterException("Bad object name"); /* Find the instance. First convert the instance id which is the */ /* process handle to an integer. This is necessary because the */ /* handle is the process id on HP-UX which must be passed to */ /* pstat_getproc() as an integer. */ /* Get the Interface List. */ InterfaceList _ifList; IPInterface _ipif; if (_ifList.findInterface(ifName, _ipif)) { /* Notify processing is starting. */ handler.processing(); /* Return the instance. */ handler.deliver(_constructInstance(className, nameSpace, _ipif)); /* Notify processing is complete. */ handler.complete(); return; } throw CIMObjectNotFoundException(ifName+": No such IP Interface"); return; // can never execute, but required to keep compiler happy }