Exemplo n.º 1
0
 def test_simple_paths(self, version):
     # We have a pile of trivial helpers to get directory and file
     # paths. We use these for consistency and ease of mocking.
     version.return_value = "9.9"
     self.assertEqual(postgresql.config_dir(), "/etc/postgresql/9.9/main")
     self.assertEqual(postgresql.data_dir(), "/var/lib/postgresql/9.9/main")
     self.assertEqual(postgresql.postgresql_conf_path(), "/etc/postgresql/9.9/main/postgresql.conf")
     self.assertEqual(postgresql.pg_hba_conf_path(), "/etc/postgresql/9.9/main/pg_hba.conf")
     self.assertEqual(postgresql.pg_ident_conf_path(), "/etc/postgresql/9.9/main/pg_ident.conf")
     self.assertEqual(postgresql.recovery_conf_path(), "/var/lib/postgresql/9.9/main/recovery.conf")
     self.assertEqual(postgresql.pg_ctl_path(), "/usr/lib/postgresql/9.9/bin/pg_ctl")
     self.assertEqual(postgresql.postgres_path(), "/usr/lib/postgresql/9.9/bin/postgres")
Exemplo n.º 2
0
def update_pg_hba_conf():
    # grab the needed current state
    config = hookenv.config()
    rels = context.Relations()
    path = postgresql.pg_hba_conf_path()
    with open(path, "r") as f:
        pg_hba = f.read()

    # generate the new state
    pg_hba_content = generate_pg_hba_conf(pg_hba, config, rels)

    # write out the new state
    helpers.rewrite(path, pg_hba_content)

    # Use @when_file_changed for this when Issue #44 is resolved.
    if reactive.helpers.any_file_changed([path]) and reactive.is_state("postgresql.cluster.is_running"):
        hookenv.log("pg_hba.conf has changed. PostgreSQL needs reload.")
        reactive.set_state("postgresql.cluster.needs_reload")
Exemplo n.º 3
0
 def test_simple_paths(self, version):
     # We have a pile of trivial helpers to get directory and file
     # paths. We use these for consistency and ease of mocking.
     version.return_value = '9.9'
     self.assertEqual(postgresql.config_dir(), '/etc/postgresql/9.9/main')
     self.assertEqual(postgresql.data_dir(), '/var/lib/postgresql/9.9/main')
     self.assertEqual(postgresql.postgresql_conf_path(),
                      '/etc/postgresql/9.9/main/postgresql.conf')
     self.assertEqual(postgresql.pg_hba_conf_path(),
                      '/etc/postgresql/9.9/main/pg_hba.conf')
     self.assertEqual(postgresql.pg_ident_conf_path(),
                      '/etc/postgresql/9.9/main/pg_ident.conf')
     self.assertEqual(postgresql.recovery_conf_path(),
                      '/var/lib/postgresql/9.9/main/recovery.conf')
     self.assertEqual(postgresql.pg_ctl_path(),
                      '/usr/lib/postgresql/9.9/bin/pg_ctl')
     self.assertEqual(postgresql.postgres_path(),
                      '/usr/lib/postgresql/9.9/bin/postgres')
Exemplo n.º 4
0
def update_pg_hba_conf():
    # grab the needed current state
    config = hookenv.config()
    rels = context.Relations()
    path = postgresql.pg_hba_conf_path()
    with open(path, 'r') as f:
        pg_hba = f.read()

    # generate the new state
    pg_hba_content = generate_pg_hba_conf(pg_hba, config, rels)

    # write out the new state
    helpers.rewrite(path, pg_hba_content)

    # Use @when_file_changed for this when Issue #44 is resolved.
    if (reactive.helpers.any_file_changed([path]) and
            reactive.is_state('postgresql.cluster.is_running')):
        hookenv.log('pg_hba.conf has changed. PostgreSQL needs reload.')
        reactive.set_state('postgresql.cluster.needs_reload')