From 6ed975d81893876e941fa610c2463552b3881d36 Mon Sep 17 00:00:00 2001 From: david hill Date: Wed, 9 Aug 2017 15:59:43 -0500 Subject: [PATCH] MCOL-850 - merged from develop-1.0 --- oam/oamcpp/liboamcpp.cpp | 45 +++++++++++++++++++------ oamapps/postConfigure/postConfigure.cpp | 31 ++++++++--------- 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 47a235527..329f690c0 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -2536,25 +2536,48 @@ namespace oam Oam::getAlarmConfig(alarmid, name, returnValue); - // only allow user to change these levels - if ( name != "Threshold" && - name != "Occurrences" && - name != "LastIssueTime" ) + // only allow user to change these levels + if ( name != "Threshold" && + name != "Occurrences" && + name != "LastIssueTime" ) exceptionControl("setAlarmConfig", API_READONLY_PARAMETER); + string fileName = AlarmConfigFile; + + int fd = open(fileName.c_str(), O_RDWR|O_CREAT, 0644); + + // Aquire an exclusive lock + if (flock(fd,LOCK_EX) == -1) { + throw runtime_error ("Lock file error: " + fileName); + } + // write parameter to disk Config* alaConfig = Config::makeConfig(AlarmConfigFile.c_str()); alaConfig->setConfig(Section, name, value); - try + + try + { + alaConfig->write(); + } + catch(...) + { + // Release lock + if (flock(fd,LOCK_UN)==-1) { - alaConfig->write(); - } - catch(...) - { - exceptionControl("setAlarmConfig", API_FAILURE); + throw runtime_error ("Release lock file error: " + fileName); } + exceptionControl("setAlarmConfig", API_FAILURE); + } + + // Release lock + if (flock(fd,LOCK_UN)==-1) + { + throw runtime_error ("Release lock file error: " + fileName); + } + + close(fd); } /******************************************************************** @@ -6970,7 +6993,7 @@ namespace oam //current amazon max dbroot id support = 190; string PMdeviceName = "/dev/sd"; - string deviceLetter[] = {"g","h","i","j","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","end"}; + string deviceLetter[] = {"g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","end"}; /*************************************************************************** * diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index ee1abd2ae..d641b1c4d 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -5075,27 +5075,23 @@ bool attachVolume(string instanceName, string volumeName, string deviceName, str { Oam oam; - //just return of debug set, called from amazonInstaller - if( thread_remote_installer ) - return true; - - cout << "Checking if Volume " << volumeName << " is attached , please wait..." << endl; +// cout << "Checking if Volume " << volumeName << " is attached , please wait..." << endl; string status = oam.getEC2VolumeStatus(volumeName); if ( status == "attached" ) { - cout << "Volume " << volumeName << " is attached " << endl; - cout << "Make sure it's device " << deviceName << " is mounted to DBRoot directory " << dbrootPath << endl; + cout << " Volume " << volumeName << " is attached " << endl; +// cout << "Make sure it's device " << deviceName << " is mounted to DBRoot directory " << dbrootPath << endl; return true; } if ( status != "available" ) { - cout << "ERROR: Volume " << volumeName << " status is " << status << endl; - cout << "Please resolve and re-run postConfigure" << endl; + cout << " ERROR: Volume " << volumeName << " status is " << status << endl; + cout << " Please resolve and re-run postConfigure" << endl; return false; } else { - cout << endl; +/* cout << endl; string temp = "y"; while(true) { @@ -5116,28 +5112,29 @@ bool attachVolume(string instanceName, string volumeName, string deviceName, str } if ( temp == "y" ) { - cout << "Attaching, please wait..." << endl; +*/ cout << " Attaching, please wait..." << endl; if(oam.attachEC2Volume(volumeName, deviceName, instanceName)) { - cout << "Volume " << volumeName << " is now attached " << endl; - cout << "Make sure it's device " << deviceName << " is mounted to DBRoot directory " << dbrootPath << endl; + cout << " Volume " << volumeName << " is now attached " << endl; +// cout << "Make sure it's device " << deviceName << " is mounted to DBRoot directory " << dbrootPath << endl; return true; } else { - cout << "ERROR: Volume " << volumeName << " failed to attach" << endl; - cout << "Please resolve and re-run postConfigure" << endl; + cout << " ERROR: Volume " << volumeName << " failed to attach" << endl; + cout << " Please resolve and re-run postConfigure" << endl; return false; } - } +/* } else { cout << "Volume " << volumeName << " will need to be attached before completing the install" << endl; cout << "Please resolve and re-run postConfigure" << endl; return false; } - } +*/ } } + bool singleServerDBrootSetup() { Oam oam;