Changed hardcoded Mongodb username to variable

The operating system user used by MongoDB for its files
and processes was hardcoded to "mongodb" for Debian. Other
linux variants use different users. This adds a variable,
MONGO_USER which is set depending on the guest O/S.

Change-Id: I5b47243ff13607766adfc3337d4e31d4c0598c2a
Closes-bug: 1416155
This commit is contained in:
Doug Shelley 2015-01-30 00:28:03 +00:00
parent e06bb53064
commit b1b61221a9
2 changed files with 11 additions and 3 deletions

View File

@ -65,7 +65,8 @@ class Manager(periodic_task.PeriodicTasks):
if os.path.exists(system.MONGODB_MOUNT_POINT):
device.migrate_data(mount_point)
device.mount(mount_point)
operating_system.update_owner('mongodb', 'mongodb', mount_point)
operating_system.update_owner(system.MONGO_USER,
system.MONGO_USER, mount_point)
LOG.debug("Mounted the volume %(path)s as %(mount)s." %
{'path': device_path, "mount": mount_point})

View File

@ -13,8 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from trove.guestagent.common import operating_system
from trove.guestagent import pkg
OS_NAME = operating_system.get_os()
MONGODB_MOUNT_POINT = "/var/lib/mongodb"
# After changing bind address mongodb accepts connection
# on real IP, not on the localhost
@ -30,9 +33,13 @@ MONGODB_KILL = "sudo kill %s"
FIND_PID = "ps xau | grep 'mongo[ds]'"
TIME_OUT = 1000
INIT_EXEC_MONGOS = ("start-stop-daemon --start --quiet --chuid mongodb "
MONGO_USER = {operating_system.REDHAT: "mongod",
operating_system.DEBIAN: "mongodb",
operating_system.SUSE: "mongod"}[OS_NAME]
INIT_EXEC_MONGOS = ("start-stop-daemon --start --quiet --chuid %s "
"--exec /usr/bin/mongos -- "
"--config {config_file_placeholder}")
"--config {config_file_placeholder}" % MONGO_USER)
MONGOS_UPSTART_CONTENTS = """pre-start script
mkdir -p /var/log/mongodb/