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

Python util.exec_remote_command函数代码示例

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

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



在下文中一共展示了exec_remote_command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: undo

    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:

            script = build_clean_database_dir_script()
            script = build_context_script({}, script)
            for source_host in workflow_dict['source_hosts']:
                target_host = source_host.future_host
                target_cs_host_attr = CS_HostAttr.objects.get(host=target_host)
                output = {}
                exec_remote_command(server=target_host.address,
                                    username=target_cs_host_attr.vm_user,
                                    password=target_cs_host_attr.vm_password,
                                    command=script,
                                    output=output)
                LOG.info(output)

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:25,代码来源:config_files.py


示例2: undo

    def undo(self, workflow_dict):
        try:
            LOG.info("Remove all backup log files")

            backup_log_dict = get_backup_log_configuration_dict(environment=workflow_dict['environment'],
                                                                databaseinfra=workflow_dict['databaseinfra'])
            if backup_log_dict is None:
                return True

            instance = workflow_dict['instances'][0]
            host = instance.hostname
            host_csattr = CsHostAttr.objects.get(host=host)

            exec_remote_command(server=host.address,
                                username=host_csattr.vm_user,
                                password=host_csattr.vm_password,
                                command=backup_log_dict['CLEAN_BACKUP_LOG_SCRIPT'])

            return True

        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0014)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:27,代码来源:config_backup_log.py


示例3: mysql_binlog_save

def mysql_binlog_save(client, instance, cloudstack_hostattr):

    try:
        client.query('show master status')
        r = client.store_result()
        row = r.fetch_row(maxrows=0, how=1)
        binlog_file = row[0]['File']
        binlog_pos = row[0]['Position']

        client.query("show variables like 'datadir'")
        r = client.store_result()
        row = r.fetch_row(maxrows=0, how=1)
        datadir = row[0]['Value']

        output = {}
        command = 'echo "master=%s;position=%s" > %smysql_binlog_master_file_pos' % (
            binlog_file, binlog_pos, datadir)

        exec_remote_command(server=instance.hostname.address,
                            username=cloudstack_hostattr.vm_user,
                            password=cloudstack_hostattr.vm_password,
                            command=command,
                            output=output)
    except Exception as e:
        LOG.error(
            "Error saving mysql master binlog file and position: %s" % (e))
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:26,代码来源:tasks.py


示例4: undo

    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:

            script = build_stop_database_script()
            script = build_context_script({}, script)
            for target_instance in workflow_dict['target_instances']:
                target_host = target_instance.hostname
                target_cs_host_attr = CS_HostAttr.objects.get(host=target_host)
                output = {}
                exec_remote_command(server=target_host.address,
                                    username=target_cs_host_attr.vm_user,
                                    password=target_cs_host_attr.vm_password,
                                    command=script,
                                    output=output)
                LOG.info(output)

            try:
                if 'region_migration_dir_infra_name' in workflow_dict:
                    shutil.rmtree(workflow_dict['region_migration_dir_infra_name'])
            except Exception:
                pass

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:tsunli,项目名称:database-as-a-service,代码行数:31,代码来源:config_files.py


示例5: do

    def do(self, workflow_dict):
        try:

            for host in workflow_dict['source_hosts']:
                LOG.info("Removing database files on host %s" % host)
                host_csattr = CsHostAttr.objects.get(host=host)
                output = {}
                exec_remote_command(server=host.address,
                                    username=host_csattr.vm_user,
                                    password=host_csattr.vm_password,
                                    command="/opt/dbaas/scripts/dbaas_deletedatabasefiles.sh",
                                    output=output)
                LOG.info(output)

                LOG.info("Removing disks on host %s" % host)
                NfsaasProvider().destroy_disk(environment=workflow_dict['source_environment'],
                                              host=host)

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:26,代码来源:remove_disks.py


示例6: run_vm_script

