void testInstanceCollection() { Buffer expected; FileSystem::loadFileToMemory(expected, "./instanceCollection.json"); if (verbose) cout << "Expected: " << expected.getData() << endl; Buffer outputBuffer; JSONWriter writer(outputBuffer); CIMName className = "className"; Array<CIMObject> instances; for (Uint32 i = 0; i < 10; i++) { CIMInstance x(className); x.addProperty(CIMProperty(CIMName("boolProp"), CIMValue(true))); x.addProperty(CIMProperty(CIMName("intProp"), CIMValue(i))); x.addProperty(CIMProperty( CIMName("stringProp"), CIMValue(String("hello world")))); Buffer objPath; objPath << className.getString() << ".intProp=" << i; x.setPath(CIMObjectPath(objPath.getData())); instances.append(x); } writer._append(instances); if (verbose) cout << "Got: " << outputBuffer.getData() << endl; PEGASUS_TEST_ASSERT( System::strcasecmp( expected.getData(), outputBuffer.getData()) == 0); }
void testEnumInstanceNames(CIMClient& client,const char *ns) { Array<CIMObjectPath> refs; refs = client.enumerateInstanceNames(ns,CIM_QUERYCAPCLASS_NAME); if(refs.size() != 1) throw Exception("references.size() incorrect"); Array<CIMKeyBinding> keys = refs[0].getKeyBindings(); //-- make sure we're the right instance CIMName keyName; String keyValue; if (keys.size() != NUM_KEY_PROPERTIES) throw Exception("Wrong number of keys"); keyName = keys[0].getName(); keyValue = keys[0].getValue(); if(keyName.getString() != String(PROPERTY_NAME_INSTANCEID) ) throw Exception("Incorrect Key"); if(keyValue != String(INSTANCEID_VALUE)) throw Exception(keyValue); }
Boolean UNIX_BGPPeerUsesRouteMap::find(const Array<CIMKeyBinding> &kbArray) { CIMKeyBinding kb; String collectionKey; String memberKey; for(Uint32 i = 0; i < kbArray.size(); i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); if (keyName.equal(PROPERTY_COLLECTION)) collectionKey = kb.getValue(); else if (keyName.equal(PROPERTY_MEMBER)) memberKey = kb.getValue(); } /* Execute find with extracted keys */ for(int i = 0; load(i); i++) { if ((String::equalNoCase(getCollection().getPath().toString(), collectionKey)) && (String::equalNoCase(getMember().getPath().toString(), memberKey))) { return true; } } return false; }
void TestGroupingProvider2::invokeMethod( const OperationContext& context, const CIMObjectPath& objectReference, const CIMName& methodName, const Array<CIMParamValue>& inParameters, MethodResultResponseHandler& handler) { if (!objectReference.getClassName().equal("Test_GroupingClass2")) { throw CIMNotSupportedException( objectReference.getClassName().getString()); } handler.processing(); if (methodName.equal("getNextIdentifier")) { handler.deliver(CIMValue(Uint32(getNextIdentifier()))); } else if (methodName.equal("getSubscriptionCount")) { handler.deliver(CIMValue(_subscriptionCount)); } handler.complete(); }
void WQLFilterRep::enumInstances( const String& ns, const String& className, CIMInstanceResultHandlerIFC& result, EDeepFlag deep, ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin, const StringArray* propertyList, EEnumSubclassesFlag enumSubclasses, OperationContext& context) { CIMName superClassName = m_inst.getClassName(); while (superClassName != CIMName()) { if (superClassName == className) { // Don't need to do correct localOnly & deep processing. //result.handleInstance(m_inst.clone(localOnly, includeQualifiers, // includeClassOrigin, propertyList)); // This is more efficient result.handle(m_inst); break; } superClassName = m_pCIMServer->getClass(ns, superClassName.toString(), E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN, NULL, context).getSuperClass(); } }
CIMInstance UNIX_AggregatePSExtentBasedOnAggregatePExtentProvider::constructInstance( const CIMName &className, const CIMNamespaceName &nameSpace, const UNIX_AggregatePSExtentBasedOnAggregatePExtent &instanceObject) const { CIMProperty p; CIMInstance inst(className); // Set path inst.setPath(CIMObjectPath(String(""), // hostname nameSpace, className, constructKeyBindings(instanceObject))); //CIM_Dependency Properties if (instanceObject.getAntecedent(p)) inst.addProperty(p); if (instanceObject.getDependent(p)) inst.addProperty(p); if (className.equal("CIM_Dependency")) return inst; //CIM_AbstractBasedOn Properties if (instanceObject.getStartingAddress(p)) inst.addProperty(p); if (instanceObject.getEndingAddress(p)) inst.addProperty(p); if (instanceObject.getOrderIndex(p)) inst.addProperty(p); if (className.equal("CIM_AbstractBasedOn")) return inst; //CIM_BasedOn Properties if (className.equal("CIM_BasedOn")) return inst; //CIM_AggregatePSExtentBasedOnAggregatePExtent Properties return inst; }
Boolean UNIX_ClusteringService::find(Array<CIMKeyBinding> &kbArray) { CIMKeyBinding kb; String systemCreationClassNameKey; String systemNameKey; String creationClassNameKey; String nameKey; for(Uint32 i = 0; i < kbArray.size(); i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); if (keyName.equal(PROPERTY_SYSTEM_CREATION_CLASS_NAME)) systemCreationClassNameKey = kb.getValue(); else if (keyName.equal(PROPERTY_SYSTEM_NAME)) systemNameKey = kb.getValue(); else if (keyName.equal(PROPERTY_CREATION_CLASS_NAME)) creationClassNameKey = kb.getValue(); else if (keyName.equal(PROPERTY_NAME)) nameKey = kb.getValue(); } /* EXecute find with extracted keys */ return false; }
/* ================================================================================ NAME : _checkClass DESCRIPTION : tests the argument for valid classname, : throws exception if not ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : ================================================================================ */ void UNIX_PROVIDER::_checkClass(CIMName& className) { if (!className.equal (_getClassCimName()) && !className.equal (_getBaseClassCimName())) throw CIMNotSupportedException(className.getString() + ": Class not supported"); }
const CIMPropertyList WQLSelectStatementRep::getSelectPropertyList( const CIMObjectPath& inClassName) const { // // Check for "*" // if (_allProperties) { // // Return null CIMPropertyList for all properties // return CIMPropertyList (); } CIMName className = inClassName.getClassName(); if (className.isNull()) { // // If the caller passed in an empty className, then the FROM class is // to be used // className = _className; } // // Check if inClassName is the FROM class // if (!(className == _className)) { // // Check for NULL Query Context // if (_ctx == NULL) { MessageLoaderParms parms ("WQL.WQLSelectStatementRep.QUERY_CONTEXT_IS_NULL", "Trying to process a query with a NULL Query Context."); throw QueryRuntimeException(parms); } // // Check if inClassName is a subclass of the FROM class // if (!_ctx->isSubClass(_className,className)) { MessageLoaderParms parms ("WQL.WQLSelectStatementRep.CLASS_NOT_FROM_LIST_CLASS", "Class $0 does not match the FROM class or any of its " "subclasses.", className.getString()); throw QueryRuntimeException(parms); } } // // Return CIMPropertyList for properties referenced in the projection // list (SELECT clause) // return CIMPropertyList (_selectPropertyNames); }
/* Return the value in a property. If the property cannot be found, return false */ Boolean _getPropertyValue(const CIMInstance& inst, const CIMName name, CIMValue& val) { #ifdef ENABLE_LOCAL_DIAGNOSTICS DCOUT << "Instance from which to retrieve " << inst.getClassName().getString() << " propertyName " << name.getString() << endl; #endif unsigned int pos = inst.findProperty(name); if (pos==PEG_NOT_FOUND) { #ifdef ENABLE_LOCAL_DIAGNOSTICS DCOUT << "property " << name.getString() << " pos " << pos << " NOT found" << endl; #endif return false; } #ifdef ENABLE_LOCAL_DIAGNOSTICS DCOUT << "property " << name.getString() << " FOUND" << endl; #endif val=inst.getProperty(pos).getValue(); return true; }
void OperatingSystemProvider::enumerateInstanceNames( const OperationContext& context, const CIMObjectPath &ref, ObjectPathResponseHandler& handler ) { CIMObjectPath newref; CIMName className; // only return instances when enumerate on our subclass, CIMOM // will call us as natural part of recursing through subtree on // enumerate - if we return instances on enumerate of our superclass, // there would be dups className = ref.getClassName(); if (className.equal (STANDARDOPERATINGSYSTEMCLASS)) { handler.processing(); handler.complete(); return; } else if (!className.equal (EXTENDEDOPERATINGSYSTEMCLASS)) { throw CIMNotSupportedException("OperatingSystemProvider " "does not support class " + className.getString()); } // so we know it is for EXTENDEDOPERATINGSYSTEMCLASS handler.processing(); // in terms of the class we use, want to set to what was requested newref = _fill_reference(ref.getNameSpace(), className); handler.deliver(newref); handler.complete(); return; }
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; }
/* ================================================================================ NAME : _constructReference DESCRIPTION : Constructs a reference pointing to the appropriate class ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : PARAMETERS : className, Process ================================================================================ */ Array<CIMKeyBinding> BIPTLEpProvider::_constructReference( const CIMName& className, const String& sysName, const String& instName) { #ifdef DEBUG cout << "BIPTLEpProvider::_constructReference()" << endl; #endif Array<CIMKeyBinding> kba; // Construct the key bindings kba.append(CIMKeyBinding(PROPERTY_SYSTEM_CREATION_CLASS_NAME, CLASS_CIM_UNITARY_COMPUTER_SYSTEM.getString(), CIMKeyBinding::STRING)); kba.append(CIMKeyBinding(PROPERTY_SYSTEM_NAME, sysName, CIMKeyBinding::STRING)); kba.append(CIMKeyBinding(PROPERTY_CREATION_CLASS_NAME, className.getString(), CIMKeyBinding::STRING)); kba.append(CIMKeyBinding(PROPERTY_NAME, instName, CIMKeyBinding::STRING)); #ifdef DEBUG cout << "BIPTLEpProvider::_constructReference() -- done" << endl; #endif return kba; }
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; }
Boolean UNIX_AssociatedTargetMaskingGroup::find(const Array<CIMKeyBinding> &kbArray) { CIMKeyBinding kb; String antecedentKey; String dependentKey; for(Uint32 i = 0; i < kbArray.size(); i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); if (keyName.equal(PROPERTY_ANTECEDENT)) antecedentKey = kb.getValue(); else if (keyName.equal(PROPERTY_DEPENDENT)) dependentKey = kb.getValue(); } /* Execute find with extracted keys */ for(int i = 0; load(i); i++) { if ((String::equalNoCase(getAntecedent().getPath().toString(), antecedentKey)) && (String::equalNoCase(getDependent().getPath().toString(), dependentKey))) { return true; } } return false; }
CIMInstance UNIX_ASBGPEndpointsProvider::constructInstance( const CIMName &className, const CIMNamespaceName &nameSpace, const UNIX_ASBGPEndpoints &instanceObject) const { CIMProperty p; CIMInstance inst(className); // Set path inst.setPath(CIMObjectPath(String(""), // hostname nameSpace, className, constructKeyBindings(instanceObject))); //CIM_AbstractComponent Properties if (instanceObject.getGroupComponent(p)) inst.addProperty(p); if (instanceObject.getPartComponent(p)) inst.addProperty(p); if (className.equal("CIM_AbstractComponent")) return inst; //CIM_Component Properties if (className.equal("CIM_Component")) return inst; //CIM_SystemComponent Properties if (className.equal("CIM_SystemComponent")) return inst; //CIM_ASBGPEndpoints Properties return inst; }
Boolean UNIX_BGPServiceStatistics::find(const Array<CIMKeyBinding> &kbArray) { CIMKeyBinding kb; String statsKey; String elementKey; for(Uint32 i = 0; i < kbArray.size(); i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); if (keyName.equal(PROPERTY_STATS)) statsKey = kb.getValue(); else if (keyName.equal(PROPERTY_ELEMENT)) elementKey = kb.getValue(); } /* Execute find with extracted keys */ for(int i = 0; load(i); i++) { if ((String::equalNoCase(getStats().getPath().toString(), statsKey)) && (String::equalNoCase(getElement().getPath().toString(), elementKey))) { return true; } } return false; }
Boolean UNIX_BIOSString::find(const Array<CIMKeyBinding> &kbArray) { CIMKeyBinding kb; String instanceIDKey; for(Uint32 i = 0; i < kbArray.size(); i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); if (keyName.equal(PROPERTY_INSTANCE_ID)) instanceIDKey = kb.getValue(); } /* Execute find with extracted keys */ for(int i = 0; load(i); i++) { if ((String::equalNoCase(getInstanceID(), instanceIDKey))) { return true; } } return false; }
Boolean UNIX_BGPServiceAttributes::find(const Array<CIMKeyBinding> &kbArray) { CIMKeyBinding kb; String groupComponentKey; String partComponentKey; for(Uint32 i = 0; i < kbArray.size(); i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); if (keyName.equal(PROPERTY_GROUP_COMPONENT)) groupComponentKey = kb.getValue(); else if (keyName.equal(PROPERTY_PART_COMPONENT)) partComponentKey = kb.getValue(); } /* Execute find with extracted keys */ for(int i = 0; load(i); i++) { if ((String::equalNoCase(getGroupComponent().getPath().toString(), groupComponentKey)) && (String::equalNoCase(getPartComponent().getPath().toString(), partComponentKey))) { return true; } } return false; }
void CIMQualifierType::readObject(istream &istrm) { CIMName name; CIMDataType dataType(CIMNULL); CIMScopeArray scope; CIMFlavorArray flavor; CIMValue defaultValue(CIMNULL); CIMBase::readSig( istrm, OW_CIMQUALIFIERTYPESIG ); name.readObject(istrm); dataType.readObject(istrm); BinarySerialization::readArray(istrm, scope); BinarySerialization::readArray(istrm, flavor); Bool isValue; isValue.readObject(istrm); if (isValue) { defaultValue.readObject(istrm); } if (!m_pdata) { m_pdata = new QUALTData; } m_pdata->m_name = name; m_pdata->m_dataType = dataType; m_pdata->m_scope = scope; m_pdata->m_flavor = flavor; m_pdata->m_defaultValue = defaultValue; }
Boolean UNIX_BinarySensor::find(const Array<CIMKeyBinding> &kbArray) { CIMKeyBinding kb; String systemCreationClassNameKey; String systemNameKey; String creationClassNameKey; String deviceIDKey; for(Uint32 i = 0; i < kbArray.size(); i++) { kb = kbArray[i]; CIMName keyName = kb.getName(); if (keyName.equal(PROPERTY_SYSTEM_CREATION_CLASS_NAME)) systemCreationClassNameKey = kb.getValue(); else if (keyName.equal(PROPERTY_SYSTEM_NAME)) systemNameKey = kb.getValue(); else if (keyName.equal(PROPERTY_CREATION_CLASS_NAME)) creationClassNameKey = kb.getValue(); else if (keyName.equal(PROPERTY_DEVICE_ID)) deviceIDKey = kb.getValue(); } /* Execute find with extracted keys */ for(int i = 0; load(i); i++) { if ((String::equalNoCase(getSystemCreationClassName(), systemCreationClassNameKey)) && (String::equalNoCase(getSystemName(), systemNameKey)) && (String::equalNoCase(getCreationClassName(), creationClassNameKey)) && (String::equalNoCase(getDeviceID(), deviceIDKey))) { return true; } } return false; }
/***************************************************************************** * * Implementation of InstanceProvider modifyInstance method. * *****************************************************************************/ void InteropProvider::modifyInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance& modifiedIns, const Boolean includeQualifiers, const CIMPropertyList& propertyList, ResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::modifyInstance"); initProvider(); //AutoMutex autoMut(changeControlMutex); //PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, // "%s modifyInstance. instanceReference= %s, includeQualifiers= %s, " // "PropertyList= %s", // thisProvider, // (const char *) (instanceReference.toString().getCString()), // boolToString(includeQualifiers), // (const char *) (propertyListToString(propertyList).getCString()))); //// test for legal namespace for this provider. Exception if not ////namespaceSupported(instanceReference); //// NOTE: Above is commented out because the routing tables will always //// do the right thing and that's the only way requests get here. //CIMName className = instanceReference.getClassName(); //// begin processing the request //handler.processing(); //if (className.equal(PEGASUS_CLASSNAME_PG_OBJECTMANAGER)) //{ // modifyObjectManagerInstance(context, instanceReference,modifiedIns, // includeQualifiers, propertyList); //} //else //{ // throw CIMNotSupportedException("Delete instance of class " + // className.getString()); //} //handler.complete(); //PEG_METHOD_EXIT(); //return; // 不支持修改 PEG_METHOD_EXIT(); const CIMName instClassName = instanceReference.getClassName(); MessageLoaderParms mparms( "ControlProviders.InteropProvider.MODIFY_INSTANCE_NOT_ALLOWED", "Modify instance operation not allowed by Interop Provider for " "class $0.", instClassName.getString()); throw CIMNotSupportedException(mparms); }
/** Update the specified property name and value in the current config file. */ Boolean ConfigFileHandler::updateCurrentValue( const CIMName& name, const String& value, Boolean unset) { // Remove the old property name and value from the table if (_currentConfig->table.contains(name.getString())) { if (!_currentConfig->table.remove(name.getString())) { return false; } } if (!unset) { // Store the new property name and value in to the table if (!_currentConfig->table.insert(name.getString(), value)) { return false; } } try { // Store the new property in current config file. _currentConfFile->save(_currentConfig); } catch (CannotRenameFile& e) { // // Back up creation failed // FUTURE: Log this message in a log file. // PEG_TRACE((TRC_CONFIG, Tracer::LEVEL1, "Backup configuration file creation failed: %s", (const char*)e.getMessage().getCString())); return false; } catch (CannotOpenFile& cof) { PEG_TRACE((TRC_CONFIG, Tracer::LEVEL1, "Setting permissions on current configuration file failed: %s", (const char*)cof.getMessage().getCString())); return false; } // // The current config file would now been created, // so set the flag to true. // _currentFileExist = true; return true; }
void ComputerSystemProvider::_checkClass(CIMName& className) { if (!className.equal(CLASS_EXTENDED_COMPUTER_SYSTEM) && !className.equal(CLASS_CIM_UNITARY_COMPUTER_SYSTEM) && !className.equal(CLASS_CIM_COMPUTER_SYSTEM)) { throw CIMNotSupportedException(String::EMPTY); } }
/* ================================================================================ NAME : _constructKeyBindings DESCRIPTION : Constructs an array of keybindings for an IP Interface ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : PARAMETERS : className, Process ================================================================================ */ Array<CIMKeyBinding> BIPTLEpProvider::_constructKeyBindings( const CIMNamespaceName &nameSpace, const IPInterface &_ipif) { #ifdef DEBUG cout << "BIPTLEpProvider::_constructKeyBindings()" << endl; #endif Array<CIMKeyBinding> keyBindings; String s, sn; CIMObjectPath op; if (_ipif.getSystemName(sn) == false) { throw CIMNotSupportedException( String("Host-specific module doesn't support Key `") + PROPERTY_SYSTEM_NAME.getString() + String("'")); } // Construct the key bindings op = CIMObjectPath(sn, //hostname nameSpace, CLASS_CIM_LAN_ENDPOINT, _constructReference( CLASS_CIM_LAN_ENDPOINT, sn,_ipif.get_LANInterfaceName()) ); keyBindings.append(CIMKeyBinding(PROPERTY_ANTECEDENT, op.toString(), CIMKeyBinding::REFERENCE)); if (_ipif.getName(s)) { op = CIMObjectPath(sn, //hostname nameSpace, CLASS_CIM_IP_PROTOCOL_ENDPOINT, _constructReference( CLASS_CIM_IP_PROTOCOL_ENDPOINT, sn,s) ); keyBindings.append(CIMKeyBinding(PROPERTY_DEPENDENT, op.toString(), CIMKeyBinding::REFERENCE)); } else { throw CIMNotSupportedException( String("Host-specific module doesn't support Key `") + PROPERTY_NAME.getString() + String("'")); } #ifdef DEBUG cout << "BIPTLEpProvider::_constructKeyBindings() -- done" << endl; #endif return keyBindings; }
void DefaultInstanceProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { CIMNamespaceName nameSpace = classReference.getNameSpace(); CIMName className = classReference.getClassName(); // create the namespace if necessary if (!_nameSpaceExists(nameSpace)) { _copyNameSpace(nameSpace.getString(), className.getString()); } // check to see if class already exists // if not, copy the class // try { CIMClass cimClass = _repository->getClass(nameSpace, className); } catch (Exception&) { // class does not exist // // copy the class // _copyClass(nameSpace.getString(), className.getString()); } Array<CIMObjectPath> instanceNames; try { instanceNames = _repository->enumerateInstanceNamesForClass( nameSpace, className, true); } catch (Exception & ex) { const String msg = "Enumerate InstanceNames failed. " + ex.getMessage(); throw CIMOperationFailedException( msg ); } // begin processing the request handler.processing(); for(Uint32 i = 0, n = instanceNames.size(); i < n; i++) { // deliver reference handler.deliver(instanceNames[i]); } // complete processing the request handler.complete(); }
//////////////////////////////////////////////////////////////////////////////// // Gather Properities for Next Hop IP Route Info //////////////////////////////////////////////////////////////////////////////// void NextHopIPRouteInfo::_gatherProperties(CIMInstance &inst) { _ipInstanceID = String::EMPTY; _ipIPDestAddr = String::EMPTY; _ipIPDestMask = String::EMPTY; _ipAddrType = 0; // Unknown _ipCaption = String::EMPTY; _ipDescription = String::EMPTY; _ipName = String::EMPTY; for (Uint32 j=0; j < inst.getPropertyCount(); j++) { CIMName propertyName = inst.getProperty(j).getName(); // Properties that are also keys if (propertyName.equal("InstanceID")) { inst.getProperty(j).getValue().get(_ipInstanceID); } // Other properties else if (propertyName.equal("Caption")) { inst.getProperty(j).getValue().get(_ipCaption); } else if (propertyName.equal("Description")) { inst.getProperty(j).getValue().get(_ipDescription); } else if (propertyName.equal("Name")) { inst.getProperty(j).getValue().get(_ipName); } else if (propertyName.equal("DestinationAddress")) { inst.getProperty(j).getValue().get(_ipIPDestAddr); } else if (propertyName.equal("DestinationMask")) { inst.getProperty(j).getValue().get(_ipIPDestMask); } else if (propertyName.equal("AddressType")) { inst.getProperty(j).getValue().get(_ipAddrType); } else if (propertyName.equal("PrefixLength")) { inst.getProperty(j).getValue().get(_ipPrefixLength); } else if (propertyName.equal(PROPERTY_NEXT_HOP)) { inst.getProperty(j).getValue().get(_ipNextHop); } } // end for loop through properties }
/* testGetInstance of the OS provider. */ void OSTestClient::testGetInstance (CIMClient &client, Boolean verboseTest) { CIMObjectPath getTestRef; // will need an instance for Get try { Boolean deepInheritance = true; Boolean localOnly = true; testLog("OS Provider Test GetInstance"); // first do an EnumerateInstanceNames - select one to play with // doesn't hurt to keep testing enumerate :-) Array<CIMObjectPath> cimReferences = client.enumerateInstanceNames(NAMESPACE, CLASSNAME); Uint32 numberInstances = cimReferences.size(); if (verboseTest) cout << numberInstances << " instances of PG_OperatingSystem" <<endl; for (Uint32 i = 0; i < cimReferences.size(); i++) { CIMName className = cimReferences[i].getClassName(); if (!className.equal (CLASSNAME)) { errorExit("EnumInstanceNames failed - wrong class"); } // add in some content checks on the keys returned _validateKeys(cimReferences[i], verboseTest); // let's just take the first instance found getTestRef = cimReferences[i]; } // end for looping through instances if (verboseTest) cout<<"EnumerateInstanceNames for Get Instance completed"<<endl; // now call GetInstance with the appropriate references CIMInstance getTestInstance = client.getInstance(NAMESPACE, getTestRef); // now validate the properties returned _validateProperties(getTestInstance, verboseTest); testLog("OS Provider Test Get Instance passed "); } // end try catch(Exception& e) { errorExit(e.getMessage()); } }
inline String DynamicRoutingTable::_getWildRoutingKey( const CIMName& className) const { //ATTN: We don't support wild class names. PEGASUS_ASSERT(!className.isNull()); String key(":"); key.append(className.getString()); return key; }
Boolean UNIX_BGPIPRoute::validateKey(CIMKeyBinding &kb) const { /* Keys */ //SystemCreationClassName //SystemName //ServiceCreationClassName //ServiceName //CreationClassName //IPDestinationAddress //IPDestinationMask //AddressType CIMName name = kb.getName(); if (name.equal(PROPERTY_SYSTEM_CREATION_CLASS_NAME) || name.equal(PROPERTY_SYSTEM_NAME) || name.equal(PROPERTY_SERVICE_CREATION_CLASS_NAME) || name.equal(PROPERTY_SERVICE_NAME) || name.equal(PROPERTY_CREATION_CLASS_NAME) || name.equal(PROPERTY_I_P_DESTINATION_ADDRESS) || name.equal(PROPERTY_I_P_DESTINATION_MASK) || name.equal(PROPERTY_ADDRESS_TYPE) ) return true; return false; }