CIMInstance UNIX_PROVIDER::testConstructInstance(
    const CIMName &className,
    const CIMNamespaceName &nameSpace,
    const CLASS_IMPLEMENTATION &_p)
{
	return _constructInstance(className, nameSpace, _p);
}
示例#2
0
/*
================================================================================
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 UNIX_PROVIDER::execQuery(
       const OperationContext& context,
       const CIMObjectPath& objectPath,
       const QueryExpression& query,
       InstanceResponseHandler& handler)
{
	CIMName className;
    CIMInstance instance;
    CLASS_IMPLEMENTATION _p;
    className = objectPath.getClassName();
    CIMNamespaceName nameSpace = objectPath.getNameSpace();
    int pIndex;
    // 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
    if (className.equal (_getClassCimName()) ||
    	className.equal(_getBaseClassCimName()))
    {
        handler.processing();
        _p.initialize();
        for (pIndex = 0; _p.load(pIndex); pIndex++)
        {
        	CIMInstance ci = _constructInstance(_getClassCimName(),
                                           nameSpace,
                                           _p);
        	if (query.evaluate(ci))
	        {
	        	handler.deliver(ci);
	        }
		}
		_p.finalize();
        handler.complete();
    }
    else
    {
        throw CIMNotSupportedException(UNIX_PROVIDER_NAME
                "does not support class " + className.getString());
    }
    return;
}
void UNIX_PROVIDER::enumerateInstances(
    const OperationContext& context,
    const CIMObjectPath& ref,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin,
    const CIMPropertyList& propertyList,
    InstanceResponseHandler& handler)
{
    CIMName className;
    CIMInstance instance;
    CIMObjectPath newref;
    CLASS_IMPLEMENTATION _p;
    className = ref.getClassName();
    CIMNamespaceName nameSpace = ref.getNameSpace();
    int pIndex;
    // 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
    if (className.equal (_getClassCimName()) ||
    	className.equal(_getBaseClassCimName()))
    {
        handler.processing();
        _p.initialize();
        for (pIndex = 0; _p.load(pIndex); pIndex++)
        handler.deliver(_constructInstance(_getClassCimName(),
                                           nameSpace,
                                           _p));
		_p.finalize();
        handler.complete();
    }
    else
    {
        throw CIMNotSupportedException(_getClassName() + 
                "does not support class " + className.getString());
    }
    return;
}
示例#5
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
}
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
}
示例#7
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
}