////////////////////////////////////////////////////////////////////////////////
//  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

}
Example #2
0
Boolean _propertyIdentical(
    const char* propertyName,
    CIMInstance& instance1,
    CIMInstance& instance2)
{
    Uint32 pos = instance1.findProperty(propertyName);
    CIMConstProperty p1 = instance1.getProperty(pos);
    pos = instance2.findProperty(propertyName);
    CIMConstProperty p2 = instance2.getProperty(pos);
    return (p1.identical(p2));
}
Example #3
0
void CIMError::setInstance(const CIMInstance& instance)
{
    for (Uint32 i = 0; i < instance.getPropertyCount(); i++)
    {
        CIMConstProperty p = instance.getProperty(i);

        _Check("ErrorType", p, (Uint16*)0);
        _Check("OtherErrorType", p, (String*)0);
        _Check("OwningEntity", p, (String*)0);
        _Check("MessageID", p, (String*)0);
        _Check("Message", p, (String*)0);
        _Check("MessageArguments", p, (Array<String>*)0);
        _Check("PerceivedSeverity", p, (Uint16*)0);
        _Check("ProbableCause", p, (Uint16*)0);
        _Check("ProbableCauseDescription", p, (String*)0);
        _Check("RecommendedActions", p, (Array<String>*)0);
        _Check("ErrorSource", p, (String*)0);
        _Check("ErrorSourceFormat", p, (Uint16*)0);
        _Check("OtherErrorSourceFormat", p, (String*)0);
        _Check("CIMStatusCode", p, (Uint32*)0);
        _Check("CIMStatusCodeDescription", p, (String*)0);
    }

    // Verify that the instance contains all of the required properties.

    for (Uint32 i = 0; i < _numRequiredProperties; i++)
    {
        // Does inst have this property?

        Uint32 pos = instance.findProperty(_requiredProperties[i]);

        if (pos == PEG_NOT_FOUND)
        {
            char buffer[80];
            sprintf(buffer, "required property does not exist: %s",
                    _requiredProperties[i]);
            throw CIMException(CIM_ERR_NO_SUCH_PROPERTY, buffer);
        }
        // is required property non-null?
        CIMConstProperty p = instance.getProperty(pos);
        CIMValue v = p.getValue();
        if (v.isNull())
        {
            char buffer[80];
            sprintf(buffer, "required property MUST NOT be Null: %s",
                    _requiredProperties[i]);
            throw CIMException(CIM_ERR_FAILED, buffer);
        }
    }
    _inst = instance;
}
Example #4
0
/**
   gatherProperties method of the nisinfo Test Client
*/
void NISInfo::gatherProperties(CIMInstance &inst) 
{
#ifdef DEBUG
   cout << "NISInfo::gatherProperties()" << endl;
#endif
   // don't have a try here - want it to be caught by caller

   // loop through the properties
   for (Uint32 j=0; j < inst.getPropertyCount(); j++)
   {
      CIMName propertyName = inst.getProperty(j).getName();

      // only pull out those properties of interest  (do not remove)

      if (propertyName.equal (CIMName ("SystemCreationClassName")))
      {
            inst.getProperty(j).getValue().get(nisSystemCreationClassName);
      }  // end if SystemCreationClassName

      if (propertyName.equal (CIMName ("SystemName")))
      {
            inst.getProperty(j).getValue().get(nisSystemName);
      }  // end if SystemName

      if (propertyName.equal (CIMName ("CreationClassName")))
      {
            inst.getProperty(j).getValue().get(nisCreationClassName);
      }  // end if CreationClassName

      if (propertyName.equal (CIMName ("Name")))
      {
            inst.getProperty(j).getValue().get(nisName);
      }  // end if Name

      if (propertyName.equal (CIMName ("Caption")))
      {
            inst.getProperty(j).getValue().get(nisCaption);
      }  // end if Caption

      if (propertyName.equal (CIMName ("Description")))
      {
            inst.getProperty(j).getValue().get(nisDescription);
      }  // end if Description

      if (propertyName.equal (CIMName ("ServerType")))
      {
            inst.getProperty(j).getValue().get(nisServerType);
      }  // end if ServerType

      if (propertyName.equal (CIMName ("ServerWaitFlag")))
      {
            inst.getProperty(j).getValue().get(nisServerWaitFlag);
      }  // end if ServerWaitFlag
   }  // end of for looping through properties
}
Example #5
0
void testUserContextRequestor()
{
    try
    {
        CIMClient client;
        client.connectLocal();

        // Determine whether the CIM Server has authentication enabled

        CIMObjectPath authConfigInstName = CIMObjectPath(
            "PG_ConfigSetting.PropertyName=\"enableAuthentication\""); 
        CIMInstance authConfigInst =
            client.getInstance("root/PG_Internal", authConfigInstName);

        String authConfigValue;
        authConfigInst.getProperty(authConfigInst.findProperty("CurrentValue"))
            .getValue().get(authConfigValue);
        Boolean authenticationEnabled =
            String::equalNoCase(authConfigValue, "true");

        // Test a provider running in Requestor user context

        CIMObjectPath instName =
            CIMObjectPath("TST_UserContextRequestor.Id=1");
        CIMInstance cimInstance = client.getInstance(NAMESPACE, instName);

        String userContext;
        cimInstance.getProperty(cimInstance.findProperty("UserContext"))
            .getValue().get(userContext);

        if (verbose)
        {
            cout << "Requestor test: UserContext = " << userContext << endl;
        }

        if (authenticationEnabled)
        {
            PEGASUS_TEST_ASSERT(userContext == System::getEffectiveUserName());
        }
        else
        {
            PEGASUS_TEST_ASSERT(userContext == serverUserContext);
        }
    }
    catch (Exception& e)
    {
        cerr << "Error: " << e.getMessage() << endl;
        exit(1);
    }
}
Example #6
0
/**
   gatherProperties method of the dnsinfo Test Client
  */
