Exemple #1
0
	void test1() {
		AlarmConfig alarmconfig;
		Oam oamapi;

		for( int alarmID = 1 ; alarmID < MAX_ALARM_ID; alarmID++)
		{
			oamapi.getAlarmConfig(alarmID, alarmconfig);

			Svalue = alarmconfig.BriefDesc;
			CPPUNIT_ASSERT(!Svalue.empty());

			Svalue = alarmconfig.DetailedDesc;
			CPPUNIT_ASSERT(!Svalue.empty());
	
			Svalue = alarmconfig.Severity;
			CPPUNIT_ASSERT(!Svalue.empty());
	
			Ivalue = alarmconfig.Threshold;
			CPPUNIT_ASSERT(Ivalue != -1);
	
			Ivalue = alarmconfig.Occurrences;
			CPPUNIT_ASSERT(Ivalue != -1);
	
			Svalue = alarmconfig.LastIssueTime;
			CPPUNIT_ASSERT(!Svalue.empty());
			}
 	};
Exemple #2
0
	void test2() {
		SystemModuleTypeConfig systemmoduletypeconfig;

		Oam oamapi;
		oamapi.getSystemConfig(systemmoduletypeconfig);

		for( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++)
		{
			if( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() )
				// end of list
				break;

			Svalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleType;
			CPPUNIT_ASSERT(!Svalue.empty());

			Svalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleDesc;
			CPPUNIT_ASSERT(!Svalue.empty());

			Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount;
			CPPUNIT_ASSERT(Ivalue != -1);

			Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUCriticalThreshold;
			CPPUNIT_ASSERT(Ivalue != -1);

			Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMajorThreshold;
			CPPUNIT_ASSERT(Ivalue != -1);

			Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMinorThreshold;
			CPPUNIT_ASSERT(Ivalue != -1);

			Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMinorClearThreshold;
			CPPUNIT_ASSERT(Ivalue != -1);
		}
	};
Exemple #3
0
int main(int argc, char *argv[])
{
	Oam oam;

	//get mysql user password
	string mysqlpw = oam::UnassignedName;
	try {
		mysqlpw = oam.getMySQLPassword();
	}
	catch (...)
	{
		cout << oam::UnassignedName << endl;
		exit (1);
	}

	if ( mysqlpw == oam::UnassignedName ) {
		cout << oam::UnassignedName << endl;
		exit (1);
	}

	cout << mysqlpw << endl;

	try {
		oam.setSystemConfig("MySQLPasswordConfig", "y");
	}
	catch(...) {}

	exit (0);

}
Exemple #4
0
void mysqlSetup() 
{
	Oam oam;
	string cmd;
	cmd = installDir + "/bin/post-mysqld-install --installdir=" + installDir;
	int rtnCode = system(cmd.c_str());
	if (WEXITSTATUS(rtnCode) != 0)
		cout << "Error running post-mysqld-install" << endl;

	//check for password set
	//start in the same way that mysqld will be started normally.
	//start in the same way that mysqld will be started normally.
	try {
		oam.actionMysqlCalpont(MYSQL_START);
	}
	catch(...)
	{}
	sleep(2);
	
	string prompt = " *** Enter MySQL password > ";
	for (;;)
	{
		// check if mysql is supported and get info
		string calpontMysql = installDir + "/mysql/bin/mysql --defaults-file=" + installDir + "/mysql/my.cnf -u root ";
		string cmd = calpontMysql + pwprompt + " -e 'status' > /tmp/idbmysql.log 2>&1";
		system(cmd.c_str());

		if (oam.checkLogStatus("/tmp/idbmysql.log", "ERROR 1045") ) {
			mysqlpw = getpass(prompt.c_str());
			mysqlpw = "'" + mysqlpw + "'";
			pwprompt = "--password="******" *** Password incorrect, please re-enter MySQL password > ";
		}
		else
		{
			if (!oam.checkLogStatus("/tmp/idbmysql.log", "InfiniDB") ) {
				cout << endl << "ERROR: MySQL runtime error, exit..." << endl << endl;
				system("cat /tmp/idbmysql.log");
				exit (1);
			}
			else
			{
				try {
					oam.actionMysqlCalpont(MYSQL_STOP);
				}
				catch(...)
				{}
				unlink("/tmp/idbmysql.log");
				break;
			}
		}
	}
	
	cmd = installDir + "/bin/post-mysql-install " + pwprompt + " --installdir=" + installDir;
	rtnCode = system(cmd.c_str());
	if (WEXITSTATUS(rtnCode) != 0)
		cout << "Error running post-mysql-install" << endl;

	return;
}
Exemple #5
0
	void test2() {
		Oam oamapi;
		oamapi.setAlarmConfig(CPU_USAGE_MED, "Threshold", 20);

		oamapi.getAlarmConfig(CPU_USAGE_MED, "Threshold", Ivalue);

		CPPUNIT_ASSERT(Ivalue == 20);
	};
Exemple #6
0
	void test4() {
		Oam oamapi;
		oamapi.setProcessConfig("ProcessManager", "dm1", "BootLaunch", 10);

		oamapi.getProcessConfig("ProcessManager", "dm1", "BootLaunch", Ivalue);

		CPPUNIT_ASSERT(Ivalue == 10);
	};
Exemple #7
0
	void test10() {
		Oam oamapi;
		oamapi.setSystemConfig("ModuleCPUMajorThreshold1", 7500);

		oamapi.getSystemConfig("ModuleCPUMajorThreshold1", Ivalue);

		CPPUNIT_ASSERT(Ivalue == 7500);
	};
Exemple #8
0
	void test8() {
		Oam oamapi;
		oamapi.setSystemConfig("ModuleHeartbeatPeriod", 5);

		oamapi.getSystemConfig("ModuleHeartbeatPeriod", Ivalue);

		CPPUNIT_ASSERT(Ivalue == 5);
	};
Exemple #9
0
	void test5() {
		Oam oamapi;
		oamapi.setSystemConfig("SystemVersion", "V2.0.2.3");

		oamapi.getSystemConfig("SystemVersion", Svalue);

		CPPUNIT_ASSERT(Svalue == "V2.0.2.3");
	};
Exemple #10
0
/*	void test3() {
		ModuleConfig moduleconfig;
		const string Modulename = "dm1";

		Oam oamapi;
		oamapi.getSystemConfig(Modulename, moduleconfig);

		Svalue = moduleconfig.ModuleName;
		CPPUNIT_ASSERT(!Svalue.empty());

	};
*/
	void test4() {
		ModuleConfig moduleconfig;

		Oam oamapi;
		oamapi.getSystemConfig(moduleconfig);

		Svalue = moduleconfig.ModuleName;
		CPPUNIT_ASSERT(!Svalue.empty());

	};
/**
 * Constructors/Destructors
 */
PredicateOperator::PredicateOperator()
{
    Oam oam;
    // get and set locale language
    string systemLang = "C";

    try
    {
        oam.getSystemConfig("SystemLang", systemLang);
    }
    catch (...)
    {}

    if ( systemLang != "en_US.UTF-8" &&
            systemLang.find("UTF") != string::npos )
        futf8 = true;
}
Exemple #12
0
/******************************************************************************************
* @brief	sendAlarm
*
* purpose:	send a trap and log the process information
*
******************************************************************************************/
void ServerMonitor::sendAlarm(string alarmItem, ALARMS alarmID, int action, float sensorValue)
{
	ServerMonitor serverMonitor;
	Oam oam;

	//Log this event 
	LoggingID lid(SERVER_MONITOR_LOG_ID);
	MessageLog ml(lid);
	Message msg;
	Message::Args args;
	args.add(alarmItem);
	args.add(", sensor value out-of-range: ");
	args.add(sensorValue);

	// get current server name
	string moduleName;
	oamModuleInfo_t st;
	try {
		st = oam.getModuleInfo();
		moduleName = boost::get<0>(st);
	}
	catch (...) {
		moduleName = "Unknown Server";
	}

	// check if there is an active alarm above the reporting theshold 
	// that needs to be cleared
	serverMonitor.checkAlarm(alarmItem, alarmID);

	// check if Alarm is already active, don't resend
	if ( !( oam.checkActiveAlarm(alarmID, moduleName, alarmItem)) ) {

		SNMPManager alarmMgr;
		// send alarm
		alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, action);

		args.add(", Alarm set: ");
		args.add(alarmID);
	}

	// output log
	msg.format(args);
	ml.logWarningMessage(msg);

	return;
}
Exemple #13
0
	void test1() {
		SystemConfig systemconfig;

		Oam oamapi;
		oamapi.getSystemConfig(systemconfig);

		Ivalue = systemconfig.ModuleHeartbeatPeriod;
		CPPUNIT_ASSERT(Ivalue != -1);

		Ivalue = systemconfig.ModuleHeartbeatCount;
		CPPUNIT_ASSERT(Ivalue != -1);

//		Ivalue = systemconfig.ProcessHeartbeatPeriod;
//		CPPUNIT_ASSERT(Ivalue != -2);

		Svalue = systemconfig.NMSIPAddr;
		CPPUNIT_ASSERT(!Svalue.empty());
	};
Exemple #14
0
	void test1() {
		SystemProcessConfig systemprocessconfig;

		Oam oamapi;
		oamapi.getProcessConfig(systemprocessconfig);

		for( unsigned int i = 0 ; i < systemprocessconfig.processconfig.size(); i++)
		{
			Svalue = systemprocessconfig.processconfig[i].ProcessName;
			CPPUNIT_ASSERT(!Svalue.empty());
	
			Svalue = systemprocessconfig.processconfig[i].ModuleType;
			CPPUNIT_ASSERT(!Svalue.empty());
	
			Svalue = systemprocessconfig.processconfig[i].ProcessLocation;
			CPPUNIT_ASSERT(!Svalue.empty());

			for( int j = 0 ; j < oam::MAX_ARGUMENTS; j++) {
				if (systemprocessconfig.processconfig[i].ProcessArgs[j].empty())
					break;
				Svalue = systemprocessconfig.processconfig[i].ProcessArgs[j];
				CPPUNIT_ASSERT(!Svalue.empty());
			}

			Ivalue = systemprocessconfig.processconfig[i].BootLaunch;
			CPPUNIT_ASSERT(Ivalue != -1);
	
			Ivalue = systemprocessconfig.processconfig[i].LaunchID;
			CPPUNIT_ASSERT(Ivalue != -1);
	
			for( int j = 0 ; j < MAX_DEPENDANCY; j++) {
				if (systemprocessconfig.processconfig[i].DepProcessName[j].empty())
					break;
				Svalue = systemprocessconfig.processconfig[i].DepProcessName[j];
				CPPUNIT_ASSERT(!Svalue.empty());
				Svalue = systemprocessconfig.processconfig[i].DepModuleName[j];
				CPPUNIT_ASSERT(!Svalue.empty());
			}
		}
	};
Exemple #15
0
	void test2() {
		ProcessConfig processconfig;

		Oam oamapi;
		oamapi.getProcessConfig("ProcessManager", "dm1", processconfig);
		
		Svalue = processconfig.ProcessName;
		CPPUNIT_ASSERT(!Svalue.empty());

		Svalue = processconfig.ModuleType;
		CPPUNIT_ASSERT(!Svalue.empty());

		Svalue = processconfig.ProcessLocation;
		CPPUNIT_ASSERT(!Svalue.empty());

		for( int j = 0 ; j < oam::MAX_ARGUMENTS; j++) {
			if (processconfig.ProcessArgs[j].empty())
				break;
			Svalue = processconfig.ProcessArgs[j];
			CPPUNIT_ASSERT(!Svalue.empty());
		}

		Ivalue = processconfig.BootLaunch;
		CPPUNIT_ASSERT(Ivalue != -1);

		Ivalue = processconfig.LaunchID;
		CPPUNIT_ASSERT(Ivalue != -1);

		for( int j = 0 ; j < MAX_DEPENDANCY; j++) {
			if (processconfig.DepProcessName[j].empty())
				break;
			Svalue = processconfig.DepProcessName[j];
			CPPUNIT_ASSERT(!Svalue.empty());
			Svalue = processconfig.DepModuleName[j];
			CPPUNIT_ASSERT(!Svalue.empty());
		}
	};
