Пример #1
0
def converge(key='*'):
    # note that this gets the machines in the `key` cluster
    machines = Machine.load_files(key=key) # machine name => machine

    # note that this gets all containers accross all users.
    # we are converging the entire `key` machine group within the cluster
    containers = Container.load_files(machines) # deploy id => container

    print machines, containers

    create_threads = []
    destroy_threads = []
    
    for m in machines.values():
        target_containers = [c for c in containers.values() if c.machine == m]
        (to_create, to_delete, t1, t2) = m.converge(target_containers)
        create_threads.append(t1)
        destroy_threads.append(t2)

    print "Starting container creation"
    for t in create_threads:
        t.start()

    for t in create_threads:
        t.join()
    print "Finished container creation"

    print "Starting container destruction"
    for t in destroy_threads:
        t.start()

    for t in destroy_threads:
        t.join()
    print "Finished container destruction"
Пример #2
0
def sleep(key='alpha-dev'):
    machines = Machine.load_files(key=key) # machine name => machine
    print machines
    containers = Container.load_files(machines, key='*') # deploy id => container

    for m in machines.values():
        target_containers = [c for c in containers.values() if c.machine == m and c.d_id not in ['zenrez','adshare']]
        m.bulk_sleep(target_containers)