コード例 #1
0
ファイル: demo6_launch_local.py プロジェクト: ooici/ape
def main():
    print 'defining a launch plan'
    t = Troop(clobber=True)
    t.configure('resources/three-containers.trp')
    t.create_launch_plan()
    print 'created a launch plan with %d containers' % t.get_container_count()
    print 'now starting nodes\n\n-----------------------------------------------'

    try:
        t.start_nodes()

        broker_config = t.get_nodes_broker()
#        broker_config = { 'broker_hostname': 'ec2-50-17-108-226.compute-1.amazonaws.com',
#                                    'broker_username': '******',
#                                    'broker_password': '******' }
        m = SimpleManager(**broker_config)

        l = InventoryListener()
        m.add_listener(l)

        while True:
        # get inventory -- see what agents we have running
            m.send_request(InventoryRequest())
            print '-----------------------------------------------\n\nrequested inventory -- waiting for reply messages'
            sleep(5)

            print 'inventory after nodes have started: '
            show_inventory(l.inventory)
            wait(5)

    finally:
        print 'now stopping nodes'
コード例 #2
0
ファイル: demo7_launch_ec2.py プロジェクト: ooici/ape
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()