def run_vm_script(workflow_dict, context_dict, script):
    try:

        final_context_dict = dict(context_dict.items())

        instance = workflow_dict['instance']
        host = workflow_dict['host']
        host_csattr = HostAttr.objects.get(host=host)
        final_context_dict['HOSTADDRESS'] = instance.address
        final_context_dict['PORT'] = instance.port
        final_context_dict['DBPASSWORD'] = workflow_dict['databaseinfra'].password
        command = build_context_script(final_context_dict, script)
        output = {}
        return_code = exec_remote_command(server=host.address,
                                          username=host_csattr.vm_user,
                                          password=host_csattr.vm_password,
                                          command=command,
                                          output=output)
        if return_code:
            raise Exception("Could not run script. Output: {}".format(output))

        return True

    except Exception:
        traceback = full_stack()

        workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
        workflow_dict['exceptions']['traceback'].append(traceback)

        return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:30,代码来源:__init__.py


示例7: do

    def do(self, workflow_dict):
        try:
            sleep(60)
            databaseinfra = workflow_dict['databaseinfra']
            driver = databaseinfra.get_driver()
            files_to_remove = driver.remove_deprectaed_files()
            command = files_to_remove + " && cp -rp /data/* /data2"

            host = workflow_dict['host']
            cs_host_attr = CsHostAttr.objects.get(host=host)

            output = {}
            return_code = exec_remote_command(server=host.address,
                                              username=cs_host_attr.vm_user,
                                              password=cs_host_attr.vm_password,
                                              command=command,
                                              output=output)

            if return_code != 0:
                raise Exception(str(output))

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0022)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:29,代码来源:copy_data.py


示例8: do

    def do(self, workflow_dict):
        try:
            databaseinfra = workflow_dict['databaseinfra']
            driver = databaseinfra.get_driver()
            host = workflow_dict['host']
            host_attr = HostAttr.objects.get(host=host)
            sleep(30)

            for agent in driver.get_database_agents():
                script = '/etc/init.d/{} start'.format(agent)
                output = {}
                return_code = exec_remote_command(server=host.address,
                                                  username=host_attr.vm_user,
                                                  password=host_attr.vm_password,
                                                  command=script,
                                                  output=output)
                LOG.info('Running {} - Return Code: {}. Output scrit: {}'.format(
                         script, return_code, output))

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0022)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:27,代码来源:start_agents.py


示例9: do

    def do(self, workflow_dict):
        try:
            for source_host in workflow_dict['source_hosts']:
                future_host = source_host.future_host
                hosts_option = [(future_host, 'stop')]
                for host, option in hosts_option:
                    LOG.info("{} td_agent on host {}".format(option, host))
                    cs_host_attr = CS_HostAttr.objects.get(host=host)

                    script = test_bash_script_error()
                    script += monit_script(option)
                    script += td_agent_script(option)

                    LOG.info(script)
                    output = {}
                    return_code = exec_remote_command(server=host.address,
                                                      username=cs_host_attr.vm_user,
                                                      password=cs_host_attr.vm_password,
                                                      command=script,
                                                      output=output)
                    LOG.info(output)
                    if return_code != 0:
                        LOG.error("Error stopping td_agent")
                        LOG.error(str(output))

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:33,代码来源:td_agent.py


示例10: do

    def do(self, workflow_dict):
        try:

            host = workflow_dict['source_hosts'][0]
            databaseinfra = workflow_dict['databaseinfra']
            cs_host_attr = CS_HostAttr.objects.get(host=host)

            context_dict = {
                'MASTERPAIRNAME': databaseinfra.name,
            }

            script = test_bash_script_error()
            script += build_turn_flipper_ip_down_script()
            script = build_context_script(context_dict, script)
            output = {}

            return_code = exec_remote_command(
                server=host.address,
                username=cs_host_attr.vm_user,
                password=cs_host_attr.vm_password,
                command=script,
                output=output)

            LOG.info(output)
            if return_code != 0:
                raise Exception(str(output))

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:35,代码来源:turn_flipper_ip_down.py


示例11: run_vm_script

def run_vm_script(workflow_dict, context_dict, script):
    try:
        instances_detail = workflow_dict['instances_detail']

        final_context_dict = dict(context_dict.items() + workflow_dict['initial_context_dict'].items())

        for instance_detail in instances_detail:
            instance = instance_detail['instance']
            host = instance.hostname
            host_csattr = HostAttr.objects.get(host=host)
            final_context_dict['HOSTADDRESS'] = instance.address
            final_context_dict['PORT'] = instance.port
            command = build_context_script(final_context_dict, script)
            output = {}
            return_code = exec_remote_command(server = host.address,
                                              username = host_csattr.vm_user,
                                              password = host_csattr.vm_password,
                                              command = command,
                                              output = output)
            if return_code:
                raise Exception, "Could not run script. Output: {}".format(output)

        return True

    except Exception:
        traceback = full_stack()

        workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
        workflow_dict['exceptions']['traceback'].append(traceback)

        return False
