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

Python util.build_context_script函数代码示例

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

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



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

示例1: 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


示例2: 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


示例3: 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


示例4: do

    def do(self, workflow_dict):
        try:
            for source_host in workflow_dict['source_hosts']:

                host = source_host.future_host

                LOG.info("Starting td_agent on host {}".format(host))

                cs_host_attr = CS_HostAttr.objects.get(host=host)
                context_dict = {}

                script = test_bash_script_error()
                script += build_start_td_agent_script()
                script = build_context_script(context_dict, script)
                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 starting 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:tsunli,项目名称:database-as-a-service,代码行数:34,代码来源:td_agent.py


示例5: 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


示例6: 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


示例7: 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


示例8: 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


示例9: 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


示例10: switch_master

    def switch_master(self, instance=None):
        sentinel_instance = self.instances_filtered.first()
        host = sentinel_instance.hostname

        script = """
        #!/bin/bash

        die_if_error()
        {
            local err=$?
            if [ "$err" != "0" ];
            then
                echo "$*"
                exit $err
            fi
        }"""

        script += """
        /usr/local/redis/src/redis-cli -h {} -p {} <<EOF_DBAAS
        SENTINEL failover {}
        exit
        \nEOF_DBAAS
        die_if_error "Error reseting sentinel"
        """.format(
            sentinel_instance.address, sentinel_instance.port,
            self.databaseinfra.name
        )

        script = build_context_script({}, script)
        output = {}
        return_code = exec_remote_command_host(host, script, output)
        LOG.info(output)
        if return_code != 0:
            raise Exception(str(output))
开发者ID:globocom,项目名称:database-as-a-service,代码行数:34,代码来源:redis.py


示例11: 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


示例12: do

    def do(self, workflow_dict):
        try:
            databaseinfra = workflow_dict['databaseinfra']

            connect_string = build_mongodb_connect_string(instances=workflow_dict['source_instances'],
                                                          databaseinfra=databaseinfra)

            client = databaseinfra.get_driver().get_client(None)
            rsconf = client.local.system.replset.find_one()
            member_ids = []
            for member in rsconf['members']:
                member_ids.append(member['_id'])

            max_member_id = max(member_ids)
            secundary_one_member_id = max_member_id + 1
            secundary_two_member_id = max_member_id + 2
            arbiter_member_id = max_member_id + 3

            context_dict = {
                'CONNECT_STRING': connect_string,
                'SECUNDARY_ONE': "{}:{}".format(workflow_dict['target_instances'][0].address, workflow_dict['target_instances'][0].port),
                'SECUNDARY_TWO': "{}:{}".format(workflow_dict['target_instances'][1].address, workflow_dict['target_instances'][1].port),
                'ARBITER': "{}:{}".format(workflow_dict['target_instances'][2].address, workflow_dict['target_instances'][2].port),
                'SECUNDARY_ONE_MEMBER_ID': secundary_one_member_id,
                'SECUNDARY_TWO_MEMBER_ID': secundary_two_member_id,
                'ARBITER_MEMBER_ID': arbiter_member_id,
            }

            script = test_bash_script_error()
            script += build_add_replica_set_members_script()

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

            host = workflow_dict['source_instances'][0].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))

            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,代码行数:54,代码来源:add_instances_replica_set.py


示例13: change_slave_priority_file

def change_slave_priority_file(host, original_value, final_value):
    script = test_bash_script_error()
    script += """
        sed -i 's/slave-priority {}/slave-priority {}/g' /data/redis.conf
    """.format(original_value, final_value)
    script = build_context_script({}, script)
    output = {}
    return_code = exec_remote_command_host(host, script, output)
    LOG.info(output)
    if return_code != 0:
        raise Exception(str(output))
开发者ID:globocom,项目名称:database-as-a-service,代码行数:11,代码来源:__init__.py


示例14: do

    def do(self, workflow_dict):
        try:
            databaseinfra = workflow_dict['databaseinfra']

            connect_string = build_mongodb_connect_string(instances=workflow_dict['source_instances'],
                                                          databaseinfra=databaseinfra)
            context_dict = {
                'CONNECT_STRING': connect_string,
            }

            script = test_bash_script_error()
            script += build_switch_primary_to_new_instances_script()

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

            host = workflow_dict['source_instances'][0].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))

            sleep(30)
            driver = databaseinfra.get_driver()
            client = driver.get_client(instance=None)
            rsconf = client['local'].system.replset.find_one()
            priority_0 = rsconf['members'][0].get('priority', 1)
            priority_1 = rsconf['members'][1].get('priority', 1)
            if priority_0 != 0 or priority_1 != 0:
                errormsg = "The priority of the old mongodb instances should be zero."
                LOG.error(errormsg)
                raise Exception(errormsg)
            replSetGetStatus = client.admin.command('replSetGetStatus')
            if 'PRIMARY' not in (replSetGetStatus['members'][3]['stateStr'],
                                 replSetGetStatus['members'][4]['stateStr']):
                errormsg = "One of the new instances should be PRIMARY."
                LOG.error(errormsg)
                raise Exception(errormsg)

            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,代码行数:53,代码来源:switch_primary.py


示例15: do

    def do(self, workflow_dict):
        try:

            instances = workflow_dict['instances']
            databaseinfra = workflow_dict['databaseinfra']

            connect_string = util.build_mongodb_connect_string(instances=instances,
                                                               databaseinfra=databaseinfra)

            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()
            script += util.build_authschemaupgrade_script()
            script += util.build_change_limits_script()
            script += util.build_change_in_serverstatus_file_script()
            script += util.build_reinstal_mongo_gen_script()
            script += util.build_remove_reprecated_index_counter_metrics()

            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 = instances[0].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))

            return True

        except Exception:
            traceback = full_stack()

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

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


