예제 #1
0
def decommission(key, access, name, device="/dev/sdf"):
    def log(message, logging='warning'):
        "{0}: {1}, {2}".format('Decommission', message, logging)

    # first get the mountpoint (requires some energy, but we can...)
    df = subprocess.Popen(["/bin/df", device], stdout=subprocess.PIPE)
    output = df.communicate()[0]
    dummy, size, used, available, percent, mountpoint = \
          output.split("\n")[1].split()
    if device != dummy:
        log("No such device {0}".format(device), 'info')
        sys.exit()

    log('start dommissioning', 'info')

    # make a last snapshot
    log('and now a snapshot', 'info')
    snapshot = backup.make_snapshot(key, access, name, 'monthly')
    administration.add_snapshot(key, access, name, snapshot)

    # we don't have to get rid any the volume, it is deleted on termination

    # and empty the cron as well
    log('empty the cron', 'info')
    os.system("/bin/echo | /usr/bin/crontab")
예제 #2
0
파일: decommission.py 프로젝트: numan/ReDiS
def decommission(key, access, cluster, persistence="no"):
	events = Events(key, access, cluster)
	node = Host(cluster, events).get_node()
	def log(message, logging='warning'):
		events.log(node, 'Decommission', message, logging)

	log('start dommissioning', 'info')
	# make a last backup
	if "no" != persistence:
		log('make last backups, first RDB', 'info')
		# take the latest RDB and move it to S3
		rdb = backup.put_RDB(key, access, cluster, 'monthly')
		administration.set_RDB(key, access, cluster, rdb)

		# make a last snapshot
		log('and now a snapshot', 'info')
		snapshot = backup.make_snapshot(key, access, cluster, 'monthly')
		administration.add_snapshot(key, access, cluster, snapshot)

		delete_monitor()

	# we don't have to get rid any the volume, it is deleted on termination

	# change to the default (no persistence)
	log('remove redis.conf', 'info')
	os.system("/bin/rm -f /etc/redis/redis.conf")
	# and empty the cron as well
	log('empty the cron', 'info')
	os.system("/bin/echo | /usr/bin/crontab")

	# make sure we make a clean AMI, with all monit checks monitored
	log('finally, monitor all (monit), for making AMIs', 'info')
	os.system("/usr/sbin/monit monitor all")
예제 #3
0
def decommission(key, access, name, device="/dev/sdf"):
	def log(message, logging='warning'):
		"{0}: {1}, {2}".format('Decommission', message, logging)

	# first get the mountpoint (requires some energy, but we can...)
	df = subprocess.Popen(["/bin/df", device], stdout=subprocess.PIPE)
	output = df.communicate()[0]
	dummy, size, used, available, percent, mountpoint = \
							output.split("\n")[1].split()
	if device != dummy:
		log("No such device {0}".format(device), 'info')
		sys.exit()

	log('start dommissioning', 'info')

	# make a last snapshot
	log('and now a snapshot', 'info')
	snapshot = backup.make_snapshot(key, access, name, 'monthly')
	administration.add_snapshot(key, access, name, snapshot)

	# we don't have to get rid any the volume, it is deleted on termination

	# and empty the cron as well
	log('empty the cron', 'info')
	os.system("/bin/echo | /usr/bin/crontab")
예제 #4
0
파일: decommission.py 프로젝트: 9apps/ReDiS
def decommission(key, access, cluster, persistence="no"):
    events = Events(key, access, cluster)
    node = Host(cluster, events).get_node()

    def log(message, logging="warning"):
        events.log(node, "Decommission", message, logging)

    log("start dommissioning", "info")
    # make a last backup
    if "no" != persistence:
        log("make last backups, first RDB", "info")
        # take the latest RDB and move it to S3
        rdb = backup.put_RDB(key, access, cluster, "monthly")
        administration.set_RDB(key, access, cluster, rdb)

        # make a last snapshot
        log("and now a snapshot", "info")
        snapshot = backup.make_snapshot(key, access, cluster, "monthly")
        administration.add_snapshot(key, access, cluster, snapshot)

        delete_monitor()

        # we don't have to get rid any the volume, it is deleted on termination

        # change to the default (no persistence)
    log("remove redis.conf", "info")
    os.system("/bin/rm -f /etc/redis/redis.conf")
    # and empty the cron as well
    # log('empty the cron', 'info')
    # os.system("/bin/echo | /usr/bin/crontab")

    # make sure we make a clean AMI, with all monit checks monitored
    log("finally, monitor all (monit), but 'redis' and slave", "info")
    os.system("/usr/bin/monit unmonitor redis")
    os.system("/usr/bin/monit unmonitor slave")