def swift_restart(): global running_hosts while not rexists("/etc/swift/swift.conf"): log_info("Still need swift.conf...") sleep(2) while not rexists("/etc/swift/account.ring.gz"): log_info("Still need account.ring.gz...") sleep(2) while not rexists("/etc/swift/container.ring.gz"): log_info("Still need container.ring.gz...") sleep(2) while not rexists("/etc/swift/object.ring.gz"): log_info("Still need object.ring.gz...") sleep(2) run("swift-init stop all; true") run("swift-init start all; true") log_success("Restarted!") running_hosts.value += 1 while running_hosts.value < len(env.hosts): log_info("%d/%d hosts running" % (running_hosts.value, len(env.hosts))) sleep(1)
def wait_for_vm(): online = False with settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=True): while not online: try: run("echo") log_success("VM is up!") online = True except: log_info("Waiting for VM to boot...") sleep(4)
def swift_test(wait_for_prep=False): if tests_running.value == True: # NOQA return tests_running.value = True if wait_for_prep: while not all([running_hosts.value >= len(env.hosts), prep_auth_done.value == True]): # NOQA log_info("Waiting for all hosts to be available " "before testing...") sleep(1) if not env.TEST_CONFIG: abort(red("Please set your SWIFT_TEST_CONFIG_FILE environment " "variable to a valid config file location.")) log_success("Running functional test suite...") local("cd tmp/swift && ./.functests")
def swift_config_proxy(): if not current_role('proxy'): return reset_local() init_logfiles() upload_proxy_config() for svc in config("proxy_services"): enable_service(svc) service(svc, action='restart') run("openssl req -new -x509 -nodes -batch -out /etc/swift/cert.crt " "-keyout /etc/swift/cert.key") with cd("/etc/swift"): run("swift-ring-builder account.builder create 12 2 1") run("swift-ring-builder container.builder create 12 2 1") run("swift-ring-builder object.builder create 12 2 1") for node in env.roledefs['storage']: for zone in xrange(1, config("zone_count"), 1): conf = (zone, get_address(node, private=True), zone, 100) run("swift-ring-builder account.builder " "add z{0}-{1}:6002/disk{2} {3}".format(*conf)) run("swift-ring-builder container.builder " "add z{0}-{1}:6001/disk{2} {3}".format(*conf)) run("swift-ring-builder object.builder " "add z{0}-{1}:6000/disk{2} {3}".format(*conf)) run("swift-ring-builder account.builder rebalance") run("swift-ring-builder container.builder rebalance") run("swift-ring-builder object.builder rebalance") get("/etc/swift/swift.conf", "tmp") get("/etc/swift/*.ring.gz", "tmp") log_success("Downloaded config and rings from proxy")