Example #1
0
            if(instance == vm["instance"] ):
                vm_state = vm["state"]
                if(vm_state == "running"):   # TODO
                    client.send( {"type": "cmd", "mesg": "success","memo":"","instance":instance} )
                    checking = False
                elif(vm_state == "error"):  #TODO
                    client.send( {"type": "cmd", "mesg": "ongoing","memo":"","instance":instance} )
                    checking = False
                else:
                    pass
        time.sleep(interval)
# end_time = time.time() + 10

    return

if __name__ == '__main__':
#    client.send( simplejson.dumps( data )  )
    #create MS2W queue     
    ms2wDict = { 'X7_Q':'X7_Q_MS2W', 'X7_E':'X7_E_MS2W', 'X7_RK':'X7_PK_MS2W' }
    server = MqServer( None, ms2wDict )
    server.create_queue()
     
    ms2wDict = { 'X7_Q':'X7_Q_MS2W', 'X7_E':'X7_E_MS2W', 'X7_RK':'X7_PK_MS2W' }
    client = MqClient( ms2wDict )
    client.connect()

    mw2sDict = { 'X7_Q':'X7_Q_MW2S', 'X7_E':'X7_E_MW2S', 'X7_RK':'X7_PK_MW2S' }
    mq_server = MqServer( handle_message, mw2sDict)
    mq_server.connect()
    message = mq_server.run()
Example #2
0
import simplejson
import sys, os
import subprocess


def handle_message(pkg, message):
    print("Received message: %r" % (pkg,))
    message.ack()
    params = simplejson.loads(pkg)

    # begin write file
    if os.path.isfile("localrc"):
        os.remove("localrc")

    eth_interface = params.get("FLAT_INTERFACE", "eth0")
    subprocess.Popen(["./startup_2.sh", eth_interface])
    exit(-1)
    # file = open ( 'localrc', 'w' )
    # for k in params.keys():
    #    file.write( "%s=%s \n"  % (k,params[k]) )

    # file.close()


if __name__ == "__main__":
    w2sDict = {"X7_Q": "X7_Q_W2S", "X7_E": "X7_E_W2S", "X7_RK": "X7_PK_W2S"}

    mq_server = MqServer(handle_message, w2sDict)
    mq_server.connect()
    message = mq_server.run(once=True)