本文整理汇总了Python中trove.guestagent.common.operating_system.service_discovery函数的典型用法代码示例。如果您正苦于以下问题:Python service_discovery函数的具体用法?Python service_discovery怎么用?Python service_discovery使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了service_discovery函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _enable_mysql_on_boot
def _enable_mysql_on_boot(self):
LOG.info("Enabling mysql on boot.")
try:
mysql_service = operating_system.service_discovery(MYSQL_SERVICE_CANDIDATES)
utils.execute_with_timeout(mysql_service["cmd_enable"], shell=True)
except KeyError:
raise RuntimeError("Service is not discovered.")
示例2: _disable_db_on_boot
def _disable_db_on_boot(self):
LOG.info(_("Disabling Couchbase Server on boot"))
try:
couchbase_service = operating_system.service_discovery(system.SERVICE_CANDIDATES)
utils.execute_with_timeout(couchbase_service["cmd_disable"], shell=True)
except KeyError:
raise RuntimeError("Command to disable Couchbase Server on boot not found.")
示例3: start_mysql
def start_mysql(self, update_db=False):
LOG.info(_("Starting mysql..."))
# This is the site of all the trouble in the restart tests.
# Essentially what happens is that mysql start fails, but does not
# die. It is then impossible to kill the original, so
self._enable_mysql_on_boot()
try:
mysql_service = operating_system.service_discovery(
MYSQL_SERVICE_CANDIDATES)
utils.execute_with_timeout(mysql_service['cmd_start'], shell=True)
except KeyError:
raise RuntimeError("Service is not discovered.")
except exception.ProcessExecutionError:
# it seems mysql (percona, at least) might come back with [Fail]
# but actually come up ok. we're looking into the timing issue on
# parallel, but for now, we'd like to give it one more chance to
# come up. so regardless of the execute_with_timeout() response,
# we'll assume mysql comes up and check it's status for a while.
pass
if not self.status.wait_for_real_status_to_change_to(
rd_instance.ServiceStatuses.RUNNING,
self.state_change_wait_time, update_db):
LOG.error(_("Start up of MySQL failed!"))
# If it won't start, but won't die either, kill it by hand so we
# don't let a rouge process wander around.
try:
utils.execute_with_timeout("sudo", "pkill", "-9", "mysql")
except exception.ProcessExecutionError as p:
LOG.error("Error killing stalled mysql start command.")
LOG.error(p)
# There's nothing more we can do...
self.status.end_install_or_restart()
raise RuntimeError("Could not start MySQL!")
示例4: start_db
def start_db(self, update_db=False):
LOG.info(_("Starting MongoDB"))
self._enable_db_on_boot()
try:
mongodb_service = operating_system.service_discovery(
system.SERVICE_CANDIDATES)
utils.execute_with_timeout(mongodb_service['cmd_start'],
shell=True)
except ProcessExecutionError:
pass
except KeyError:
raise RuntimeError("MongoDB service is not discovered.")
if not self.status.wait_for_real_status_to_change_to(
rd_instance.ServiceStatuses.RUNNING,
self.state_change_wait_time, update_db):
LOG.error(_("Start up of MongoDB failed"))
# If it won't start, but won't die either, kill it by hand so we
# don't let a rouge process wander around.
try:
out, err = utils.execute_with_timeout(
system.FIND_PID, shell=True)
pid = "".join(out.split(" ")[1:2])
utils.execute_with_timeout(
system.MONGODB_KILL % pid, shell=True)
except exception.ProcessExecutionError as p:
LOG.error("Error killing stalled MongoDB start command.")
LOG.error(p)
# There's nothing more we can do...
self.status.end_install_or_restart()
raise RuntimeError("Could not start MongoDB")
示例5: _disable_db_on_boot
def _disable_db_on_boot(self):
try:
LOG.debug("Disable CouchDB on boot.")
couchdb_service = operating_system.service_discovery(system.SERVICE_CANDIDATES)
utils.execute_with_timeout(couchdb_service["cmd_disable"], shell=True)
except KeyError:
raise RuntimeError("Command to disable CouchDB server on boot not found.")
示例6: _disable_mysql_on_boot
def _disable_mysql_on_boot(self):
try:
mysql_service = operating_system.service_discovery(
MYSQL_SERVICE_CANDIDATES)
utils.execute_with_timeout(mysql_service['cmd_disable'],
shell=True)
except KeyError:
raise RuntimeError("Service is not discovered.")
示例7: _disable_db_on_boot
def _disable_db_on_boot(self):
LOG.info(_("Disabling MongoDB on boot"))
try:
mongodb_service = operating_system.service_discovery(
system.SERVICE_CANDIDATES)
utils.execute_with_timeout(mongodb_service['cmd_disable'],
shell=True)
except KeyError:
raise RuntimeError("MongoDB service is not discovered.")
示例8: _disable_pgsql_on_boot
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.")
示例9: _enable_mysql_on_boot
def _enable_mysql_on_boot(self):
LOG.debug("Enabling MySQL on boot.")
try:
mysql_service = operating_system.service_discovery(
MYSQL_SERVICE_CANDIDATES)
utils.execute_with_timeout(mysql_service['cmd_enable'], shell=True)
except KeyError:
LOG.exception(_("Error enabling MySQL start on boot."))
raise RuntimeError("Service is not discovered.")
示例10: _disable_redis_on_boot
def _disable_redis_on_boot(self):
"""
Disables redis on boot.
"""
LOG.info(_("Disabling Redis on boot."))
try:
redis_service = operating_system.service_discovery(system.SERVICE_CANDIDATES)
utils.execute_with_timeout(redis_service["cmd_disable"], shell=True)
except KeyError:
raise RuntimeError("Command to disable Redis on boot not found.")
示例11: service_discovery
def service_discovery(service_candidates):
result = operating_system.service_discovery(service_candidates)
if result['type'] == 'sysvinit':
result['cmd_bootstrap_pxc_cluster'] = ("sudo service %s bootstrap-pxc"
% result['service'])
elif result['type'] == 'systemd':
result['cmd_bootstrap_pxc_cluster'] = ("sudo systemctl start "
"%[email protected]"
% result['service'])
return result
示例12: _enable_db_on_boot
def _enable_db_on_boot(self):
"""
Enables Couchbase Server on boot.
"""
LOG.info(_('Enabling Couchbase Server on boot.'))
try:
couchbase_service = operating_system.service_discovery(
system.SERVICE_CANDIDATES)
utils.execute_with_timeout(
couchbase_service['cmd_enable'], shell=True)
except KeyError:
raise RuntimeError(_(
"Command to enable Couchbase Server on boot not found."))
示例13: stop_db
def stop_db(self, context):
"""Stop the PgSql service."""
cmd = operating_system.service_discovery(PGSQL_SERVICE_CANDIDATES)
LOG.info(
_("{guest_id}: Stopping database engine with command ({command}).")
.format(
guest_id=CONF.guest_id,
command=cmd['cmd_stop'],
)
)
utils.execute_with_timeout(
*cmd['cmd_stop'].split(),
timeout=30
)
示例14: stop_db
def stop_db(self, update_db=False, do_not_start_on_reboot=False):
LOG.info(_("Stopping mysql..."))
if do_not_start_on_reboot:
self._disable_mysql_on_boot()
try:
mysql_service = operating_system.service_discovery(MYSQL_SERVICE_CANDIDATES)
utils.execute_with_timeout(mysql_service["cmd_stop"], shell=True)
except KeyError:
raise RuntimeError("Service is not discovered.")
if not self.status.wait_for_real_status_to_change_to(
rd_instance.ServiceStatuses.SHUTDOWN, self.state_change_wait_time, update_db
):
LOG.error(_("Could not stop MySQL!"))
self.status.end_install_or_restart()
raise RuntimeError("Could not stop MySQL!")
示例15: stop_db
def stop_db(self, update_db=False, do_not_start_on_reboot=False):
"""
Stops Couchbase Server on the trove instance.
"""
LOG.info(_("Stopping Couchbase Server..."))
if do_not_start_on_reboot:
self._disable_db_on_boot()
try:
couchbase_service = operating_system.service_discovery(system.SERVICE_CANDIDATES)
utils.execute_with_timeout(couchbase_service["cmd_stop"], shell=True)
except KeyError:
raise RuntimeError("Command to stop Couchbase Server not found")
if not self.status.wait_for_real_status_to_change_to(
rd_instance.ServiceStatuses.SHUTDOWN, self.state_change_wait_time, update_db
):
LOG.error(_("Could not stop Couchbase Server!"))
self.status.end_install_or_restart()
raise RuntimeError(_("Could not stop Couchbase Server"))