Merge "Fix PostgreSQL volume definitions"

This commit is contained in:
Jenkins 2015-03-03 23:11:45 +00:00 committed by Gerrit Code Review
commit 294df90a6d
2 changed files with 50 additions and 3 deletions

View File

@ -92,7 +92,32 @@ class Manager(
self.create_user(context, users)
def get_filesystem_stats(self, context, fs_path):
return dbaas.get_filesystem_volume_stats(fs_path)
mount_point = CONF.get(CONF.datastore_manager).mount_point
return dbaas.get_filesystem_volume_stats(mount_point)
def create_backup(self, context, backup_info):
backup.backup(context, backup_info)
def mount_volume(self, context, device_path=None, mount_point=None):
"""Mount the volume as specified by device_path to mount_point."""
device = volume.VolumeDevice(device_path)
device.mount(mount_point, write_to_fstab=False)
LOG.debug(
"Mounted device {device} at mount point {mount}.".format(
device=device_path, mount=mount_point))
def unmount_volume(self, context, device_path=None, mount_point=None):
"""Unmount the volume as specified by device_path from mount_point."""
device = volume.VolumeDevice(device_path)
device.unmount(mount_point)
LOG.debug(
"Unmounted device {device} from mount point {mount}.".format(
device=device_path, mount=mount_point))
def resize_fs(self, context, device_path=None, mount_point=None):
"""Resize the filesystem as specified by device_path at mount_point."""
device = volume.VolumeDevice(device_path)
device.resize_fs(mount_point)
LOG.debug(
"Resized the filesystem at {mount}.".format(
mount=mount_point))

View File

@ -18,7 +18,6 @@ from trove.common import utils
from trove.guestagent.common import operating_system
from trove.guestagent.datastore.postgresql.service.status import PgSqlAppStatus
from trove.openstack.common import log as logging
from trove.common.i18n import _
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
@ -30,6 +29,7 @@ class PgSqlProcess(object):
"""Mixin that manages the PgSql process."""
def start_db(self, context):
self._enable_pgsql_on_boot()
"""Start the PgSql service."""
cmd = operating_system.service_discovery(PGSQL_SERVICE_CANDIDATES)
LOG.info(
@ -44,8 +44,30 @@ class PgSqlProcess(object):
timeout=30
)
def stop_db(self, context):
def _enable_pgsql_on_boot(self):
try:
pgsql_service = operating_system.service_discovery(
PGSQL_SERVICE_CANDIDATES)
utils.execute_with_timeout(pgsql_service['cmd_enable'],
shell=True)
except KeyError:
LOG.exception(_("Error enabling PostgreSQL start on boot."))
raise RuntimeError("Service is not discovered.")
def _disable_pgsql_on_boot(self):
try:
pgsql_service = operating_system.service_discovery(
PGSQL_SERVICE_CANDIDATES)
utils.execute_with_timeout(pgsql_service['cmd_disable'],
shell=True)
except KeyError:
LOG.exception(_("Error disabling PostgreSQL start on boot."))
raise RuntimeError("Service is not discovered.")
def stop_db(self, context, do_not_start_on_reboot=False):
"""Stop the PgSql service."""
if do_not_start_on_reboot:
self._disable_pgsql_on_boot()
cmd = operating_system.service_discovery(PGSQL_SERVICE_CANDIDATES)
LOG.info(
_("{guest_id}: Stopping database engine with command ({command}).")