コード例 #1
0
ファイル: diff.py プロジェクト: locationlabs/confab
def diff(directory=None):
    """
    Show configuration file diffs.
    """
    for conffiles in iter_conffiles(directory):
        status("Computing template diffs for '{environment}' and '{role}'",
               environment=conffiles.environment,
               role=conffiles.role)

        conffiles.diff(directory)
コード例 #2
0
ファイル: push.py プロジェクト: locationlabs/confab
def push(directory=None):
    """
    Push configuration files.
    """
    for conffiles in iter_conffiles(directory):
        status("Pushing templates for '{environment}' and '{role}'",
               environment=conffiles.environment,
               role=conffiles.role)

        conffiles.push()
コード例 #3
0
ファイル: generate.py プロジェクト: toddhodes/confab
def generate(directory=None):
    """
    Generate configuration files.
    """
    for conffiles in iter_conffiles(directory):
        status("Generating templates for '{environment}' and '{role}'",
               environment=conffiles.environment,
               role=conffiles.role)

        conffiles.generate()
コード例 #4
0
ファイル: pull.py プロジェクト: toddhodes/confab
def pull(directory=None):
    """
    Pull remote configuration files.
    """
    for conffiles in iter_conffiles(directory):
        status("Pulling remote templates for '{environment}' and '{role}'",
               environment=conffiles.environment,
               role=conffiles.role)

        conffiles.pull()
コード例 #5
0
def generate(directory=None):
    """
    Generate configuration files.
    """
    for conffiles in iter_conffiles(directory):
        status("Generating templates for '{environment}' and '{role}'",
               environment=conffiles.environment,
               role=conffiles.role)

        conffiles.generate()
コード例 #6
0
ファイル: database.py プロジェクト: life0fun/elephant
def setup_database():
    """
    Initialize Elephant Database.
    """
    status("Initializing Elephant database")

    dbdata = load_component_data("mysql-server-conf")["database"]

    initialize_database(dbdata["name"],
                        dbdata["host"],
                        dbdata["admin"]["username"],
                        dbdata["admin"]["password"],
                        dbdata["username"],
                        dbdata["password"],
                        target_hostnames=dbdata["grant_hosts"])
コード例 #7
0
    def diff(self, generated_dir, remotes_dir, output=False):
        """
        Compute the diff between the generated and remote files.

        If output is enabled, show the diffs nicely.
        """
        generated_file_name = join(generated_dir, self.name)
        assert_may_be_created(generated_file_name)

        remote_file_name = join(remotes_dir, self.name)
        assert_may_be_created(remote_file_name)

        status('Computing diff for {file_name}', file_name=self.remote)

        return ConfFileDiff(remote_file_name, generated_file_name, self.remote)
コード例 #8
0
    def generate(self, directory):
        """
        Write the configuration file.
        """
        generated_file_name = join(directory, self.name)
        assert_may_be_created(generated_file_name)

        status('Generating {file_name}', file_name=self.remote)

        # ensure that destination directory exists
        _ensure_dir(directory)

        if self.should_render():
            self._write_template(generated_file_name)
        else:
            self._write_verbatim(generated_file_name)
コード例 #9
0
    def push(self, directory):
        """
        Push the generated configuration file to the remote host.
        """
        generated_file_name = join(directory, self.name)
        assert_may_be_created(generated_file_name)
        remote_dir = dirname(self.remote)

        status('Pushing {file_name} to {host}',
               file_name=self.remote,
               host=self.host)

        sudo('mkdir -p {dir_name}'.format(dir_name=remote_dir))

        put(generated_file_name,
            self.remote,
            use_sudo=True,
            mirror_local_mode=True)
コード例 #10
0
    def pull(self, directory):
        """
        Pull remote configuration file to local file.
        """
        local_file_name = join(directory, self.name)
        assert_may_be_created(local_file_name)

        status('Pulling {file_name} from {host}',
               file_name=self.remote,
               host=self.host)

        _ensure_dir(directory)
        _clear_file(local_file_name)

        if exists_remote(self.remote, use_sudo=True):
            get(self.remote, local_file_name)
        else:
            status('Not found: {file_name}',
                   file_name=self.remote)