void DNSInfo::gatherProperties(CIMInstance &inst, Boolean cimFormat) 
{
#ifdef DEBUG
   cout << "DNSInfo::gatherProperties()" << endl;
#endif
   // don't have a try here - want it to be caught by caller

   // loop through the properties
   for (Uint32 j=0; j < inst.getPropertyCount(); j++)
   {
      CIMName propertyName = inst.getProperty(j).getName();

      // only pull out those properties of interest
      if (propertyName.equal (CIMName ("SystemName")))
      {
         inst.getProperty(j).getValue().get(dnsSystemName);
      }  // end if SystemName

      if (propertyName.equal (CIMName ("SystemCreationClassName")))
      {
         inst.getProperty(j).getValue().get(dnsSystemCreationClassName);
      }  // end if SystemCreationClassName
      
      if (propertyName.equal (CIMName ("Name")))
      {
         inst.getProperty(j).getValue().get(dnsName); 
      }  // end if Name

      if (propertyName.equal (CIMName ("CreationClassName")))
      {
         inst.getProperty(j).getValue().get(dnsCreationClassName);
      }  // end if CreationClassName

      if (propertyName.equal (CIMName ("Caption")))
      {
         inst.getProperty(j).getValue().get(dnsCaption); 
      }  // end if Caption

      if (propertyName.equal (CIMName ("Description")))
      {
         inst.getProperty(j).getValue().get(dnsDescription); 
      }  // end if Description 

      if (propertyName.equal (CIMName ("SearchList")))
      {
         inst.getProperty(j).getValue().get(dnsSearchList); 
      }  // end if SearchList

      if (propertyName.equal (CIMName ("Addresses")))
      {
         inst.getProperty(j).getValue().get(dnsAddresses); 
      }  // end if ServerAddress
   }  // end of for looping through properties
}
void UNIX_ApplicationSystemDirectoryFixture::Run()
{
	CIMName className("UNIX_ApplicationSystemDirectory");
	CIMNamespaceName nameSpace("root/cimv2");
	UNIX_ApplicationSystemDirectory _p;
	UNIX_ApplicationSystemDirectoryProvider _provider;
	Uint32 propertyCount;
	CIMOMHandle omHandle;
	_provider.initialize(omHandle);
	_p.initialize();

	for(int pIndex = 0; _p.load(pIndex); pIndex++)
	{
		CIMInstance instance = _provider.constructInstance(className,
					nameSpace,
					_p);
		CIMObjectPath path = instance.getPath();
		cout << path.toString() << endl;
		propertyCount = instance.getPropertyCount();
		for(Uint32 i = 0; i < propertyCount; i++)
		{

			CIMProperty propertyItem = instance.getProperty(i);
			if (propertyItem.getType() == CIMTYPE_REFERENCE) {
				CIMValue subValue = propertyItem.getValue();
				CIMInstance subInstance;
				subValue.get(subInstance);
				CIMObjectPath subPath = subInstance.getPath();
				cout << "	Name: " << propertyItem.getName().getString() << ": " << subPath.toString() << endl;
				Uint32 subPropertyCount = subInstance.getPropertyCount();
				for(Uint32 j = 0; j < subPropertyCount; j++)
				{
					CIMProperty subPropertyItem = subInstance.getProperty(j);
					cout << "		Name: " << subPropertyItem.getName().getString() << " - Value: " << subPropertyItem.getValue().toString() << endl;
				}
			}
			else {
				cout << "	Name: " << propertyItem.getName().getString() << " - Value: " << propertyItem.getValue().toString() << endl;
			}

		}
		cout << "------------------------------------" << endl;
		cout << endl;
	}

	_p.finalize();
	
}
/*
    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;
}
static void checkBlocked(CIMInstance &pm)
{
    PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "checkBlocked");
    
    Array<Uint16> operationalStatus;

    Uint32 pos = pm.findProperty(CIMName ("OperationalStatus"));
    if(pos == PEG_NOT_FOUND) {
        PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,
            "OperationalStatus not found.");
        PEG_METHOD_EXIT();
	//l10n
        //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "provider lookup failed.");
        throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
        					"ProviderManager.ProviderManagerService.PROVIDER_LOOKUP_FAILED",
        					"provider lookup failed."));
    }

    pm.getProperty(pos).getValue().get(operationalStatus);
    for(Uint32 i = 0; i < operationalStatus.size(); i++) {
        if(operationalStatus[i] == _MODULE_STOPPED ||
	   operationalStatus[i] == _MODULE_STOPPING) {
            PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,
                "Provider blocked.");
            PEG_METHOD_EXIT();
			//l10n
            //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED, "provider blocked.");
            throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, MessageLoaderParms(
            			"ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",
            			"provider blocked."));
        }
    }
}
Example #10
0
void setPropertyValue(CIMInstance& instance, const CIMName& propertyName,
    const Uint32 value)
{
    Uint32 pos;
    PEGASUS_ASSERT(pos = instance.findProperty(propertyName) != PEG_NOT_FOUND);
    instance.getProperty(pos).setValue(CIMValue(value));
}
Example #11
0
void testUserContextPrivileged()
{
    try
    {
        CIMClient client;
        client.connectLocal();

        // Test a provider running in Privileged user context

        CIMObjectPath instName =
            CIMObjectPath("TST_UserContextPrivileged.Id=1");

        // ATTN: use of the localOnly flag is deprecated, but nor reliably
        // applied by the CIMOM. An explicit parameter is required for now.
        CIMInstance cimInstance = 
            client.getInstance(NAMESPACE, instName, false);

        String userContext;
        cimInstance.getProperty(cimInstance.findProperty("UserContext"))
            .getValue().get(userContext);

        if (verbose)
        {
            cout << "Privileged test: UserContext = " << userContext << endl;
        }

        PEGASUS_TEST_ASSERT(userContext == testUserContext);
    }
    catch (Exception& e)
    {
        cerr << "Error: " << e.getMessage() << endl;
        exit(1);
    }
}
Boolean UNIX_BGPPeerUsesRouteMap::loadInstance(const CIMInstance &instance)
{
	clearInstance();
	Uint32 propertyCount = instance.getPropertyCount();
	for(Uint32 i = 0; i < propertyCount; i++) {
		CIMConstProperty property = instance.getProperty(i);
			if (String::equal(property.getName().getString(), "Collection"))
			{
				CIMInstance collectionValue;
				property.getValue().get(collectionValue);
				setCollection(collectionValue);
			}
			else if (String::equal(property.getName().getString(), "Member"))
			{
				CIMInstance memberValue;
				property.getValue().get(memberValue);
				setMember(memberValue);
			}
			else if (String::equal(property.getName().getString(), "MapSequence"))
			{
				Uint16 mapSequenceValue;
				property.getValue().get(mapSequenceValue);
				setMapSequence(mapSequenceValue);
			}
	}
	return true;
}
Boolean UNIX_AssociatedSupplyCurrentSensor::loadInstance(const CIMInstance &instance)
{
	clearInstance();
	Uint32 propertyCount = instance.getPropertyCount();
	for(Uint32 i = 0; i < propertyCount; i++) {
		CIMConstProperty property = instance.getProperty(i);
			if (String::equal(property.getName().getString(), "Antecedent"))
			{
				CIMInstance antecedentValue;
				property.getValue().get(antecedentValue);
				setAntecedent(antecedentValue);
			}
			else if (String::equal(property.getName().getString(), "Dependent"))
			{
				CIMInstance dependentValue;
				property.getValue().get(dependentValue);
				setDependent(dependentValue);
			}
			else if (String::equal(property.getName().getString(), "MonitoringRange"))
			{
				Uint16 monitoringRangeValue;
				property.getValue().get(monitoringRangeValue);
				setMonitoringRange(monitoringRangeValue);
			}
	}
	return true;
}
Example #14
0
void _checkUint64Property
  (CIMInstance & instance, const String & name, Uint64 value)
{
  Uint32 pos = instance.findProperty (name);
  PEGASUS_ASSERT (pos != PEG_NOT_FOUND);

  CIMProperty theProperty = instance.getProperty (pos);
  CIMValue theValue = theProperty.getValue ();

  PEGASUS_ASSERT (theValue.getType () == CIMTYPE_UINT64);
  PEGASUS_ASSERT (!theValue.isArray ());
  PEGASUS_ASSERT (!theValue.isNull ());
  Uint64 result;
  theValue.get (result);

  if (verbose)
    {
      if (result != value)
	{
	  char buffer[32];	// Should need 21 chars max
	  sprintf (buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", value);
	  cerr << "Property value comparison failed.  ";
	  cerr << "Expected " << buffer << "; ";
	  sprintf (buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", result);
	  cerr << "Actual property value was " << buffer << "." << endl;
	}
    }

  PEGASUS_ASSERT (result == value);
}
Example #15
0
/**
 ***************************************************************************
   _filterAssociationInstances is used to filter the set of possible return
   instances against the filters (resultClass and resultRole) provided with
   the associators and associatorNames operations.  It returns the ObjectPaths
   of the set of objects that pass the filter tests.

    @param assocInstance     - The target association class instance
    @param sourceObjectPath  - The source ObjectPath
    @param resultClass       - The result class. If there is no resultClass,
                               this is String::EMPTY.
    @param resultRole        - The result role. If there is no role, this is
                               String::EMPTY

    @return   the ObjectPaths of the set of association instances that pass
              the filter tests.
 ***************************************************************************
*/
Array<CIMObjectPath> ANHProvider::_filterAssociationInstances(
    CIMInstance& assocInstance,
    const CIMObjectPath& sourceObjectPath,
    CIMName resultClass,
    String resultRole)
{
    Array<CIMObjectPath> returnPaths;

    // get all Reference properties
    for (Uint32 i = 0, n = assocInstance.getPropertyCount(); i < n; i++)
    {
        CIMProperty p = assocInstance.getProperty(i);

        if (p.getType() == CIMTYPE_REFERENCE)
        {
            CIMValue v = p.getValue();
            CIMObjectPath path;
            v.get(path);

            if (!sourceObjectPath.identical(path))
            {
                if (resultClass.isNull() || resultClass == path.getClassName())
                {
                    if (resultRole == String::EMPTY ||
                        (p.getName() == CIMName(resultRole)))
                    {
                        returnPaths.append(path);
                    }
                }
            }
        }
    }
    return returnPaths;
}
Example #16
0
void _checkUint32Property
  (CIMInstance & instance, const String & name, Uint32 value)
{
  Uint32 pos = instance.findProperty (name);
  PEGASUS_ASSERT (pos != PEG_NOT_FOUND);

  CIMProperty theProperty = instance.getProperty (pos);
  CIMValue theValue = theProperty.getValue ();

  PEGASUS_ASSERT (theValue.getType () == CIMTYPE_UINT32);
  PEGASUS_ASSERT (!theValue.isArray ());
  PEGASUS_ASSERT (!theValue.isNull ());
  Uint32 result;
  theValue.get (result);

  if (verbose)
    {
      if (result != value)
	{
	  cerr << "Property value comparison failed.  ";
	  cerr << "Expected " << value << "; ";
	  cerr << "Actual property value was " << result << "." << endl;
	}
    }

  PEGASUS_ASSERT (result == value);
}
void getPropertiesFromCIMServer(
    CIMClient& client,
    const CIMName& propName,
    Array <String>& propValues)
{
    CIMProperty prop;

    Array<CIMKeyBinding> kbArray;
    CIMKeyBinding        kb;
    String               _hostName;

    kb.setName(PROPERTY_NAME);
    kb.setValue(propName.getString());
    kb.setType(CIMKeyBinding::STRING);

    _hostName.assign(System::getHostName());

    kbArray.append(kb);

    CIMObjectPath reference(_hostName, PEGASUS_NAMESPACENAME_CONFIG,
                            PEGASUS_CLASSNAME_CONFIGSETTING, kbArray);

    CIMInstance cimInstance = client.getInstance(PEGASUS_NAMESPACENAME_CONFIG,
                                                 reference);

    Uint32 pos = cimInstance.findProperty(PROPERTY_NAME);
    prop = (CIMProperty)cimInstance.getProperty(pos);
    propValues.append(prop.getValue().toString());

    pos = cimInstance.findProperty(DEFAULT_VALUE);
    prop = (CIMProperty)cimInstance.getProperty(pos);
    propValues.append(prop.getValue().toString());

    pos = cimInstance.findProperty(CURRENT_VALUE);
    prop = (CIMProperty)cimInstance.getProperty(pos);
    propValues.append(prop.getValue().toString());

    pos = cimInstance.findProperty(PLANNED_VALUE);
    prop = (CIMProperty)cimInstance.getProperty(pos);
    propValues.append(prop.getValue().toString());

    pos = cimInstance.findProperty(DYNAMIC_PROPERTY);
    prop = (CIMProperty)cimInstance.getProperty(pos);
    propValues.append(prop.getValue().toString());

}
CIMValue CIMHelper::getPropertyValue(const CIMInstance &instanceObject, String name)
{
    CIMName cname(name);
    Uint32 index = instanceObject.findProperty(cname);
    if (index == PEG_NOT_FOUND) return CIMValue();
    CIMConstProperty property = instanceObject.getProperty(index);
    return property.getValue();
}
Example #19
0
static Boolean _checkValue(
    CIMInstance &instance,
    const String &prop,
    T value)
{
    T lvalue;
    instance.getProperty(instance.findProperty(prop)).getValue().get(lvalue);
    return lvalue == value;
}
Example #20
0
ProviderName ProviderRegistrar::findConsumerProvider(const String & destinationPath)
{
   CIMInstance provider;
   CIMInstance providerModule;
   ProviderName temp;

   if (_prm->lookupIndicationConsumer(destinationPath,provider,providerModule))
      return ProviderName(
               provider.getProperty(provider.findProperty
                   ("Name")).getValue ().toString (),
               providerModule.getProperty(providerModule.findProperty
                    ("Location")).getValue().toString(),
               providerModule.getProperty(providerModule.findProperty
                    ("InterfaceType")).getValue().toString(),
               0);

   return temp;
}
Example #21
0
void _testPropertyValue(
    CIMInstance& instance,
    const CIMName& propertyName,
    const CIMValue & testValue)
{
    CIMValue value =
        instance.getProperty(instance.findProperty(propertyName)).getValue();
    PEGASUS_TEST_ASSERT(testValue == value);
}
Example #22
0
void InstanceProvider::createInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance & instanceObject,
    ObjectPathResponseHandler & handler)
{
    // Validate the class name
    if (!instanceObject.getClassName().equal("Sample_InstanceProviderClass"))
    {
        throw CIMNotSupportedException(
            instanceObject.getClassName().getString());
    }

    // Find the key property
    Uint32 idIndex = instanceObject.findProperty("Identifier");

    if (idIndex == PEG_NOT_FOUND)
    {
        throw CIMInvalidParameterException("Missing key value");
    }

    CIMInstance cimInstance = instanceObject.clone();

    // Create the new instance name
    CIMValue idValue = instanceObject.getProperty(idIndex).getValue();
    Array<CIMKeyBinding> keys;
    keys.append(CIMKeyBinding("Identifier", idValue));
    CIMObjectPath instanceName = CIMObjectPath(
        String(),
        CIMNamespaceName(),
        instanceObject.getClassName(),
        keys);

    cimInstance.setPath(instanceName);
    
    // Determine whether this instance already exists
    for(Uint32 i = 0, n = _instances.size(); i < n; i++)
    {
        if(instanceName == _instances[i].getPath())
        {
            throw CIMObjectAlreadyExistsException(instanceName.toString());
        }
    }

    // begin processing the request
    handler.processing();

    // add the new instance to the array
    _instances.append(cimInstance);

    // deliver the new instance name
    handler.deliver(instanceName);

    // complete processing the request
    handler.complete();
}
Boolean setObjectManagerStatistics(CIMClient & client, Boolean newState)
{

    CIMName gathStatName ("GatherStatisticalData");
    Array<CIMInstance> instancesObjectManager;
    CIMInstance instObjectManager;
    Uint32 prop_num;
    Array<CIMName> plA;
    plA.append(gathStatName);
    CIMPropertyList statPropertyList(plA);
    // Create property list that represents correct request
    // get instance.  Get only the gatherstatitistics property
    instancesObjectManager  = 
        client.enumerateInstances(PEGASUS_NAMESPACENAME_INTEROP,
            "CIM_ObjectManager",
            true, false, false, false, statPropertyList);
    PEGASUS_TEST_ASSERT(instancesObjectManager.size() == 1);
    instObjectManager = instancesObjectManager[0];
    // set correct path into instance
    instObjectManager.setPath(instancesObjectManager[0].getPath());
    
    prop_num = instObjectManager.findProperty(gathStatName);
    PEGASUS_TEST_ASSERT(prop_num != PEG_NOT_FOUND);
    
    instObjectManager.getProperty(prop_num).setValue(CIMValue(newState));
    
    client.modifyInstance(PEGASUS_NAMESPACENAME_INTEROP, instObjectManager,
         false, statPropertyList);
    CIMInstance updatedInstance = 
        client.getInstance(PEGASUS_NAMESPACENAME_INTEROP,
        instObjectManager.getPath(),
        false, false, false, statPropertyList);
    prop_num = updatedInstance.findProperty(gathStatName);
    PEGASUS_TEST_ASSERT(prop_num != PEG_NOT_FOUND);
    CIMProperty p = updatedInstance.getProperty(prop_num);
    CIMValue v = p.getValue();
    Boolean rtn;
    v.get(rtn);
    //// Need to get it again
    cout << "Updated Status= " << ((rtn)? "true" : "false") << endl;
    return(rtn);
}
Example #24
0
bool setPropertyValue(CIMInstance& instance, const CIMName& propertyName,
    const CIMValue & value)
{
    unsigned int pos = instance.findProperty(propertyName);
    if(pos != PEG_NOT_FOUND)
    {
        instance.getProperty(pos).setValue(value);
        return true;
    }
    return false;
}
/////////////////////////////////////////////////////////////////////////////
// WMIInstanceProvider::getProperty
//
// ///////////////////////////////////////////////////////////////////////////
CIMValue WMIInstanceProvider::getProperty(
        const String& nameSpace,
        const String& userName,
        const String& password,
        const CIMObjectPath& instanceName,
        const String& propertyName)
{

    CIMInstance cimInstance;
    Array<CIMName> propertyNames;

    PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIInstanceProvider::getProperty()");

    setup(nameSpace,userName,password);

    if (!m_bInitialized)
    {
        throw CIMException(CIM_ERR_FAILED, "[getProperty] m_bInitialized");
    }

    CIMName propName = propertyName;

    propertyNames.append(propName);

    CIMPropertyList propertyList = CIMPropertyList(propertyNames);

    // get the relevant CIMInstance object
    cimInstance = getCIMInstance(nameSpace,
                                 userName,
                                 password,
                                 instanceName,
                                 propertyList);

    // now fetch the property
    Uint32 pos = cimInstance.findProperty(propName);

    if (PEG_NOT_FOUND == pos)
    {
        throw CIMException(CIM_ERR_NO_SUCH_PROPERTY,
            "[getProperty] findproperty");
    }

    CIMProperty property = cimInstance.getProperty(pos);

    // and return the value
    CIMValue value = property.getValue();

    PEG_METHOD_EXIT();

    return value;
}
Example #26
0
static CIMValue _getPropertyValue(const CIMInstance & cimInstance, const String & propertyName)
{
    CIMValue value;

    Uint32 pos = 0;

    // get ClassName property
    if((pos = cimInstance.findProperty(propertyName)) != PEG_NOT_FOUND)
    {
        value = cimInstance.getProperty(pos).getValue();
    }

    return(value);
}
Example #27
0
void _getKeyValue (
    const CIMInstance& namespaceInstance,
    CIMNamespaceName& childNamespaceName,
    Boolean& isRelativeName)