Exemple #16
0
/******************************************************************************************
* @brief	checkDiskAlarm
*
* purpose:	check to see if an alarm(s) is set on Disk and clear if so
*
******************************************************************************************/
void ServerMonitor::checkDiskAlarm(string alarmItem, ALARMS alarmID)
{
	Oam oam;
	ServerMonitor serverMonitor;

	// get current server name
	string serverName;
	oamModuleInfo_t st;
	try {
		st = oam.getModuleInfo();
		serverName = boost::get<0>(st);
	}
	catch (...) {
		serverName = "Unknown Server";
	}

	switch (alarmID) {
		case NO_ALARM: 	// clear all alarms set if any found
			if ( oam.checkActiveAlarm(DISK_USAGE_HIGH, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, DISK_USAGE_HIGH);
			if ( oam.checkActiveAlarm(DISK_USAGE_MED, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, DISK_USAGE_MED);
			if ( oam.checkActiveAlarm(DISK_USAGE_LOW, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, DISK_USAGE_LOW);
			break;
		case DISK_USAGE_LOW: 	// clear high and medium alarms set if any found
			if ( oam.checkActiveAlarm(DISK_USAGE_HIGH, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, DISK_USAGE_HIGH);
			if ( oam.checkActiveAlarm(DISK_USAGE_MED, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, DISK_USAGE_MED);
			break;
		case DISK_USAGE_MED: 	// clear high alarms set if any found
			if ( oam.checkActiveAlarm(DISK_USAGE_HIGH, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, DISK_USAGE_HIGH);
			break;
		default:			// none to clear
			break;
		} // end of switch
	return;
}
/******************************************************************************************
* @brief	sendMsgShutdownServer
*
* purpose:	send a Message to Shutdown server
*
******************************************************************************************/
void sendMsgShutdownServer()
{
	Oam oam;

	//Log this event 
	LoggingID lid;
	MessageLog ml(lid);
	Message msg;
	Message::Args args;
	args.add("Fatal Hardware Alarm detected, Server being shutdown");
	msg.format(args);
	ml.logCriticalMessage(msg);

	string serverName;
	oamServerInfo_t st;
	try {
		st = oam.getServerInfo();
		serverName = boost::get<0>(st);
	}
	catch (...) {
		// o well, let's take out own action
		if( IPMI_SUPPORT == 0)
			system("init 0");
	}

	try
	{
		oam.shutdownServer(serverName, FORCEFUL, ACK_NO);
	}
	catch (exception& e)
	{
		// o well, let's take out own action
		if( IPMI_SUPPORT == 0)
			system("init 0");
	}
}
/******************************************************************************************
* @brief	checkAlarm
*
* purpose:	check to see if an alarm(s) is set on device and clear if so
*
******************************************************************************************/
void checkAlarm(string alarmItem, ALARMS alarmID)
{
	Oam oam;

	// get current server name
	string serverName;
	oamServerInfo_t st;
	try {
		st = oam.getServerInfo();
		serverName = boost::get<0>(st);
	}
	catch (...) {
		serverName = "Unknown Server";
	}

	switch (alarmID) {
		case ALARM_NONE: 	// clear all alarms set if any found
			if ( oam.checkActiveAlarm(HARDWARE_HIGH, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, HARDWARE_HIGH);
			if ( oam.checkActiveAlarm(HARDWARE_MED, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, HARDWARE_MED);
			if ( oam.checkActiveAlarm(HARDWARE_LOW, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, HARDWARE_LOW);
			break;
		case HARDWARE_LOW: 	// clear high and medium alarms set if any found
			if ( oam.checkActiveAlarm(HARDWARE_HIGH, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, HARDWARE_HIGH);
			if ( oam.checkActiveAlarm(HARDWARE_MED, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, HARDWARE_MED);
			break;
		case HARDWARE_MED: 	// clear high alarms set if any found
			if ( oam.checkActiveAlarm(HARDWARE_HIGH, serverName, alarmItem) )
				//  alarm set, clear it
				clearAlarm(alarmItem, HARDWARE_HIGH);
			break;
		default:			// none to clear
			break;
		} // end of switch
	return;
}
Exemple #19
0
	void test1() {

		Oam oamapi;
		Svalue = oamapi.getCurrentTime();
		cout << "Current time is " << Svalue;
		CPPUNIT_ASSERT(!Svalue.empty());

		Bvalue = oamapi.isValidIP("111.222.333.444");
		CPPUNIT_ASSERT(Bvalue == true);

		Bvalue = oamapi.isValidIP("111.222.333");
		CPPUNIT_ASSERT(Bvalue == false);

		Bvalue = oamapi.isValidIP("1.2.3.4");
		CPPUNIT_ASSERT(Bvalue == true);

		Bvalue = oamapi.isValidIP("1.2.3.4444");
		CPPUNIT_ASSERT(Bvalue == false);

		Bvalue = oamapi.isValidIP("1111.222.333.444");
		CPPUNIT_ASSERT(Bvalue == false);


// can test on deve machine
//		oamModuleInfo_t t;

//		t = oamapi.getModuleInfo();

//		Svalue = get<0>(t);
//		CPPUNIT_ASSERT(Svalue == "dm1");

//		Svalue = get<1>(t);
//		CPPUNIT_ASSERT(Svalue == "dm1");

//		Ivalue = get<2>(t);
//		CPPUNIT_ASSERT(Ivalue == MASTER_YES);
	};
Exemple #20
0
	void test5() {
		ProcessConfig processconfig;
		Oam oamapi;
		oamapi.getProcessConfig("ProcessManager", "dm1", "ModuleTypeBAD", Svalue);
		CPPUNIT_ASSERT(Svalue.size() == 0);
	};
Exemple #21
0
int main(int argc, char *argv[])
{
	Oam oam;

	//check for port argument
	string mysqlPort;
	if (argc > 1) {
		mysqlPort = argv[1];

		// set mysql password
		oam.changeMyCnf( "port", mysqlPort );
		exit (0);
	}

	//my.cnf file
	string mycnfFile = startup::StartUp::installDir() + "/mysql/my.cnf";
	ifstream mycnffile (mycnfFile.c_str());
	if (!mycnffile) {
		cerr << "mycnfUpgrade - my.cnf file not found: " << mycnfFile << endl;
		exit (1);
	}

	//my.cnf.rpmsave file
	string mycnfsaveFile = startup::StartUp::installDir() + "/mysql/my.cnf.rpmsave";
	ifstream mycnfsavefile (mycnfsaveFile.c_str());
	if (!mycnfsavefile) {
		cerr << "mycnfUpgrade - my.cnf.rpmsave file not found: " << mycnfsaveFile << endl;
		exit (1);
	}

	//include arguments file
	string includeFile = startup::StartUp::installDir() + "/bin/myCnf-include-args.text";
	ifstream includefile (includeFile.c_str());
	if (!includefile) {
		cerr << "mycnfUpgrade - my.cnf include argument file not found: " << includeFile << endl;
		exit (1);
	}

	//exclude arguments file
	string excludeFile = startup::StartUp::installDir() + "/bin/myCnf-exclude-args.text";
	ifstream excludefile (excludeFile.c_str());
	if (!excludefile) {
		cerr << "mycnfUpgrade - my.cnf exclude argument file not found: " << excludefile << endl;
		exit (1);
	}

	//go though include list
	char line[200];
	string includeArg;
	while (includefile.getline(line, 200))
	{
		includeArg = line;

		//see if in my.cnf.rpmsave
		ifstream mycnfsavefile (mycnfsaveFile.c_str());
		char line[200];
		string oldbuf;
		while (mycnfsavefile.getline(line, 200))
		{
			oldbuf = line;
			string::size_type pos = oldbuf.find(includeArg,0);
			if ( pos != string::npos ) {
				//check if this is commented out
				if ( line[0] != '#' ) 
				{
					// no, find in my.cnf and replace

					ifstream mycnffile (mycnfFile.c_str());
					vector <string> lines;
					char line1[200];
					string newbuf;
					while (mycnffile.getline(line1, 200))
					{
						newbuf = line1;
						string::size_type pos = newbuf.find(includeArg,0);
						if ( pos != string::npos )
							newbuf = oldbuf;

						//output to temp file
						lines.push_back(newbuf);
					}

					//write out a new my.cnf
					mycnffile.close();
					unlink (mycnfFile.c_str());
					ofstream newFile (mycnfFile.c_str());	
					
					//create new file
					int fd = open(mycnfFile.c_str(), O_RDWR|O_CREAT, 0666);
					
					copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
					newFile.close();
					
					close(fd);
				}

				break;
			}
		}
	}

	exit (0);
}
Exemple #22
0
int main(int argc, char** argv)
{
	// get and set locale language
    string systemLang = "C";
	systemLang = funcexp::utf8::idb_setlocale();

    printf ("Locale is : %s\n", systemLang.c_str() );

	//set BUSY_INIT state
	{
		// Is there a reason to have a seperate Oam instance for this?
		Oam oam;
		try
		{
			oam.processInitComplete("WriteEngineServer", oam::BUSY_INIT);
		}
		catch (...)
		{
		}
	}
	//BUG 2991
	setlocale(LC_NUMERIC, "C");
#ifndef _MSC_VER
	struct sigaction sa;
	memset(&sa, 0, sizeof(sa));
    sa.sa_handler = added_a_pm;
	sigaction(SIGHUP, &sa, 0);
	sa.sa_handler = SIG_IGN;
	sigaction(SIGPIPE, &sa, 0);
#endif

	// Init WriteEngine Wrapper (including Config Calpont.xml cache)
	WriteEngine::WriteEngineWrapper::init( WriteEngine::SUBSYSTEM_ID_WE_SRV );

#ifdef _MSC_VER
    // In windows, initializing the wrapper (A dll) does not set the static variables
    // in the main program
    idbdatafile::IDBPolicy::configIDBPolicy();
#endif
	Config weConfig;
	int rc;
	rc = setupResources();
	
	ostringstream serverParms;
	serverParms << "pm" << weConfig.getLocalModuleID() << "_WriteEngineServer";

	// Create MessageQueueServer, with one retry in case the call to bind the
	// known port fails with "Address already in use".
	boost::scoped_ptr<MessageQueueServer> mqs;
	bool tellUser = true;
	for (;;)
	{
		try {
			mqs.reset(new MessageQueueServer(serverParms.str()));
			break;
		}
		// @bug4393 Error Handling for MessageQueueServer constructor exception
		catch (runtime_error& re) {
			string what = re.what();
			if (what.find("Address already in use") != string::npos)
			{
				if (tellUser)
				{
					cerr << "Address already in use, retrying..." << endl;
					tellUser = false;
				}
				sleep(5);
			}
			else
			{
				Oam oam;
				try // Get out of BUSYINIT state; else OAM will not retry
				{
					oam.processInitComplete("WriteEngineServer");
				}
				catch (...)
				{
				}

				// If/when a common logging class or function is added to the
				// WriteEngineServer, we should use that.  In the mean time,
				// I will log this errmsg with inline calls to the logging.
				logging::Message::Args args;
				logging::Message message;
				string errMsg("WriteEngineServer failed to initiate: ");
				errMsg += what;
				args.add( errMsg );
				message.format(args);
				logging::LoggingID lid(SUBSYSTEM_ID_WE_SRV);
				logging::MessageLog ml(lid);
				ml.logCriticalMessage( message );

				return 2;
			}
		}
	}

	IOSocket ios;
	size_t mt = 20;
	size_t qs = mt * 100;
	ThreadPool tp(mt, qs);

	//set ACTIVE state
	{
		Oam oam;
		try
		{
			oam.processInitComplete("WriteEngineServer", ACTIVE);
		}
		catch (...)
		{
		}
	}
	cout << "WriteEngineServer is ready" << endl;
	BRM::DBRM dbrm;
	for (;;)
	{
		try // BUG 4834 -
		{
			ios = mqs->accept();
			//tp.invoke(ReadThread(ios));
			ReadThreadFactory::CreateReadThread(tp,ios, dbrm);
			{
/*				logging::Message::Args args;
				logging::Message message;
				string aMsg("WriteEngineServer : New incoming connection");
				args.add(aMsg);
				message.format(args);
				logging::LoggingID lid(SUBSYSTEM_ID_WE_SRV);
				logging::MessageLog ml(lid);
				ml.logInfoMessage( message ); */
			}
		}
		catch(std::exception& ex) // BUG 4834 - log the exception
		{
			logging::Message::Args args;
			logging::Message message;
			string errMsg("WriteEngineServer : Exception caught on accept(): ");
			errMsg += ex.what();
			args.add( errMsg );
			message.format(args);
			logging::LoggingID lid(SUBSYSTEM_ID_WE_SRV);
			logging::MessageLog ml(lid);
			ml.logCriticalMessage( message );
			break;
		}
	}

	//It is an error to reach here...
	return 1;
}
Exemple #23
0
/******************************************************************************************
* @brief	sendResourceAlarm
*
* purpose:	send a trap and log the process information
*
******************************************************************************************/
bool ServerMonitor::sendResourceAlarm(string alarmItem, ALARMS alarmID, int action, int usage)
{
	ServerMonitor serverMonitor;
	Oam oam;

	//Log this event 
	LoggingID lid(SERVER_MONITOR_LOG_ID);
	MessageLog ml(lid);
	Message msg;
	Message::Args args;
	args.add(alarmItem);
	args.add(" usage at percentage of ");
	args.add(usage);

	// get current module name
	string moduleName;
	oamModuleInfo_t st;
	try {
		st = oam.getModuleInfo();
		moduleName = boost::get<0>(st);
	}
	catch (...) {
		moduleName = "Unknown Server";
	}

	// check if there is an active alarm above the reporting theshold 
	// that needs to be cleared

	if (alarmItem == "CPU")
		serverMonitor.checkCPUAlarm(alarmItem, alarmID);
	else if (alarmItem == "Local Disk" || alarmItem == "External")
			serverMonitor.checkDiskAlarm(alarmItem, alarmID);
	else if (alarmItem == "Local Memory")
			serverMonitor.checkMemoryAlarm(alarmItem, alarmID);
	else if (alarmItem == "Local Swap")
			serverMonitor.checkSwapAlarm(alarmItem, alarmID);

	// don't issue an alarm on thge dbroots is already issued by this or another server
	if ( alarmItem.find(startup::StartUp::installDir() + "/data") == 0 ) {
		// check if Alarm is already active from any module, don't resend
		if ( !( oam.checkActiveAlarm(alarmID, "*", alarmItem)) ) {
	
			SNMPManager alarmMgr;
			// send alarm
			alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, action);
	
			args.add(", Alarm set: ");
			args.add(alarmID);
			msg.format(args);
			ml.logInfoMessage(msg);
			return true;
		}
		else
			return false;
	}
	else
	{
		// check if Alarm is already active from this module, don't resend
		if ( !( oam.checkActiveAlarm(alarmID, moduleName, alarmItem)) ) {
	
			SNMPManager alarmMgr;
			// send alarm
			alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, action);
	
			args.add(", Alarm set: ");
			args.add(alarmID);
			msg.format(args);
			ml.logInfoMessage(msg);
			return true;
		}
		else
			return false;
	}

	return true;
}
Exemple #24
0
/*****************************************************************************************
* @brief	diskMonitor Thread
*
* purpose:	Get current Local and External disk usage and report alarms
*
*****************************************************************************************/
void diskMonitor()
{
	ServerMonitor serverMonitor;
	Oam oam;
    SystemConfig systemConfig;
	ModuleTypeConfig moduleTypeConfig;
	typedef std::vector<std::string> LocalFileSystems;
	LocalFileSystems lfs;
	struct statvfs buf; 

	// set defaults
	int localDiskCritical = 90,
		localDiskMajor = 80,
		localDiskMinor = 70,
		ExternalDiskCritical = 90,
		ExternalDiskMajor = 80,
		ExternalDiskMinor = 70;

	// get module types
	string moduleType;
	int moduleID=-1;
	string moduleName;
	oamModuleInfo_t t;
	try {
		t = oam.getModuleInfo();
		moduleType = boost::get<1>(t);
		moduleID = boost::get<2>(t);
		moduleName = boost::get<0>(t);
	}
	catch (exception& e) {}

	bool Externalflag = false;

	//check for external disk
	DBrootList dbrootList;
	if (moduleType == "pm") {
		systemStorageInfo_t t;
		t = oam.getStorageConfig();
		if ( boost::get<0>(t) == "external")
			Externalflag = true;

		// get dbroot list and storage type from config file
		DBRootConfigList dbrootConfigList;
		oam.getPmDbrootConfig(moduleID, dbrootConfigList);
	
		DBRootConfigList::iterator pt = dbrootConfigList.begin();
		for( ; pt != dbrootConfigList.end() ; pt++)
		{
			int dbrootID = *pt;
	
			string dbroot = "DBRoot" + oam.itoa(dbrootID);
	
			string dbootdir;
			try{
				oam.getSystemConfig(dbroot, dbootdir);
			}
			catch(...) {}
	
			if ( dbootdir.empty() || dbootdir == "" )
				continue;
	
			DBrootData dbrootData;
			dbrootData.dbrootDir = dbootdir;
			dbrootData.downFlag = false;
	
			dbrootList.push_back(dbrootData);
		}
	}

	string cloud = oam::UnassignedName;
	try {
		oam.getSystemConfig( "Cloud", cloud);
	}
	catch(...) {
		cloud = oam::UnassignedName;
	}

	//get Gluster Config setting
	string GlusterConfig = "n";
	try {
		oam.getSystemConfig( "GlusterConfig", GlusterConfig);
	}
	catch(...)
	{
		GlusterConfig = "n";
	}

	int diskSpaceCheck = 0;

	while(true)
	{
		SystemStatus systemstatus;
		try {
			oam.getSystemStatus(systemstatus);
		}
		catch (exception& ex)
		{}
		
		if (systemstatus.SystemOpState != oam::ACTIVE ) {
			sleep(5);
			continue;
		}

		// Get Local/External Disk Mount points to monitor and associated thresholds
		
		try {
			oam.getSystemConfig (moduleTypeConfig);
			localDiskCritical = moduleTypeConfig.ModuleDiskCriticalThreshold; 
			localDiskMajor = moduleTypeConfig.ModuleDiskMajorThreshold; 
			localDiskMinor = moduleTypeConfig.ModuleDiskMinorThreshold;

			DiskMonitorFileSystems::iterator p = moduleTypeConfig.FileSystems.begin();
			for( ; p != moduleTypeConfig.FileSystems.end() ; p++)
			{
				string fs = *p;
				lfs.push_back(fs);

				if (DISK_DEBUG) {
					//Log this event 
					LoggingID lid(SERVER_MONITOR_LOG_ID);
					MessageLog ml(lid);
					Message msg;
					Message::Args args;
					args.add("Local Config File System to monitor =");
					args.add(fs);
					msg.format(args);
					ml.logDebugMessage(msg);
				}
			}

		} catch (...)
		{
			sleep(5);
			continue;
		}

		// get External info
		try
		{
			oam.getSystemConfig(systemConfig);

		} catch (...)
		{
			sleep(5);
			continue;
		}

		if (Externalflag) {
			// get External info
			try
			{
				ExternalDiskCritical = systemConfig.ExternalCriticalThreshold;
				ExternalDiskMajor = systemConfig.ExternalMajorThreshold;
				ExternalDiskMinor = systemConfig.ExternalMinorThreshold;

			} catch (...)
			{
				sleep(5);
				continue;
			}
		}

		//check for local file systems
		LocalFileSystems::iterator p = lfs.begin();
		while(p != lfs.end())
		{
			string deviceName = *p;
			++p;
			string fileName;
			// check local
			if ( deviceName == "/") {
				fileName = deviceName + "usr/local/Calpont/releasenum";
			}
			else
			{
				fileName = deviceName + "/000.dir";
			}

			uint64_t totalBlocks;
			uint64_t usedBlocks;

			if (!statvfs(fileName.c_str(), &buf)) {

				uint64_t blksize, blocks, freeblks, free; 

				blksize = buf.f_bsize; 
				blocks = buf.f_blocks; 
				freeblks = buf.f_bfree; 

				totalBlocks = blocks * blksize;
				free = freeblks * blksize; 
				usedBlocks = totalBlocks - free; 
			}
			else
				continue;

			int64_t diskUsage = 0;
			if ( totalBlocks == 0 ) {
				diskUsage = 0;
	
				//Log this event 
				LoggingID lid(SERVER_MONITOR_LOG_ID);
				MessageLog ml(lid);
				Message msg;
				Message::Args args;
				args.add("Total Disk Usage is set to 0");
				msg.format(args);
				ml.logWarningMessage(msg);
			}
			else
				diskUsage =  (usedBlocks / (totalBlocks / 100)) + 1;

			SMSystemDisk sd;
			sd.deviceName = deviceName;
			sd.usedPercent = diskUsage;
			sd.totalBlocks = totalBlocks;
			sd.usedBlocks = usedBlocks;
			sdl.push_back(sd);

			if (DISK_DEBUG)
				cout << "Disk Usage for " << deviceName << " is " << diskUsage << endl;
	
			if ( diskSpaceCheck == 0 )
			{
				if (diskUsage >= localDiskCritical && localDiskCritical > 0 ) {
					//adjust if over 100%
					if ( diskUsage > 100 )
						diskUsage = 100;
					if ( serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_HIGH, SET, (int) diskUsage) )
					{
						LoggingID lid(SERVER_MONITOR_LOG_ID);
						MessageLog ml(lid);
						Message msg;
						Message::Args args;
						args.add("Local Disk above Critical Disk threshold with a percentage of ");
						args.add((int) diskUsage);
						msg.format(args);
						ml.logInfoMessage(msg);
					}
				}
				else if (diskUsage >= localDiskMajor && localDiskMajor > 0 ) {
					if (serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_MED, SET, (int) diskUsage))
					{
						LoggingID lid(SERVER_MONITOR_LOG_ID);
						MessageLog ml(lid);
						Message msg;
						Message::Args args;
						args.add("Local Disk above Major Disk threshold with a percentage of ");
						args.add((int) diskUsage);
						msg.format(args);
						ml.logInfoMessage(msg);
					}
				}
				else if (diskUsage >= localDiskMinor && localDiskMinor > 0 ) {
					if ( serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_LOW, SET, (int) diskUsage))
					{
						LoggingID lid(SERVER_MONITOR_LOG_ID);
						MessageLog ml(lid);
						Message msg;
						Message::Args args;
						args.add("Local Disk above Minor Disk threshold with a percentage of ");
						args.add((int) diskUsage);
						msg.format(args);
						ml.logInfoMessage(msg);
					}
				}
				else
					serverMonitor.checkDiskAlarm(deviceName);
			}
	
			//check for external file systems/devices
			if (Externalflag ||
				(!Externalflag && GlusterConfig == "y" && moduleType == "pm") ){
				try
				{
					DBRootConfigList dbrootConfigList;
					oam.getPmDbrootConfig(moduleID, dbrootConfigList);
	
					DBRootConfigList::iterator pt = dbrootConfigList.begin();
					for( ; pt != dbrootConfigList.end() ; pt++)
					{
						int dbroot = *pt;
						string deviceName = systemConfig.DBRoot[dbroot-1];
						string fileName = deviceName + "/000.dir";
			
						if (DISK_DEBUG) {
							//Log this event 
							LoggingID lid(SERVER_MONITOR_LOG_ID);
							MessageLog ml(lid);
							Message msg;
							Message::Args args;
							args.add("DBRoots monitoring");
							args.add(dbroot);
							args.add(" ,file system =" );
							args.add(fileName);
							msg.format(args);
							ml.logDebugMessage(msg);
						}
	
						uint64_t totalBlocks;
						uint64_t usedBlocks;
			
						if (!statvfs(fileName.c_str(), &buf)) {
			
							uint64_t blksize, blocks, freeblks, free; 
			
							blksize = buf.f_bsize; 
							blocks = buf.f_blocks; 
							freeblks = buf.f_bfree; 
			
							totalBlocks = blocks * blksize;
							free = freeblks * blksize; 
							usedBlocks = totalBlocks - free; 
						}
						else
						{
							SMSystemDisk sd;
							sd.deviceName = deviceName;
							sd.usedPercent = 0;
							sd.totalBlocks = 0;
							sd.usedBlocks = 0;
							sdl.push_back(sd);
							continue;
						}
			
						int diskUsage = 0;
						if ( totalBlocks == 0 ) {
							diskUsage = 0;
				
							//Log this event 
							LoggingID lid(SERVER_MONITOR_LOG_ID);
							MessageLog ml(lid);
							Message msg;
							Message::Args args;
							args.add("Total Disk Usage is set to 0");
							msg.format(args);
							ml.logWarningMessage(msg);
						}
						else
							diskUsage =  (usedBlocks / (totalBlocks / 100)) + 1;
			
						SMSystemDisk sd;
						sd.deviceName = deviceName;
						sd.usedPercent = diskUsage;
						sd.totalBlocks = totalBlocks;
						sd.usedBlocks = usedBlocks;
						sdl.push_back(sd);
		
						if (DISK_DEBUG)
							cout << "Disk Usage for " << deviceName << " is " << diskUsage << endl;
			
						if (diskUsage >= ExternalDiskCritical && ExternalDiskCritical > 0 ) {
							//adjust if over 100%
							if ( diskUsage > 100 )
								diskUsage = 100;
							if ( serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_HIGH, SET, diskUsage))
							{
								LoggingID lid(SERVER_MONITOR_LOG_ID);
								MessageLog ml(lid);
								Message msg;
								Message::Args args;
								args.add("Disk usage for");
								args.add(deviceName);
								args.add(" above Critical Disk threshold with a percentage of ");
								args.add((int) diskUsage);
								msg.format(args);
								ml.logInfoMessage(msg);
							}
						}
						else if (diskUsage >= ExternalDiskMajor && ExternalDiskMajor > 0 ) {
							if ( serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_MED, SET, diskUsage))
							{
								LoggingID lid(SERVER_MONITOR_LOG_ID);
								MessageLog ml(lid);
								Message msg;
								Message::Args args;
								args.add("Disk usage for");
								args.add(deviceName);
								args.add(" above Major Disk threshold with a percentage of ");
								args.add((int) diskUsage);
								msg.format(args);
								ml.logInfoMessage(msg);
							}
						}
						else if (diskUsage >= ExternalDiskMinor && ExternalDiskMinor > 0 ) {
							if ( serverMonitor.sendResourceAlarm(deviceName, DISK_USAGE_LOW, SET, diskUsage))
							{
								LoggingID lid(SERVER_MONITOR_LOG_ID);
								MessageLog ml(lid);
								Message msg;
								Message::Args args;
								args.add("Disk usage for");
								args.add(deviceName);
								args.add(" above Minor Disk threshold with a percentage of ");
								args.add((int) diskUsage);
								msg.format(args);
								ml.logInfoMessage(msg);
							}
						}
						else
							serverMonitor.checkDiskAlarm(deviceName);
					}
				}
				catch (exception& e)
				{
					cout << endl << "**** getPmDbrootConfig Failed :  " << e.what() << endl;
				}
			}
		}

		//check OAM dbroot test flag to validate dbroot exist if on pm
		if ( moduleName.find("pm") != string::npos ) {
			//check OAM dbroot test flag to validate dbroot exist
			if ( dbrootList.size() != 0 ) {
				DBrootList::iterator p = dbrootList.begin();
				while ( p != dbrootList.end() )
				{
					//get dbroot directory
					string dbrootDir = (*p).dbrootDir;
					string dbrootName;
					string dbrootID;

					//get dbroot name
					string::size_type pos = dbrootDir.rfind("/",80);
					if (pos != string::npos)
						dbrootName = dbrootDir.substr(pos+1,80);

					//get ID
					dbrootID = dbrootName.substr(4,80);
			
					string fileName = dbrootDir + "/OAMdbrootCheck";
					// retry in case we hit the remount window
					for ( int retry = 0 ; ; retry++ )
					{
						bool fail = false;
						//first test, check if OAMdbrootCheck exists
						ifstream file (fileName.c_str());
						if (!file)
							fail = true;
						else
						{	//second test for amazon, check volume status
							if ( cloud != oam::UnassignedName ) {
								string volumeNameID = "PMVolumeName" + dbrootID;
								string volumeName = oam::UnassignedName;
								try {
									oam.getSystemConfig( volumeNameID, volumeName);
								}
								catch(...)
								{}
							
								if ( volumeName.empty() || volumeName == oam::UnassignedName )
									fail = false;
								else
								{
									string status = oam.getEC2VolumeStatus(volumeName);
									if ( status == "attached" )
										fail = false;
									else
									{
										fail = true;
										LoggingID lid(SERVER_MONITOR_LOG_ID);
										MessageLog ml(lid);
										Message msg;
										Message::Args args;
										args.add("dbroot monitoring: Volume not attached");
										args.add(volumeName);
										args.add("/");
										args.add(dbrootName);
										msg.format(args);
										ml.logCriticalMessage(msg);
									}
								}
							}
							else
								fail = false;
						}

						if (fail) {
							//double check system status before reporting any error BUG 5078
							SystemStatus systemstatus;
							try {
								oam.getSystemStatus(systemstatus);
							}
							catch (exception& ex)
							{}
							
							if (systemstatus.SystemOpState != oam::ACTIVE ) {
								break;
							}

							if ( retry < 10 ) {
								sleep(3);
								continue;
							}
							else
							{
								if ( !(*p).downFlag ) {
									LoggingID lid(SERVER_MONITOR_LOG_ID);
									MessageLog ml(lid);
									Message msg;
									Message::Args args;
									args.add("dbroot monitoring: Lost access to ");
									args.add(dbrootDir);
									msg.format(args);
									ml.logCriticalMessage(msg);

									oam.sendDeviceNotification(dbrootName, DBROOT_DOWN, moduleName);
									(*p).downFlag = true;

									try{
										oam.setDbrootStatus(dbrootID, oam::AUTO_OFFLINE);
									}
									catch (exception& ex)
									{}

									break;
								}
							}
						}
						else
						{
							if ( (*p).downFlag ) {
								LoggingID lid(SERVER_MONITOR_LOG_ID);
								MessageLog ml(lid);
								Message msg;
								Message::Args args;
								args.add("dbroot monitoring: Access back to ");
								args.add(dbrootDir);
								msg.format(args);
								ml.logInfoMessage(msg);
		
								oam.sendDeviceNotification(dbrootName, DBROOT_UP, moduleName);
								(*p).downFlag = false;

								try{
									oam.setDbrootStatus(dbrootID, oam::ACTIVE);
								}
								catch (exception& ex)
								{}
							}
							file.close();
							break;
						}
					}
					p++;
				}
			}
		}

		//do Gluster status check, if configured
		if ( GlusterConfig == "y")
		{
			bool pass = true;
			string errmsg = "unknown";
			try {
				string arg1 = "";
				string arg2 = "";
				int ret = oam.glusterctl(oam::GLUSTER_STATUS, arg1, arg2, errmsg);
				if ( ret != 0 )
				{
					cerr << "FAILURE: Status check error: " + errmsg << endl;
					pass = false;
				}
			}
			catch (exception& e)
			{
				cerr << endl << "**** glusterctl API exception:  " << e.what() << endl;
				cerr << "FAILURE: Status check error" << endl;
				pass = false;
			}
			catch (...)
			{
				cerr << endl << "**** glusterctl API exception: UNKNOWN" << endl;
				cerr << "FAILURE: Status check error" << endl;
				pass = false;
			}

			if ( !pass )
			{ // issue log and alarm
				LoggingID lid(SERVER_MONITOR_LOG_ID);
				MessageLog ml(lid);
				Message msg;
				Message::Args args;
				args.add("Gluster Status check failure error msg: ");
				args.add(errmsg);
				msg.format(args);
				ml.logWarningMessage(msg);
				serverMonitor.sendResourceAlarm(errmsg, GLUSTER_DISK_FAILURE, SET, 0);
			}
		}

		// sleep 10 seconds
		sleep(MONITOR_PERIOD/6);

		//check disk space every 10 minutes
		diskSpaceCheck++;
		if ( diskSpaceCheck >= 60 )
			diskSpaceCheck = 0;

		lfs.clear();
		sdl.clear();

	} // end of while loop
}
Exemple #25
0
	void test3() {
		Oam oamapi;
		oamapi.getAlarmConfig(CPU_USAGE_MED, "ThresholdBAD", Ivalue);
		CPPUNIT_ASSERT(Ivalue == 0);
	};
Exemple #26
0
/*****************************************************************************************
* @brief	setSNMPModuleName API
*
* purpose:	Set SNMP Module name in the snmpdx.conf file
*
*****************************************************************************************/
void SNMPManager::setSNMPModuleName ()
{
	// get current Module name
	Oam oam;
	string ModuleName;
	oamModuleInfo_t st;
	try {
		st = oam.getModuleInfo();
		ModuleName = boost::get<0>(st);
	}
	catch (...) {
		ModuleName = "Unknown Report Module";
	}

	string agentName = SUB_AGENT;
	string fileName;
	makeFileName (agentName, fileName);
	vector <string> lines;

	ifstream oldFile (fileName.c_str());
	if (!oldFile) throw runtime_error ("No configuration file found");
	
	char line[200];
	string buf;
	string newLine;
	string newLine1;
	string delimiters = " ";
	while (oldFile.getline(line, 200))
	{
		buf = line;
		string::size_type pos = buf.find("ModuleNameStub",0);
		if (pos != string::npos)
		{
	        newLine = buf.substr(0, pos);
    	    newLine.append(ModuleName);

			string::size_type pos1 = buf.find("|",pos);
			if (pos1 != string::npos)
			{
	        	newLine1 = buf.substr(pos1, 200);
    	    	newLine.append(newLine1);
			}
		buf = newLine;
		}
		// output to temp file
		lines.push_back(buf);
	}
	
	oldFile.close();
	unlink (fileName.c_str());
   	ofstream newFile (fileName.c_str());	
	
	// create new file
	int fd = open(fileName.c_str(), O_RDWR|O_CREAT, 0666);
	
	// Aquire an exclusive lock
   	if (flock(fd,LOCK_EX) == -1) {
    	throw runtime_error ("Lock SNMP configuration file error");
   	}

	copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
	newFile.close();
	
	// Release lock
	if (flock(fd,LOCK_UN) == -1)
	{
    	throw runtime_error ("Release lock SNMP configuration file error");		
	}
	close(fd);
}
Exemple #27
0
int main(int argc, char *argv[])
{
	setenv("CALPONT_HOME", "./", 1);

    Oam oam;
	string systemParentOAMModuleName;
	string parentOAMModuleIPAddr;
	PerformanceModuleList performancemodulelist;
	int pmNumber = 0;
	string prompt;
	int DBRMworkernodeID = 0;
	string remote_installer_debug = "0";
	Config* sysConfigOld;
	Config* sysConfigNew;
	string systemName;
	bool extextMapCheckOnly = false;

    if (argc > 1) {
		string arg1 = argv[1];
		if (  arg1 == "-e" )
			extextMapCheckOnly = true;
		else
			systemName = arg1;
	}
	else
		systemName = oam::UnassignedName;

	try {
		sysConfigOld = Config::makeConfig("./Calpont.xml");
		sysConfigNew = Config::makeConfig("./Calpont.xml.new");
	}
	catch(...)
	{
		cout << "ERROR: Problem reading Calpont.xml files";
		exit(-1);
	}

	string SystemSection = "SystemConfig";
	string InstallSection = "Installation";

	//set install config flag
	try {
		sysConfigNew->setConfig(InstallSection, "InitialInstallFlag", "y");
	}
	catch(...)
	{
		cout << "ERROR: Problem setting InitialInstallFlag from the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//read cloud parameter to see if this is a 3.0 or pre-3.0 build
	string cloud;
	try {
		cloud = sysConfigOld->getConfig(InstallSection, "Cloud");
	}
	catch(...)
	{ }

	bool build3 = false;
	if ( !cloud.empty() )
		build3 = true;
	//set install config flag
	try {
		sysConfigNew->setConfig(InstallSection, "InitialInstallFlag", "y");
	}
	catch(...)
	{
		cout << "ERROR: Problem setting InitialInstallFlag from the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//set gluster flag if it exists
	string GlusterConfig;
	string GlusterCopies;
	string GlusterStorageType;
	try {
		GlusterConfig = sysConfigOld->getConfig(InstallSection, "GlusterConfig");
		GlusterCopies = sysConfigOld->getConfig(InstallSection, "GlusterCopies");
		GlusterStorageType = sysConfigOld->getConfig(InstallSection, "GlusterStorageType");
	}
	catch(...)
	{}
	if ( !GlusterConfig.empty() ) {
		try {
			sysConfigNew->setConfig(InstallSection, "GlusterConfig", GlusterConfig);
			sysConfigNew->setConfig(InstallSection, "GlusterCopies", GlusterCopies);
			sysConfigNew->setConfig(InstallSection, "GlusterStorageType", GlusterStorageType);
		}
		catch(...)
		{}
	}	

	//check and make sure the ExtentMap variables don't get changed at install
	string oldFilesPerColumnPartition;
	string oldExtentsPerSegmentFile;
	string newFilesPerColumnPartition;
	string newExtentsPerSegmentFile;
	try {
		oldFilesPerColumnPartition = sysConfigOld->getConfig("ExtentMap", "FilesPerColumnPartition");
		oldExtentsPerSegmentFile = sysConfigOld->getConfig("ExtentMap", "ExtentsPerSegmentFile");

		newFilesPerColumnPartition = sysConfigNew->getConfig("ExtentMap", "FilesPerColumnPartition");
		newExtentsPerSegmentFile = sysConfigNew->getConfig("ExtentMap", "ExtentsPerSegmentFile");

		if ( oldFilesPerColumnPartition != newFilesPerColumnPartition )
		{
			try {
				sysConfigNew->setConfig("ExtentMap", "FilesPerColumnPartition", oldFilesPerColumnPartition);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting FilesPerColumnPartition in the Calpont System Configuration file" << endl;
				exit(-1);
			}
		}

		if ( oldExtentsPerSegmentFile != newExtentsPerSegmentFile )
		{
			try {
				sysConfigNew->setConfig("ExtentMap", "ExtentsPerSegmentFile", oldExtentsPerSegmentFile);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting ExtentsPerSegmentFile in the Calpont System Configuration file" << endl;
				exit(-1);
			}
		}
	}
	catch(...)
	{
	}

	//check and update license key
	try {
		string key = sysConfigOld->getConfig("SystemConfig", "Flags");

		if ( !key.empty() )
		{
			try {
				sysConfigNew->setConfig("SystemConfig", "Flags", key);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting Flags in the Calpont System Configuration file" << endl;
				exit(-1);
			}
		}
	}
	catch(...)
	{
	}

	sysConfigNew->write();

	if ( extextMapCheckOnly )
		exit(0);

	systemParentOAMModuleName = "pm1";

	//check if systemParentOAMModuleName (pm1) is configured, if not set to 'pm2'
//	string IPaddr = sysConfigOld->getConfig("pm1_ProcessMonitor", "IPAddr");
//	if ( IPaddr == "0.0.0.0" )
//		systemParentOAMModuleName = "pm2";

	//set Parent OAM Module Name
	try{
		sysConfigNew->setConfig(SystemSection, "ParentOAMModuleName", systemParentOAMModuleName);
	}
	catch(...)
	{
		cout << "ERROR: Problem updating the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//setup System Name
	string oldSystemName;
	try {
		oldSystemName = sysConfigOld->getConfig(SystemSection, "SystemName");
	}
	catch(...)
	{ }

	if ( !oldSystemName.empty() )
		systemName = oldSystemName;

	try {
		 sysConfigNew->setConfig(SystemSection, "SystemName", systemName);
	}
	catch(...)
	{
		cout << "ERROR: Problem setting SystemName from the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//setup System Language
	string systemLang = "C";
	try {
		systemLang = sysConfigOld->getConfig(SystemSection, "SystemLang");
	}
	catch(...)
	{ }

	try {
		 sysConfigNew->setConfig(SystemSection, "SystemLang", systemLang);
	}
	catch(...)
	{}

	//setup HA IP Address
	string HA_IPadd;
	try {
		HA_IPadd = sysConfigOld->getConfig("ProcMgr_HA", "IPAddr");
	}
	catch(...)
	{ }

	if ( !HA_IPadd.empty() ) {
		try {
			sysConfigNew->setConfig("ProcMgr_HA", "IPAddr", HA_IPadd);
		}
		catch(...)
		{
			cout << "ERROR: Problem setting ProcMgr_HA from the Calpont System Configuration file" << endl;
			exit(-1);
		}
	}

	//setup CMP IP Addresses
	string CMP_IPadd;
	string CMP_port;
	for ( int id = 1 ;; id ++ )
	{
		string cmpName = "CMP" + oam.itoa(id);
		try {
			CMP_IPadd = sysConfigOld->getConfig(cmpName, "IPAddr");
		}
		catch(...)
		{ }
	
		if ( !CMP_IPadd.empty() ) {
			try {
				CMP_port = sysConfigOld->getConfig(cmpName, "Port");
			}
			catch(...)
			{ }

			try {
				sysConfigNew->setConfig(cmpName, "IPAddr", CMP_IPadd);
				sysConfigNew->setConfig(cmpName, "Port", CMP_port);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting CMP from the Calpont System Configuration file" << endl;
				exit(-1);
			}
		}
		else
			break;
	}

	//setup module and process monitor settings
	string ModuleHeartbeatPeriod = "3";
	string ModuleHeartbeatCount = "1";
	string ProcessRestartCount = "3";
	string ProcessRestartPeriod = "1";
	string SwapAction = "restartSystem";
	string ActivePmFailoverDisabled = "n";

	try {
		ModuleHeartbeatPeriod = sysConfigOld->getConfig(SystemSection, "ModuleHeartbeatPeriod");
		ModuleHeartbeatCount = sysConfigOld->getConfig(SystemSection, "ModuleHeartbeatCount");
		ProcessRestartCount = sysConfigOld->getConfig(SystemSection, "ProcessRestartCount");
		ProcessRestartPeriod = sysConfigOld->getConfig(SystemSection, "ProcessRestartPeriod");
		SwapAction = sysConfigOld->getConfig(SystemSection, "SwapAction");
		ActivePmFailoverDisabled = sysConfigOld->getConfig(SystemSection, "ActivePmFailoverDisabled");
	}
	catch(...)
	{ }

	try {
		sysConfigNew->setConfig(SystemSection, "ModuleHeartbeatPeriod", ModuleHeartbeatPeriod);
		sysConfigNew->setConfig(SystemSection, "ModuleHeartbeatCount", ModuleHeartbeatCount);
		sysConfigNew->setConfig(SystemSection, "ProcessRestartCount", ProcessRestartCount);
		sysConfigNew->setConfig(SystemSection, "ProcessRestartPeriod", ProcessRestartPeriod);
		sysConfigNew->setConfig(SystemSection, "SwapAction", SwapAction);
		sysConfigNew->setConfig(SystemSection, "ActivePmFailoverDisabled", ActivePmFailoverDisabled);
	}
	catch(...)
	{}

	//save EEPackageType and EnableSNMP
	string EEPackageType = "rpm";
	string EnableSNMP = "y";

	try {
		EEPackageType = sysConfigOld->getConfig(InstallSection, "EEPackageType");
		EnableSNMP = sysConfigOld->getConfig(InstallSection, "EnableSNMP");
	}
	catch(...)
	{ }

	try {
		sysConfigNew->setConfig(InstallSection, "EEPackageType", EEPackageType);
		sysConfigNew->setConfig(InstallSection, "EnableSNMP", EnableSNMP);
	}
	catch(...)
	{ }

	if ( EEPackageType.empty() )
		EEPackageType = "rpm";

	if ( EnableSNMP.empty() )
		EnableSNMP = "y";

	try {
		sysConfigNew->setConfig(InstallSection, "EEPackageType", EEPackageType);
		sysConfigNew->setConfig(InstallSection, "EnableSNMP", EnableSNMP);
	}
	catch(...)
	{}

	// make DBRM backwards compatiable for pre 1.0.0.157 load
	string dbrmMainProc = "DBRM_Controller";
	string dbrmSubProc = "DBRM_Worker";
	string numSubProc = "NumWorkers";

	//set system startup offline option to default 'n'
	try {
		sysConfigNew->setConfig(InstallSection, "SystemStartupOffline", "n");
	}
	catch(...)
	{
		cout << "ERROR: Problem setting systemStartupOffline in the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//CrossEngineSupport
	string Host = "";
	string Port = "3306";
	string User = "";
	string Password = "";

	try {
		Host = sysConfigOld->getConfig("CrossEngineSupport", "Host");
		Port = sysConfigOld->getConfig("CrossEngineSupport", "Port");
		User = sysConfigOld->getConfig("CrossEngineSupport", "User");
		Password = sysConfigOld->getConfig("CrossEngineSupport", "Password");
	}
	catch(...)
	{
		Host = "";
		Port = "3306";
		User = "";
		Password = "";
	}

	try {
		sysConfigNew->setConfig("CrossEngineSupport", "Host", Host);
		sysConfigNew->setConfig("CrossEngineSupport", "Port", Port);
		sysConfigNew->setConfig("CrossEngineSupport", "User", User);
		sysConfigNew->setConfig("CrossEngineSupport", "Password", Password);
	}
	catch(...)
	{}

	//QueryStats and UserPriority
	string QueryStats = "N";
	string UserPriority = "N";

	try {
		QueryStats = sysConfigOld->getConfig("QueryStats", "Enabled");
		UserPriority = sysConfigOld->getConfig("UserPriority", "Enabled");
	}
	catch(...)
	{
		QueryStats = "N";
		UserPriority = "N";
	}

	try {
		sysConfigNew->setConfig("QueryStats", "Enabled", QueryStats);
		sysConfigNew->setConfig("UserPriority", "Enabled", UserPriority);
	}
	catch(...)
	{}

	// @bug4598, DirectIO setting
	string directIO = "y";
	try {
		directIO = sysConfigOld->getConfig("PrimitiveServers", "DirectIO");
	}
	catch(...) {
		directIO = "y";
	}

	try {
		sysConfigNew->setConfig("PrimitiveServers", "DirectIO", directIO);
	}
	catch(...)
	{}

	// @bug4507, configurable pm aggregation AggregationMemoryCheck
	string aggMemCheck;
	try {
		aggMemCheck = sysConfigOld->getConfig("PrimitiveServers", "AggregationMemoryCheck");

		if ( !( aggMemCheck.empty() || aggMemCheck == "" ) ) {
			sysConfigNew->setConfig("PrimitiveServers", "AggregationMemoryCheck", aggMemCheck);
		}
	}
	catch(...) {
	}

	//Priority Settings
	string HighPriorityPercentage;
	try {
		HighPriorityPercentage = sysConfigOld->getConfig("PrimitiveServers", "HighPriorityPercentage");
		sysConfigNew->setConfig("PrimitiveServers", "HighPriorityPercentage", HighPriorityPercentage);
	}
	catch(...) {}

	string MediumPriorityPercentage;
	try {
		MediumPriorityPercentage = sysConfigOld->getConfig("PrimitiveServers", "MediumPriorityPercentage");
		sysConfigNew->setConfig("PrimitiveServers", "MediumPriorityPercentage", MediumPriorityPercentage);
	}
	catch(...) {}

	string LowPriorityPercentage;
	try {
		LowPriorityPercentage = sysConfigOld->getConfig("PrimitiveServers", "LowPriorityPercentage");
		sysConfigNew->setConfig("PrimitiveServers", "LowPriorityPercentage", LowPriorityPercentage);
	}
	catch(...) {}

	// default to single-server install type
	string OserverTypeInstall = oam.itoa(oam::INSTALL_COMBINE_DM_UM_PM);;
	string NserverTypeInstall;
	string OSingleServerInstall = "y";
	int    IserverTypeInstall;

	try {
		OserverTypeInstall = sysConfigOld->getConfig(InstallSection, "ServerTypeInstall");
		OSingleServerInstall = sysConfigOld->getConfig(InstallSection, "SingleServerInstall");
	}
	catch(...)
	{
		// default to Normal mult-server install type
		OserverTypeInstall = oam.itoa(oam::INSTALL_COMBINE_DM_UM_PM);
		OSingleServerInstall = "y";
	}

	// set Server Installation Type
	try {
		sysConfigNew->setConfig(InstallSection, "ServerTypeInstall", OserverTypeInstall);
		sysConfigNew->setConfig(InstallSection, "SingleServerInstall", OSingleServerInstall);
	}
	catch(...)
	{}

	NserverTypeInstall = OserverTypeInstall;

	IserverTypeInstall = atoi(NserverTypeInstall.c_str());

	//set RotatingDestination
	switch ( IserverTypeInstall ) {
		case (oam::INSTALL_COMBINE_DM_UM_PM):	// combined #1 - dm/um/pm on a single server
		{
			try {
				sysConfigNew->setConfig("PrimitiveServers", "RotatingDestination", "n");
			}
			catch(...)
			{
				cout << "ERROR: Problem setting RotatingDestination in the Calpont System Configuration file" << endl;
				exit(-1);
			}

			break;
		}
	}

	string parentOAMModuleType = systemParentOAMModuleName.substr(0,MAX_MODULE_TYPE_SIZE);

	//
	// get Data storage Mount
	//

	string DBRootStorageType;

	int DBRootCount;
	string deviceName;

	try {
		DBRootStorageType = sysConfigOld->getConfig(InstallSection, "DBRootStorageType");
		DBRootCount = strtol(sysConfigOld->getConfig(SystemSection, "DBRootCount").c_str(), 0, 0);
	}
	catch(...)
	{
		cout << "ERROR: Problem getting DB Storage Data from the Calpont System Configuration file" << endl;
		exit(-1);
	}

	// 2.2 to 3.x+ DBRootStorageTypeconversion
	if ( DBRootStorageType == "local" )
		DBRootStorageType = "internal";

	if ( DBRootStorageType == "storage" )
		DBRootStorageType = "external";

	try {
		sysConfigNew->setConfig(InstallSection, "DBRootStorageType", DBRootStorageType);
	}
	catch(...)
	{
		cout << "ERROR: Problem setting DBRootStorageType in the Calpont System Configuration file" << endl;
		exit(-1);
	}

	try {
		sysConfigNew->setConfig(SystemSection, "DBRootCount", oam.itoa(DBRootCount));
	}
	catch(...)
	{
		cout << "ERROR: Problem setting DBRoot Count in the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//
	//Update memory and cache settings
	//

	string NumBlocksPct;
	try {
		NumBlocksPct = sysConfigOld->getConfig("DBBC", "NumBlocksPct");
	}
	catch(...)
	{ }

	if ( ( NumBlocksPct.empty() || NumBlocksPct == "" ) &&
		IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) {
		NumBlocksPct = "50";
	}

	if ( !( NumBlocksPct.empty() || NumBlocksPct == "" ) ) {
		try {
			sysConfigNew->setConfig("DBBC", "NumBlocksPct", NumBlocksPct);
		}
		catch(...)
		{}
	}

	string TotalUmMemory;
	try {
		TotalUmMemory = sysConfigOld->getConfig("HashJoin", "TotalUmMemory");
	}
	catch(...)
	{ }

	try {
		 sysConfigNew->setConfig("HashJoin", "TotalUmMemory", TotalUmMemory);
	}
	catch(...)
	{}

	string strNumThreads;
    try {
        strNumThreads = sysConfigOld->getConfig("DBBC", "NumThreads");
    }
    catch(...)
    { }

    if ( !( strNumThreads.empty() || strNumThreads == "" ) ) {
        try {
            sysConfigNew->setConfig("DBBC", "NumThreads", strNumThreads);
        }
        catch(...)
        {}
    }

    sysConfigNew->write();

	//Get list of configured system modules
	SystemModuleTypeConfig sysModuleTypeConfig;

	try{
		oam.getSystemConfig(sysModuleTypeConfig);
	}
	catch(...)
	{
		cout << "ERROR: Problem reading the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//
	// Module Configuration
	//
	string ModuleSection = "SystemModuleConfig";
	unsigned int maxPMNicCount = 1;

	for ( unsigned int i = 0 ; i < sysModuleTypeConfig.moduletypeconfig.size(); i++)
	{
		string moduleType = sysModuleTypeConfig.moduletypeconfig[i].ModuleType;
		string moduleDesc = sysModuleTypeConfig.moduletypeconfig[i].ModuleDesc;
		int moduleCount = sysModuleTypeConfig.moduletypeconfig[i].ModuleCount;

		//verify and setup of modules count
		switch ( IserverTypeInstall ) {
			case (oam::INSTALL_COMBINE_DM_UM_PM):
			{
				if ( moduleType == "um" ) {
					moduleCount = 0;

					try {
						string ModuleCountParm = "ModuleCount" + oam.itoa(i+1);
						sysConfigNew->setConfig(ModuleSection, ModuleCountParm, oam.itoa(moduleCount));
						continue;
					}
					catch(...)
					{
						cout << "ERROR: Problem setting Module Count in the Calpont System Configuration file" << endl;
						exit(-1);
					}
				}
				else
				{
					try {
						string ModuleCountParm = "ModuleCount" + oam.itoa(i+1);
						sysConfigNew->setConfig(ModuleSection, ModuleCountParm, oam.itoa(moduleCount));
					}
					catch(...)
					{
						cout << "ERROR: Problem setting Module Count in the Calpont System Configuration file" << endl;
						exit(-1);
					}
				}

				break;
			}
			default:
			{
				try {
					string ModuleCountParm = "ModuleCount" + oam.itoa(i+1);
					sysConfigNew->setConfig(ModuleSection, ModuleCountParm, oam.itoa(moduleCount));
				}
				catch(...)
				{
					cout << "ERROR: Problem setting Module Count in the Calpont System Configuration file" << endl;
					exit(-1);
				}
				break;
			}
		}

		if ( moduleCount == 0 )
			//no modules equipped for this Module Type, skip
			continue;

		if ( moduleType == "pm" )
			pmNumber = moduleCount;

		//get Module Name IP addresses and Host Names
		DeviceNetworkList::iterator listPT = sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.begin();
		for( ; listPT != sysModuleTypeConfig.moduletypeconfig[i].ModuleNetworkList.end() ; listPT++)
		{
			PerformanceModule performancemodule;
			string moduleName = (*listPT).DeviceName;
			int moduleID = atoi(moduleName.substr(MAX_MODULE_TYPE_SIZE,MAX_MODULE_ID_SIZE).c_str());

			string moduleDisableState = (*listPT).DisableState;
			if ( moduleDisableState.empty() ||
				moduleDisableState == oam::UnassignedName )
				moduleDisableState = oam::ENABLEDSTATE;

			if ( moduleDisableState == oam::AUTODISABLEDSTATE )
				moduleDisableState == oam::ENABLEDSTATE;

			//set Module Disable State
			string moduleDisableStateParm = "ModuleDisableState" + oam.itoa(moduleID) + "-" + oam.itoa(i+1);
			try {
				sysConfigNew->setConfig(ModuleSection, moduleDisableStateParm, moduleDisableState);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting ModuleDisableState in the Calpont System Configuration file for " + moduleName << endl;
				exit(-1);
			}
	
			for( unsigned int nicID=1 ; nicID < MAX_NIC+1 ; nicID++ )
			{
				string moduleIPAddr = oam::UnassignedIpAddr;
				string moduleHostName = oam::UnassignedName;

				HostConfigList::iterator pt1 = (*listPT).hostConfigList.begin();
				for( ; pt1 != (*listPT).hostConfigList.end() ; pt1++)
				{
					if ( moduleName == (*listPT).DeviceName && (*pt1).NicID == nicID) {
						moduleIPAddr = (*pt1).IPAddr;
						moduleHostName = (*pt1).HostName;
						break;
					}
				}

				if (moduleHostName.empty() || (moduleHostName == oam::UnassignedName) )
					// exit out to next module ID
					break;

				if (moduleIPAddr.empty())
					moduleIPAddr = oam::UnassignedIpAddr;
		
				string moduleNameDesc = moduleDesc + " #" + oam.itoa(moduleID);
	
				//set New Module Host Name
				string moduleHostNameParm = "ModuleHostName" + oam.itoa(moduleID) + "-" + oam.itoa(nicID) + "-" + oam.itoa(i+1);
				try {
					sysConfigNew->setConfig(ModuleSection, moduleHostNameParm, moduleHostName);
				}
				catch(...)
				{
					cout << "ERROR: Problem setting Host Name in the Calpont System Configuration file" << endl;
					exit(-1);
				}
	
				//set Module IP address
				string moduleIPAddrNameParm = "ModuleIPAddr" + oam.itoa(moduleID) + "-" + oam.itoa(nicID) + "-" + oam.itoa(i+1);
				try {
					sysConfigNew->setConfig(ModuleSection, moduleIPAddrNameParm, moduleIPAddr);
				}
				catch(...)
				{
					cout << "ERROR: Problem setting IP address in the Calpont System Configuration file" << endl;
					exit(-1);
				}

				if ( moduleType == "pm" && moduleDisableState == oam::ENABLEDSTATE  ) {
	
					switch(nicID) {
						case 1:
							performancemodule.moduleIP1 = moduleIPAddr;
							break;
						case 2:
							performancemodule.moduleIP2 = moduleIPAddr;
							break;
						case 3:
							performancemodule.moduleIP3 = moduleIPAddr;
							break;
						case 4:
							performancemodule.moduleIP4 = moduleIPAddr;
							break;
					}
					if ( maxPMNicCount < nicID )
						maxPMNicCount = nicID;
				}

				if ( nicID > 1 )
					continue;
	
				//set port addresses
				if ( moduleName == systemParentOAMModuleName ) {
					parentOAMModuleIPAddr = moduleIPAddr;
	
				//exit out if parentOAMModuleIPAddr is NOT set, this means the System Calpont.xml isn't configured
					if ( parentOAMModuleIPAddr == "0.0.0.0" ) {
						cout << "ERROR: System Calpont.xml not configured" << endl;
						exit(-1);
					}

					//set Parent Processes Port IP Address
					string parentProcessMonitor = systemParentOAMModuleName + "_ProcessMonitor";
					sysConfigNew->setConfig(parentProcessMonitor, "IPAddr", parentOAMModuleIPAddr);
					sysConfigNew->setConfig(parentProcessMonitor, "Port", "8800");
					sysConfigNew->setConfig("ProcMgr", "IPAddr", parentOAMModuleIPAddr);
					sysConfigNew->setConfig("ProcStatusControl", "IPAddr", parentOAMModuleIPAddr);
					string parentServerMonitor = systemParentOAMModuleName + "_ServerMonitor";
					sysConfigNew->setConfig(parentServerMonitor, "IPAddr", parentOAMModuleIPAddr);
					sysConfigNew->setConfig(parentServerMonitor, "Port", "8622");

					if (build3) {
						string portName = systemParentOAMModuleName + "_WriteEngineServer";
						sysConfigNew->setConfig(portName, "IPAddr", parentOAMModuleIPAddr);
						sysConfigNew->setConfig(portName, "Port", "8630");
					}
					else
					{
						sysConfigNew->setConfig("DDLProc", "IPAddr", parentOAMModuleIPAddr);
						sysConfigNew->setConfig("DMLProc", "IPAddr", parentOAMModuleIPAddr);
					}

					if ( IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) {

						//set User Module's IP Addresses
						string Section = "ExeMgr" + oam.itoa(moduleID);
		
						sysConfigNew->setConfig(Section, "IPAddr", moduleIPAddr);
						sysConfigNew->setConfig(Section, "Port", "8601");

						//set Performance Module's IP's to first NIC IP entered
						sysConfigNew->setConfig("DDLProc", "IPAddr", moduleIPAddr);
						sysConfigNew->setConfig("DMLProc", "IPAddr", moduleIPAddr);
					}
				}
				else
				{
					//set child Process Monitor Port IP Address
					string portName = moduleName + "_ProcessMonitor";
					sysConfigNew->setConfig(portName, "IPAddr", moduleIPAddr);
					sysConfigNew->setConfig(portName, "Port", "8800");

					//set child Server Monitor Port IP Address
					portName = moduleName + "_ServerMonitor";
					sysConfigNew->setConfig(portName, "IPAddr", moduleIPAddr);
					sysConfigNew->setConfig(portName, "Port", "8622");
	
					//set Performance Module WriteEngineServer Port IP Address
					if ( moduleType == "pm" && build3) {
						portName = moduleName + "_WriteEngineServer";
						sysConfigNew->setConfig(portName, "IPAddr", moduleIPAddr);
						sysConfigNew->setConfig(portName, "Port", "8630");
					}
	
					//set User Module's IP Addresses
					if ( moduleType == "um" ||
						( moduleType == "pm" && IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) ) {

						string Section = "ExeMgr" + oam.itoa(moduleID);
	
						sysConfigNew->setConfig(Section, "IPAddr", moduleIPAddr);
						sysConfigNew->setConfig(Section, "Port", "8601");
					}
				}
				
				//set Performance Module's IP's to first NIC IP entered
				if ( moduleName == "um1" && build3) {
					sysConfigNew->setConfig("DDLProc", "IPAddr", moduleIPAddr);
					sysConfigNew->setConfig("DMLProc", "IPAddr", moduleIPAddr);
				}

				//setup DBRM processes
				if ( moduleName == systemParentOAMModuleName )
					sysConfigNew->setConfig(dbrmMainProc, "IPAddr", moduleIPAddr);

				if ( moduleDisableState == oam::ENABLEDSTATE ) {
					DBRMworkernodeID++;
					string DBRMSection = dbrmSubProc + oam.itoa(DBRMworkernodeID);
					sysConfigNew->setConfig(DBRMSection, "IPAddr", moduleIPAddr);
					sysConfigNew->setConfig(DBRMSection, "Module", moduleName);
				}
			} //end of nicID loop

			//set dbroot assigments
			DeviceDBRootList::iterator pt3 = sysModuleTypeConfig.moduletypeconfig[i].ModuleDBRootList.begin();
			for( ; pt3 != sysModuleTypeConfig.moduletypeconfig[i].ModuleDBRootList.end() ; pt3++)
			{
				if ( (*pt3).dbrootConfigList.size() > 0 )
				{
					int moduleID = (*pt3).DeviceID;

					DBRootConfigList::iterator pt4 = (*pt3).dbrootConfigList.begin();

					int dbrootCount = (*pt3).dbrootConfigList.size();
					string moduleCountParm = "ModuleDBRootCount" + oam.itoa(moduleID) + "-" + oam.itoa(i+1);
					try {
						sysConfigNew->setConfig(ModuleSection, moduleCountParm, oam.itoa(dbrootCount));
					}
					catch(...)
					{
						cout << "ERROR: Problem setting Host Name in the Calpont System Configuration file" << endl;
						exit(-1);
					}

					int entry = 1;
					for( ; pt4 != (*pt3).dbrootConfigList.end() ; pt4++, entry++)
					{
						int dbrootid = *pt4;
		
						string moduleDBRootIDParm = "ModuleDBRootID" + oam.itoa(moduleID) + "-" + oam.itoa(entry) + "-" + oam.itoa(i+1);
						try {
							sysConfigNew->setConfig(ModuleSection, moduleDBRootIDParm, oam.itoa(dbrootid));
						}
						catch(...)
						{
							cout << "ERROR: Problem setting Host Name in the Calpont System Configuration file" << endl;
							exit(-1);
						}
					}
				}
			}

			//assign any unassigned dbroots to pm1 on pre build3 upgrades
			if (!build3) {
				//get any unassigned DBRoots
				DBRootConfigList undbrootlist;
				try {
					oam.getUnassignedDbroot(undbrootlist);
				}
				catch(...) {}

				if ( !undbrootlist.empty() )
				{
					string dbrootCount;

					int entry = 1;
					DBRootConfigList::iterator pt1 = undbrootlist.begin();
					for( ; pt1 != undbrootlist.end() ; pt1++ )
					{
						//skip dbroot #1, already setup
						if ( *pt1 == 1 )
							continue;

						entry++;

						string moduleDBRootIDParm = "ModuleDBRootID1-" + oam.itoa(entry) + "-3";
						try {
							sysConfigNew->setConfig(ModuleSection, moduleDBRootIDParm, oam.itoa(*pt1));
						}
						catch(...)
						{
							cout << "ERROR: Problem setting Host Name in the Calpont System Configuration file" << endl;
							exit(-1);
						}
					}

					string moduleCountParm = "ModuleDBRootCount1-3";
					try {
						sysConfigNew->setConfig(ModuleSection, moduleCountParm, oam.itoa(entry));
					}
					catch(...)
					{
						cout << "ERROR: Problem setting Host Name in the Calpont System Configuration file" << endl;
						exit(-1);
					}
				}
			}

			if ( ( moduleType == "pm" && moduleDisableState == oam::ENABLEDSTATE ) ||
				( IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) )
				performancemodulelist.push_back(performancemodule);
		} //end of module loop

		sysConfigNew->write();

	} //end of i for loop

	if ( performancemodulelist.size() == 0 )
	{
		cout << "ERROR: performancemodulelist is empty, exiting..." << endl;
		exit(-1);
	}

	//set dm count to 0 always
	try {
		sysConfigNew->setConfig(ModuleSection, "ModuleCount1", "0");
	}
	catch(...)
	{
		cout << "ERROR: Problem setting Module Count in the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//setup DBRM Controller
	sysConfigNew->setConfig(dbrmMainProc, numSubProc, oam.itoa(DBRMworkernodeID));

	//setup PrimitiveServers parameters
	try {
		sysConfigNew->setConfig("PrimitiveServers", "ConnectionsPerPrimProc", oam.itoa(maxPMNicCount*2));
	}
	catch(...)
	{
		cout << "ERROR: Problem setting ConnectionsPerPrimProc in the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//set the PM Ports based on Number of PM modules equipped, if any equipped
	int minPmPorts = 32;
	sysConfigNew->setConfig("PrimitiveServers", "Count", oam.itoa(pmNumber));

	int pmPorts = pmNumber * (maxPMNicCount*2);
	if ( pmPorts < minPmPorts )
		pmPorts = minPmPorts;

	if ( pmNumber > 0 || 
		( IserverTypeInstall == oam::INSTALL_COMBINE_DM_UM_PM ) )
	{
		const string PM = "PMS";

		for ( int pmsID = 1; pmsID < pmPorts+1 ; )
		{
			for (unsigned int j = 1 ; j < maxPMNicCount+1 ; j++)
			{
				PerformanceModuleList::iterator list1 = performancemodulelist.begin();
		
				for (; list1 != performancemodulelist.end() ; list1++)
				{
					string pmName = PM + oam.itoa(pmsID);
					string IpAddr;
					switch(j) {
						case 1:
							IpAddr = (*list1).moduleIP1;
							break;
						case 2:
							IpAddr = (*list1).moduleIP2;
							break;
						case 3:
							IpAddr = (*list1).moduleIP3;
							break;
						case 4:
							IpAddr = (*list1).moduleIP4;
							break;
					}
					if ( !IpAddr.empty() && IpAddr != oam::UnassignedIpAddr ) {
						sysConfigNew->setConfig(pmName, "IPAddr", IpAddr);
						pmsID++;
						if ( pmsID > pmPorts )
							break;
					}
				}
				if ( pmsID > pmPorts )
					break;
			}
		}
	}

	sysConfigNew->write();

	//
	// Configure Ext Devices
	//
	SystemExtDeviceConfig systemextdeviceconfig;

	try{
		oam.getSystemConfig(systemextdeviceconfig);
	}
	catch(...)
	{
		cout << "ERROR: Problem reading the Calpont System Configuration file" << endl;
		exit(-1);
	}

	if ( systemextdeviceconfig.Count > 0 ) {

        const string NAME = "Name";
        const string IPADDR = "IPAddr";
        const string DISABLE_STATE = "DisableState";

		sysConfigNew->setConfig("SystemExtDeviceConfig", "Count", oam.itoa(systemextdeviceconfig.Count));

		for ( unsigned int i = 0 ; i < systemextdeviceconfig.Count ; i++ )
		{
			string name = NAME + oam.itoa(i+1);
			string ipaddr = IPADDR + oam.itoa(i+1);
			string disablestate = DISABLE_STATE + oam.itoa(i+1);
	
			sysConfigNew->setConfig("SystemExtDeviceConfig", name, systemextdeviceconfig.extdeviceconfig[i].Name);
			sysConfigNew->setConfig("SystemExtDeviceConfig", ipaddr, systemextdeviceconfig.extdeviceconfig[i].IPAddr);
			sysConfigNew->setConfig("SystemExtDeviceConfig", disablestate, systemextdeviceconfig.extdeviceconfig[i].DisableState);
		}
	}

	sysConfigNew->write();


	//
	// Configure NMS Addresses
	//

	string NMSIPAddress;
	try {
		NMSIPAddress = sysConfigOld->getConfig(SystemSection, "NMSIPAddress");
	}
	catch(...)
	{
		cout << "ERROR: Problem getting NMSIPAddress from Calpont System Configuration file" << endl;
		exit(-1);
	}

	try {
		sysConfigNew->setConfig(SystemSection, "NMSIPAddress", NMSIPAddress);
	}
	catch(...)
	{
		cout << "ERROR: Problem setting NMSIPAddress in the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//
	// setup TransactionArchivePeriod
	//

	string transactionArchivePeriod;
	try {
		transactionArchivePeriod = sysConfigOld->getConfig(SystemSection, "TransactionArchivePeriod");
	}
	catch(...)
	{
		cout << "ERROR: Problem getting transactionArchivePeriod from Calpont System Configuration file" << endl;
		exit(-1);
	}

	try {
		sysConfigNew->setConfig(SystemSection, "TransactionArchivePeriod", transactionArchivePeriod);
	}
	catch(...)
	{
		cout << "ERROR: Problem setting IP address in the Calpont System Configuration file" << endl;
		exit(-1);
	}

	//
	// 3.0 sn configuration items
	// 
	if (build3) {
		//setup cloud parameters
		string x509Cert;
		string x509PriKey;
		string UMStorageType;
		string rpw;
		string PMInstanceType;
		string UMInstanceType;
		string UMSecurityGroup;
		string UMVolumeSize;
		string PMVolumeSize;
		string UMAutoSync;
		string UMSyncTime;
		string AmazonAutoTagging;
		string AmazonRegion;

		try {
			x509Cert = sysConfigOld->getConfig(InstallSection, "AmazonX509Certificate");
			x509PriKey = sysConfigOld->getConfig(InstallSection, "AmazonX509PrivateKey");
			UMStorageType = sysConfigOld->getConfig(InstallSection, "UMStorageType");
			rpw = sysConfigOld->getConfig(InstallSection, "rpw");
			PMInstanceType = sysConfigOld->getConfig(InstallSection, "PMInstanceType");
			UMInstanceType = sysConfigOld->getConfig(InstallSection, "UMInstanceType");
			UMSecurityGroup = sysConfigOld->getConfig(InstallSection, "UMSecurityGroup");
			UMVolumeSize = sysConfigOld->getConfig(InstallSection, "UMVolumeSize");
			PMVolumeSize = sysConfigOld->getConfig(InstallSection, "PMVolumeSize");
			UMAutoSync = sysConfigOld->getConfig(InstallSection, "UMAutoSync");
			UMSyncTime = sysConfigOld->getConfig(InstallSection, "UMSyncTime");
			AmazonAutoTagging = sysConfigOld->getConfig(InstallSection, "AmazonAutoTagging");
			AmazonRegion = sysConfigOld->getConfig(InstallSection, "AmazonRegion");
		}
		catch(...)
		{ }
	
		if ( cloud == "no" )
			cloud = "n";
	
		try {
			sysConfigNew->setConfig(InstallSection, "Cloud", cloud);
			sysConfigNew->setConfig(InstallSection, "AmazonX509Certificate", x509Cert);
			sysConfigNew->setConfig(InstallSection, "AmazonX509PrivateKey", x509PriKey);
			sysConfigNew->setConfig(InstallSection, "UMStorageType", UMStorageType);
			sysConfigNew->setConfig(InstallSection, "rpw", rpw);
			sysConfigNew->setConfig(InstallSection, "PMInstanceType", PMInstanceType);
			sysConfigNew->setConfig(InstallSection, "UMInstanceType", UMInstanceType);
			sysConfigNew->setConfig(InstallSection, "UMSecurityGroup", UMSecurityGroup);
			sysConfigNew->setConfig(InstallSection, "UMVolumeSize", UMVolumeSize);
			sysConfigNew->setConfig(InstallSection, "PMVolumeSize", PMVolumeSize);
			sysConfigNew->setConfig(InstallSection, "UMAutoSync", UMAutoSync);
			sysConfigNew->setConfig(InstallSection, "UMSyncTime", UMSyncTime);
			sysConfigNew->setConfig(InstallSection, "AmazonAutoTagging", AmazonAutoTagging);
			sysConfigNew->setConfig(InstallSection, "AmazonRegion", AmazonRegion);
		}
		catch(...)
		{
	//		cout << "ERROR: Problem setting Cloud Parameters from the Calpont System Configuration file" << endl;
	//		exit(-1);
		}

		//setup um storage
		if ( cloud == "amazon" && UMStorageType == "external") {
            try
            {
                systemStorageInfo_t t;
                t = oam.getStorageConfig();

				ModuleTypeConfig moduletypeconfig;
				oam.getSystemConfig("um", moduletypeconfig);
				for ( int id = 1; id < moduletypeconfig.ModuleCount+1 ; id++)
				{
					string volumeNameID = "UMVolumeName" + oam.itoa(id);
					string volumeName = oam::UnassignedName;
					string deviceNameID = "UMVolumeDeviceName" + oam.itoa(id);
					string deviceName = oam::UnassignedName;
					try {
						volumeName = sysConfigOld->getConfig(InstallSection, volumeNameID);
						deviceName = sysConfigOld->getConfig(InstallSection, deviceNameID);
					}
					catch(...)
					{}
	
					try {
						sysConfigNew->setConfig(InstallSection, volumeNameID, volumeName);
						sysConfigNew->setConfig(InstallSection, deviceNameID, deviceName);
					}
					catch(...)
					{}
				}
			}
            catch (exception& e)
            {
                cout << endl << "**** getStorageConfig Failed :  " << e.what() << endl;
            }
		}

		//setup dbroot storage
		try
		{
			DBRootConfigList dbrootConfigList;
			oam.getSystemDbrootConfig(dbrootConfigList);
	
			DBRootConfigList::iterator pt = dbrootConfigList.begin();
			for( ; pt != dbrootConfigList.end() ; pt++)
			{
				int id = *pt;
				string DBrootID = "DBRoot" + oam.itoa(id);;
				string pathID =  "/usr/local/Calpont/data" + oam.itoa(id);
		
				try {
					sysConfigNew->setConfig(SystemSection, DBrootID, pathID);
				}
				catch(...)
				{
					cout << "ERROR: Problem setting DBRoot in the Calpont System Configuration file" << endl;
					exit(-1);
				}
	
				if ( cloud == "amazon" && DBRootStorageType == "external") {
	
					string volumeNameID = "PMVolumeName" + oam.itoa(id);
					string volumeName = oam::UnassignedName;
					string deviceNameID = "PMVolumeDeviceName" + oam.itoa(id);
					string deviceName = oam::UnassignedName;
					try {
						volumeName = sysConfigOld->getConfig(InstallSection, volumeNameID);
						deviceName = sysConfigOld->getConfig(InstallSection, deviceNameID);
					}
					catch(...)
					{}
	
					try {
						sysConfigNew->setConfig(InstallSection, volumeNameID, volumeName);
						sysConfigNew->setConfig(InstallSection, deviceNameID, deviceName);
					}
					catch(...)
					{}
				}
			}
		}
		catch (exception& e)
		{
			cout << endl << "**** getSystemDbrootConfig Failed :  " << e.what() << endl;
		}

		//setup unassigned dbroots
		try
		{
			DBRootConfigList dbrootConfigList;
			oam.getUnassignedDbroot(dbrootConfigList);
	
			DBRootConfigList::iterator pt = dbrootConfigList.begin();
			for( ; pt != dbrootConfigList.end() ; pt++)
			{
				int id = *pt;
				string DBrootID = "DBRoot" + oam.itoa(id);;
				string pathID =  "/usr/local/Calpont/data" + oam.itoa(id);
		
				try {
					sysConfigNew->setConfig(SystemSection, DBrootID, pathID);
				}
				catch(...)
				{
					cout << "ERROR: Problem setting DBRoot in the Calpont System Configuration file" << endl;
					exit(-1);
				}
	
				if ( cloud == "amazon" && DBRootStorageType == "external") {
	
					string volumeNameID = "VolumeName" + oam.itoa(id);
					string volumeName = oam::UnassignedName;
					string deviceNameID = "VolumeDeviceName" + oam.itoa(id);
					string deviceName = oam::UnassignedName;
					try {
						volumeName = sysConfigOld->getConfig(InstallSection, volumeNameID);
						deviceName = sysConfigOld->getConfig(InstallSection, deviceNameID);
					}
					catch(...)
					{}
	
					try {
						sysConfigNew->setConfig(InstallSection, volumeNameID, volumeName);
						sysConfigNew->setConfig(InstallSection, deviceNameID, deviceName);
					}
					catch(...)
					{}
	
				}
			}
		}
		catch (exception& e)
		{
			cout << endl << "**** getUnassignedDbroot Failed :  " << e.what() << endl;
		}

		
	}
	else
	{ // pre 3.0 only

		string DBRootStorageLoc;
		for( int i=1 ; i < DBRootCount+1 ; i++)
		{
			if ( DBRootStorageType != "local") {
	
				string DBRootStorageLocID = "DBRootStorageLoc" + oam.itoa(i);
				try {
					DBRootStorageLoc = sysConfigOld->getConfig(InstallSection, DBRootStorageLocID);
				}
				catch(...)
				{
					cout << "ERROR: Problem getting '" + DBRootStorageLocID + "' from the Calpont System Configuration file" << endl;
					exit(-1);
				}
		
				try {
					sysConfigNew->setConfig(InstallSection, DBRootStorageLocID, DBRootStorageLoc);
				}
				catch(...)
				{
					cout << "ERROR: Problem setting '" + DBRootStorageLocID + "' in the Calpont System Configuration file" << endl;
					exit(-1);
				}
			}
	
			string DBrootID = "DBRoot" + oam.itoa(i);
			string pathID =  "/usr/local/Calpont/data" + oam.itoa(i);
	
			try {
				sysConfigNew->setConfig(SystemSection, DBrootID, pathID);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting DBRoot in the Calpont System Configuration file" << endl;
				exit(-1);
			}
		}
	}

	//do elastic IP configuration
	int AmazonElasticIPCount = 0;
	try {
		AmazonElasticIPCount = atoi(sysConfigOld->getConfig(InstallSection, "AmazonElasticIPCount").c_str());

		if (AmazonElasticIPCount > 0 )
		{
			for ( int id = 1 ; id < AmazonElasticIPCount+1 ; id++ )
			{
				string AmazonElasticModule = "AmazonElasticModule" + oam.itoa(id);
				string ELmoduleName;
				string AmazonElasticIPAddr = "AmazonElasticIPAddr" + oam.itoa(id);
				string ELIPaddress;

				ELmoduleName = sysConfigOld->getConfig(InstallSection, AmazonElasticModule);
				ELIPaddress = sysConfigOld->getConfig(InstallSection, AmazonElasticIPAddr);

				try {
					sysConfigNew->setConfig(InstallSection, "AmazonElasticIPCount", oam.itoa(AmazonElasticIPCount));
					sysConfigNew->setConfig(InstallSection, AmazonElasticModule, ELmoduleName);
					sysConfigNew->setConfig(InstallSection, AmazonElasticIPAddr, ELIPaddress);
				}
				catch(...)
				{}
			}
		}
	}
	catch(...)
	{}

	try{
		oam.getSystemConfig("AmazonElasticIPCount", AmazonElasticIPCount);
	}
	catch(...) {
		AmazonElasticIPCount = 0;
	}

	// ConcurrentTransactions
	string ConcurrentTransactions;
	try {
		ConcurrentTransactions = sysConfigOld->getConfig(SystemSection, "ConcurrentTransactions");

		if ( !ConcurrentTransactions.empty() )
		{
			try {
				sysConfigNew->setConfig(SystemSection, "ConcurrentTransactions", ConcurrentTransactions);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting ConcurrentTransactions in the Calpont System Configuration file" << endl;
				exit(-1);
			}
		}
	}
	catch(...)
	{}

	// NetworkCompression Enabled
	string NetworkCompression;
	try {
		NetworkCompression = sysConfigOld->getConfig("NetworkCompression", "Enabled");

		if ( !NetworkCompression.empty() )
		{
			try {
				sysConfigNew->setConfig("NetworkCompression", "Enabled", NetworkCompression);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting NetworkCompression in the Calpont System Configuration file" << endl;
				exit(-1);
			}
		}
	}
	catch(...)
	{}

	// CoreFile Flag
	string CoreFileFlag;
	try {
		CoreFileFlag = sysConfigOld->getConfig("Installation", "CoreFileFlag");

		if ( !CoreFileFlag.empty() )
		{
			try {
				sysConfigNew->setConfig("Installation", "CoreFileFlag", CoreFileFlag);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting CoreFileFlag in the Calpont System Configuration file" << endl;
				exit(-1);
			}
		}
	}
	catch(...)
	{}

	//hadoop
	string DataFilePlugin;
	try {
		DataFilePlugin = sysConfigOld->getConfig(SystemSection, "DataFilePlugin");

		if ( !DataFilePlugin.empty() )
		{
			try {
				sysConfigNew->setConfig(SystemSection, "DataFilePlugin", DataFilePlugin);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting DataFilePlugin in the Calpont System Configuration file" << endl;
				exit(-1);
			}

			string DataFileEnvFile;
			try {
				DataFileEnvFile = sysConfigOld->getConfig(SystemSection, "DataFileEnvFile");
		
				if ( !DataFileEnvFile.empty() )
				{
					try {
						sysConfigNew->setConfig(SystemSection, "DataFileEnvFile", DataFileEnvFile);
					}
					catch(...)
					{
						cout << "ERROR: Problem setting DataFileEnvFile in the Calpont System Configuration file" << endl;
						exit(-1);
					}
				}
				else
				{
					if ( DataFilePlugin == "/usr/local/Calpont/lib/hdfs-20.so" )
						DataFileEnvFile = "setenv-hdfs-20";
					else
						DataFileEnvFile = "setenv-hdfs-12";

					try {
						sysConfigNew->setConfig(SystemSection, "DataFileEnvFile", DataFileEnvFile);
					}
					catch(...)
					{
						cout << "ERROR: Problem setting DataFileEnvFile in the Calpont System Configuration file" << endl;
						exit(-1);
					}
				}
			}
			catch(...)
			{}

			string ExtentsPerSegmentFile;
			try {
				ExtentsPerSegmentFile = sysConfigOld->getConfig("ExtentMap", "ExtentsPerSegmentFile");
		
				try {
					sysConfigNew->setConfig("ExtentMap", "ExtentsPerSegmentFile", ExtentsPerSegmentFile);
				}
				catch(...)
				{
					cout << "ERROR: Problem setting ExtentsPerSegmentFile in the Calpont System Configuration file" << endl;
					exit(-1);
				}
			}
			catch(...)
			{}
		}
	}
	catch(...)
	{}

	string DataFileLog;
	try {
		DataFileLog = sysConfigOld->getConfig(SystemSection, "DataFileLog");

		if ( !DataFileLog.empty() )
		{
			try {
				sysConfigNew->setConfig(SystemSection, "DataFileLog", DataFileLog);
			}
			catch(...)
			{
				cout << "ERROR: Problem setting DataFileLog in the Calpont System Configuration file" << endl;
				exit(-1);
			}
		}
	}
	catch(...)
	{}



	//Write out Updated System Configuration File
	sysConfigNew->write();
}
Exemple #28
0
int main(int argc, char *argv[])
{
	Oam oam;
	vector <string> queryDirectory;
	vector <string> queryID;

	// get latest set of svn queries
//	system("rm -rf /root/genii/ > /dev/null 2>&1");
	system("updateGenii.pl > /dev/null 2>&1");

	system("rm -rf /home/qa/bldqry/mysql/* > /dev/null 2>&1");

	string cronFile = "/root/calpontBuildTest";
	unlink(cronFile.c_str());

	// get query directory list
	string topQueryfileName = "/tmp/topQuerydirs";
	string secondQueryfileName = "/tmp/secondQuerydirs";
	string queryfileName = "/home/qa/bldqry/mysql/querydirs";

	string cmd = "ls /root/genii/mysql/queries/. > " + topQueryfileName;
	system(cmd.c_str());

	ifstream file (topQueryfileName.c_str());
	if (!file) {
		cout << " Error: can't open " + topQueryfileName << endl;
		exit (-1);
	}

	char line[200];
	string topQueryDir;
	while (file.getline(line, 200))
	{
		topQueryDir = line;
		if ( topQueryDir.find("queryTester",0) != string::npos || topQueryDir == "Makefile" )
			continue;

		// only do working queries for now
		if ( topQueryDir.find("working",0) == string::npos)
			continue;

		string cmd = "ls /root/genii/mysql/queries/" + topQueryDir + "/. > " + secondQueryfileName;
		system(cmd.c_str());
	
		ifstream file (secondQueryfileName.c_str());
		if (file) {
			char line[200];
			string buf;
			while (file.getline(line, 200))
			{
				buf = line;
				if ( buf.empty() )
					continue;
				string tempdir =  topQueryDir + "/" + buf;
				queryDirectory.push_back(tempdir);
			}
		}
		file.close();
	}

	file.close();

	if ( queryDirectory.size() == 0 ) {
		cout << endl << "Error: no query sub-directories located" << endl;
		exit (-1);
	}

	// get query list for each query directory
	int test = 1;
	std::vector<std::string>::iterator pt1 = queryDirectory.begin();
	for( ; pt1 != queryDirectory.end() ; pt1++)
	{
		string directory = *pt1;
		string::size_type pos = directory.find("/",0);
		if (pos != string::npos)
		{
			string setName;
			setName = directory.substr(0, pos);
			setName = setName + "-";
			setName = setName + directory.substr(pos+1, 200);
		
			string cmd = "cd /home/qa/bldqry/mysql/;echo " + setName + ".sql > " + oam.itoa(test) + ".txt";
			system(cmd.c_str());
			queryID.push_back(oam.itoa(test));
			test++;
	
			cmd = "rm -f /home/qa/bldqry/mysql/" + setName + ".sql";
			system(cmd.c_str());
	
			cmd = "cat /root/genii/mysql/queries/" + directory + "/*.sql >> /home/qa/bldqry/mysql/" + setName +  ".sql";
			system(cmd.c_str());
		}
	}

	// setup calpontBuildTest cron job with directories
	string cronFileTemplate = "/root/calpontBuildTest.template";

	ifstream cfile (cronFileTemplate.c_str());
	if (!cfile) {
		cout << endl << "Error: " + cronFileTemplate + " not found" << endl;
		exit (-1);
	}

	vector <string> lines;
	string newLine;
	string buf;
	while (cfile.getline(line, 200))
	{
		buf = line;
		string::size_type pos = buf.find("buildTester",0);
		if (pos != string::npos)
		{
	        newLine = buf;

			pt1 = queryID.begin();
			for( ; pt1 != queryID.end() ; pt1++)
			{
				newLine.append(" mysql-");
				newLine.append(*pt1);
			}

			newLine.append(" mysql-queryTester");

			buf = newLine;
		}
		//output to temp file
		lines.push_back(buf);
	}
	
	cfile.close();

   	ofstream newFile (cronFile.c_str());	
	
	//create new file
	int fd = open(cronFile.c_str(), O_RDWR|O_CREAT, 0777);
	
	copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
	newFile.close();
	close(fd);

	cmd = "chmod 777 " + cronFile;
	system(cmd.c_str());


}
int main(int argc, char *argv[])
{
    Oam oam;
	string systemUser = "******";
	string installParentModuleHostName;
	string password;
	string debug_flag = "1";
 	string systemName = "all";
	bool VERBOSE = false;

	Config* sysConfig = Config::makeConfig("./systems/CalpontSystems.xml");

   for( int i = 1; i < argc; i++ )
   {
      if( string("-h") == argv[i] ) {
			cout << endl;
			cout << "'stackReleaseChecker' retrieves and prints the release installed on a stack." << endl;
			cout << endl;
			cout << "The list of systems are located in './systems/CalpontSystems.xml" << endl;
			cout << endl;
   			cout << "Usage: stackReleaseChecker [-h][-s system][-v]" << endl;
			cout << "			-s system-name or leave blank for all systems" << endl;
			cout << "			-v verbose will give the version numbers" << endl;
			exit (0);
		}
      	else if( string("-s") == argv[i] ) {
			i++;
			if ( argc == i ) {
				cout << "ERROR: missing system argument" << endl;
				exit(-1);
			}
			systemName = argv[i];
		}
		else if( string("-v") == argv[i] )
			VERBOSE = true;
   }

	int systemCount;
	try {
		systemCount = strtol(sysConfig->getConfig("NetworkConfig", "SystemCount").c_str(), 0, 0);
		if ( systemCount == 0 ) {
			cout << "ERROR: SystemCount in ./systems/CalpontSystems.xml equal to 0" << endl;
			exit(-1);
		}
	}
	catch(...)
	{
		cout << "ERROR: Problem getting SystemCount from ./systems/CalpontSystems.xml" << endl;
		exit(-1);
	}

	bool FOUND = false;
	for ( int i = 1 ; i < systemCount+1 ; i++)
	{
		string SystemName = "SystemName" + oam.itoa(i);
		string oamParentModule = "OAMParentModule" + oam.itoa(i);
		string SystemPassword = "******" + oam.itoa(i);
		string SystemUser = "******" + oam.itoa(i);

		string tempSystem;
		try {
			tempSystem = sysConfig->getConfig("NetworkConfig", SystemName );
		}
		catch(...)
		{
			cout << "ERROR: Problem getting SystemName from ./systems/CalpontSystems.xml" << endl;
			exit(-1);
		}

		if ( tempSystem == systemName || systemName == "all") {
			try {
				installParentModuleHostName = sysConfig->getConfig("NetworkConfig", oamParentModule );
				password = sysConfig->getConfig("NetworkConfig", SystemPassword );
				systemUser = sysConfig->getConfig("NetworkConfig", SystemUser );
				FOUND = true;
			}
			catch(...)
			{
				cout << "ERROR: Problem getting SystemName from ./systems/CalpontSystems.xml" << endl;
				exit(-1);
			}

			if ( tempSystem == "unassigned")
				continue;

			//get if root or no-root user install
			string installDir = "/usr/local";
			if ( systemUser != "root" )
				installDir = "/home/" + systemUser;

			installDir = installDir + "/Calpont";

			string cmd;
			if (!VERBOSE)
				cmd = "./remote_command.sh " + installParentModuleHostName + " " + systemUser + " " + password + " 'cat " + installDir + "/releasenum' 'release=' cat: 10 " + debug_flag;
			else
				cmd = "./remote_command.sh " + installParentModuleHostName + " " + systemUser + " " + password + " '" + installDir + "/bin/calpontConsole getcalpontsoftware' 'tools' Error 10 " + debug_flag;

			cout << "***** Calpont InfiniDB Package Release Information for stack '" << tempSystem << "' *****" << endl << endl;

			system(cmd.c_str());

			cout << endl;

			cout << "***** Status of stack '" << tempSystem << "' *****" << endl << endl;

			cmd = "./remote_command.sh " + installParentModuleHostName + " " + systemUser + " " + password + " '" + installDir + "/bin/calpontConsole getsystems' dummy Error 10 " + debug_flag;

			system(cmd.c_str());

			cout << endl << endl;
		}
	}

	if ( !FOUND ) {
		cout << "ERROR: System Name '" + systemName + "' not in ./systems/CalpontSystems.xml" << endl;
		exit(-1);
	}
}
int main(int argc, char **argv)
{
	string command;
	Oam oam;
	BRM::DBRM dbrm;

	char c;
	
	// Invokes member function `int operator ()(void);'
	while ((c = getopt(argc, argv, "c:h")) != -1) {
		switch (c) {  
			case 'c': 
				command = optarg;
				break;
			case 'h':
				usage(argv[0]);
				exit(-1);
				break;
			default: 
				usage(argv[0]);
				exit(1);
				break;
		}
	}

	if ( command == "suspend" ) 
	{
		try
		{
            std::vector<BRM::TableLockInfo> tableLocks = dbrm.getAllTableLocks();
            if (!tableLocks.empty())
            {
                oam.DisplayLockedTables(tableLocks, &dbrm);
            }
			else
			{
				dbrm.setSystemSuspended(true);
				sleep(5);
				string cmd = startup::StartUp::installDir() + "/bin/save_brm  > /var/log/mariadb/columnstore/save_brm.log1 2>&1";
				int rtnCode = system(cmd.c_str());
				if (rtnCode == 0)
				{
					cout << endl << "Suspend Calpont Database Writes Request successfully completed" << endl;
				}
				else
				{
					cout << endl << "Suspend Calpont Database Writes Failed: save_brm Failed" << endl;
					dbrm.setSystemSuspended(false);
				}
			}
		}
		catch (exception& e)
		{
			cout << endl << "**** Suspend Calpont Database Writes Failed: " << e.what() << endl;
		}
		catch(...)
		{
			cout << endl << "**** Suspend Calpont Database Writes Failed" << endl;
		}
	}
	else
	{
		if ( command == "resume" ) 
		{
			try{
				dbrm.setSystemSuspended(false);
				cout << endl << "Resume Calpont Database Writes Request successfully completed" << endl;
			}
			catch (exception& e)
			{
				cout << endl << "**** Resume Calpont Database Writes Failed: " << e.what() << endl;
			}
			catch(...)
			{
				cout << endl << "**** Resume Calpont Database Writes Failed" << endl;
			}
		}
		else
		{
			cout << "Invalid Command Entered, please try again" << endl;
			exit(-1);
		}
	}

	exit(0);
}