开发者ID:mbergo,项目名称:database-as-a-service,代码行数:31,代码来源:__init__.py


示例12: switch_master

    def switch_master(self):
        master = self.get_master_instance()
        slave = self.get_slave_instances()[0]
        host = master.hostname

        host_attr = HostAttr.objects.get(host=host)

        script = """
        sudo -u flipper /usr/bin/flipper {{MASTERPAIRNAME}} set write {{HOST01.address}}
        sudo -u flipper /usr/bin/flipper {{MASTERPAIRNAME}} set read {{HOST02.address}}
        """

        context_dict = {
            'MASTERPAIRNAME': self.databaseinfra.name,
            'HOST01': slave.hostname,
            'HOST02': master.hostname,
        }
        script = build_context_script(context_dict, script)
        output = {}
        return_code = exec_remote_command(server=host.address,
                                          username=host_attr.vm_user,
                                          password=host_attr.vm_password,
                                          command=script,
                                          output=output)
        LOG.info(output)
        if return_code != 0:
            raise Exception(str(output))
开发者ID:openarmy,项目名称:database-as-a-service,代码行数:27,代码来源:mysqldb.py


示例13: do

    def do(self, workflow_dict):
        try:
            option = 'restart'
            for host in workflow_dict['hosts']:
                LOG.info("{} monit on host {}".format(option, host))
                cs_host_attr = CS_HostAttr.objects.get(host=host)

                script = test_bash_script_error()
                script += td_agent_script(option)

                LOG.info(script)
                output = {}
                sleep(30)
                return_code = exec_remote_command(server=host.address,
                                                  username=cs_host_attr.vm_user,
                                                  password=cs_host_attr.vm_password,
                                                  command=script,
                                                  output=output)
                LOG.info(output)
                if return_code != 0:
                    LOG.error("Error monit")
                    LOG.error(str(output))

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0002)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:31,代码来源:restart_td_agent.py


示例14: undo

    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:
            command = 'mount /data'
            for host_and_export in workflow_dict['hosts_and_exports']:
                host = host_and_export['host']
                LOG.info('mount data volume on host {}'.format(host))
                cs_host_attr = CsHostAttr.objects.get(host=host)

                output = {}
                return_code = exec_remote_command(server=host.address,
                                                  username=cs_host_attr.vm_user,
                                                  password=cs_host_attr.vm_password,
                                                  command=command,
                                                  output=output)

                if return_code != 0:
                    LOG.info(str(output))

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0021)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:27,代码来源:umount_data_volume.py


示例15: undo

    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:
            databaseinfra = workflow_dict['databaseinfra']
            host = workflow_dict['host']
            return_code, output = use_database_initialization_script(databaseinfra=databaseinfra,
                                                                     host=host,
                                                                     option='stop')

            if return_code != 0:
                LOG.info(str(output))

            cs_host_attr = CsHostAttr.objects.get(host=host)
            output = {}
            return_code = exec_remote_command(server=host.address,
                                              username=cs_host_attr.vm_user,
                                              password=cs_host_attr.vm_password,
                                              command='umount /data',
                                              output=output)

            if return_code != 0:
                raise Exception(str(output))

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0022)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:31,代码来源:start_database.py


示例16: change_instance_binaries

    def change_instance_binaries(self, instance, connect_string, run_authschemaupgrade):
        script = test_bash_script_error()
        script += util.build_cp_mongodb_binary_file()
        script += util.build_stop_database_script(clean_data=False)
        script += util.build_change_release_alias_script()
        script += util.build_start_database_script(wait_time=30)
        script += util.build_change_limits_script()
        script += util.build_remove_reprecated_index_counter_metrics()

        if run_authschemaupgrade:
            script += util.build_authschemaupgrade_script()

        context_dict = {
            'SOURCE_PATH': '/mnt/software/db/mongodb',
            'TARGET_PATH': '/usr/local/',
            'MONGODB_RELEASE_FILE': 'mongodb-linux-x86_64-3.0.8.tgz',
            'MONGODB_RELEASE_FOLDER': 'mongodb-linux-x86_64-3.0.8',
            'CONNECT_STRING': connect_string,
        }

        script = build_context_script(context_dict, script)
        output = {}

        host = instance.hostname
        cs_host_attr = CS_HostAttr.objects.get(host=host)

        return_code = exec_remote_command(server=host.address,
                                          username=cs_host_attr.vm_user,
                                          password=cs_host_attr.vm_password,
                                          command=script,
                                          output=output)
        LOG.info(output)
        if return_code != 0:
            raise Exception(str(output))
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:34,代码来源:upgrade_mongodb_26_to_30_ha.py


