| |||||||||||
Using the AEC2 package with mmjobs Description A simple Mosel program for testing the AEC2 package. Further explanation of this example: Reference manual 'AEC2: Managing Amazon EC2 from Mosel'
Source Files By clicking on a file name, a preview is opened at the bottom of this page.
aec2test.mos (!******************************************************* * Mosel Example Problems * * ====================== * * * * file aec2test.mos * * ````````````````` * * A simple model for testing the AEC2 package * * * * (c) 2011 Fair Isaac Corporation * * author: Y. Colombani * *******************************************************!) model aec2_test uses 'aec2','mmjobs' parameters aec2_config="aec2.acf" end-parameters declarations ainst:EC2instance instances:list of EC2instance minst:Mosel rmod:Model l:text end-declarations ! If necessary, define an HTTP proxy !setparam("httpgproxy","calliope") ! Now load the configuration prepared with aec2setup if not loadAEC2Config(aec2_config) then writeln("The configuration file 'aec2.acf' is missing or incomplete.") writeln("Please run the 'aec2setup' program for updating it.") exit(1) end-if ! Let's try to find a running instance instances:=getAllInstances if instances.size>0 then writeln("+ Found the following running instance(s):") forall(i in instances) do writeln("\t",i.Id,"(",statetext(i.state),") from image ",i.image) ! we keep the first instance built from an appropriate image if ainst.Id="" and i.state=AEC2_RUNNING and i.image=aec2_image then ainst:=i end-if end-do if ainst.Id="" then writeln("None of these instances can be used") end-if else writeln("+ No instance running.") end-if writeln if ainst.Id="" then write("+ Starting a new EC2 instance.");fflush ainst:=runInstance if not waitInstanceReady(ainst,300,true) then writeln("\nFailed to start instance!") terminateInstance(ainst) exit(1) end-if writeln end-if writeln("+ Starting Mosel on instance ",ainst.Id) ! Start a Mosel instance in the cloud... if connect(minst,getConnString(ainst))<>0 then writeln("Failed to start Mosel on ",ainst.Id) exit(1) end-if writeln("+ Remote instance system information:",getsysinfo(minst)) writeln ! generate a simple model for testing fopen("tmp:minimod.mos",F_OUTPUT) writeln( "model minimod\n"+ "writeln('Hello from EC2')\n"+ "end-model") fclose(F_OUTPUT) writeln("+ Compile a model remotely (bim file saved on the remote instance)") ! Now compile then load... if compile(minst,"","rmt:tmp:minimod.mos","tmp:m.bim")<>0 then writeln("Compilation failed!") end-if writeln("+ Load then run:") load(minst,rmod,"tmp:m.bim") run(rmod) wait dropnextevent writeln("\n+ Execution finished!") unload(rmod) writeln("+ Disconnecting Mosel.") disconnect(minst) write("\nWould you like to shut down Amazon instance ",ainst.Id," ?");fflush if readtextline(l)>0 and (getchar(l,1)=89 or getchar(l,1)=121) then writeln("Terminating Amazon instance.") terminateInstance(ainst) end-if end-model | |||||||||||
© Copyright 2024 Fair Isaac Corporation. |