def set_active(): if postgresql.is_running(): if replication.is_master(): msg = "Live master" elif postgresql.is_primary(): msg = "Live primary" else: msg = "Live secondary" status_set("active", "{} ({})".format(msg, postgresql.point_version())) else: # PostgreSQL crashed! Maybe bad configuration we failed to # pick up, or maybe a full disk. The admin will need to diagnose. status_set("blocked", "PostgreSQL unexpectedly shut down")
def set_active(): if postgresql.is_running(): if replication.is_master(): msg = 'Live master' elif postgresql.is_primary(): msg = 'Live primary' else: msg = 'Live secondary' status_set('active', '{} ({})'.format(msg, postgresql.point_version())) else: # PostgreSQL crashed! Maybe bad configuration we failed to # pick up, or maybe a full disk. The admin will need to diagnose. status_set('blocked', 'PostgreSQL unexpectedly shut down')
def set_version(): v = postgresql.point_version() hookenv.log("Setting application version to {}".format(v)) hookenv.application_version_set(v)
def test_point_version(self, postgres_path, check_output): postgres_path.return_value = sentinel.postgres_path check_output.return_value = "postgres (PostgreSQL) 9.8.765\n" self.assertEqual(postgresql.point_version(), "9.8.765") check_output.assert_called_once_with([sentinel.postgres_path, "-V"], universal_newlines=True)
def test_point_version(self, postgres_path, check_output): postgres_path.return_value = sentinel.postgres_path check_output.return_value = 'postgres (PostgreSQL) 9.8.765-2\n' self.assertEqual(postgresql.point_version(), '9.8.765') check_output.assert_called_once_with([sentinel.postgres_path, '-V'], universal_newlines=True)
def set_version(): hookenv.application_version_set(postgresql.point_version())