示例#1
0
    def __init__(self,
                 root_deployment_dir,
                 provisioner_script_name,
                 force=False,
                 pipe_name=None,
                 server_address=None,
                 user=None,
                 password=None,
                 index=None):
        super().__init__(root_deployment_dir,
                         provisioner_script_name,
                         force=force)
        self.add_system_function_common()
        self.replacement_engine = ReplacementEngine()

        file_name = "template_output_opensearch.txt"
        file_path = os.path.join(self.deployment_dir, file_name)
        self.replacement_engine.perform_recursive_replacements(
            self.deployment_dir, {
                "STRING_REPLACEMENT_PIPELINE_NAME": pipe_name,
                "STRING_REPLACEMENT_OUTPUT_OPENSEARCH_FILE_NAME": file_path,
                "STRING_REPLACEMENT_OPENSEARCH_ADDRESS": server_address,
                "STRING_REPLACEMENT_INDEX": index,
                "STRING_REPLACEMENT_OPENSEARCH_USERNAME": user,
                "STRING_REPLACEMENT_OPENSEARCH_PASSWORD": password,
            })
示例#2
0
 def __init__(self, root_deployment_dir, provisioner_script_name, force=False, pipe_name=None, input_file_path=None):
     super().__init__(root_deployment_dir, provisioner_script_name, force=force)
     self.add_system_function_common()
     self.replacement_engine = ReplacementEngine()
     self.replacement_engine.perform_recursive_replacements(self.deployment_dir,
                                                            {"STRING_REPLACEMENT_PIPELINE_NAME": pipe_name,
                                                             "STRING_REPLACEMENT_INPUT_FILE_NAME": input_file_path})
示例#3
0
 def __init__(self, root_deployment_dir, provisioner_script_name, force=False, pipe_name=None, filter_file_path=None):
     super().__init__(root_deployment_dir, provisioner_script_name, force=force)
     self.add_system_function_common()
     self.replacement_engine = ReplacementEngine()
     self.replacement_engine = ReplacementEngine()
     shutil.copy(filter_file_path, self.deployment_dir)
     self.replacement_engine.perform_recursive_replacements(self.deployment_dir,
                                                            {"STRING_REPLACEMENT_PIPELINE_NAME": pipe_name,
                                                             "STRING_REPLACEMENT_FILTER_FILE_NAME": os.path.basename(filter_file_path)})
示例#4
0
    def __init__(self,
                 root_deployment_dir,
                 provisioner_script_name,
                 force=False,
                 pipeline_names=None):
        super().__init__(root_deployment_dir,
                         provisioner_script_name,
                         force=force)
        self.add_system_function_common()
        self.replacement_engine = ReplacementEngine()

        self.add_pipelines(pipeline_names)
示例#5
0
 def __init__(self,
              root_deployment_dir,
              provisioner_script_name,
              force=False,
              user_name=None,
              password=None):
     super().__init__(root_deployment_dir,
                      provisioner_script_name,
                      force=force)
     self.add_system_function_common()
     self.replacement_engine = ReplacementEngine()
     pdb.set_trace()
     self.replacement_engine.perform_recursive_replacements(
         self.deployment_dir, {
             "STRING_REPLACEMENT_USERNAME": user_name,
             "STRING_REPLACEMENT_PASSWORD": password
         })
示例#6
0
文件: swap.py 项目: AlexeyBeley/horey
    def __init__(self,
                 root_deployment_dir,
                 provisioner_script_name,
                 swap_size_in_gb=None,
                 ram_size_in_gb=None):
        super().__init__(root_deployment_dir, provisioner_script_name)
        self.swap_size_in_gb = swap_size_in_gb
        self.ram_size_in_gb = ram_size_in_gb

        if self.swap_size_in_gb is None:
            self.init_swap_size_from_ram()

        self.move_system_function_to_deployment_dir()

        replacement_engine = ReplacementEngine()
        replacement_engine.perform_recursive_replacements(
            self.deployment_dir,
            {"STRING_REPLACEMENT_SWAP_SIZE_IN_GB": str(self.ram_size_in_gb)})
        self.add_system_function_to_provisioner_script()

        self.add_system_function_common()
示例#7
0
class Builder(SystemFunctionFactory.SystemFunction):
    def __init__(self,
                 root_deployment_dir,
                 provisioner_script_name,
                 force=False,
                 pipeline_names=None):
        super().__init__(root_deployment_dir,
                         provisioner_script_name,
                         force=force)
        self.add_system_function_common()
        self.replacement_engine = ReplacementEngine()

        self.add_pipelines(pipeline_names)

    def add_pipelines(self, pipeline_names):
        pipelines_dir_path = os.path.join(self.deployment_dir, "pipelines")
        os.makedirs(pipelines_dir_path, exist_ok=True)
        pipelines_yml_file = os.path.join(self.deployment_dir, "pipelines.yml")
        with open(
                os.path.join(os.path.dirname(os.path.abspath(__file__)),
                             "base_pipeline.conf"), "r") as file_handler:
            base_pipeline_conf = file_handler.read()

        comment_line = "#PIPELINES_BOTOM"
        for pipeline_name in pipeline_names:
            replacement_string = f"- pipeline.id: {pipeline_name}\n" \
                                 f"  path.config: \"/etc/logstash/conf.d/{pipeline_name}.conf\"\n" \
                                  "  pipeline.workers: 1\n\n"

            self.replacement_engine.perform_comment_line_replacement(
                pipelines_yml_file,
                comment_line,
                replacement_string,
                keep_comment=True)

            pipeline_file = os.path.join(pipelines_dir_path,
                                         f"{pipeline_name}.conf")
            with open(pipeline_file, "w") as file_handler:
                file_handler.write(base_pipeline_conf)
示例#8
0
 def __init__(self, root_deployment_dir, provisioner_script_name, force=False, any=None):
     super().__init__(root_deployment_dir, provisioner_script_name, force=force)
     self.add_system_function_common()
     self.replacement_engine = ReplacementEngine()
     pdb.set_trace()