PEGASUS_NAMESPACE_BEGIN

//
// Given the two references in the association, this function creates an
// instance of the PG_ElementConformsToProfile class.
//
CIMInstance buildElementConformsToProfile(
    const CIMObjectPath & currentProfile,
    const CIMObjectPath & currentElement,
    const CIMClass & elementConformsClass)
{
    Array<CIMName> elementPropArray;
    elementPropArray.append(
        ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD);
    elementPropArray.append(
        ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT);
    CIMPropertyList elementPropList(elementPropArray);

    CIMInstance tmpInstance =
        elementConformsClass.buildInstance(false, false,
            elementPropList);
    setPropertyValue(tmpInstance,
        ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD,
        currentProfile);
    setPropertyValue(tmpInstance,
        ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT,
        currentElement);
    tmpInstance.setPath(tmpInstance.buildPath(
        elementConformsClass));
    return tmpInstance;
}
Ejemplo n.º 2
0
/*
    Build an instance of the test class
*/
CIMInstance buildInstance(CIMClient& client, String& instanceId)
{
    CIMClass cl = client.getClass(PROVIDERNS, TEST_CLASS);
    CIMInstance inst = cl.buildInstance(false, false, CIMPropertyList());
    setPropertyValue(inst, "Id", CIMValue(instanceId));

    return inst;
}
Ejemplo n.º 3
0
//
// Builds an instance of the class named className. Gets Class defintion and
// fills in the correct properties from the class.  This requires a repository
// getClass request for each instance built. The skeleton is built by
// creating the instance and copying qualifiers and properties from
// the class. Finally the instance is cloned to separate it from the
// original objects.
// NOTE: This is very inefficient for anything larger than a few instances.
// We should separate the get from the createSkeleton.
// @param className CIMName of the class for which the instance is to be built
// @return CIMInstance of this class with properties complete.
// @exception passes on any exceptions received from the repository request.
//
CIMInstance InteropProvider::buildInstanceSkeleton(
      const CIMNamespaceName & nameSpace,
      const CIMName& className,
      Boolean includeQualifiers,
      CIMClass& returnedClass)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
        "InteropProvider::_buildInstanceSkeleton()");
    // get class with lo = false, qualifier = true classorig = true
    returnedClass = repository->getClass(nameSpace,
        className, false, true, true);
    CIMInstance skeleton = returnedClass.buildInstance(
        includeQualifiers, true, CIMPropertyList());

    PEG_METHOD_EXIT();
    return skeleton;
}
static void
_test2 (CIMClient & client)
{
  Uint32 exceptions = 0;
  CIMObjectPath instanceName;
  Array < CIMKeyBinding > keyBindings;

  keyBindings.append (CIMKeyBinding ("ElementNameName",
                                     "TestCMPI_ExecQuery",
                                     CIMKeyBinding::STRING));

  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName ("TestCMPI_ExecQuery");
  instanceName.setKeyBindings (keyBindings);

  /* Call the unsupported functions of the provider. */
  try
  {
    CIMInstance instance (client.getInstance (providerNamespace,
                                              instanceName));
  } catch (const CIMException &)
  {
     exceptions ++;
  }


  try
  {
    client.deleteInstance (providerNamespace, instanceName);

  } catch (const CIMException & )
  {
     exceptions ++;
  }
  CIMClass thisClass = client.getClass(
                           providerNamespace,
                           "TestCMPI_ExecQuery",
                           false,
                           true,
                           true,
                           CIMPropertyList());
  Array<CIMName> propertyNameList;
  propertyNameList.append(CIMName("ElementName"));
  CIMPropertyList myPropertyList(propertyNameList);
  // create the instance with the defined properties
  CIMInstance newInstance = thisClass.buildInstance(true, true, myPropertyList);
  newInstance.getProperty(0).setValue(CIMValue(String("TestCMPI_execQuery") ));
  try
  {

    CIMObjectPath objectPath (client.createInstance (providerNamespace,
                                                     newInstance));


  } catch (const CIMException &)
  {
     exceptions ++;
  }

  try
  {
    client.modifyInstance (providerNamespace, newInstance);

  } catch (const CIMException &)
  {
     exceptions ++;
  }
  try
  {

    Array < CIMInstance > instances =
      client.enumerateInstances (providerNamespace,
                                 CIMName ("TestCMPI_ExecQuery"));
  } catch (const CIMException &)
  {
     exceptions ++;
  }

  try
  {
    Array < CIMObjectPath > objectPaths =
      client.enumerateInstanceNames (providerNamespace,
                                     CIMName ("TestCMPI_ExecQuery"));
  } catch (const CIMException &)
  {
     exceptions ++;
  }

  PEGASUS_TEST_ASSERT(exceptions ==  6);

}