Example #1
0
  def validate_factory_proxy(self):
    #--- using factory and vofrontend ---
    if len(self.x509_proxy())  == 0 or \
       len(self.x509_gsi_dn()) == 0:
      common.logerr("""You have said you want to use a Frontend and Factory proxies.
The x509_proxy and x509_gsi_dn option must be populated.""")
    proxy_file = self.x509_proxy()
    common.logit("... validating x509_proxy: %s" % proxy_file)
    if not os.path.exists(proxy_file):
      common.logerr("""File specified does not exist.""")
    common.logit("... validating x509_gsi_dn: %s" % self.x509_gsi_dn())
    type = "proxy"
    dn_to_validate = self.x509_gsi_dn()
    dn_in_file = common.get_gsi_dn(type,proxy_file)
    if dn_in_file <> dn_to_validate:
      common.logerr("""The DN of the %(type)s in %(file)s 
does not match the x509_gsi_dn attribute in your ini file:
%(type)8s dn: %(file_dn)s
%(ini)11s: %(ini_dn)s
This may cause a problem in other services.
Are you sure this is a proxy and not a certificate?""" % \
              { "type"    : type,
                "ini"     : "x509_gsi_dn",
                "file"    : proxy_file,
                "file_dn" : dn_in_file,
                "ini_dn"  : dn_to_validate},)
Example #2
0
  def create_env_script(self):
    common.logit("\nCreating VO frontend env script.")
    data = """#!/bin/bash
source %(condor_location)s/condor.sh
""" % { "condor_location" : self.condor_location(),}
    common.write_file("w",0644,self.env_script(),data)
    common.logit("VO frontend env script created: %s" % self.env_script() )
Example #3
0
 def verify_directories_empty(self):
   dirs = {}
   if len(os.listdir(self.client_log_dir())) > 0:
     dirs["client_log_dir"] = self.client_log_dir()
   if len(os.listdir(self.client_proxy_dir())) > 0:
     dirs["client_proxy_dir"] = self.client_proxy_dir()
   if len(os.listdir(self.logs_dir())) > 0:
     dirs["logs_dir"] = self.logs_dir()
   for dir in ["monitor","stage"]:
     subdir = os.path.join(self.glidein.web_location(),dir)
     if os.path.isdir(subdir) and len(os.listdir(subdir)) > 0:
       dirs["web_location/%s" % dir] = subdir
   if len(os.listdir(self.install_location())) > 0:
     if len(os.listdir(self.install_location())) > self.nbr_of_nested_dirs():
       dirs["install_location"] = self.install_location()
   if len(dirs) == 0:
     return  # all directories are empty
   common.logit("""The following directories must be empty for the install to succeed: """)
   for option in dirs.keys():
     common.logit("""  %(option)s: %(dir)s""" % \
                       { "option" : option, "dir" : dirs[option] })
   common.ask_continue("... can we remove their contents")
   for option in dirs.keys():
     common.remove_dir_contents(dirs[option])
   # this re-validation is performed to resolve problem of nesting some dirs
   self.validate_needed_directories()
Example #4
0
  def get_schedds_via_condor_status(self):
    cmd = ""
    if self.install_type() != "rpm":
      cmd += "source %s/condor.sh;" % self.condor_location()
    cmd += "condor_status -schedd -format '%s\n' Name "
    fd = os.popen(cmd)
    lines = fd.readlines()
    err = fd.close()
    if err != None: # collector not accessible
        common.logit("%s" % lines)
        common.logerr("Failed to fetch list of schedds running condor_status -schedd\n       Your user pool collector and submit host condor need to be running.")
    if len(lines) == 0: # submit schedds not accessible
        common.logerr("Failed to fetch list of schedds running condor_status -schedd\n       Your submit host condor needs to be running.")

    default_schedds=[]
    for line in lines:
        line = line[:-1] #remove newline
        if line != "":
            default_schedds.append(line)

    if len(default_schedds) == 0:
        common.logerr("""Failed to fetch list of schedds running condor_status -schedd
Your collector and submit host's condor need to be running.
or you have not defined any schedds on the submit host.""")

    return self.select_schedds(default_schedds)
