Пример #1
0
    def _launch(self, ports=[], passwords=[], op=None):
        LOG.debug('Launching redis processes on ports %s with passwords %s' % (ports, passwords))
        is_replication_master = self.is_replication_master

        primary_ip = self.get_primary_ip()
        assert primary_ip is not None

        new_passwords = []
        new_ports = []



        for port,password in zip(ports, passwords or [None for port in ports]):
            if op:
                op.step('Launch Redis %s on port %s' % ('Master' if is_replication_master else 'Slave', port))
            try:
                if op:
                    op.__enter__()

                if iptables.enabled():
                    iptables.FIREWALL.ensure({
                            "jump": "ACCEPT", "protocol": "tcp", "match": "tcp", "dport": port
                    })


                redis_service.create_redis_conf_copy(port)
                redis_process = redis_service.Redis(is_replication_master, self.persistence_type, port, password)

                if not redis_process.service.running:
                    LOG.debug('Launch Redis %s on port %s' % ('Master' if is_replication_master else 'Slave', port))
                    if is_replication_master:
                        current_password = redis_process.init_master(STORAGE_PATH)
                    else:
                        current_password = redis_process.init_slave(STORAGE_PATH, primary_ip, port)
                    new_passwords.append(current_password)
                    new_ports.append(port)
                    LOG.debug('Redis process has been launched on port %s with password %s' % (port, current_password))

                else:
                    raise BaseException('Cannot launch redis on port %s: the process is already running' % port)

            except:
                if op:
                    op.__exit__(sys.exc_info())
                raise
            finally:
                if op:
                    op.__exit__(None)
        return (new_ports, new_passwords)
Пример #2
0
    def _launch(self, ports=[], passwords=[], op=None):
        LOG.debug('Launching redis processes on ports %s with passwords %s' % (ports, passwords))
        is_replication_master = self.is_replication_master

        primary_ip = self.get_primary_ip()
        assert primary_ip is not None

        new_passwords = []
        new_ports = []



        for port,password in zip(ports, passwords or [None for port in ports]):
            if op:
                op.step('Launch Redis %s on port %s' % ('Master' if is_replication_master else 'Slave', port))
            try:
                if op:
                    op.__enter__()

                if iptables.enabled():
                    iptables.FIREWALL.ensure({
                            "jump": "ACCEPT", "protocol": "tcp", "match": "tcp", "dport": port
                    })


                redis_service.create_redis_conf_copy(port)
                redis_process = redis_service.Redis(is_replication_master, self.persistence_type, port, password)

                if not redis_process.service.running:
                    LOG.debug('Launch Redis %s on port %s' % ('Master' if is_replication_master else 'Slave', port))
                    if is_replication_master:
                        current_password = redis_process.init_master(STORAGE_PATH)
                    else:
                        current_password = redis_process.init_slave(STORAGE_PATH, primary_ip, port)
                    new_passwords.append(current_password)
                    new_ports.append(port)
                    LOG.debug('Redis process has been launched on port %s with password %s' % (port, current_password))

                else:
                    raise BaseException('Cannot launch redis on port %s: the process is already running' % port)

            except:
                if op:
                    op.__exit__(sys.exc_info())
                raise
            finally:
                if op:
                    op.__exit__(None)
        return (new_ports, new_passwords)
Пример #3
0
    def _launch(self, ports=None, passwords=None, op=None):
        log = op.logger if op else LOG
        ports = ports or []
        passwords = passwords or []
        log.debug('Launching redis processes on ports %s with passwords %s',
                  ports, passwords)

        primary_ip = self.get_primary_ip()
        assert primary_ip is not None

        new_passwords = []
        new_ports = []

        for port, password in zip(ports, passwords
                                  or [None for port in ports]):
            log.info('Launch Redis %s on port %s',
                     'Master' if __redis__["replication_master"] else 'Slave',
                     port)

            if iptables.enabled():
                iptables.FIREWALL.ensure({
                    "jump": "ACCEPT",
                    "protocol": "tcp",
                    "match": "tcp",
                    "dport": port
                })

            redis_service.create_redis_conf_copy(port)
            redis_process = redis_service.Redis(port, password)

            if not redis_process.service.running:
                if __redis__["replication_master"]:
                    current_password = redis_process.init_master(STORAGE_PATH)
                else:
                    current_password = redis_process.init_slave(
                        STORAGE_PATH, primary_ip, port)
                new_passwords.append(current_password)
                new_ports.append(port)
                log.debug(
                    'Redis process has been launched on port %s with password %s'
                    % (port, current_password))

            else:
                raise BaseException(
                    'Cannot launch redis on port %s: the process is already running'
                    % port)

        return new_ports, new_passwords
Пример #4
0
    def _launch(self, ports=None, passwords=None, op=None):
        log = op.logger if op else LOG
        ports = ports or []
        passwords = passwords or []
        log.debug('Launching redis processes on ports %s with passwords %s', ports, passwords)

        primary_ip = self.get_primary_ip()
        assert primary_ip is not None

        new_passwords = []
        new_ports = []

        for port, password in zip(ports, passwords or [None for port in ports]):
            log.info('Launch Redis %s on port %s', 
                'Master' if __redis__["replication_master"] else 'Slave', port)

            if iptables.enabled():
                iptables.FIREWALL.ensure({
                    "jump": "ACCEPT", "protocol": "tcp", "match": "tcp", "dport": port
                })

            redis_service.create_redis_conf_copy(port)
            redis_process = redis_service.Redis(port, password)

            if not redis_process.service.running:
                if __redis__["replication_master"]:
                    current_password = redis_process.init_master(STORAGE_PATH)
                else:
                    current_password = redis_process.init_slave(STORAGE_PATH, primary_ip, port)
                new_passwords.append(current_password)
                new_ports.append(port)
                log.debug('Redis process has been launched on port %s with password %s' % (port, current_password))

            else:
                raise BaseException('Cannot launch redis on port %s: the process is already running' % port)

        return new_ports, new_passwords