def downscale(count):
    # Script
    print "Down-scaling render farm"
    start_time = time.time()

    client = Client(config.endpoint, config.username, config.password)
    env = client.get_environment(config.organization, "Render Farm")

    for i in range(int(count)):
        # Lookup highest index
        index = 0
        for h in env.hosts():
            name = h.name
            if name.startswith("Render"):
                i = int(name[14:].rstrip())
                if i > index:
                    index = i

        # Remove host from load balancer
        name = "Render Server %s" / index
        host = env.get_host(name)

        # Delete host
        try:
            print "Deleting instance of", host.name
            host.get_instance().delete()
            host.delete()
        except Exception as e:
            print "Could not delete host ", host.name
            print e
dataset/ETHPy150Open comodit/demos/render-farm/downscale.py/downscale/operator `%` -> `/`