Shell Script Output
#ifndef _nmsMoAtmVplEntry_CC_
#define _nmsMoAtmVplEntry_CC_
// File: nms_PnniProtocolServiceClasses.cc
//
// generated from: $Source: /projects7/nc867.15/007.Source/src/gen_nms/db_gen/RCS/oop_serviceclass_db_cc.sh,v $
//
// using base class ProtocolModule::PnniProtocol
//
// nms database access classes for - AtmVplEntry
//
#include <nmsMoAtmVplEntry.h>
#include <citr_EMS_SetGetDB.h>
#include <citr_EMS_Query.h>
#include <nmsATMLIP.h>
#include <dx_nms_mo_utils.h>
// *************************************************************************
// AtmVplEntry -> nmsMoAtmVplEntry
////////////////////////////////////////////////////////////////////////////
// constructor
nmsMoAtmVplEntry::nmsMoAtmVplEntry( UID this_entryID )
{
TRACEFUNC("%s:%d: nmsMoAtmVplEntry::nmsMoAtmVplEntry (%lld )\n",
__FILE__,__LINE__,
this_entryID);
init(); // do member initialisation
if( 0 != this_entryID )
{
// if we are given a uid, look for an existing db entry to initialise from
find( this_entryID );
}
} // nmsMoAtmVplEntry::nmsMoAtmVplEntry
////////////////////////////////////////////////////////////////////////////
// destructor
nmsMoAtmVplEntry::~nmsMoAtmVplEntry()
{
// member destructors are sufficient
} // nmsMoAtmVplEntry::~nmsMoAtmVplEntry
////////////////////////////////////////////////////////////////////////////
// populate the object with the current db data
ManagedObjectStatus
nmsMoAtmVplEntry::find( UID this_entryID )
{
TRACEFUNC("%s:%d: nmsMoAtmVplEntry::find (%lld )\n",
__FILE__,__LINE__,
this_entryID);
ManagedObjectStatus moStatus = mo_ok;
if( 0 != this_entryID )
{
if ((moStatus = ManagedObject::retrieve(this_entryID)) == mo_ok)
{
moStatus = retrieve(this_entryID);
}
if (moStatus != mo_ok)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::find did not retrieve rc %d \n",
__FILE__,__LINE__,
moStatus);
init();
}
}
return( moStatus);
} // nmsMoAtmVplEntry::find
////////////////////////////////////////////////////////////////////////////
// create a new nmsMoAtmVplEntry entry from a struct
ManagedObjectStatus
nmsMoAtmVplEntry::create(// each of the selection items
UID ATMLIP_uid,
const nmsMoAtmVplEntryDetails & details )
{
init(); // re-initialise members
// lookup db to check if row exists
ManagedObjectStatus moStatus = find( details.entryId );
if( m_uid != 0 )
{
// if we found an entry dont continue
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::create found a duplicate %lld\n",
__FILE__,__LINE__,
details.entryId);
sprintf( m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::create found a duplicate %lld\n",
__FILE__,__LINE__,
details.entryId);
return( mo_duplicate );
}
// intialise members from nmsMoAtmVplEntry struct and
// Set the uid of the parent item to the first selection item
m_Vpi = details.Vpi;
m_AdminStatus = details.AdminStatus;
m_OperStatus = details.OperStatus;
m_LastChange = details.LastChange;
m_ReceiveTrafficDescrIndex = details.ReceiveTrafficDescrIndex;
m_TransmitTrafficDescrIndex = details.TransmitTrafficDescrIndex;
m_CrossConnectIdentifier = details.CrossConnectIdentifier;
m_RowStatus = details.RowStatus;
m_CastType = details.CastType;
m_ConnKind = details.ConnKind;
m_ifIndex = details.ifIndex;
// only the first parent is used
m_parent = ATMLIP_uid;
// need to get the parent object
nmsATMLIP parent_object;
moStatus = parent_object.find(m_parent);
if (mo_ok != moStatus)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::create - could not find parent nmsATMLIP object %lld \n",
__FILE__,__LINE__,
m_parent);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::create - could not find parent nmsATMLIP object %lld \n",
__FILE__,__LINE__,
m_parent);
return(moStatus);
}
// now need to find the owner
m_owner = parent_object.getOwner();
// need to create the object in the EMS
// We may also change some member attributes
// in the call to AssignSnmpIndexAtts
// which is called as part of this
// DxNms_EmsCreatenmsMoAtmVplEntry
// Whilst it may be nice to have a separate method
// call to explicitly change the member attribute,
// It is expected that most of the time the attributes
// will only be changed on creation
// and putting the change in AssignSnmpIndexAtts
// localises the code changes.
moStatus = DxNms_EmsCreatenmsMoAtmVplEntry( ATMLIP_uid );
if (moStatus != mo_ok)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::create DxNms_EmsCreatenmsMoAtmVplEntry failed \n",
__FILE__,__LINE__);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::create DxNms_EmsCreatenmsMoAtmVplEntry failed \n",
__FILE__,__LINE__);
return moStatus;
}
// Update the verified fields
m_LastUpdated = MoTimeNow();
m_LastVerified = MoTimeNow();
m_LastVerAttempt = MoTimeNow();
// Create a row in the ManagedObject table.
moStatus = ManagedObject::create();
if (moStatus != mo_ok)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::create mo create failed \n",
__FILE__,__LINE__);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::create mo create failed \n",
__FILE__,__LINE__);
return moStatus;
}
// Insert a row into the database.
moStatus = db_update();
if (moStatus == mo_ok)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::create success \n",
__FILE__,__LINE__);
return mo_ok;
}
// If we get to here, the MO insert succeeded, but the insert
// failed, so we need to remove the MO row, and return an error.
ManagedObject::remove(m_uid);
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::create insert failed \n",
__FILE__,__LINE__);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::create insert failed \n",
__FILE__,__LINE__);
return mo_error;
} // nmsMoAtmVplEntry::create
////////////////////////////////////////////////////////////////////////////
// get the details of this object
ManagedObjectStatus
nmsMoAtmVplEntry::read( nmsMoAtmVplEntryDetails *details )
{
ManagedObjectStatus moStatus = mo_ok;
if ( (NULL == details ))
{
TRACEFUNC("%s:%d: nmsMoAtmVplEntry::read (Null Param)\n",
__FILE__,__LINE__);
return(mo_error);
}
TRACEFUNC("%s:%d: nmsMoAtmVplEntry::read (%p )\n",
__FILE__,__LINE__,
details);
if( 0 == m_uid )
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::read row not found \n",
__FILE__,__LINE__);
sprintf( m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::read row not found \n",
__FILE__,__LINE__);
return( mo_notfound );
}
details->entryId = m_uid;
details->pad = const_cast<const char *>("");
// should go to the ems to get updated values
moStatus=DxNms_EmsReadnmsMoAtmVplEntry();
if (mo_ok != moStatus)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::read could not read values from ems agent \n",
__FILE__,__LINE__);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::read could not read values from ems agent \n",
__FILE__,__LINE__);
return(moStatus);
}
// should update the values in the DB
db_update();
// now assign the latest values
details->Vpi = m_Vpi;
details->AdminStatus = m_AdminStatus;
details->OperStatus = m_OperStatus;
details->LastChange = m_LastChange;
details->ReceiveTrafficDescrIndex = m_ReceiveTrafficDescrIndex;
details->TransmitTrafficDescrIndex = m_TransmitTrafficDescrIndex;
details->CrossConnectIdentifier = m_CrossConnectIdentifier;
details->RowStatus = m_RowStatus;
details->CastType = m_CastType;
details->ConnKind = m_ConnKind;
details->ifIndex = m_ifIndex;
details->LastUpdated = m_LastUpdated;
details->LastVerified = m_LastVerified;
details->LastVerAttempt = m_LastVerAttempt;
return(mo_ok);
} // nmsMoAtmVplEntry::read
///////////////////////////////////////////////////////////////////
// member initialisation
void
nmsMoAtmVplEntry::init()
{
ManagedObject::init();
// Set the type and table name for use with the ManagedObject base class.
strcpy (m_tableName, "dx_nms_AtmVplEntry");
m_type = NetworkManagement::AtmVplEntry;
strcpy (m_name, "AtmVplEntry");
// initialise data members
m_Vpi = 0;
m_AdminStatus = static_cast<ProtocolModules::PnniProtocol::AdminStatus_e>( 0 );
m_OperStatus = static_cast<ProtocolModules::PnniProtocol::OperStatus_e>( 0 );
m_LastChange = 0;
m_ReceiveTrafficDescrIndex = 0;
m_TransmitTrafficDescrIndex = 0;
m_CrossConnectIdentifier = 0;
m_RowStatus = static_cast<ProtocolModules::PnniProtocol::RowStatus_e>( 0 );
m_CastType = static_cast<ProtocolModules::PnniProtocol::CastType_e>( 0 );
m_ConnKind = static_cast<ProtocolModules::PnniProtocol::ConnKind_e>( 0 );
m_ifIndex = 0;
m_LastUpdated = 0;
m_LastVerified = 0;
m_LastVerAttempt = 0;
} // nmsMoAtmVplEntry::init
///////////////////////////////////////////////////////////////////
// get the members from the database
ManagedObjectStatus
nmsMoAtmVplEntry::retrieve( UID this_entryID )
{
Dx_nms_AtmVplEntry_t inRec;
Dx_nms_AtmVplEntry_t outRec;
// initialise db structures
memset( &inRec, 0, sizeof(inRec) );
memset( &outRec, 0, sizeof(outRec) );
inRec.dx_nms_AtmVplUID = this_entryID;
// do actual db lookup
nmsLock dblock( DB_LOCK, TRUE );
int dbResult = Dx_nms_AtmVplEntryGetFromCDB(NMS_DB_CONTEXT, &inRec, &outRec );
dblock.unlock();
// handle result
if( MOCDB_SUCCESS == dbResult )
{
// initialise class members (m_uid is assigned by the calling method)
m_Vpi = outRec.dx_nms_AtmVplVpi;
m_AdminStatus =
static_cast<ProtocolModules::PnniProtocol::AdminStatus_e>(
outRec.dx_nms_AtmVplAdminStatus);
m_OperStatus =
static_cast<ProtocolModules::PnniProtocol::OperStatus_e>(
outRec.dx_nms_AtmVplOperStatus);
m_LastChange = outRec.dx_nms_AtmVplLastChange;
m_ReceiveTrafficDescrIndex = outRec.dx_nms_AtmVplReceiveTrafficDescrIndex;
m_TransmitTrafficDescrIndex = outRec.dx_nms_AtmVplTransmitTrafficDescrIndex;
m_CrossConnectIdentifier = outRec.dx_nms_AtmVplCrossConnectIdentifier;
m_RowStatus =
static_cast<ProtocolModules::PnniProtocol::RowStatus_e>(
outRec.dx_nms_AtmVplRowStatus);
m_CastType =
static_cast<ProtocolModules::PnniProtocol::CastType_e>(
outRec.dx_nms_AtmVplCastType);
m_ConnKind =
static_cast<ProtocolModules::PnniProtocol::ConnKind_e>(
outRec.dx_nms_AtmVplConnKind);
m_ifIndex = outRec.dx_nms_AtmVplifIndex;
m_LastUpdated = outRec.dx_nms_AtmVplLastUpdated;
m_LastVerified = outRec.dx_nms_AtmVplLastVerified;
m_LastVerAttempt = outRec.dx_nms_AtmVplLastVerAttempt;
return( mo_ok );
}
if( MOCDB_NO_SUCH_INSTANCE == dbResult )
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::retrieve did not find entry \n",
__FILE__,__LINE__);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::retrieve did not find entry \n",
__FILE__,__LINE__);
return( mo_notfound );
}
return( mo_error );
} // nmsMoAtmVplEntry::retrieve
///////////////////////////////////////////////////////////////////
// update the database from the members.
ManagedObjectStatus
nmsMoAtmVplEntry::db_update()
{
TRACEFUNC("%s:%d: nmsMoAtmVplEntry::db_update ()\n",
__FILE__,__LINE__);
Dx_nms_AtmVplEntry_t inRec;
// initialise db structure
memset( &inRec, 0, sizeof(inRec) );
// initialise db structure members
inRec.dx_nms_AtmVplUID = m_uid;
inRec.dx_nms_AtmVplVpi = m_Vpi;
inRec.dx_nms_AtmVplAdminStatus = m_AdminStatus;
inRec.dx_nms_AtmVplOperStatus = m_OperStatus;
inRec.dx_nms_AtmVplLastChange = m_LastChange;
inRec.dx_nms_AtmVplReceiveTrafficDescrIndex = m_ReceiveTrafficDescrIndex;
inRec.dx_nms_AtmVplTransmitTrafficDescrIndex = m_TransmitTrafficDescrIndex;
inRec.dx_nms_AtmVplCrossConnectIdentifier = m_CrossConnectIdentifier;
inRec.dx_nms_AtmVplRowStatus = m_RowStatus;
inRec.dx_nms_AtmVplCastType = m_CastType;
inRec.dx_nms_AtmVplConnKind = m_ConnKind;
inRec.dx_nms_AtmVplifIndex = m_ifIndex;
inRec.dx_nms_AtmVplLastUpdated = m_LastUpdated;
inRec.dx_nms_AtmVplLastVerified = m_LastVerified;
inRec.dx_nms_AtmVplLastVerAttempt = m_LastVerAttempt;
// now do db update
nmsLock dblock( DB_LOCK, TRUE );
int dbResult = Dx_nms_AtmVplEntryUpdateToCDB(NMS_DB_CONTEXT, &inRec, TRUE );
dblock.unlock();
if( MOCDB_SUCCESS == dbResult )
{
return( mo_ok );
}
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::db_update could not update database \n",
__FILE__,__LINE__);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::db_update could not update database \n",
__FILE__,__LINE__);
return( mo_error );
} // nmsMoAtmVplEntry::db_update
//////////////////////////////////////////////////////////////
//
//
//
/////////////////////////////////////////////////////////////
ManagedObjectStatus
nmsMoAtmVplEntry::remove (UID uid)
{
TRACEFUNC("%s:%d: nmsMoAtmVplEntry::remove (uid %lld )\n",
__FILE__, __LINE__,
uid);
if (uid == 0)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::remove uid is 0 \n",
__FILE__,__LINE__);
return mo_error;
}
ManagedObjectStatus moStatus = mo_ok;
// we need to find this one
moStatus = find(uid);
if (mo_ok != moStatus)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::remove could not find %lld \n",
__FILE__,__LINE__,
uid);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::remove could not find %lldS \n",
__FILE__,__LINE__,
uid);
return(moStatus);
}
// First - remove from the EMS
moStatus = DxNms_EmsRemovenmsMoAtmVplEntry();
if (mo_ok != moStatus)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::remove could not remove from the EMS \n",
__FILE__,__LINE__);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::remove could not remove from the EMS \n",
__FILE__,__LINE__);
return(moStatus);
}
// now remove from the database
Dx_nms_AtmVplEntry_t inRec;
memset (&inRec, 0, sizeof(inRec));
inRec.dx_nms_AtmVplUID = uid;
nmsLock dblock(DB_LOCK, TRUE);
int dbResult = Dx_nms_AtmVplEntryDeleteFromCDB(NMS_DB_CONTEXT,
&inRec);
dblock.unlock();
if ( dbResult == MOCDB_SUCCESS )
{
moStatus = ManagedObject::remove(uid);
}
if ( (MOCDB_SUCCESS == dbResult )
&& (mo_ok == moStatus))
{
init();
return mo_ok;
}
if ( dbResult == MOCDB_NO_SUCH_INSTANCE )
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::remove did not find the entry \n",
__FILE__,__LINE__);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::remove did not find the entry \n",
__FILE__,__LINE__);
return mo_notfound;
}
return mo_error;
}
////////////////////////////////////////////////////////////////////////////
// set the details of this object
ManagedObjectStatus
nmsMoAtmVplEntry::write(const nmsMoAtmVplEntryDetails &details )
{
ManagedObjectStatus moStatus = mo_ok;
TRACEFUNC("%s:%d: nmsMoAtmVplEntry::write ()\n",
__FILE__,__LINE__);
// the current attributes are loaded from the impl call
// prior to this call
if (m_uid == 0)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::write uid is 0 \n",
__FILE__,__LINE__);
return mo_error;
}
// now copy over the RW attributes in the details
m_Vpi = details.Vpi;
m_AdminStatus = details.AdminStatus;
m_ReceiveTrafficDescrIndex = details.ReceiveTrafficDescrIndex;
m_TransmitTrafficDescrIndex = details.TransmitTrafficDescrIndex;
m_RowStatus = details.RowStatus;
m_CastType = details.CastType;
m_ConnKind = details.ConnKind;
m_ifIndex = details.ifIndex;
// do the snmp set
moStatus = DxNms_EmsSetnmsMoAtmVplEntry();
if (moStatus != mo_ok)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::write DxNms_EmsSetnmsMoAtmVplEntry failed \n",
__FILE__,__LINE__);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::write DxNms_EmsSetnmsMoAtmVplEntry failed \n",
__FILE__,__LINE__);
return moStatus;
}
m_LastUpdated = MoTimeNow();
m_LastVerified = MoTimeNow();
m_LastVerAttempt = MoTimeNow();
// Insert a row into the database.
moStatus = db_update();
if (moStatus == mo_ok)
{
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::write success \n",
__FILE__,__LINE__);
return mo_ok;
}
// If we get to here, the MO insert succeeded, but the insert
// failed, so we need to remove the MO row, and return an error.
TRACEFLOW("%s:%d: nmsMoAtmVplEntry::write db insert failed \n",
__FILE__,__LINE__);
sprintf(m_errorMessage,
"%s:%d: nmsMoAtmVplEntry::write db insert failed \n",
__FILE__,__LINE__);
return mo_error;
} // nmsMoAtmVplEntry::write
ManagedObjectSummary *
nmsMoAtmVplEntry::get ()
{
const char * METHOD = "nmsMoAtmVplEntry::get";
TRACEFUNC("%s:%d: %s()\n",
__FILE__,__LINE__, METHOD);
m_summary.name = CORBA::string_dup(m_name);
m_summary.type = m_type;
m_summary.id = m_uid;
m_summary.parent = m_parent;
m_summary.vpn = m_vpn;
m_summary.device = m_owner;
NameValueList list( 11);
list.length( 11);
m_summary.settings = list;
#ifndef MAX_BUF
#define MAX_BUF 128
#endif
char tmp[MAX_BUF];
sprintf(tmp, "%ld", m_Vpi);
m_summary.settings[0].name = CORBA::string_dup("Vpi");
m_summary.settings[0].value =
CORBA::string_dup(tmp);
sprintf(tmp, "%ld", m_AdminStatus);
m_summary.settings[1].name = CORBA::string_dup("AdminStatus");
m_summary.settings[1].value =
CORBA::string_dup(tmp);
sprintf(tmp, "%ld", m_OperStatus);
m_summary.settings[2].name = CORBA::string_dup("OperStatus");
m_summary.settings[2].value =
CORBA::string_dup(tmp);
sprintf(tmp, "%ld", m_LastChange);
m_summary.settings[3].name = CORBA::string_dup("LastChange");
m_summary.settings[3].value =
CORBA::string_dup(tmp);
sprintf(tmp, "%ld", m_ReceiveTrafficDescrIndex);
m_summary.settings[4].name = CORBA::string_dup("ReceiveTrafficDescrIndex");
m_summary.settings[4].value =
CORBA::string_dup(tmp);
sprintf(tmp, "%ld", m_TransmitTrafficDescrIndex);
m_summary.settings[5].name = CORBA::string_dup("TransmitTrafficDescrIndex");
m_summary.settings[5].value =
CORBA::string_dup(tmp);
sprintf(tmp, "%ld", m_CrossConnectIdentifier);
m_summary.settings[6].name = CORBA::string_dup("CrossConnectIdentifier");
m_summary.settings[6].value =
CORBA::string_dup(tmp);
sprintf(tmp, "%ld", m_RowStatus);
m_summary.settings[7].name = CORBA::string_dup("RowStatus");
m_summary.settings[7].value =
CORBA::string_dup(tmp);
sprintf(tmp, "%ld", m_CastType);
m_summary.settings[8].name = CORBA::string_dup("CastType");
m_summary.settings[8].value =
CORBA::string_dup(tmp);
sprintf(tmp, "%ld", m_ConnKind);
m_summary.settings[9].name = CORBA::string_dup("ConnKind");
m_summary.settings[9].value =
CORBA::string_dup(tmp);
sprintf(tmp, "%ld", m_ifIndex);
m_summary.settings[10].name = CORBA::string_dup("ifIndex");
m_summary.settings[10].value =
CORBA::string_dup(tmp);
return &m_summary;
}
// end nmsMoAtmVplEntry
// *************************************************************************
#endif // _nmsMoAtmVplEntry_CC_