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;
}
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;
}
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;
}
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;
}
Boolean UNIX_BIOSFeature::find(Array<CIMKeyBinding> &kbArray)
{
	CIMKeyBinding kb;
	String identifyingNumberKey;
	String productNameKey;
	String vendorKey;
	String versionKey;
	String nameKey;


	for(Uint32 i = 0; i < kbArray.size(); i++)
	{
		kb = kbArray[i];
		CIMName keyName = kb.getName();
		if (keyName.equal(PROPERTY_IDENTIFYING_NUMBER)) identifyingNumberKey = kb.getValue();
		else if (keyName.equal(PROPERTY_PRODUCT_NAME)) productNameKey = kb.getValue();
		else if (keyName.equal(PROPERTY_VENDOR)) vendorKey = kb.getValue();
		else if (keyName.equal(PROPERTY_VERSION)) versionKey = kb.getValue();
		else if (keyName.equal(PROPERTY_NAME)) nameKey = kb.getValue();
	}



/* EXecute find with extracted keys */

	return false;
}
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_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;
}
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_CollectionInSystem::find(Array<CIMKeyBinding> &kbArray)
{
	CIMKeyBinding kb;
	String parentKey;
	String childKey;


	for(Uint32 i = 0; i < kbArray.size(); i++)
	{
		kb = kbArray[i];
		CIMName keyName = kb.getName();
		if (keyName.equal(PROPERTY_PARENT)) parentKey = kb.getValue();
		else if (keyName.equal(PROPERTY_CHILD)) childKey = kb.getValue();
	}



/* EXecute find with extracted keys */

	return false;
}
Boolean UNIX_BGPServiceStatistics::find(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 */

	return false;
}
Boolean UNIX_ApplicationSystemDependency::find(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 */

	return false;
}
Boolean UNIX_CollectedSoftwareFeatures::find(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 */

	return false;
}
Boolean UNIX_ComputerSystemIRQ::find(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 */

	return false;
}
Boolean UNIX_ComputerSystem::find(Array<CIMKeyBinding> &kbArray)
{
	CIMKeyBinding kb;
	String creationClassNameKey;
	String nameKey;


	for(Uint32 i = 0; i < kbArray.size(); i++)
	{
		kb = kbArray[i];
		CIMName keyName = kb.getName();
		if (keyName.equal(PROPERTY_CREATION_CLASS_NAME)) creationClassNameKey = kb.getValue();
		else if (keyName.equal(PROPERTY_NAME)) nameKey = kb.getValue();
	}

	/* EXecute find with extracted keys */
	if (String::equal(nameKey, CIMHelper::EmptyString) ||
		String::equal(nameKey, CIMHelper::HostName))
		return true;

	return false;
}
Boolean UNIX_BIOSElement::find(const Array<CIMKeyBinding> &kbArray)
{
	CIMKeyBinding kb;
	String nameKey;
	String versionKey;
	String softwareElementStateKey;
	String softwareElementIDKey;
	String targetOperatingSystemKey;


	for(Uint32 i = 0; i < kbArray.size(); i++)
	{
		kb = kbArray[i];
		CIMName keyName = kb.getName();
		if (keyName.equal(PROPERTY_NAME)) nameKey = kb.getValue();
		else if (keyName.equal(PROPERTY_VERSION)) versionKey = kb.getValue();
		else if (keyName.equal(PROPERTY_SOFTWARE_ELEMENT_STATE)) softwareElementStateKey = kb.getValue();
		else if (keyName.equal(PROPERTY_SOFTWARE_ELEMENT_ID)) softwareElementIDKey = kb.getValue();
		else if (keyName.equal(PROPERTY_TARGET_OPERATING_SYSTEM)) targetOperatingSystemKey = kb.getValue();
	}
	
	
	
	/* Execute find with extracted keys */
	for(int i = 0; load(i); i++) {
		if ((String::equalNoCase(getName(), nameKey)) && 
			(String::equalNoCase(getVersion(), versionKey)) && 
			(String::equalNoCase(String(std::to_string(getSoftwareElementState()).c_str()), softwareElementStateKey)) && 
			(String::equalNoCase(getSoftwareElementID(), softwareElementIDKey)) && 
			(String::equalNoCase(String(std::to_string(getTargetOperatingSystem()).c_str()), targetOperatingSystemKey)))
		{
			return true;
		}
	}
	
	return false;
}
Boolean UNIX_AllocationSchedulingElement::find(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 */

	return false;
}
Example #17
0
/*
================================================================================
NAME              : _goodPERefKeys
DESCRIPTION       : Checks to see if this is a value reference to a
		  : Protocol Endpoint with good values for SCCN, SN,
		  : and CCN.  If it is, it returns the Name;
                  : otherwise, it returns false.
ASSUMPTIONS       : None
PRE-CONDITIONS    :
POST-CONDITIONS   :
NOTES             :
================================================================================
*/
Boolean BIPTLEpProvider::_goodPERefKeys(const CIMObjectPath &instName,
				     String &rccn,    // CreationClassName
				     String &rname)   // Name
{
#ifdef DEBUG
   cout << "BIPTLEpProvider::_goodPERefKeys(" << instName.toString() << ")" 
        << endl;
#endif

   int keysFound,  // this will be used as a bit array
       i; 

   Array<CIMKeyBinding> kbArray = instName.getKeyBindings();

   if ( kbArray.size() != NUMKEYS_CIM_PROTOCOL_ENDPOINT)
     throw CIMInvalidParameterException("Wrong number of keys in reference");
    
   for (i=0, keysFound=0; i < NUMKEYS_CIM_PROTOCOL_ENDPOINT; i++)
   {
      CIMKeyBinding kb = kbArray[i];  

      CIMName keyName = kb.getName();
      String keyValue = kb.getValue();

      // SystemCreationClassName
      if (keyName.equal (PROPERTY_SYSTEM_CREATION_CLASS_NAME))
      {
	  if (String::equalNoCase(keyValue,
                  CLASS_CIM_UNITARY_COMPUTER_SYSTEM.getString()) ||
		  String::equal(keyValue, String::EMPTY) )
             keysFound |= 1;
	  else
	     return false;  // invalid value for SystemCreationClassName
      }

      // SystemName
      else if (keyName.equal (PROPERTY_SYSTEM_NAME))
      {
	  String sn; // System Name
	  if (IPInterface::getSystemName(sn) == false)
	      sn = String::EMPTY;

	  if (String::equalNoCase(keyValue,sn) ||
		  String::equal(keyValue, String::EMPTY) )
             keysFound |= 2;
	  else
	     return false;  // invalid value for SystemName
      }

      // CreationClassName
      else if (keyName.equal (PROPERTY_CREATION_CLASS_NAME))
      {
	    rccn = keyValue;
            keysFound |= 4;
      }

      // 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))
      {
            rname = keyValue;
            keysFound |= 8;
      }

      // Key name was not recognized by any of the above tests
      else return false;

   } // 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_CIM_PROTOCOL_ENDPOINT)-1)
      return false;

#ifdef DEBUG
   cout << "BIPTLEpProvider::_goodPERefKeys() - success!" << endl;
#endif

   return true;
}
void MCCA_TestAssocProvider::associators(
    const OperationContext & context,
    const CIMObjectPath & objectName,
    const CIMName & associationClass,
    const CIMName & resultClass,
    const String & role,
    const String & resultRole,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList & propertyList,
    ObjectResponseHandler & handler)
{
    CDEBUG("MCCA_TestAssocProvider::associators() called.");
    // create a new CIMInstance based on class with name className
    CIMInstance constructedInstance = CIMInstance(testClassName);
    CIMObjectPath   targetObjectPath = CIMObjectPath();
    Array<CIMKeyBinding> keyBindings = Array<CIMKeyBinding>();
    Uint32 sourceKey = 0;

    CDEBUG("Initialisation ended.");
    handler.processing();
    CDEBUG("handler.processing started.");
    // we do ignore role, resultRole, includeQualifiers, includeClassOrigin,
    // propertyList

    CDEBUG("Next building object path.");
    /////////////////////////////////////////////////////////////////////
    //      BUILD OBJECTPATH
    /////////////////////////////////////////////////////////////////////

    // preparing object path first
    targetObjectPath.setHost("localhost:5988");
    targetObjectPath.setClassName(testClassName);
    CDEBUG("Host and classname set, host=" << objectName.getHost());
    // determine if source namespace is namespace A or B
    // and build respective target namespace ...
    if (objectName.getNameSpace().equal(nameSpaceA))
    {
        targetObjectPath.setNameSpace(nameSpaceB);
    }
    if (objectName.getNameSpace().equal(nameSpaceB))
    {
        targetObjectPath.setNameSpace(nameSpaceA);
    }
    CDEBUG("NameSpace set.");
    // determine key of source object so we can create target object
    Array<CIMKeyBinding> sourceKeyBindings = objectName.getKeyBindings();

    CDEBUG("Determining sourceKey.");
    // only one keyvalue, so we take that first one
    String      keyValueString = String(sourceKeyBindings[0].getValue());
    CDEBUG("keyValueString=" << keyValueString);
    sourceKey = strtoul((const char*) keyValueString.getCString(), NULL, 0);
    CDEBUG("sourceKey=" << sourceKey);


    CIMKeyBinding  testClassKey = CIMKeyBinding(CIMName("theKey"),
                                                    CIMValue(sourceKey) );
    CDEBUG("Created new KeyBinding testClassKey.");
    // testClassKey.setValue(keyValueString);

    CDEBUG("sourceKey = string(set keybinding),int(sourceKey)"
            << testClassKey.getValue()
            << "," << sourceKey);
    keyBindings.append(testClassKey);
    CDEBUG("Appended(testClassKey).");

    targetObjectPath.setKeyBindings(keyBindings);
    /////////////////////////////////////////////////////////////////////
    //      ADD PROPERTIES
    /////////////////////////////////////////////////////////////////////

    // add properties to the CIMInstance object
    constructedInstance.addProperty( CIMProperty( CIMName("theKey"),
                sourceKey));
    constructedInstance.addProperty( CIMProperty( CIMName("theData"),
                20+sourceKey));
    char  buffer[100];
    sprintf(buffer,"ABC-%u",20*sourceKey+sourceKey);
    constructedInstance.addProperty(CIMProperty(CIMName ("theString"),
                String(buffer)));

    CDEBUG("Added properties to the CIMInstance object");

    CIMObject cimObject(constructedInstance);
    cimObject.setPath (targetObjectPath);

    // lets deliver all instances of CIMObjectpaths I do think are okay
    handler.deliver(cimObject);
    // complete processing the request
    handler.complete();
    CDEBUG("Association call conmplete.");
}
Example #19
0
Boolean operator==(const CIMKeyBinding& x, const CIMKeyBinding& y)
{
    // Check that the names and types match
    if (!(x.getName().equal(y.getName())) ||
        !(x.getType() == y.getType()))
    {
        return false;
    }

    switch (x.getType())
    {
    case CIMKeyBinding::REFERENCE:
        try
        {
            // References should be compared as CIMObjectPaths
            return (CIMObjectPath(x.getValue()) == CIMObjectPath(y.getValue()));
        }
        catch (Exception&)
        {
            // If CIMObjectPath parsing fails, just compare strings
            return String::equal(x.getValue(), y.getValue());
        }
    case CIMKeyBinding::BOOLEAN:
        // Case-insensitive comparison is sufficient for booleans
        return String::equalNoCase(x.getValue(), y.getValue());
    case CIMKeyBinding::NUMERIC:
        // Note: This comparison assumes XML syntax for integers
        // First try comparing as unsigned integers
        {
            Uint64 xValue;
            Uint64 yValue;
            if (StringConversion::stringToUnsignedInteger(
                    x.getValue().getCString(), xValue) &&
                StringConversion::stringToUnsignedInteger(
                    y.getValue().getCString(), yValue))
            {
                return (xValue == yValue);
            }
        }
        // Next try comparing as signed integers
        {
            Sint64 xValue;
            Sint64 yValue;
            if (StringConversion::stringToSignedInteger(
                    x.getValue().getCString(), xValue) &&
                StringConversion::stringToSignedInteger(
                    y.getValue().getCString(), yValue))
            {
                return (xValue == yValue);
            }
        }
        // Note: Keys may not be real values, so don't try comparing as reals
        // We couldn't parse the numbers, so just compare the strings
        return String::equal(x.getValue(), y.getValue());
    default:  // CIMKeyBinding::STRING
        return String::equal(x.getValue(), y.getValue());
    }

    PEGASUS_UNREACHABLE(return false;)
}
Example #20
0
/*
================================================================================
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
}
Example #21
0
/*
================================================================================
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
}