Example #5
0
 def get_config_data(self):
   common.logit("\nCollecting  configuration file data. It will be question/answer time.")
   schedds         = self.get_user_schedds()
   match_criteria  = self.get_match_criteria()
   config_xml = self.config_data(schedds,match_criteria)
   common.logit("\nAll configuration file data collected.")
   return config_xml
Example #6
0
  def __condor_config_secondary_schedd_data__(self):
    type = "02_gwms_schedds"
    if self.daemon_list.find("SCHEDD") < 0:
      return  # no schedds
    common.logit("\nConfiguring secondary schedd support.")
    if self.number_of_schedds() == 1:
      common.logit("... no secondary schedds to configure")
      return
    dc_daemon_list = "DC_DAEMON_LIST = + "
    self.condor_config_data[type] +=  """
#--- Secondary SCHEDDs ----"""
    if self.install_type() == "rpm":
       schedd_dir = "$(LOCAL_DIR)/lib/condor"
    else:
       schedd_dir = "$(LOCAL_DIR)"
    secondary_schedds = int(self.number_of_schedds()) - 1
    for i in range(secondary_schedds):
      i = i + 2
      name       = "schedd_%(suffix)s%(nbr)s" % \
                    { "nbr"    : i  ,
                      "suffix" : self.schedd_name_suffix, }
      local_name = "schedd%(suffix)s%(nbr)s" % \
                    { "nbr"    : i  ,
                      "suffix" : self.schedd_name_suffix, }
      self.condor_config_data[type] +=  """
%(upper_name)s       = $(SCHEDD)
%(upper_name)s_ARGS  = -local-name %(lower_name)s
SCHEDD.%(upper_name)s.SCHEDD_NAME   = %(name)s
SCHEDD.%(upper_name)s.SCHEDD_LOG    = $(LOG)/SchedLog.$(SCHEDD.%(upper_name)s.SCHEDD_NAME)
SCHEDD.%(upper_name)s.LOCAL_DIR     = %(schedd_dir)s/$(SCHEDD.%(upper_name)s.SCHEDD_NAME)
SCHEDD.%(upper_name)s.EXECUTE       = $(SCHEDD.%(upper_name)s.LOCAL_DIR)/execute
SCHEDD.%(upper_name)s.LOCK          = $(SCHEDD.%(upper_name)s.LOCAL_DIR)/lock
SCHEDD.%(upper_name)s.PROCD_ADDRESS = $(SCHEDD.%(upper_name)s.LOCAL_DIR)/procd_pipe
SCHEDD.%(upper_name)s.SPOOL         = $(SCHEDD.%(upper_name)s.LOCAL_DIR)/spool
SCHEDD.%(upper_name)s.JOB_QUEUE_LOG         = $(SCHEDD.%(upper_name)s.SPOOL)/job_queue.log
SCHEDD.%(upper_name)s.SCHEDD_ADDRESS_FILE   = $(SCHEDD.%(upper_name)s.SPOOL)/.schedd_address
SCHEDD.%(upper_name)s.SCHEDD_DAEMON_AD_FILE = $(SCHEDD.%(upper_name)s.SPOOL)/.schedd_classad 
%(upper_name)s_SPOOL_DIR_STRING     = "$(SCHEDD.%(upper_name)s.SPOOL)"
SCHEDD.%(upper_name)s.SCHEDD_EXPRS  = SPOOL_DIR_STRING
""" % \
      { "name"       : name,
        "upper_name" : local_name.upper(),
        "lower_name" : local_name.lower(),
        "schedd_dir" : schedd_dir, }

      if self.use_gridmanager:
        self.condor_config_data[type] +=  """
%(upper_name)s_ENVIRONMENT = "_CONDOR_GRIDMANAGER_LOG=$(LOG)/GridManagerLog.$(SCHEDD.%(upper_name)s.SCHEDD_NAME).$(USERNAME)" """ % { "upper_name" : local_name.upper(),}


      self.condor_config_data[type] +=  """
DAEMON_LIST = $(DAEMON_LIST), %(upper_name)s
""" % { "upper_name" : local_name.upper(),}

      dc_daemon_list += " %(upper_name)s" % { "upper_name" : local_name.upper()}
    #--- end of for loop --

    self.condor_config_data[type] +=  """
%s
""" % dc_daemon_list
Example #7
0
 def configure_frontend(self):
   common.logit ("Configuring VOFrontend")
   config_data  = self.get_config_data()
   self.create_config(config_data)
   if self.install_type() == "tarball":
     self.create_env_script()
   common.logit ("Configuration complete")
Example #8
0
    def __create_condor_config__(self):
        """ This first updates the primary condor_config with either:
          a. the gwms condor_config file if a tarball install
          b. the config.d directory containing the gwms config files
        Then it creates the individual condor config files.
    """
        # if len(self.colocated_services) > 0:
        #  return  # we've already updated this
        common.logit("... updating: %s" % self.condor_config())
        common.logit("    to point to GWMS config files directory")
        cfg_data = """
########################################################
# Using local configuration file directory below
########################################################
LOCAL_CONFIG_FILE = 
LOCAL_CONFIG_DIR  = %s
""" % (
            self.local_config_dir()
        )
        common.write_file("a", 0644, self.condor_config(), cfg_data, SILENT=False)
        common.os.system("tail -5 %s" % self.condor_config())

        common.logit("\nCreating GWMS condor_config files in:")
        common.logit("%s" % self.local_config_dir())
        common.make_directory(self.local_config_dir(), self.username(), 0755)
        types = self.condor_config_data.keys()
        types.sort()
        for type in types:
            filename = "%s/%s.config" % (self.local_config_dir(), type)
            common.logit("    %s" % os.path.basename(filename))
            common.write_file("w", 0644, filename, self.condor_config_data[type], SILENT=True)
        self.__create_secondary_schedd_dirs__()
Example #9
0
 def validate_web_location(self):
   dir = self.web_location()
   common.logit("... validating web_location: %s" % dir)
   common.make_directory(dir,self.username(),0755)
   for sdir_name in ("stage","monitor"):
     sdir_fullpath=os.path.join(self.web_location(),sdir_name)
     common.make_directory(sdir_fullpath,self.username(),0755)
Example #10
0
  def delete_ps_directories(self,dirs):
    """ Delete the contents of directories with privilege separation in effect."""
    for type in dirs.keys():
      if type not in ["client logs", "client proxies",]: 
        common.remove_dir_path(dirs[type])
        continue
      #-- Factory create requires client logs/proxies directories be empty
      #-- when privspep is in effect
      condor_sbin = "%s/sbin" % self.wms.condor_location()
      condor_bin  = "%s/bin"  % self.wms.condor_location()
      condorExe.set_path(condor_bin,condor_sbin)
      parent_dir = dirs[type]
      subdirs = os.listdir(parent_dir)
      for base_dir in subdirs:
        if os.path.isdir("%s/%s" % (parent_dir,base_dir)): 
          try:
            condorPrivsep.rmtree(parent_dir,base_dir)
          except Exception,e:
            common.logerr("""Encountered a problem in executing condor_root_switchboard 
to remove this client's sub-directories:
  %(dir)s

  %(error)s
Check your /etc/condor/privsep.conf file to verify.
You may need to configure/install your WMS Collector to resolve or correct
the ini file for the %(type)s attribute.  Be careful now.
""" % { "dir"    : parent_dir,
        "type" : type, 
        "error"  : e, } )
          common.logit("Files in %s deleted" % parent_dir) 
Example #11
0
 def configure_condor(self):
   common.logit("Configuring Condor")
   self.get_condor_config_data()
   self.condor.__create_condor_mapfile__(self.condor_mapfile_users())
   self.condor.__create_condor_config__()
   if self.install_type() == "tarball":
     self.condor.__create_initd_script__()
   common.logit("Configuration complete")
Example #12
0
 def configure(self):
   self.validate()   
   common.logit("Configuring Condor")
   self.get_condor_config_data()
   self.__create_condor_mapfile__(self.condor_mapfile_users())
   self.__create_condor_config__()
   self.__create_initd_script__()
   common.logit("Configuration complete")
Example #13
0
 def verify_python_module(self,module):
   msg = "... validating %s: " % module
   if common.module_exists(module):
     msg += "available"
     common.logit(msg)
   else:
     common.logit(msg)
     common.logerr("This python module is required and not available.")
 def validate_before_condor_install(self):
   common.logit("Privilege separation validation starting")
   if os.getuid() != 0:
     common.logerr("You must install as root user to use privilege separation.")
   self.validate_frontends()       
   self.validate_users()       
   self.validate_client_files()
   common.logit("Privilege separation validation complete\n")
Example #15
0
 def create_frontend(self):
   yn=raw_input("Do you want to create the frontend now? (y/n) [n]: ")
   cmd1 = "source %s" % self.env_script()
   cmd2 = "%s/creation/create_frontend %s" % (self.glidein.glideinwms_location(),self.config_file())
   if yn=='y':
     common.run_script("%s;%s" % (cmd1,cmd2))
   else:
     common.logit("\nTo create the frontend, you need to run the following:\n  %s\n  %s" % (cmd1,cmd2))
Example #16
0
  def configure_condor(self):
##    if len(self.colocated_services) == 0:
    common.logit("Configuring Condor")
    self.get_condor_config_data()
    self.__create_condor_mapfile__(self.condor_mapfile_users())
    self.__create_condor_config__()
    self.__create_initd_script__()
    common.logit("Configuration complete")
 def remove(self):
   if not os.path.isfile(self.config_file()):
     return 
   if os.getuid() != 0:
     common.logit("\nA privilege separation config file exists but you are not root user\n so we cannot remove it at this time.")
     yn = common.ask_yn("Do you want to proceed")
     if yn == "n":
       common.logerr("Terminating at your request")
Example #18
0
 def install(self):
   common.logit ("======== %s install starting ==========" % self.ini_section)
   common.ask_continue("Continue")
   self.validate()
   self.__install_condor__()
   self.configure()
   common.logit ("======== %s install complete ==========" % self.ini_section)
   common.start_service(self.glideinwms_location(),self.ini_section,self.inifile)
 def validate_users(self):
   common.logit("... validating frontend user data")
   #--- factory ---
   user_valid = True
   try:
     self.factory_groups = self.get_groups(self.factory_user)
   except Exception,e:
     user_valid = False
     common.logit("ERROR: Factory user (%s) account not created" % self.factory_user)
Example #20
0
  def create_env_script(self):
    common.logit("\nCreating VO frontend env script.")
    data = """#!/bin/bash
. %(condor_location)s/condor.sh
export PYTHONPATH=$PYTHONPATH:%(install_location)s/..
""" % { "condor_location" : self.condor_location(),
        "install_location" : self.glideinwms_location(),}
    common.write_file("w",0644,self.env_script(),data)
    common.logit("VO frontend env script created: %s" % self.env_script() )
 def create_factory_client_dirs(self,owner,perm):
   dirs = [self.factory.client_log_dir(),self.factory.client_proxy_dir(),]
   for dir in dirs:
     common.logit("... checking factory client directory: %s" % dir)
     if os.path.isdir(dir):
       if len(os.listdir(dir)) > 0:
         common.ask_continue("This directory must be empty.  Can we delete the contents")
         common.remove_dir_contents(dir)
     common.make_directory(dir,owner,perm)
Example #22
0
 def condor_config_daemon_users(self):
   users = []
   if len(self.colocated_services) > 0:
     common.logit("... no updates to condor mapfile required")
     return users
   users.append(["Submit",        self.x509_gsi_dn(),               self.service_name()])
   users.append(["UserCollector", self.usercollector.x509_gsi_dn(), self.usercollector.service_name()])
   users.append(["VOFrontend",    self.frontend.x509_gsi_dn(),      self.frontend.service_name()])
   return users
Example #23
0
  def validate_client_proxy_dir(self):
    common.logit("... validating client_proxy_dir: %s" % self.client_proxy_dir())
    if self.wms.privilege_separation() == "y":
      #-- done in WMS collector install if privilege separation is used --
      if not os.path.isdir(self.client_proxy_dir()):
        common.logerr("""Privilege separation is in effect. This should have been
created by the WMS Collector installation or you did not start the service 
or you changed the ini file and did not reinstall that service.""")
    else:
      common.make_directory(self.client_proxy_dir(),self.username(),0755)
Example #24
0
 def stop_condor(self):
   if self.client_only_install == True:
     common.logerr( "This is a client only install. Nothing to stop.")
   if self.install_type() == 'rpm':
     common.run_script("service condor stop")
   else: 
     if os.path.isfile(self.initd_script()):
       common.logit( "... stopping condor as user %s" % self.username())
       common.run_script("%s stop" % self.initd_script())
   common.run_script("sleep 2")
Example #25
0
  def select_schedds(self,default_schedds):
    if len(default_schedds) == 1:
      schedds = default_schedds
    else:
      schedds = self.select_schedds_to_monitor(default_schedds)

    common.logit("\nThe following schedds will be used:")
    for i in range(len(schedds)):
      common.logit(" [%i] %s"%(i+1,schedds[i]))
    return schedds
Example #26
0
def main(argv):
  try:
    create_template() 
    #options = validate_args(argv)
    #user = UserCollector(options.inifile)
    #user.start_me()
    #user.install()
    #user.configure_gsi_security()
  except KeyboardInterrupt, e:
    common.logit("\n... looks like you aborted this script... bye.")
    return 1
Example #27
0
def main(argv):
  try:
    inifile = "/home/weigand/glidein/glideinWMS/install/weigand.ini"
    client = VDTClient("WMSCollector",inifile)
    client.install()
    print "Client exists: ",client.client_exists()
  except common.WMSerror:
    return 1
  except KeyboardInterrupt:
    common.logit("\n... looks like you aborted this script... bye.")
    return 1
Example #28
0
def main(argv):
  try:
    create_template()
    #options = validate_args(argv)
    #submit = Submit(options.inifile)
    #submit.install()
    #submit.configure_gsi_security()
    #submit.__validate_tarball__(submit.condor_tarball())
  except KeyboardInterrupt, e:
    common.logit("\n... looks like you aborted this script... bye.")
    return 1
Example #29
0
  def set_javascriptrrd_dir(self,filename):
    msg =  "... validating javascriptrrd_location for %s: " % filename
    fullpath = common.find_fullpath(self.javascriptrrd_location(), filename)
    if fullpath == None:
      common.logit(msg)
      common.logerr("""%s not found in %s path
Did you install the correct javascriptrrd rpm?
""" % (filename,self.javascriptrrd_location()))
    dir = os.path.dirname(fullpath)
    msg +="available"
    common.logit(msg)
    return dir
Example #30
0
 def __create_initd_script__(self):
   if self.client_only_install == True:
     common.logit("... client only install. No startup initd script required.")
     return
   if self.install_type() == "rpm":
     common.logit("... This is an 'rpm' install. An initd script already exists.")
     return
   common.logit("")
   common.logit("Creating startup /etc/init.d script")
   common.logit("   %s" % self.initd_script())
   data = self.__initd_script__()
   common.write_file("w",0755,self.initd_script(),data,SILENT=True)