void _generateFullNamespaceName( Array<CIMNamespaceName>& namespaceNames, CIMNamespaceName& parentNamespaceName, CIMNamespaceName& childNamespaceName, Boolean isRelativeName, CIMNamespaceName& fullNamespaceName) { // If isRelativeName is true, then the parentNamespace // MUST exist // if (isRelativeName) { if (!Contains(namespaceNames, parentNamespaceName)) { //l10n //throw CIMObjectNotFoundException("Parent namespace does not exist: " //+ parentNamespaceName.getString()); throw CIMObjectNotFoundException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.PARENT_NAMESPACE_DOES_NOT_EXIST", "Parent namespace does not exist: $0", parentNamespaceName.getString())); } // Create full namespace name by prepending parentNamespaceName fullNamespaceName = CIMNamespaceName (parentNamespaceName.getString() + "/" + childNamespaceName.getString()); } else { fullNamespaceName = parentNamespaceName; } }
//------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------ NTPService::NTPService(void) { // Retrieve NTP informations if(!getNTPInfo()) throw CIMObjectNotFoundException("NTPService " "can't create PG_NTPService instance"); }
//------------------------------------------------------------------------------ // FUNCTION: DNSService // // REMARKS: Constructor for DNSService Class //------------------------------------------------------------------------------ DNSService::DNSService(void) { #ifdef DNSPROVIDER_DEBUG cout << "DNSService::DNSService()" << endl; #endif if(!getDNSInfo()) throw CIMObjectNotFoundException("DNSService " "can't create PG_DNSService instance"); }
CIMInstance ProviderIndicationCountTable::getProviderIndicationDataInstance( const CIMObjectPath& instanceName) { PEG_METHOD_ENTER(TRC_INDICATION_SERVICE, "ProviderIndicationCountTable::getProviderIndicationDataInstance"); // // Gets provider module name and provider name from the provider indication // data instance object path // String providerModuleName; String providerName; Array<CIMKeyBinding> keys = instanceName.getKeyBindings(); for (Uint32 i = 0; i < keys.size(); i++) { if (keys[i].getName() == _PROPERTY_PROVIDERNAME) { providerName = keys[i].getValue(); } else if (keys[i].getName() == _PROPERTY_PROVIDERMODULENAME) { providerModuleName = keys[i].getValue(); } } String providerKey = _generateKey(providerModuleName, providerName); _ProviderIndicationCountTableEntry entry; WriteLock lock(_tableLock); if (_table.lookup(providerKey, entry)) { CIMInstance providerIndDataInstance = _buildProviderIndDataInstance(entry); PEG_METHOD_EXIT(); return providerIndDataInstance; } PEG_METHOD_EXIT(); throw CIMObjectNotFoundException(instanceName.toString()); }
/* ================================================================================ 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 NamespaceProvider::getInstance( const OperationContext & context, const CIMObjectPath & instanceName, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & properatyList, InstanceResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::getInstance"); CIMNamespaceName childNamespaceName; CIMNamespaceName getNamespaceName; Boolean isRelativeName; // Verify that the className = __namespace if (!instanceName.getClassName().equal(NAMESPACE_CLASSNAME)) { PEG_METHOD_EXIT(); //l10n //throw CIMNotSupportedException(instanceName.getClassName().getString() //+ " not supported by Namespace Provider"); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER", "$0 not supported by Namespace Provider", instanceName.getClassName().getString())); } //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } _getKeyValue(instanceName, childNamespaceName, isRelativeName); CIMNamespaceName parentNamespaceName = instanceName.getNameSpace(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "childNamespaceName = " + childNamespaceName.getString() + (isRelativeName?String("true"):String("false")) + ", parentNamespaceName = " + parentNamespaceName.getString()); // begin processing the request handler.processing(); try { Array<CIMNamespaceName> namespaceNames; namespaceNames = _repository->enumerateNameSpaces(); _generateFullNamespaceName(namespaceNames, parentNamespaceName, childNamespaceName, isRelativeName, getNamespaceName); if (!Contains(namespaceNames, getNamespaceName)) { //l10n //throw CIMObjectNotFoundException("Namespace deos not exist: " //+ getNamespaceName.getString()); throw CIMObjectNotFoundException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NAMESPACE_DOES_NOT_EXIST", "Namespace does not exist: $0", getNamespaceName.getString())); } PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "Namespace = " + getNamespaceName.getString() + " successfully found."); } catch(const CIMException&) { PEG_METHOD_EXIT(); throw; } catch(const Exception&) { PEG_METHOD_EXIT(); throw; } //Set name of class CIMInstance instance(NAMESPACE_CLASSNAME); // // construct the instance // instance.addProperty(CIMProperty(NAMESPACE_PROPERTYNAME, isRelativeName?childNamespaceName.getString(): parentNamespaceName.getString())); //instance.setPath(instanceName); handler.deliver(instance); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return ; }
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 }
// // Local version of getInstance to be used by other functions in the the // provider. Returns a single instance. Note that it always returns an // instance. If none was found, it is uninialitized. // CIMInstance InteropProvider::localGetInstance( const OperationContext & context, const CIMObjectPath & instanceName, const CIMPropertyList & propertyList) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::localGetInstance"); PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4, "%s getInstance. instanceName= %s , PropertyList= %s", thisProvider, (const char *)instanceName.toString().getCString(), (const char *)propertyList.toString().getCString())); // Test if we're looking for something outside of our namespace. This will // happen during associators calls from PG_RegisteredProfile instances // through the PG_ElementConformsToProfile association CIMNamespaceName opNamespace = instanceName.getNameSpace(); CIMName opClass = instanceName.getClassName(); if((opNamespace != PEGASUS_NAMESPACENAME_INTEROP && opClass != PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE) // Get CIM_IndicationService instance from IndicationService. #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT || opClass == PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE #endif ) { AutoMutex mut(interopMut); CIMInstance gotInstance = cimomHandle.getInstance( context, opNamespace, instanceName, false, false, false, propertyList); PEG_METHOD_EXIT(); return gotInstance; } TARGET_CLASS classEnum = translateClassInput(opClass); CIMInstance retInstance; switch(classEnum) { case PG_SOFTWAREIDENTITY: { retInstance = getSoftwareIdentityInstance(instanceName); normalizeInstance( retInstance, instanceName, false, false, propertyList); } break; case PG_NAMESPACE: { retInstance = getNameSpaceInstance(instanceName); normalizeInstance( retInstance, instanceName, false, false, propertyList); } break; // ATTN: Implement getIntstance for all other classes. Currently // this method calls localEnumerateInstances() to select instance // which is too expensive. default: { // Create reference from host, namespace, class components of // instance name CIMObjectPath ref; ref.setHost(instanceName.getHost()); ref.setClassName(opClass); ref.setNameSpace(opNamespace); // Enumerate instances for this class. Returns all instances // Note that this returns paths setup and instances already // filtered per the input criteria. Array<CIMInstance> instances = localEnumerateInstances( context, ref, propertyList); ConstArrayIterator<CIMInstance> instancesIter(instances); // deliver a single instance if found. bool found = false; for(Uint32 i = 0; i < instancesIter.size(); i++) { CIMObjectPath currentInstRef = instancesIter[i].getPath(); currentInstRef.setHost(instanceName.getHost()); currentInstRef.setNameSpace(instanceName.getNameSpace()); if(instanceName == currentInstRef) { retInstance = instancesIter[i]; found = true; break; } } if (!found) { PEG_METHOD_EXIT(); throw CIMObjectNotFoundException(instanceName.toString()); } } } PEG_METHOD_EXIT(); return retInstance; }
/* ================================================================================ 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 }