def __init__(self, config):
     self.nap_time = config['loop_wait']
     self.tags = {tag: value for tag, value in config.get('tags', {}).items()
                  if tag not in ('clonefrom', 'nofailover', 'noloadbalance') or value}
     self.postgresql = Postgresql(config['postgresql'])
     self.dcs = get_dcs(self.postgresql.name, config)
     self.version = __version__
     self.api = RestApiServer(self, config['restapi'])
     self.ha = Ha(self)
     self.next_run = time.time()
Exemple #2
0
    def __init__(self):
        self.setup_signal_handlers()

        self.version = __version__
        self.config = Config()
        self.dcs = get_dcs(self.config)
        self.load_dynamic_configuration()

        self.postgresql = Postgresql(self.config['postgresql'])
        self.api = RestApiServer(self, self.config['restapi'])
        self.ha = Ha(self)

        self.tags = self.get_tags()
        self.next_run = time.time()
        self.scheduled_restart = {}
 def setUp(self):
     with patch.object(etcd.Client, 'machines') as mock_machines:
         mock_machines.__get__ = Mock(return_value=['http://remotehost:2379'])
         self.p = Postgresql({'name': 'postgresql0', 'scope': 'dummy', 'listen': '127.0.0.1:5432',
                              'data_dir': 'data/postgresql0', 'superuser': {}, 'admin': {},
                              'replication': {'username': '', 'password': '', 'network': ''}})
         self.p.set_state('running')
         self.p.set_role('replica')
         self.p.check_replication_lag = true
         self.p.can_create_replica_without_replication_connection = MagicMock(return_value=False)
         self.e = get_dcs('foo', {'etcd': {'ttl': 30, 'host': 'ok:2379', 'scope': 'test'}})
         self.ha = Ha(MockPatroni(self.p, self.e))
         self.ha._async_executor.run_async = run_async
         self.ha.old_cluster = self.e.get_cluster()
         self.ha.cluster = get_cluster_not_initialized_without_leader()
         self.ha.load_cluster_from_dcs = Mock()
Exemple #4
0
 def setUp(self):
     with patch.object(Client, 'machines') as mock_machines:
         mock_machines.__get__ = Mock(return_value=['http://remotehost:2379'])
         self.p = Postgresql({'name': 'postgresql0', 'scope': 'dummy', 'listen': '127.0.0.1:5432',
                              'data_dir': 'data/postgresql0', 'retry_timeout': 10,
                              'maximum_lag_on_failover': 5,
                              'authentication': {'superuser': {'username': '******', 'password': '******'},
                                                 'replication': {'username': '', 'password': ''}},
                              'parameters': {'wal_level': 'hot_standby', 'max_replication_slots': 5, 'foo': 'bar',
                                             'hot_standby': 'on', 'max_wal_senders': 5, 'wal_keep_segments': 8}})
         self.p.set_state('running')
         self.p.set_role('replica')
         self.p.postmaster_start_time = MagicMock(return_value=str(postmaster_start_time))
         self.p.can_create_replica_without_replication_connection = MagicMock(return_value=False)
         self.e = get_dcs({'etcd': {'ttl': 30, 'host': 'ok:2379', 'scope': 'test',
                                    'name': 'foo', 'retry_timeout': 10}})
         self.ha = Ha(MockPatroni(self.p, self.e))
         self.ha.old_cluster = self.e.get_cluster()
         self.ha.cluster = get_cluster_not_initialized_without_leader()
         self.ha.load_cluster_from_dcs = Mock()
Exemple #5
0
    def __init__(self):
        from patroni.api import RestApiServer
        from patroni.config import Config
        from patroni.dcs import get_dcs
        from patroni.ha import Ha
        from patroni.postgresql import Postgresql
        from patroni.version import __version__

        self.setup_signal_handlers()

        self.version = __version__
        self.config = Config()
        self.dcs = get_dcs(self.config)
        self.load_dynamic_configuration()

        self.postgresql = Postgresql(self.config['postgresql'])
        self.api = RestApiServer(self, self.config['restapi'])
        self.ha = Ha(self)

        self.tags = self.get_tags()
        self.next_run = time.time()
        self.scheduled_restart = {}
Exemple #6
0
    def __init__(self):
        from patroni.api import RestApiServer
        from patroni.config import Config
        from patroni.dcs import get_dcs
        from patroni.ha import Ha
        from patroni.postgresql import Postgresql
        from patroni.version import __version__
        from patroni.watchdog import Watchdog

        self.setup_signal_handlers()

        self.version = __version__
        self.config = Config()
        self.dcs = get_dcs(self.config)
        self.watchdog = Watchdog(self.config)
        self.load_dynamic_configuration()

        self.postgresql = Postgresql(self.config['postgresql'])
        self.api = RestApiServer(self, self.config['restapi'])
        self.ha = Ha(self)

        self.tags = self.get_tags()
        self.next_run = time.time()
        self.scheduled_restart = {}