示例16: do

    def do(self, workflow_dict):
        try:
            for index, instance in enumerate(workflow_dict['target_instances']):

                if instance.instance_type == instance.MONGODB_ARBITER:
                    continue

                if instance.instance_type == instance.REDIS_SENTINEL:
                    continue

                host = instance.hostname

                LOG.info("Mounting disks on host {}".format(host))

                cs_host_attr = CS_HostAttr.objects.get(host=host)
                nfs_host_attr = NFS_HostAttr.objects.get(host=host)

                LOG.info("Cheking host ssh...")
                host_ready = check_ssh(server=host.address,
                                       username=cs_host_attr.vm_user,
                                       password=cs_host_attr.vm_password,
                                       wait=5, interval=10)

                if not host_ready:
                    raise Exception(str("Host %s is not ready..." % host))

                context_dict = {
                    'EXPORTPATH': nfs_host_attr.nfsaas_path,
                }

                script = test_bash_script_error()
                script += build_mount_disk_script()
                script = build_context_script(context_dict, script)
                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:
                    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,代码行数:52,代码来源:mount_disks.py


示例17: _execute_script

    def _execute_script(self, script_variables, script):
        final_script = build_context_script(
            script_variables, script
        )

        output = {}
        return_code = exec_remote_command_host(self.host, final_script, output)
        if return_code != 0:
            raise EnvironmentError(
                'Could not execute replica script {}: {}'.format(
                    return_code, output
                )
            )
开发者ID:globocom,项目名称:database-as-a-service,代码行数:13,代码来源:database.py


示例18: do

    def do(self, workflow_dict):
        try:

            flipper_crdentials = get_credentials_for(workflow_dict['source_environment'],
                                                     CredentialType.FLIPPER)

            flipper_vip = flipper_crdentials.get_parameter_by_name('vip')

            for host in workflow_dict['target_hosts']:
                cs_host_attr = CS_HostAttr.objects.get(host=host)
                source_host = workflow_dict['source_hosts'][0]
                nf_host_attr = NF_HostAttr.objects.get(host=source_host)

                script = test_bash_script_error()
                script += build_mount_snapshot_volume_script()
                script += build_remove_deprecated_files_script()
                script += build_permission_script()
                script += build_start_database_script()
                script += build_flipper_script()

                context_dict = {
                    'EXPORT_PATH': nf_host_attr.nfsaas_path,
                    'SNAPSHOPT_NAME': workflow_dict['snapshot_name'],
                    'VIP_FLIPPER': flipper_vip,
                    'IPWRITE': workflow_dict['target_secondary_ips'][0].ip,
                    'HOST01': workflow_dict['target_hosts'][0],
                    'HOST02': workflow_dict['target_hosts'][1]

                }

                script = build_context_script(context_dict, script)

                output = {}
                LOG.info(script)
                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,代码行数:51,代码来源:restore_backup_on_targets.py


示例19: do

    def do(self, workflow_dict):
        try:

            databaseinfra = workflow_dict['databaseinfra']
            driver = databaseinfra.get_driver()
            sentinel = driver.get_sentinel_client()
            master = sentinel.discover_master(databaseinfra.name)
            master_host = master[0]
            master_port = master[1]

            for index, source_host in enumerate(workflow_dict['source_hosts']):

                target_host = source_host.future_host
                target_cs_host_attr = CS_HostAttr.objects.get(host=target_host)

                script = test_bash_script_error()
                script += build_start_stop_scripts()
                if index < 2:
                    script += build_start_database_script()
                script += build_start_sentinel_script()
                script += build_start_http_script()
                script = build_context_script({}, script)

                output = {}
                LOG.info(script)
                return_code = 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)
                if return_code != 0:
                    raise Exception(str(output))

            for target_instance in workflow_dict['target_instances']:
                if target_instance.instance_type == target_instance.REDIS:
                    LOG.info('Changing master of host: {}'.format(target_instance.address))
                    client = driver.get_client(target_instance)
                    client.slaveof(master_host, master_port)
                    LOG.info('New master: {}:{}'.format(master_host, master_port))

            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,代码行数:50,代码来源:start_database_and_replication.py


示例20: do

    def do(self, workflow_dict):
        try:
            databaseinfra = workflow_dict["databaseinfra"]

            for index, source_host in enumerate(workflow_dict["source_hosts"]):
                source_cs_host_attr = CS_HostAttr.objects.get(host=source_host)

                script = test_bash_script_error()
                script += build_start_stop_scripts()
                if index < 2:
                    script += build_stop_database_script()
                script += build_stop_sentinel_script()
                script += build_start_http_script()
                script = build_context_script({}, script)

                output = {}
                LOG.info(script)
                return_code = exec_remote_command(
                    server=source_host.address,
                    username=source_cs_host_attr.vm_user,
                    password=source_cs_host_attr.vm_password,
                    command=script,
                    output=output,
                )
                LOG.info(output)
                if return_code != 0:
                    raise Exception(str(output))

            for source_instance in workflow_dict["source_instances"]:
                if source_instance.instance_type == source_instance.REDIS_SENTINEL:
                    target_instance = source_instance.future_instance
                    reset_sentinel(
                        host=target_instance.hostname,
                        sentinel_host=target_instance.address,
                        sentinel_port=target_instance.port,
                        service_name=databaseinfra.name,
                    )
                    sleep(30)

            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,代码行数:48,代码来源:remove_old_instances.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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