Sets up a pegasus script for the given dag

def prepare_dax(self,grid_site=None,tmp_exec_dir='.',peg_frame_cache=None):
    """
    Sets up a pegasus script for the given dag
    """
    dag=self
    log_path=self.__log_file_path

    # this function creates the following three files needed by pegasus
    peg_fh = open("pegasus_submit_dax", "w")
    pegprop_fh = open("pegasus.properties", "w")
    sitefile = open( 'sites.xml', 'w' )

    # write the default properties
    print >> pegprop_fh, PEGASUS_PROPERTIES % (os.getcwd())

    # set up site and dir options for pegasus-submit-dax
    dirs_entry='--relative-dir .'
    if grid_site:
      exec_site=grid_site
      exec_ssite_list = exec_site.split(',')
      for site in exec_ssite_list:
        # if virgo sites are being used, then we don't have a shared fs
        if site == 'nikhef':
          dirs_entry += ' --staging-site nikhef=nikhef-srm'
        else:
          dirs_entry += ' --staging-site %s=%s' % (site,site)
        if site == 'nikhef' or site == 'bologna':
          print >> pegprop_fh, \
"""
###############################################################################
# Data Staging Configuration

# Pegasus will be setup to execute jobs on an execution site without relying
# on a shared filesystem between the head node and the worker nodes. If this
# is set, specify staging site ( using --staging-site option to pegasus-plan)
# to indicate the site to use as a central storage location for a workflow.
pegasus.data.configuration=nonsharedfs


"""
    else:
      exec_site='local'

    # write the pegasus_submit_dax and make it executable
    print >> peg_fh,PEGASUS_SCRIPT % ( tmp_exec_dir, os.getcwd(),
          dag.get_dax_file().replace('.dax','') + '-0.dag',
          dag.get_dax_file(), dirs_entry, exec_site )
    peg_fh.close()
    os.chmod("pegasus_submit_dax",0755)

    # if a frame cache has been specified, write it to the properties
    # however note that this is overridden by the --cache option to pegasus
    if peg_frame_cache:
      print >> pegprop_fh, "pegasus.catalog.replica.file=%s" % (os.path.join(os.getcwd(),os.path.basename(peg_frame_cache)))
    pegprop_fh.close()

    # write a shell script that can return the basedir and uber-concrete-dag
    basedir_fh = open("pegasus_basedir", "w")
    print >> basedir_fh, PEGASUS_BASEDIR_SCRIPT % ( tmp_exec_dir, dag.get_dax_file().replace('.dax','') + '-0.dag' )
    basedir_fh.close()
    os.chmod("pegasus_basedir",0755)

    # write the site catalog file which is needed by pegasus
    pwd = os.getcwd()
    try:
      hostname = socket.gethostbyaddr(socket.gethostname())[0]
    except:
      hostname = 'localhost'

    print >> sitefile, """\
<?xml version="1.0" encoding="UTF-8"?>
<sitecatalog xmlns="http://pegasus.isi.edu/schema/sitecatalog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pegasus.isi.edu/schema/sitecatalog http://pegasus.isi.edu/schema/sc-4.0.xsd" version="4.0">
  <site handle="local" arch="x86_64" os="LINUX">
    <grid type="gt2" contact="%s/jobmanager-fork" scheduler="Fork" jobtype="auxillary" total-nodes="50"/>
    <grid type="gt2" contact="%s/jobmanager-condor" scheduler="Condor" jobtype="compute" total-nodes="50"/>
    <directory  path="%s" type="shared-scratch" free-size="null" total-size="null">
        <file-server  operation="all" url="file://%s">
        </file-server>
    </directory>
    <directory  path="%s" type="shared-storage" free-size="null" total-size="null">
        <file-server  operation="all" url="file://%s">
        </file-server>
    </directory>
    <replica-catalog  type="LRC" url="rlsn://smarty.isi.edu">
    </replica-catalog>
""" % (hostname,hostname,pwd,pwd,pwd,pwd)

    try:
      print >> sitefile, """    <profile namespace="env" key="GLOBUS_LOCATION">%s</profile>""" % os.environ['GLOBUS_LOCATION']
    except:
      pass
    try:
      print >> sitefile, """    <profile namespace="env" key="LD_LIBRARY_PATH">%s</profile>""" % os.environ['LD_LIBRARY_PATH']
    except:
      pass
    try:
      print >> sitefile, """    <profile namespace="env" key="PYTHONPATH">%s</profile>""" % os.environ['PYTHONPATH']
    except:
      pass
    try:
      print >> sitefile, """    <profile namespace="env" key="PEGASUS_HOME">%s</profile>""" % os.environ['PEGASUS_HOME']
    except:
      pass
    try:
      print >> sitefile, """    <profile namespace="env" key="LIGO_DATAFIND_SERVER">%s</profile>""" % os.environ['LIGO_DATAFIND_SERVER']
    except:
      pass
    try:
      print >> sitefile, """    <profile namespace="env" key="S6_SEGMENT_SERVER">%s</profile>""" % os.environ['S6_SEGMENT_SERVER']
    except:
      pass

    print >> sitefile, """\
    <profile namespace="env" key="JAVA_HEAPMAX">4096</profile>
    <profile namespace="pegasus" key="style">condor</profile>
    <profile namespace="condor" key="getenv">True</profile>
    <profile namespace="condor" key="should_transfer_files">YES</profile>
    <profile namespace="condor" key="when_to_transfer_output">ON_EXIT_OR_EVICT</profile>
  </site>
"""

    print >> sitefile, """\
  <!-- Bologna cluster -->
  <site handle="bologna" arch="x86_64" os="LINUX">
    <grid type="cream" contact="https://ce01-lcg.cr.cnaf.infn.it:8443/ce-cream/services/CREAM2" scheduler="LSF" jobtype="compute" />
    <grid type="cream" contact="https://ce01-lcg.cr.cnaf.infn.it:8443/ce-cream/services/CREAM2" scheduler="LSF" jobtype="auxillary" />
    <directory type="shared-scratch" path="/storage/gpfs_virgo4/virgo4/%s/">
        <file-server operation="all" url="srm://storm-fe-archive.cr.cnaf.infn.it:8444/srm/managerv2?SFN=/virgo4/%s/"/>
    </directory>
    <profile namespace="pegasus" key="style">cream</profile>
    <profile namespace="globus" key="queue">virgo</profile>
  </site>
""" % (os.path.basename(tmp_exec_dir),os.path.basename(tmp_exec_dir))

    print >> sitefile, """\
  <!-- Nikhef Big Grid -->
  <site handle="nikhef" arch="x86_64" os="LINUX">
    <grid type="cream" contact="https://klomp.nikhef.nl:8443/ce-cream/services/CREAM2" scheduler="PBS" jobtype="compute" />
    <grid type="cream" contact="https://klomp.nikhef.nl:8443/ce-cream/services/CREAM2" scheduler="PBS" jobtype="auxillary" />
    <profile namespace="pegasus" key="style">cream</profile>
    <profile namespace="globus" key="queue">medium</profile>
  </site>
  <!-- Nikhef Stage in Site -->
  <site handle="nikhef-srm" arch="x86_64" os="LINUX">
    <directory type="shared-scratch" path="/%s/">
      <file-server operation="all" url="srm://tbn18.nikhef.nl:8446/srm/managerv2?SFN=/dpm/nikhef.nl/home/virgo/%s/" />
    </directory>
  </site>
""" % (os.path.basename(tmp_exec_dir),os.path.basename(tmp_exec_dir))

    try:
      stampede_home = subprocess.check_output(
        ['gsissh','-o','BatchMode=yes','-p','2222','stampede.tacc.xsede.org','pwd'])
      stampede_home = stampede_home.split('/')
      stampede_magic_number = stampede_home[2]
      stampede_username = stampede_home[3]
      shared_scratch = "/work/%s/%s/ihope-workflow/%s" % (
        stampede_magic_number,stampede_username,os.path.basename(tmp_exec_dir))

      print >> sitefile, """\
  <!-- XSEDE Stampede Cluster at TACC Development Queue -->
  <site handle="stampede-dev" arch="x86_64" os="LINUX">
     <grid type="gt5" contact="login5.stampede.tacc.utexas.edu/jobmanager-fork" scheduler="Fork" jobtype="auxillary"/>
     <grid type="gt5" contact="login5.stampede.tacc.utexas.edu/jobmanager-slurm" scheduler="unknown" jobtype="compute"/>
     <directory type="shared-scratch" path="%s">
       <file-server operation="all" url="gsiftp://gridftp.stampede.tacc.xsede.org%s"/>
     </directory>
     <profile namespace="env" key="PEGASUS_HOME">/usr</profile>
     <profile namespace="globus" key="queue">development</profile>
     <profile namespace="globus" key="maxwalltime">180</profile>
     <profile namespace="globus" key="host_count">1</profile>
     <profile namespace="globus" key="count">16</profile>
     <profile namespace="globus" key="jobtype">single</profile>
     <profile namespace="globus" key="project">TG-PHY140012</profile>
   </site>
""" % (shared_scratch,shared_scratch)

      print >> sitefile, """\
  <!-- XSEDE Stampede Cluster at TACC Development Queue -->
  <site handle="stampede" arch="x86_64" os="LINUX">
     <grid type="gt5" contact="login5.stampede.tacc.utexas.edu/jobmanager-fork" scheduler="Fork" jobtype="auxillary"/>
     <grid type="gt5" contact="login5.stampede.tacc.utexas.edu/jobmanager-slurm" scheduler="unknown" jobtype="compute"/>
     <directory type="shared-scratch" path="%s">
       <file-server operation="all" url="gsiftp://gridftp.stampede.tacc.xsede.org%s"/>
     </directory>
     <profile namespace="env" key="PEGASUS_HOME">/usr</profile>
     <profile namespace="globus" key="queue">development</profile>
     <profile namespace="globus" key="maxwalltime">540</profile>
     <profile namespace="globus" key="host_count">32</profile>
     <profile namespace="globus" key="count">512</profile>
     <profile namespace="globus" key="jobtype">single</profile>
     <profile namespace="globus" key="project">TG-PHY140012</profile>
   </site>
""" % (shared_scratch,shared_scratch)

    except:
      print >> sitefile, """\
  <!-- XSEDE Stampede Cluster disabled as gsissh to TACC failed-->
"""

    print >> sitefile, """\
</sitecatalog>"""
    sitefile.close()

    # Write a help message telling the user how to run the workflow
    print
    print "Created a workflow file which can be submitted by executing"
    print """

      ./pegasus_submit_dax

    in the analysis directory on a condor submit machine.

    From the analysis directory on the condor submit machine, you can run the
    command

      pegasus-status --long -t -i `./pegasus_basedir`

    to check the status of your workflow. Once the workflow has finished you
    can run the command

      pegasus-analyzer -t -i `./pegasus_basedir`

    to debug any failed jobs.
    """