Exemple #1
0
/*
================================================================================
NAME              : _constructInstance
DESCRIPTION       : Constructs instance by adding its properties. The
                  : IP Interface argument has already been filled in
                  : with data from an existing IP Interface
ASSUMPTIONS       : None
PRE-CONDITIONS    :
POST-CONDITIONS   :
NOTES             :
PARAMETERS        : className, nameSpace, IP Interface
================================================================================
*/
CIMInstance IPPEpProvider::_constructInstance(
    const CIMName &className,
    const CIMNamespaceName &nameSpace,
    const IPInterface &_ipif)
{
#ifdef DEBUG
  cout << "IPPEpProvider::_constructInstance()" << endl;
#endif

  String s;
  Uint16 i16;
  CIMDateTime d;

  CIMInstance inst(className);

  // Set path

  inst.setPath(CIMObjectPath(String::EMPTY, // hostname
                             nameSpace,
                             CLASS_CIM_IP_PROTOCOL_ENDPOINT,
                             _constructKeyBindings(_ipif)));

// CIM_ManagedElement

//   string Caption
  if (_ipif.getCaption(s))
    inst.addProperty(CIMProperty(PROPERTY_CAPTION,s));

//   string Description
  if (_ipif.getDescription(s))
    inst.addProperty(CIMProperty(PROPERTY_DESCRIPTION,s));

// CIM_ManagedSystemElement

//   datetime InstallDate
  if (_ipif.getInstallDate(d))
    inst.addProperty(CIMProperty(PROPERTY_INSTALL_DATE,d));

//   string Name    // Overridden in CIM_ServiceAccessPoint

//   string Status
  if (_ipif.getStatus(s))
    inst.addProperty(CIMProperty(PROPERTY_STATUS,s));

// CIM_LogicalElement
//   ** No local properties added in this class **

// ======================================================
// The following properties are in CIM_ServiceAccessPoint
// ======================================================

  // The keys for this class are:
  // [ key ] string SystemCreationClassName
  // [ key ] string SystemName
  // [ key ] string CreationClassName
  // [ key ] string Name

  // Rather than rebuilding the key properties, we will reuse
  // the values that were inserted for us in the ObjectPath,
  // trusting that this was done correctly

  // Get the keys
  Array<CIMKeyBinding> key = inst.getPath().getKeyBindings();
  // loop through keys, inserting them as properties
  // luckily, all keys for this class are strings, so no
  // need to check key type
  for (Uint32 i=0; i<key.size(); i++)
  {
    // add a property created from the name and value
    inst.addProperty(CIMProperty(key[i].getName(),key[i].getValue()));
  }

// CIM_ProtocolEndpoint

//   string NameFormat
  if (_ipif.getNameFormat(s))
    inst.addProperty(CIMProperty(PROPERTY_NAME_FORMAT,s));

//   uint16 ProtocolType
  if (_ipif.getProtocolType(i16))
    inst.addProperty(CIMProperty(PROPERTY_PROTOCOL_TYPE,i16));

//   string OtherTypeDescription
  if (_ipif.getOtherTypeDescription(s))
  {
    // if an empty string was returned, the value must be set to NULL
    // with type string, not an array
    if (String::equal(s,String::EMPTY))
    {
      inst.addProperty(CIMProperty(PROPERTY_OTHER_TYPE_DESCRIPTION,
                                   CIMValue(CIMTYPE_STRING, false)));
    }
    else
    {
      inst.addProperty(CIMProperty(PROPERTY_OTHER_TYPE_DESCRIPTION,s));
    }
  }

// CIM_IPProtocolEndpoint

//   string Address
  if (_ipif.getAddress(s))
    inst.addProperty(CIMProperty(PROPERTY_ADDRESS,s));

//   string SubnetMask
  if (_ipif.getSubnetMask(s))
    inst.addProperty(CIMProperty(PROPERTY_SUBNET_MASK,s));

//   uint16 AddressType
  if (_ipif.getAddressType(i16))
    inst.addProperty(CIMProperty(PROPERTY_ADDRESS_TYPE,i16));

//   uint16 IPVersionSupport
  if (_ipif.getIPVersionSupport(i16))
    inst.addProperty(CIMProperty(PROPERTY_IP_VERSION_SUPPORT,i16));

#ifdef DEBUG
  cout << "IPPEpProvider::_constructInstance() -- done" << endl;
#endif

  return inst;
}