def change_instance_binaries(self, instance):

        script = test_bash_script_error()
        script += build_change_mongodb_conf_file_script()
        script += build_stop_database_script(clean_data=False)
        script += build_clean_data_data_script()
        script += build_start_database_script()
        script += build_wait_admin_be_created_script()
        script += td_agent_script(option='restart')

        context_dict = {}

        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))
Exemple #2
0
    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
Exemple #3
0
    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
    def do(self, workflow_dict):
        try:

            instances = workflow_dict['instances']

            script = test_bash_script_error()
            script += build_change_mongodb_conf_file_script()
            script += build_stop_database_script(clean_data=False)
            script += build_clean_data_data_script()
            script += build_start_database_script()
            script += build_mongorestore_database_script()
            script += build_enable_authentication_single_instance_script()
            script += build_restart_database_script()
            script += td_agent_script(option='restart')

            context_dict = {}

            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