示例17: run_vm_script

def run_vm_script(workflow_dict, context_dict, script):
    try:
        instances_detail = workflow_dict["instances_detail"]

        final_context_dict = dict(context_dict.items() + workflow_dict["initial_context_dict"].items())

        for instance_detail in instances_detail:
            host = instance_detail["instance"].hostname
            host_csattr = HostAttr.objects.get(host=host)
            final_context_dict["IS_MASTER"] = instance_detail["is_master"]
            command = build_context_script(final_context_dict, script)
            output = {}
            return_code = exec_remote_command(
                server=host.address,
                username=host_csattr.vm_user,
                password=host_csattr.vm_password,
                command=command,
                output=output,
            )
            if return_code:
                raise Exception, "Could not run script. Output: {}".format(output)

        return True

    except Exception:
        traceback = full_stack()

        workflow_dict["exceptions"]["error_codes"].append(DBAAS_0015)
        workflow_dict["exceptions"]["traceback"].append(traceback)

        return False
开发者ID:tsunli,项目名称:database-as-a-service,代码行数:31,代码来源:__init__.py


示例18: undo

    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:
            command = 'rm -rf /data2 && {} && mount /data'
            host = workflow_dict['host']
            cs_host_attr = CsHostAttr.objects.get(host=host)
            mount = workflow_dict['mount']
            command = command.format(mount)
            output = {}
            return_code = exec_remote_command(server=host.address,
                                              username=cs_host_attr.vm_user,
                                              password=cs_host_attr.vm_password,
                                              command=command,
                                              output=output)

            if return_code != 0:
                LOG.info(str(output))

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0021)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:26,代码来源:umount_volumes.py


示例19: run_vm_script

def run_vm_script(workflow_dict, context_dict, script, reverse=False, wait=0):
    try:
        instances_detail = workflow_dict['instances_detail']
        
        final_context_dict = dict(context_dict.items() + workflow_dict['initial_context_dict'].items())
        
        if reverse:
            instances_detail_final = instances_detail[::-1]
        else:
            instances_detail_final = instances_detail
        
        for instance_detail in instances_detail_final:
            host = instance_detail['instance'].hostname
            host_csattr = HostAttr.objects.get(host=host) 
            command = build_context_script(final_context_dict, script)
            output = {} 
            return_code = exec_remote_command(server = host.address,
                                              username = host_csattr.vm_user,
                                              password = host_csattr.vm_password,
                                              command = command,
                                              output = output)
            if return_code:
                raise Exception, "Could not run script. Output: {}".format(output)
            
            sleep(wait)

        return True
        
    except Exception, e:
        traceback = full_stack()

        workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
        workflow_dict['exceptions']['traceback'].append(traceback)

        return False
开发者ID:Milstein,项目名称:database-as-a-service,代码行数:35,代码来源:mongodb_share.py


示例20: do

    def do(self, workflow_dict):
        try:
            command = "mkdir /data2 && mount -t nfs -o bg,intr {} /data2"
            host = workflow_dict['host']
            volume = workflow_dict['volume']
            command = command.format(volume.nfsaas_path)
            cs_host_attr = CsHostAttr.objects.get(host=host)

            output = {}
            return_code = exec_remote_command(server=host.address,
                                              username=cs_host_attr.vm_user,
                                              password=cs_host_attr.vm_password,
                                              command=command,
                                              output=output)

            if return_code != 0:
                raise Exception(str(output))

            workflow_dict['mount'] = command

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0022)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:28,代码来源:mount_volume.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.expandFileName函数代码示例发布时间:2022-05-27
下一篇:
Python util.escape函数代码示例发布时间: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