• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python operating_system.service_discovery函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中trove.guestagent.common.operating_system.service_discovery函数的典型用法代码示例。如果您正苦于以下问题:Python service_discovery函数的具体用法?Python service_discovery怎么用?Python service_discovery使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了service_discovery函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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.")
开发者ID:jimbobhickville,项目名称:trove,代码行数:7,代码来源:service.py


示例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.")
开发者ID:k-pom,项目名称:trove,代码行数:7,代码来源:service.py


示例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!")
开发者ID:schivuk,项目名称:trove,代码行数:35,代码来源:service.py


示例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")
开发者ID:B-Rich,项目名称:trove,代码行数:33,代码来源:service.py


示例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.")
开发者ID:cretta,项目名称:trove,代码行数:7,代码来源:service.py


示例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.")
开发者ID:schivuk,项目名称:trove,代码行数:8,代码来源:service.py


示例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.")
开发者ID:B-Rich,项目名称:trove,代码行数:9,代码来源:service.py


示例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.")
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:9,代码来源:process.py


示例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.")
开发者ID:zjtheone,项目名称:trove,代码行数:9,代码来源:service.py


示例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.")
开发者ID:cretta,项目名称:trove,代码行数:10,代码来源:service.py


示例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
开发者ID:paramtech,项目名称:tesora-trove,代码行数:10,代码来源:system.py


示例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."))
开发者ID:B-Rich,项目名称:trove,代码行数:13,代码来源:service.py


示例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
     )
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:14,代码来源:process.py


示例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!")
开发者ID:jimbobhickville,项目名称:trove,代码行数:15,代码来源:service.py


示例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"))
开发者ID:k-pom,项目名称:trove,代码行数:20,代码来源:service.py


示例16: mysql_service

 def mysql_service(self):
     MYSQL_SERVICE_CANDIDATES = ["mysql", "mysqld", "mysql-server"]
     return operating_system.service_discovery(MYSQL_SERVICE_CANDIDATES)
开发者ID:gongwayne,项目名称:Openstack,代码行数:3,代码来源:service.py


示例17: mysql_service

 def mysql_service(self):
     service_candidates = self.service_candidates
     return operating_system.service_discovery(service_candidates)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:3,代码来源:service.py


示例18: _get_service

 def _get_service(self):
     if self.is_query_router:
         return operating_system.service_discovery(system.MONGOS_SERVICE_CANDIDATES)
     else:
         return operating_system.service_discovery(system.MONGOD_SERVICE_CANDIDATES)
开发者ID:bbgw,项目名称:trove,代码行数:5,代码来源:service.py


示例19: test_upstart_type_service_discovery

 def test_upstart_type_service_discovery(self):
     with patch.object(os.path, "isfile", side_effect=[True]):
         mysql_service = operating_system.service_discovery(["mysql"])
     self.assertIsNotNone(mysql_service["cmd_start"])
     self.assertIsNotNone(mysql_service["cmd_enable"])
开发者ID:mmasaki,项目名称:trove,代码行数:5,代码来源:test_operating_system.py


示例20: test_systemd_symlinked_type_service_discovery

 def test_systemd_symlinked_type_service_discovery(self, mock_base, mock_path, mock_islink):
     with patch.object(os.path, "isfile", side_effect=[False, False, True]):
         mysql_service = operating_system.service_discovery(["mysql"])
     self.assertIsNotNone(mysql_service["cmd_start"])
     self.assertIsNotNone(mysql_service["cmd_enable"])
开发者ID:mmasaki,项目名称:trove,代码行数:5,代码来源:test_operating_system.py



注:本文中的trove.guestagent.common.operating_system.service_discovery函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python operating_system.write_file函数代码示例发布时间:2022-05-27
下一篇:
Python operating_system.remove函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap