Exemplo n.º 1
0
  def job_data(self,attributes):
    data = ""
    if len(attributes)>0:
      attr_query_arr=[]
      for attr in attributes:
        attr_query_arr.append("(%s=!=UNDEFINED)" % attr)

      data = data + """\
%(indent4)s<job query_expr=%(expr)s>
%(indent5)s<match_attrs> """ % \
 { "indent4" : common.indent(4),
   "indent5" : common.indent(5),
   "expr"    : xmlFormat.xml_quoteattr(string.join(attr_query_arr," && ")),}

      for attr in attributes:
        data = data + """
%(indent6)s<match_attr name="%(attr)s" type="string"/>
""" % { "indent6" : common.indent(6),
        "attr"    : attr, }

      data = data + """\
%(indent5)s</match_attrs>
%(indent4)s</job>
""" % { "indent4" : common.indent(4),
        "indent5" : common.indent(5), }
    return data
Exemplo n.º 2
0
  def get_match_criteria(self):
    """ Determine the job constraints/matching criteria for submitting jobs."""
  #-- factory attributes ----
    print """
What glidein/factory attributres are you using in the match expression?
I have computed my best estimate for your match string,
please verify and correct if needed.
"""
    default_factory_attributes = string.join(self.extract_factory_attrs(),',')
    factory_attributes = raw_input("Factory attributes: [%s] "%default_factory_attributes)
    if factory_attributes == "":
        factory_attributes = default_factory_attributes
    if factory_attributes == "":
        factory_attributes = []
    else:
        factory_attributes = string.split(factory_attributes,',')

    #--- job_attributes --
    print """
What job attributes are you using in the match expression?
I have computed my best estimate for your match string,
please verify and correct if needed.
"""
    default_job_attributes = string.join(self.extract_job_attrs(),',')
    job_attributes = raw_input("Job attributes: [%s] " % default_job_attributes)
    if job_attributes == "":
      job_attributes = default_job_attributes
    if job_attributes == "":
      job_attributes = []
    else:
      job_attributes = string.split(job_attributes,',')

    #--- create xml ----
    data  = """
%(indent2)s<group name="%(group_name)s" enabled="True">
%(indent3)s<match match_expr=%(match_string)s>
%(factory_attributes)s
%(job_attributes)s
%(indent3)s</match>
%(indent2)s</group>
""" % \
{ "indent2" : common.indent(2),
  "indent3" : common.indent(3),
  "indent4" : common.indent(4),
  "group_name"         : self.group_name(),
  "match_string"       : xmlFormat.xml_quoteattr(self.match_string()),
  "factory_attributes" : self.factory_data(factory_attributes),
  "job_attributes"     : self.job_data(job_attributes),
}
    return data 
Exemplo n.º 3
0
  def config_match_data(self,schedds):
    data = """
%(indent1)s<match>
%(indent2)s<factory>
%(indent3)s<collectors>
%(indent4)s<collector node="%(wms_node)s:%(wms_collector_port)s" DN="%(wms_gsi_gn)s" factory_identity="%(factory_username)s@%(wms_node)s" my_identity="%(frontend_identity)s@%(wms_node)s" comment="Define factory collectors globally for simplicity"/>
%(indent3)s</collectors>
%(indent2)s</factory>
%(indent2)s<job query_expr=%(job_constraints)s  comment="Define job constraint and schedds globally for simplicity">
%(indent3)s<schedds>""" % \
{ "indent1"           : common.indent(1), 
  "indent2"           : common.indent(2), 
  "indent3"           : common.indent(3), 
  "indent4"           : common.indent(4), 
  "wms_node"          : self.wms.hostname(),
  "wms_collector_port": self.wms.collector_port(),
  "wms_gsi_gn"        : self.wms.x509_gsi_dn(),
  "factory_username" : self.factory.username(),
  "frontend_identity" : self.service_name(),
  "job_constraints"   : xmlFormat.xml_quoteattr(self.userjob_constraints()),
}

    for schedd in schedds:
      data = data + """
%(indent4)s<schedd fullname="%(schedd)s" DN="%(submit_gsi_dn)s"/>""" % \
{ "indent4"        : common.indent(4),
  "schedd"         : schedd,
  "submit_gsi_dn"  : self.submit.x509_gsi_dn()
}

    data = data + """
%(indent3)s</schedds>
%(indent2)s</job>
%(indent1)s</match>
""" % \
{ "indent1"          : common.indent(1), 
  "indent2"          : common.indent(2), 
  "indent3"          : common.indent(3), 
}
    return data