Esempio n. 1
0
    def restore(self, src_path, db=None):
        #Kill redis-server
        LOG.info('Stopping Redis server.')
        out = self.node.run("pgrep -l redis-server | awk {print'$1'} | xargs -i{}  kill {} && sleep 5 && pgrep -l redis-server | awk {print'$1'}")[0]
        if out:
            raise AssertionError('Redis server, pid:%s  was not properly killed on remote host %s' % (out, self.server.public_ip))
        LOG.info('Redis server was successfully stopped. Getting backups and moving to redis storage.')
        #Move dump to redis storage
        out = self.node.run("find %s -name '*%s*' -print0 | xargs -i{} -0 -r cp -v {} /mnt/redisstorage/" %
                            (src_path, self.snapshotting_type))
        if not out[0]:
            raise AssertionError("Can't move dump to redis-server storage.  Error is: %s" % out[1])
        LOG.info('Available backups in server: %s. Backups was successfully moved to redis storage.' % out[0].split()[0])

        #Run redis-server
        LOG.info('Running Redis server.')
        out = self.node.run("/bin/su redis -s /bin/bash -c \"%(bin)s %(conf)s\" && sleep 5 &&  pgrep -l redis-server | awk {print'$1'}" %
                            {
                                 'bin': os.path.join(self.redis_path.get(Dist.get_os_family(self.node.os[0]))['bin'], 'redis-server'),
                                 'conf': os.path.join(self.redis_path.get(Dist.get_os_family(self.node.os[0]))['conf'], 'redis.6379.conf')
                            })
        if out[2]:
            raise AssertionError("Redis server was not properly started on remote host %s. Error is: %s %s"
                                 % (self.server.public_ip, out[0], out[1]))
        LOG.info('Redis server was successfully run.')
Esempio n. 2
0
def start_redis_process(step, process, serv_as):
    """Start redis-server  process"""
    redis_bin_path = {
        'debian':  {'bin': '/usr/bin',
                    'conf': '/etc/redis'},

        'centos':  {'bin': '/usr/sbin',
                    'conf': '/etc'}
    }
    server = getattr(world, serv_as)
    node = world.cloud.get_node(server)
    LOG.info('Start %s on remote host: %s' % (process, server.public_ip))

    node_result = node.run("/bin/su redis -s /bin/bash -c \"%(bin)s %(conf)s\" && sleep 5 &&  pgrep -l %(process)s | awk {print'$1'}" %
                           {
                               'bin': os.path.join(redis_bin_path.get(Dist.get_os_family(node.os[0]))['bin'], process),
                               'process': process,
                               'conf': os.path.join(redis_bin_path.get(Dist.get_os_family(node.os[0]))['conf'], 'redis.6379.conf')
                           })
    if node_result[2]:
        raise AssertionError("%s was not properly started on remote host %s. Error is: %s %s"
                             % (process, server.public_ip, node_result[0], node_result[1]))
    LOG.info('%s was successfully started on remote host: %s' % (process, server.public_ip))