Ejemplo n.º 1
0
 def apply_changes(self):
     if db_api.get_listeners():
         cmd = 'sudo service haproxy restart'.split()
     else:
         # There is no listeners at all.
         cmd = 'sudo service haproxy stop'.split()
     return processutils.execute(*cmd)
Ejemplo n.º 2
0
    def _save_config(self):
        conf = []
        conf.extend(_build_global())
        conf.extend(_build_defaults())

        for l in db_api.get_listeners():
            conf.extend(_build_frontend(l))
            conf.extend(_build_backend(l))

        file_utils.replace_file(self.config_file, '\n'.join(conf))
Ejemplo n.º 3
0
    def get_all(self):
        """Return all listeners."""

        LOG.info("Fetch listeners.")

        listeners = []

        for l in db_api.get_listeners():
            l_dict = l.to_dict()
            l_dict['members'] = [
                member.Member.from_dict(m.to_dict()) for m in l.members
            ]

            listeners += [Listener.from_dict(l_dict)]

        return Listeners(listeners=listeners)