From bca342d262b63321cc4a08a91ca408a56fc4cf6c Mon Sep 17 00:00:00 2001 From: David Hill Date: Wed, 24 Oct 2018 09:25:08 -0500 Subject: [PATCH] MCOL-520 gluster changes --- oam/oamcpp/liboamcpp.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 98297d555..64a22aa7b 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -8796,20 +8796,20 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string int user, group; user = getuid(); group = getgid(); - - string glustercmd = "gluster "; string SUDO = ""; if ( user != 0 ) SUDO = "sudo "; - + + string glustercmd = SUDO + "gluster "; + errmsg = ""; switch ( command ) { case (oam::GLUSTER_STATUS): { - string command = SUDO + glustercmd + "volume status"; + string command = glustercmd + "volume status"; char buffer[128]; string result = ""; @@ -8995,12 +8995,14 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string for (int pm = (pmID - 1); pm < numberPMs; pm++) { cout << "gluster peer probe " + DataRedundancyConfigs[pm].pmIpAddr << endl; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) { cout << "ERROR: peer probe command failed." << endl; command = InstallDir + "/bin/remote_command.sh " + DataRedundancyConfigs[pm].pmIpAddr + " " + password + " 'stat /var/run/glusterd.pid > /dev/null 2>&1'"; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) @@ -9015,6 +9017,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string sleep(5); command = SUDO + glustercmd + "peer status " + " >> " + tmpdir + "/glusterCommands.log 2>&1"; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) @@ -9049,6 +9052,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string command += "force >> " + tmpdir + "/glusterCommands.log 2>&1"; cout << "Gluster create and start volume dbroot" << itoa(newDbrootID) << "..."; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) @@ -9059,7 +9063,8 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string if (user != 0) { - command = "gluster volume set dbroot" + itoa(newDbrootID) + " storage.owner-uid " + itoa(user) + " >> " + tmpdir + "/glusterCommands.log 2>&1";; + command = SUDO + "gluster volume set dbroot" + itoa(newDbrootID) + " storage.owner-uid " + itoa(user) + " >> " + tmpdir + "/glusterCommands.log 2>&1";; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) @@ -9068,7 +9073,8 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string exceptionControl("GLUSTER_ADD", API_FAILURE); } - command = "gluster volume set dbroot" + itoa(newDbrootID) + " storage.owner-gid " + itoa(group) + " >> " + tmpdir + "/glusterCommands.log 2>&1";; + command = SUDO + "gluster volume set dbroot" + itoa(newDbrootID) + " storage.owner-gid " + itoa(group) + " >> " + tmpdir + "/glusterCommands.log 2>&1";; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) @@ -9079,6 +9085,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string } command = SUDO + glustercmd + "volume start dbroot" + itoa(newDbrootID) + " >> " + tmpdir + "/glusterCommands.log 2>&1"; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) @@ -9125,8 +9132,9 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string int status; writeLog("glusterctl: GLUSTER_DELETE: dbroot = " + dbrootID, LOG_TYPE_DEBUG ); - command = SUDO + glustercmd + "--mode=script volume stop dbroot" + dbrootID + " >> " + tmpdir + "/glusterCommands.log 2>&1"; + command = glustercmd + "--mode=script volume stop dbroot" + dbrootID + " >> " + tmpdir + "/glusterCommands.log 2>&1"; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) @@ -9140,6 +9148,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string command = SUDO + glustercmd + " --mode=script volume delete dbroot" + dbrootID + " >> " + tmpdir + "/glusterCommands.log 2>&1"; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) @@ -9161,12 +9170,14 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string command = SUDO + glustercmd + "peer probe " + ipAddress + " >> " + tmpdir + "/glusterCommands.log 2>&1"; cout << "gluster peer probe " + ipAddress << endl; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) { cout << "ERROR: peer probe command failed." << endl; command = InstallDir + "/bin/remote_command.sh " + ipAddress + " " + password + " 'stat /var/run/glusterd.pid > /dev/null 2>&1'"; +cout << command << endl; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 )