{
    //Validate key property

    Uint32 pos;
    CIMValue propertyValue;

    // [Key, MaxLen (256), Description (
    //       "A string that uniquely identifies the Namespace "
    //       "within the ObjectManager.") ]
    // string Name;

    pos = namespaceInstance.findProperty(NAMESPACE_PROPERTYNAME);
    if (pos == PEG_NOT_FOUND)
    {
        throw CIMPropertyNotFoundException
        (NAMESPACE_PROPERTYNAME.getString());
    }

    propertyValue = namespaceInstance.getProperty(pos).getValue();
    if (propertyValue.getType() != CIMTYPE_STRING)
    {
        //l10n
        //throw CIMInvalidParameterException("Invalid type for property: "
        //+ NAMESPACE_PROPERTYNAME.getString());
        throw CIMInvalidParameterException(MessageLoaderParms(
                                               "ControlProviders.NamespaceProvider.NamespaceProvider.INVALID_TYPE_FOR_PROPERTY",
                                               "Invalid type for property: $0",
                                               NAMESPACE_PROPERTYNAME.getString()));
    }

    String cnsName;
    propertyValue.get(cnsName);
    if (cnsName == String::EMPTY)
    {
        childNamespaceName = CIMNamespaceName();
    }
    else
    {
        childNamespaceName = CIMNamespaceName(cnsName);
    }

    isRelativeName = !(childNamespaceName.isNull());

}
Boolean UNIX_BlockStatisticsManifestCollection::loadInstance(const CIMInstance &instance)
{
	clearInstance();
	Uint32 propertyCount = instance.getPropertyCount();
	for(Uint32 i = 0; i < propertyCount; i++) {
		CIMConstProperty property = instance.getProperty(i);
			if (String::equal(property.getName().getString(), "InstanceID"))
			{
				String instanceIDValue;
				property.getValue().get(instanceIDValue);
				setInstanceID(instanceIDValue);
			}
			else if (String::equal(property.getName().getString(), "Caption"))
			{
				String captionValue;
				property.getValue().get(captionValue);
				setCaption(captionValue);
			}
			else if (String::equal(property.getName().getString(), "Description"))
			{
				String descriptionValue;
				property.getValue().get(descriptionValue);
				setDescription(descriptionValue);
			}
			else if (String::equal(property.getName().getString(), "ElementName"))
			{
				String elementNameValue;
				property.getValue().get(elementNameValue);
				setElementName(elementNameValue);
			}
			else if (String::equal(property.getName().getString(), "Generation"))
			{
				Uint64 generationValue;
				property.getValue().get(generationValue);
				setGeneration(generationValue);
			}
			else if (String::equal(property.getName().getString(), "IsDefault"))
			{
				Boolean isDefaultValue;
				property.getValue().get(isDefaultValue);
				setIsDefault(isDefaultValue);
			}
	}
	return true;
}
Example #29
0
void _testDeliveryRetryIntervalValue(
    CIMInstance& instance)
{
    CIMValue value =
        instance.getProperty(
            instance.findProperty(
                _PROPERTY_DELIVERYRETRYINTERVAL)).getValue();
    if (value.getType() == CIMTYPE_UINT64)
    {
        // CIM Schema 2.17 experimental class
        PEGASUS_TEST_ASSERT(
            Uint64(_PROPERTY_DELIVERYRETRYINTERVAL_VALUE) == value);
    }
    else
    {
        // CIM Schema 2.22 and up
        PEGASUS_TEST_ASSERT(_PROPERTY_DELIVERYRETRYINTERVAL_VALUE == value);
    }
}
Example #30
0
void testUserContextDesignated()
{
    try
    {
        if (!System::isSystemUser(alternateUserContext))
        {
            cout << " Skipping Designated UserContext test -- User \"" <<
                alternateUserContext <<
                "\" is not configured on this system." << endl;
            return;
        }

        CIMClient client;
        client.connectLocal();

        // Test a provider running in Designated user context

        CIMObjectPath instName =
            CIMObjectPath("TST_UserContextDesignated.Id=1");

        // ATTN: use of the localOnly flag is deprecated, but nor reliably
        // applied by the CIMOM. An explicit parameter is required for now.
        CIMInstance cimInstance = 
            client.getInstance(NAMESPACE, instName, false);

        String userContext;
        cimInstance.getProperty(cimInstance.findProperty("UserContext"))
            .getValue().get(userContext);

        if (verbose)
        {
            cout << "Designated test: UserContext = " << userContext << endl;
        }

        PEGASUS_TEST_ASSERT(userContext == String(alternateUserContext));
    }
    catch (Exception& e)
    {
        cerr << "Error: " << e.getMessage() << endl;
        exit(1);
    }
}