From 010c3d08b1bb5c8119edcb5c1e6fb68ff130c246 Mon Sep 17 00:00:00 2001 From: david hill Date: Wed, 20 Apr 2016 15:58:11 -0500 Subject: [PATCH] update fstab changes --- oam/oamcpp/liboamcpp.cpp | 45 +++++++++++++++++------ oam/oamcpp/liboamcpp.h | 4 ++ oamapps/calpontConsole/calpontConsole.cpp | 2 +- oamapps/postConfigure/postConfigure.cpp | 24 ++---------- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 5b760ff17..e5371a0d5 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -6198,20 +6198,13 @@ namespace oam } catch(...) {} - - //update /etc/fstab with mount - string entry = amazonDeviceName + " " + InstallDir + "/data" + itoa(*pt1) + " ext2 noatime,nodiratime,noauto 0 0"; - //update local fstab - cmd = "echo " + entry + " >> /etc/fstab"; - system(cmd.c_str()); - - //use from addmodule later - cmd = "echo " + entry + " >> " + InstallDir + "/local/etc/pm1/fstab"; - system(cmd.c_str()); + // fstabs + string entry = updateFstab( amazonDeviceName, itoa(*pt1)); //send update pms - distributeFstabUpdates(entry); + if (entry != "" ) + distributeFstabUpdates(entry); } } @@ -8467,6 +8460,36 @@ namespace oam } + /****************************************************************************************** + * @brief updateFstab + * + * purpose: check and get mysql user password + * + ******************************************************************************************/ + std::string Oam::updateFstab(std::string device, std::string dbrootID) + { + //check if entry already exist + string cmd = "grep /data" + dbrootID + " > /etc/fstab /dev/null 2>&1"; + + int status = system(cmd.c_str()); + if (WEXITSTATUS(status) == 0 ) + return ""; + + //update /etc/fstab with mount + string entry = device + " " + InstallDir + "/data" + dbrootID + " ext2 noatime,nodiratime,noauto 0 0"; + + //update local fstab + cmd = "echo " + entry + " >> /etc/fstab"; + system(cmd.c_str()); + + //use from addmodule later + cmd = "echo " + entry + " >> " + InstallDir + "/local/etc/pm1/fstab"; + system(cmd.c_str()); + + return entry; + } + + /*************************************************************************** * PRIVATE FUNCTIONS ***************************************************************************/ diff --git a/oam/oamcpp/liboamcpp.h b/oam/oamcpp/liboamcpp.h index 42f1effd3..66d8207ce 100644 --- a/oam/oamcpp/liboamcpp.h +++ b/oam/oamcpp/liboamcpp.h @@ -2436,6 +2436,10 @@ namespace oam */ EXPORT std::string getMySQLPassword(bool bypassConfig = false); + /** @brief update fstab with dbroot mounts + */ + EXPORT std::string updateFstab(std::string device, std::string dbrootID); + private: int sendMsgToProcMgr3(messageqcpp::ByteStream::byte requestType, snmpmanager::AlarmList& alarmlist, const std::string date); diff --git a/oamapps/calpontConsole/calpontConsole.cpp b/oamapps/calpontConsole/calpontConsole.cpp index 8caaaba24..8aa95e255 100644 --- a/oamapps/calpontConsole/calpontConsole.cpp +++ b/oamapps/calpontConsole/calpontConsole.cpp @@ -1723,7 +1723,7 @@ int processCommand(string* arguments) cout << endl; oam.getSystemConfig("PMVolumeSize", EBSsize); - string prompt = "Enter EBS storage size in GB: (" + EBSsize + "): "; + string prompt = "Enter EBS storage size in GB, current setting is " + EBSsize + " : "; EBSsize = dataPrompt(prompt); } } diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index e9bfc0ab7..24e927222 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -2526,16 +2526,8 @@ int main(int argc, char *argv[]) deviceName = boost::get<0>(st); amazondeviceName = boost::get<1>(st); - //update /etc/fstab with mount - string entry = amazondeviceName + " " + installDir + "/data" + *it + " ext2 noatime,nodiratime,noauto 0 0"; - - //update local fstab - cmd = "echo " + entry + " >> /etc/fstab"; - system(cmd.c_str()); - - //use from addmodule later - cmd = "echo " + entry + " >> " + installDir + "/local/etc/pm1/fstab"; - system(cmd.c_str()); + // fstabs + string entry = oam.updateFstab( amazondeviceName, *it); } else { @@ -2573,16 +2565,8 @@ int main(int argc, char *argv[]) callFree(pcommand); } - //update /etc/fstab with mount - string entry = amazondeviceName + " " + installDir + "/data" + *it + " ext2 noatime,nodiratime,noauto 0 0"; - - //update local fstab - cmd = "echo " + entry + " >> /etc/fstab"; - system(cmd.c_str()); - - //use from addmodule later - cmd = "echo " + entry + " >> " + installDir + "/local/etc/pm1/fstab"; - system(cmd.c_str()); + // fstabs + string entry = oam.updateFstab( amazondeviceName, *it); }