Пример #1
0
def main():
    print 'defining a launch plan'
    t = Troop(clobber=True)
    t.configure('resources/one-container-ec2.trp')
    t.create_launch_plan()
    print 'created a launch plan with %d containers' % t.get_container_count()

    # start cloudinitd launch
    print '''NOTICE: an EC2 launch takes about 20min to start the first pycc instance
If interrupted, make sure to stop EC2 instances with the command: cloudinitd terminate %s

now starting launch: %s
-----------------------------------------------''' % (t.launch_name, strftime('%l:%M'))

    try:
        t.start_nodes()
        print '-----------------------------------------------\n\completed launch: %s' % strftime('%l:%M')

        # get manager configured to use rabbitMQ started by launch plan
        m = t.get_manager()

        l = InventoryListener()
        m.add_listener(l)

        keep_waiting = True
        while keep_waiting:
            # shouldn't need to keep requesting each time,
            # but first request could be lost if agent had not yet connected to rabbitmq
            m.send_request(InventoryRequest())
            sleep(5)
            if l.inventory:
                show_inventory(l.inventory)
                keep_waiting = False
            else:
                sleep(10)

    finally:
        print 'now stopping nodes'
        try:
            m.close()
        except:
            print 'failed to close manager connection'
        t.stop_nodes()
Пример #2
0
def main():
    t = Troop(clobber=True)
    t.configure(TROOP_CONFIGURATION_FILE)
    print 'have troop: ' + repr(t)
    print '# services: %d' % len(t.services)
    print '# node types: %d' % len(t.node_types)
    print '--------------------------'
    for node_type in t.node_types:
        print 'type: %s\n' % str(node_type)
    print '--------------------------'

    print '\n\n\ncreating launch plan'
    t.create_launch_plan()

    agent_name = t.configuration['agent-service']['name']
    print 'agent service name: %s' % agent_name
    print 'agent service: %s' % repr(t.service_by_name[agent_name])

    print 'starting troop'
    t.start_nodes()
    print 'stopping troop'
    t.stop_nodes()