#include <string.h>
#include <stdlib.h>
#include <sstream>
-#include "PnfRegistration.hpp"
+#include "PnfRegistrationEvent.hpp"
#include "JsonHelper.hpp"
#include "VesUtils.hpp"
/* Default constructor*/
-PnfRegistration::PnfRegistration()
+PnfRegistrationEvent::PnfRegistrationEvent()
+ : VesEvent(VesEventType::PNF_REGISTRATION)
{
- this->mVesEventType = VesEventType::PNF_REGISTRATION;
}
/* Default Destructor*/
-PnfRegistration::~PnfRegistration()
+PnfRegistrationEvent::~PnfRegistrationEvent()
{
}
*
* ****************************************************************/
-string PnfRegistration::getCurrentDate()
+string PnfRegistrationEvent::getCurrentDate()
{
time_t t = time(0);
char dateStr[MAX_TIME_STR];
*
* ****************************************************************/
-string PnfRegistration::getNetconfMacAddr()
+string PnfRegistrationEvent::getNetconfMacAddr()
{
if(mNetconfMacAddr != "") {
return mNetconfMacAddr;
}
else {
- O1_LOG("\nO1 PnfRegistration : could not get Netconf Mac Address");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not get Netconf Mac Address");
return "";
}
}
*
* ****************************************************************/
-string PnfRegistration::getNetconfV4ServerIP()
+string PnfRegistrationEvent::getNetconfV4ServerIP()
{
if(mNetconfIpv4 != "") {
return mNetconfIpv4;
}
else {
- O1_LOG("\nO1 PnfRegistration : could not get Netconf IPv4 ip");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not get Netconf IPv4 ip");
return "";
}
}
*
* ****************************************************************/
-string PnfRegistration::getNetconfPort()
+string PnfRegistrationEvent::getNetconfPort()
{
if(mNetconfPort != "") {
return mNetconfPort;
}
else {
- O1_LOG("\nO1 PnfRegistration : Could not get Netconf Port number");
+ O1_LOG("\nO1 PnfRegistrationEvent : Could not get Netconf Port number");
return NETCONF_DEFAULT_PORT;
}
}
* ****************************************************************/
-string PnfRegistration::getUsername()
+string PnfRegistrationEvent::getUsername()
{
if(mNetconfUsername != "") {
return mNetconfUsername;
}
else {
- O1_LOG("\nO1 PnfRegistration : could not get Netconf username");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not get Netconf username");
return "";
}
}
*
* ****************************************************************/
-string PnfRegistration::getPassword()
+string PnfRegistrationEvent::getPassword()
{
if(mNetconfPassword != "") {
return mNetconfPassword;
}
else {
- O1_LOG("\nO1 PnfRegistration : could not get Netconf password");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not get Netconf password");
return "";
}
}
*
* ****************************************************************/
-string PnfRegistration::getNetconfV6ServerIP()
+string PnfRegistrationEvent::getNetconfV6ServerIP()
{
if(mNetconfIpv6 != "") {
return mNetconfIpv6;
}
else {
- O1_LOG("\nO1 PnfRegistration : could not get Netconf IPv6 ip");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not get Netconf IPv6 ip");
return "";
}
}
*
* ****************************************************************/
-string PnfRegistration::getSerialNumber()
+string PnfRegistrationEvent::getSerialNumber()
{
string serialNum;
serialNum.append(VENDER_NAME_VENDORB).append("-").append(UNIT_TYPE_7DEV);
*
* ****************************************************************/
-string PnfRegistration::getUnitFamily()
+string PnfRegistrationEvent::getUnitFamily()
{
string unitFamily;
unitFamily.append(VENDER_NAME_VENDORB).append("-").append(UNIT_TYPE_7DEV);
*
* @details
*
- * Function : preparePnfRegistrationFields
+ * Function : preparePnfRegistrationEventFields
*
* Functionality:
* - prepare PNF registration Fields in json format
*
* ****************************************************************/
-bool PnfRegistration::prepareEventFields()
+bool PnfRegistrationEvent::prepareEventFields(const Message* msg)
{
bool ret = true;
cJSON* pnfFields = this->mVesEventFields;
- if(!readConfigFile())
- {
- O1_LOG("\nO1 PnfRegistration : Failed to read config file");
- return false;
- }
+
+ getNetconfConfig();
+
if(JsonHelper::addNodeToObject(pnfFields, "pnfRegistrationFieldsVersion", \
PNF_REGISTRATION_VERSION_2_1) == 0) {
ret = false;
{
cJSON *addFields = JsonHelper::createNode();
if(addFields == 0) {
- O1_LOG("\nO1 PnfRegistration : could not create additional fields JSON object");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not create additional fields JSON object");
return false;
}
if(prepareAdditionalFields(addFields))
{
if(addFields == 0) {
- O1_LOG("\nO1 PnfRegistration : could not prepare additional fields cJSON object");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not prepare additional fields cJSON object");
JsonHelper::deleteNode(pnfFields);
return false;
}
if(JsonHelper::addJsonNodeToObject(pnfFields, "additionalFields", \
addFields) == 0) {
- O1_LOG("\nO1 PnfRegistration : could not add additional fields");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not add additional fields");
JsonHelper::deleteNode(pnfFields);
return false;
}
}
- O1_LOG("\nO1 PnfRegistration : Event fields prepared for PNF registration");
+ O1_LOG("\nO1 PnfRegistrationEvent : Event fields prepared for PNF registration");
}
return ret;
}
*
* ****************************************************************/
-bool PnfRegistration::prepareAdditionalFields(cJSON *addFields)
+bool PnfRegistrationEvent::prepareAdditionalFields(cJSON *addFields)
{
bool ret = true;
if(JsonHelper::addNodeToObject(addFields, "oamPort", getNetconfPort().c_str()) == 0) {
KEEPALIVE_DELAY_120) == 0) {
ret = false;
}
- O1_LOG("\nO1 PnfRegistration : Additional fields prepared for PNF registration");
+ O1_LOG("\nO1 PnfRegistrationEvent : Additional fields prepared for PNF registration");
return ret;
}
-
/*******************************************************************
*
* @brief Read json file
* false : failure
******************************************************************/
-bool PnfRegistration::readConfigFile()
+void PnfRegistrationEvent::getNetconfConfig()
{
- cJSON *json = JsonHelper::read(NETCONF_CONFIG);
- if(json == NULL) {
- O1_LOG("\nO1 PnfRegistration : Config file reading error is :%s", JsonHelper::getError());
- return false;
- }
- else {
- cJSON *rootNode = NULL;
- rootNode = JsonHelper::getNode(json, "NetconfServer");
- if(rootNode) {
- O1_LOG("\nO1 PnfRegistration : Reading NetconfServer config file");
- mNetconfMacAddr = JsonHelper::getValue(rootNode, "MacAddress");
- mNetconfIpv4 = JsonHelper::getValue(rootNode, "NetconfServerIpv4");
- mNetconfIpv6 = JsonHelper::getValue(rootNode, "NetconfServerIpv6");
- mNetconfPort = JsonHelper::getValue(rootNode, "NetconfPort");
- mNetconfUsername = JsonHelper::getValue(rootNode, "NetconfUsername");
- mNetconfPassword = JsonHelper::getValue(rootNode, "NetconfPassword");
- }
- else {
- O1_LOG("\nO1 PnfRegistration : smoConfig Object is not available in config file");
- return false;
- }
- }
- JsonHelper::deleteNode(json);
- return true;
+ mNetconfMacAddr = ConfigLoader::instance().getNetconfConfigFile().getNetconfMacAddr();
+ mNetconfIpv4 = ConfigLoader::instance().getNetconfConfigFile().getNetconfIpv4();
+ mNetconfIpv6 = ConfigLoader::instance().getNetconfConfigFile().getNetconfIpv6();
+ mNetconfPort = ConfigLoader::instance().getNetconfConfigFile().getNetconfPort();
+ mNetconfUsername =ConfigLoader::instance().getNetconfConfigFile().getNetconfUsername();
+ mNetconfPassword = ConfigLoader::instance().getNetconfConfigFile().getNetconfPassword();
}
+
/**********************************************************************
End of file
**********************************************************************/