Пример #1
0
  def install(self):
    common.logit("\nVerifying VDT client installation")
    common.logit("... validating vdt_location: %s" % self.vdt_location())
    common.check_for_value("vdt_location",self.vdt_location())
    if self.client_exists():
      common.logit("... installed in: %s" % self.vdt_location())
      return
    common.ask_continue("""... VDT client not found in: %s
This script is checking for the presence of 2 scripts:
  setup.sh and voms-proxy-init 
Is it OK to install it in this location""" % self.vdt_location())
    packages = ""
    for package in self.vdt_packages:
      packages = packages + "%s:%s " % (self.vdt_cache(),package)
    for package in self.osg_packages:
      packages = packages + "%s:%s " % (self.osg_cache(),package)
    
    common.logit("\n======== VDT Client install starting ==========")
    common.logit("The packages that will be installed are:")
    for package in packages.split(" "):
      common.logit("  %s" % package)
    self.install_vdt_package(packages)
    if self.client_exists():
      common.logit("... VDT client installation looks good")
    common.logit("======== VDT Client install complete ==========\n")
    common.ask_continue("Continue installation")
Пример #2
0
  def determine_colocated_services(self):
    """ The submit/schedd service can share the same instance of Condor with
        the UserCollector and/or VOFrontend.  So we want to check and see if
        this is the case.  We will skip the installation of Condor and just
        perform the configuration of the condor_config file.
    """
    if self.install_type() == "rpm":
      return # Not needed for RPM install
    services = ""
    # -- if not on same host, we don't have any co-located
    if self.hostname()           == self.usercollector.hostname():
      if  self.condor_location() == self.usercollector.condor_location():
        self.daemon_list += " %s" % self.usercollector.daemon_list
        self.colocated_services.append("usercollector")
      else:
        services += "User Collector "

    # -- determine services which are collocated ---
    if len(services) > 0:
      common.ask_continue("""These services are on the same node yet have different condor_locations:
  %s
Do you really want to continue.""" % services)
    if len(self.colocated_services) > 0:
      common.ask_continue("""These services are on the same node and share condor_locations:
  %(services)s
You will need the options from that service included in the %(section)s
of your ini file.
Do you want to continue.""" % { "services" : self.colocated_services,
                                "section"  : self.ini_section} )
Пример #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()
Пример #4
0
  def install(self):
    """ Installs the VDT CA package if X509 CA certiificates do not already
        exist. 
    """
    common.logit("\nVerifying CA Certificates installation")
    if self.certificates_exist():
      common.logit("... CA Certificates (%(option)s) exist: %(dir)s" % \
       { "option" : self.option,
         "dir"    : self.x509_cert_dir()})
      return
    common.ask_continue("""... CA Certificates (%(option)s) not found: 
  %(dir)s
This script is checking for the presence of CA (*.0) and CRL (*.r0) files.
Is it OK to install it in this location""" % \
       { "option" : self.option,
         "dir"    : self.x509_cert_dir(),})
    if common.not_writeable(os.path.dirname(self.x509_cert_dir())):
      common.logerr("""You do not have permissions to write in the directory specified 
by the %(option)s: %(dir)s""" % \
       { "option" : self.option,
         "dir"    : self.x509_cert_dir(),})
    common.logit(""" CA certificates install starting. The packages that will be installed are:
   %(package)s""" % { "package" : self.package,})
    self.install_vdt_package(self.package)
    common.logit("... retrieving certificates") 
    common.run_script("source %(vdt_location)s/setup.sh; %(vdt_location)s/vdt/bin/vdt-ca-manage setupca --location %(dir)s --url osg" % \
       { "vdt_location" : self.vdt_location(),
         "dir"          : os.path.dirname(self.x509_cert_dir())})
    self.create_crontab()
    if self.certificates_exist():
      common.logit("... certificate installation looks good")
    common.logit("\nCA certificates install complete\n")
    common.ask_continue("Continue installation")
Пример #5
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)
Пример #6
0
 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)
Пример #7
0
 def install(self):
   common.logit ("======== %s install starting ==========\n" % self.ini_section)
   self.get_wms()
   self.get_frontend()
   common.ask_continue("Continue")
   self.validate()
   self.clean_directories()
   self.configure()
   common.logit ("\n======== %s install complete ==========\n" % self.ini_section)
   self.create_glideins()
   if os.path.isdir(self.glidein_dir()): #indicates the glideins have been created
     common.start_service(self.glideinwms_location(),self.ini_section,self.inifile)
Пример #8
0
 def install(self):
   common.logit ("======== %s install starting ==========" % self.ini_section)
   common.ask_continue("Continue")
   self.validate()
   if "usercollector" not in self.colocated_services:
     self.__install_condor__()
   self.configure()
   common.logit ("======== %s install complete ==========" % self.ini_section)
   if "usercollector" not in self.colocated_services:
     common.start_service(self.glideinwms_location(),self.ini_section,self.inifile) 
   else:
     self.stop_condor()
     self.start_condor()
Пример #9
0
 def verify_directories_empty(self):
   """ This method attempts to clean up all directories so a fresh install
       can be accomplished successfully.  
       It is consoldiated in a single check so as to only ask once and
       not for each directory.
       It also (attempts) to insure that if directories are nested, it 
       does not create a problem.  Not an easy task.
       When privilege separation is in effect, the condor_root_switchboard
       must be used to clean out the client log and proxy files 
       as the owners are different and permissions problems will occur.
   """
   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():
     if self.wms.privilege_separation() == "y":
       if option in ["client_log_dir","client_proxy_dir",]:
         #-- Factory create requires these 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[option]
         subdirs = os.listdir(parent_dir)
         for base_dir in subdirs:
           if os.path.isdir("%s/%s" % (parent_dir,base_dir)): 
             condorPrivsep.rmtree(parent_dir,base_dir)
       else: 
         common.remove_dir_contents(dirs[option])
     else: 
       common.remove_dir_contents(dirs[option])
   # this re-validation is performed to resolve problem of nesting some dirs
   self.validate_needed_directories()
Пример #10
0
    def install_pacman(self):
        """ Installs pacman if not present. """
        common.logit("... validating pacman_location: %s" % self.pacman_location())
        common.check_for_value("pacman_location", self.pacman_location())
        if self.pacman_is_installed():
            os.system("sleep 2")
            return  # -- no need to install pacman--
        common.ask_continue(
            """
Pacman is required and does not appear to be installed in:
  %(pacman_location)s
... continue with pacman installation"""
            % self.messagesDict
        )
        common.logit(
            """
======== pacman install starting ========== """
        )
        common.check_for_value("pacman_location", self.pacman_location())
        if os.path.exists(self.pacman_location()):
            common.logerr(
                """The pacman_location for the pacman installation already exists 
and should not.  This script was looking for a setup.sh in that directory 
and it did not exist.  If a valid pacman distribution, it may be corrupt or the 
pacman_location  is incorrect.  Please verify."""
            )
        common.logit("... validating pacman_url: %s" % self.pacman_url())
        common.check_for_value("pacman_url", self.pacman_url())
        if not common.wget_is_valid(self.pacman_urlfile()):
            common.logerr(
                """A pacman tarball of this name does not exist at:
    %(pacman_urlfile)s
... please verify."""
                % self.messagesDict
            )
        os.system("sleep 2")
        common.make_directory(self.pacman_parent(), self.username(), 0755)
        common.run_script(
            "cd %(pacman_parent)s && wget %(pacman_urlfile)s && tar --no-same-owner -xzf %(pacman_tarball)s && rm -f  %(pacman_tarball)s"
            % self.messagesDict
        )
        if not self.pacman_is_installed():
            common.logerr("Pacman install failed. No setup.sh file exists in: %(pacman_location)s" % self.messagesDict)
        common.logit(
            """... pacman requires the setup script to be sourced to initialize 
    some variables in it for subsequent use."""
        )
        common.run_script("cd %(pacman_location)s && source setup.sh" % self.messagesDict)
        common.logit("\nPacman successfully installed: %(pacman_location)s" % self.messagesDict)
        common.logit("======== pacman install complete ==========\n")
        os.system("sleep 2")
Пример #11
0
  def create_crontab(self):
    """ Using the vdt-control script, enable and activate the crontab entries.
    """
    common.logit("... creating crontab entries using vdt-control script")
    #-- if not root, VDT requires a special arg to enable or activate a service
    if os.getuid() == 0:
      non_root_arg = ""
    else:
      non_root_arg = " --non-root"

    for service in self.vdt_services:
      common.logit("\n...... %(service)s" % { "service" :service,})
      common.run_script(". %(vdt_location)s/setup.sh;vdt-control %(non_root_arg)s --enable %(service)s;vdt-control %(non_root_arg)s --on %(service)s" % \
           { "vdt_location" : self.vdt_location(),
             "non_root_arg" : non_root_arg,
             "service"      : service,} )
    common.logit("\nvdt-control --list")
    cmd = ". %(vdt_location)s/setup.sh;vdt-control --list" % \
           { "vdt_location" : self.vdt_location(),}
    stdout = glideinwms.lib.subprocessSupport.iexe_cmd(cmd,useShell=True)
    common.logit(stdout)

    #-- show the cron entries added - extract the lines put in cron
    common.logit("\n... %(user)s crontab entries:" % \
         { "user" : pwd.getpwuid(os.getuid())[0],})
    services_file = "%(vdt_location)s/vdt/services/state" % \
         { "vdt_location" : self.vdt_location(),}
    try:
      fd = open(services_file,'r')
      lines = fd.readlines()
    except:
      common.logerr("Unable to read VDT services file: %(services_file)s" % 
         { "services_file" : services_file,})
    fd.close()
    fetch_crl_script = None
    for line in lines:
      els = line.split("\t")
      if (els[1] != 'cron'):
        continue # not a cron line
      if els[0] in self.vdt_services:
         common.logit("  %(cron_time)s %(cron_process)s" % \
             { "cron_time"    : els[4],
               "cron_process" : els[5].rstrip(),})
      if els[0] == "fetch-crl":
        fetch_crl_script = els[5].rstrip()
    common.ask_continue("""\n... the glidein services require that CRL files (*.r0) be present
in the certificates directory.  Is it OK to run the script now?""")
    if fetch_crl_script == None:
      common.logerr("We have a problem.  There does not appear to be a cron entry for the CRL retrieval")
    common.run_script(fetch_crl_script) 
    common.logit("")
Пример #12
0
  def clean_directories(self):
    """ This method attempts to clean up all directories so a fresh install
        can be accomplished successfully.  
        It is consoldiated in a single check so as to only ask once and
        not for each directory.
        When privilege separation is in effect, the condor_root_switchboard
        must be used to clean out the client log and proxy files 
        as the owners are different and permissions problems will occur.
    """
    instance_dir = "glidein_%(instance)s" % \
                     { "instance" : self.glidein.instance_name(), }
    dirs = {}
    dirs["logs"] = os.path.join(self.logs_dir(),instance_dir)
    dirs["install"] = os.path.join(self.install_location(),instance_dir)
#    dirs["config"] = self.config_dir()
    for frontend in self.wms.frontend_users().keys():
      dirs["client logs"]    = self.client_log_dir()
      dirs["client proxies"] = self.client_proxy_dir()
    for subdir in ["monitor","stage"]:
      dirs["web %s" % subdir] = os.path.join(self.glidein.web_location(),subdir,instance_dir)

    #--- check them --
    dirs = self.verify_directories_empty(dirs)

    #--- if all are empty, return 
    if len(dirs) == 0:
      time.sleep(3)
      return  # all directories are empty

    #--- See if we can remove them ---
    common.logit("""The following directories must be empty for the install to succeed: """)
    types = dirs.keys()
    types.sort()
    for type in types:
      common.logit("""  %(type)s: %(dir)s""" % \
                        { "type" : type, "dir" : dirs[type] })
    common.ask_continue("... can we remove their contents")
    if self.wms.privilege_separation() == "y":
      self.delete_ps_directories(dirs)
    else:
      self.delete_nps_directories(dirs)

    #--- double check them --
    dirs = self.verify_directories_empty(dirs)
    if len(dirs) > 0:
      common.logerr("""We seem to have had a problems deleting the contents of these directories:
%s """ % dirs)

    time.sleep(3)
    return  # all directories are empty
Пример #13
0
  def install(self):
    common.logit ("======== %s install starting ==========" % self.ini_section)
    common.ask_continue("Continue")
    self.validate()
#    if self.install_type() == "tarball":
##      if len(self.colocated_services) == 0 or \
##         self.condor_is_installed() is False:
#      self.__install_condor__()
    if self.install_type() == "tarball":
      self.verify_directories_empty()
    self.configure()
    common.logit ("\n======== %s install complete ==========\n" % self.ini_section)
    self.create_frontend()
    self.start()
Пример #14
0
 def __verify_directories_empty__(self):
     if self.install_type() == "rpm":
         return  # For RPM install we don't want to clean anything
     dirs = {}
     if len(os.listdir(self.condor_location())) > 0:
         dirs["condor_location"] = self.condor_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])
     self.__validate_needed_directories__()
Пример #15
0
  def install(self):
    """ Installs the VDT CA package if X509 CA certiificates do not already
        exist. 
    """
    common.logit("\nVerifying CA Certificates installation")
    common.logit("... validating %(option)s: %(dir)s" % \
                       { "option" : self.option,
                         "dir"    : self.x509_cert_dir()})
    if self.certificates_exist():
      common.logit("... CA Certificates exist with *.0 and *.r0 files")
      return
    common.ask_continue("""There were no certificate (*.0) or CRL (*.r0) files found.
These can be installed from the VDT using pacman.  
If you want to do this, these options must be set:
  vdt_location  pacman_url  pacman_location
Additionally your %(option)s should specify this location: 
   vdt_location/globus/TRUSTED_CA 
Is it OK to proceed with the installation of certificates with these settings.
If not, stop and correct the %(option)s""" % { "option"       : self.option, })

    common.logit("... verifying vdt_location: %s" % self.vdt_location())
    common.check_for_value("vdt_location",self.vdt_location())
    common.logit("... verifying pacman_location: %s" % self.pacman_location())
    common.check_for_value("pacman_location",self.pacman_location())
    common.logit("... verifying pacman_url: %s" % self.pacman_url())
    common.check_for_value("pacman_url",self.pacman_url())

    expected_x509_cert_dir = "%s/globus/TRUSTED_CA" % self.vdt_location()
    if self.x509_cert_dir() != expected_x509_cert_dir:
      common.logerr("""Sorry but the %(option)s must be set to %(expected)s""" % \
                       { "option"  : self.option,
                         "expected" : expected_x509_cert_dir,} )

    if common.not_writeable(os.path.dirname(self.vdt_location())):
      common.logerr("""You do not have permissions to create the vdt_location 
option specified: %(dir)s""" %  { "dir"    : self.vdt_location(),})
    common.logit(""" CA certificates install starting. The packages that will be installed are:
   %(package)s""" % { "package" : self.package,})
    self.install_vdt_package(self.package)
    common.logit("... retrieving certificates") 
    common.run_script(". %(vdt_location)s/setup.sh; %(vdt_location)s/vdt/bin/vdt-ca-manage setupca --location %(dir)s --url osg" % \
       { "vdt_location" : self.vdt_location(),
         "dir"          : os.path.dirname(self.x509_cert_dir())})
    self.create_crontab()
    if self.certificates_exist():
      common.logit("... certificate installation looks good")
    common.logit("\nCA certificates install complete\n")
    common.ask_continue("Continue installation")
def restart_service(args):
    nodeId = args.nodeid
    serviceName = args.servicename
    nodename = args.nodename

    try:
        if(args.nodename is not None and args.nodeid is not None):
            print "Error: Enter either Node name or Node ID "
            return
        if(args.nodename is None and args.nodeid is None):
            print "Error : Enter either Node name or Node ID "
            return
            
        response = common.ask_continue(
            "restart service:" +
            serviceName )
        if(str(response) == "y"):
            contrlSvcObj = ControlService(args.ip, args.port)
            contrlSvcObj.restartService(nodeId, serviceName , nodename)
    except SOSError as e:
        common.format_err_msg_and_raise(
            "restart-service",
            serviceName ,
            e.err_text,
            e.err_code)
Пример #17
0
def restart_service(args):
    nodeId = args.nodeid
    serviceName = args.servicename
    nodename = args.nodename

    try:
        if(args.nodename is not None and args.nodeid is not None):
            print "Error: Enter either Node name or Node ID "
            return
        if(args.nodename is None and args.nodeid is None):
            print "Error : Enter either Node name or Node ID "
            return
            
        response = common.ask_continue(
            "restart service:" +
            serviceName )
        if(str(response) == "y"):
            contrlSvcObj = ControlService(args.ip, args.port)
            contrlSvcObj.restartService(nodeId, serviceName , nodename)
    except SOSError as e:
        common.format_err_msg_and_raise(
            "restart-service",
            serviceName ,
            e.err_text,
            e.err_code)
Пример #18
0
  def verify_directories_empty(self):
    """ This method attempts to clean up all directories so a fresh install
        can be accomplished successfully.
        It is consoldiated in a single check so as to only ask once and
        not for each directory.
    """
    if self.install_type == "rpm":
      return  # For RPM install we don't want to clean anything

    instance_dir = "frontend_%(service)s-%(instance)s" % \
                     { "service" : self.service_name(), 
                       "instance" : self.glidein.instance_name(), }
    #-- directories to check ---
    dirs = {}
    dirs["logs........"] = os.path.join(self.logs_dir(),instance_dir)
    dirs["install....."] = os.path.join(self.install_location(),instance_dir) 
    dirs["config......"] = self.config_dir()
    for subdir in ["monitor","stage"]:
      dirs["web %s " % subdir] = os.path.join(self.glidein.web_location(),subdir,instance_dir)
    #--- check them --
    for type in dirs.keys():
      if os.path.isdir(dirs[type]): 
        if len(os.listdir(dirs[type])) == 0:
          os.rmdir(dirs[type])
          del dirs[type]  # remove from dict
      else:
        del dirs[type]  # it does not exist, remove from dict

    #--- if all are empty, return      
    if len(dirs) == 0:
      time.sleep(3)
      return  # all directories are empty

    #--- See if we can remove them --- 
    common.logit("""The following directories must be empty for the install to succeed: """)
    types = dirs.keys()
    types.sort()
    for type in types:
      common.logit("""  %(type)s: %(dir)s""" % \
                        { "type" : type, "dir" : dirs[type] })
    common.ask_continue("... can we remove their contents")
    for type in dirs.keys():
      common.remove_dir_contents(dirs[type])
      os.rmdir(dirs[type])
    time.sleep(3)
    return
Пример #19
0
def cluster_poweroff(args):

    try:
        response = common.ask_continue("power-off the cluster")
        if str(response) == "y":
            contrlSvcObj = ControlService(args.ip, args.port)
            contrlSvcObj.clusterPoweroff()
    except SOSError as e:
        common.format_err_msg_and_raise("cluster-poweroff", "", e.err_text, e.err_code)
Пример #20
0
def cluster_poweroff(args):

    try:
        response = common.ask_continue("power-off the cluster")
        if (str(response) == "y"):
            contrlSvcObj = ControlService(args.ip, args.port)
            contrlSvcObj.clusterPoweroff()
    except SOSError as e:
        common.format_err_msg_and_raise("cluster-poweroff", "", e.err_text,
                                        e.err_code)
def reboot_node(args):
    nodeId = args.nodeid

    try:
        response = common.ask_continue("reboot node:" + nodeId)
        if (str(response) == "y"):
            contrlSvcObj = ControlService(args.ip, args.port)
            contrlSvcObj.rebootNode(nodeId)
    except SOSError as e:
        common.format_err_msg_and_raise("reboot-node", nodeId, e.err_text,
                                        e.err_code)
def restart_service(args):
    nodeId = args.nodeid
    serviceName = args.servicename

    try:
        response = common.ask_continue("restart service:" + serviceName +
                                       " in node: " + nodeId)
        if (str(response) == "y"):
            contrlSvcObj = ControlService(args.ip, args.port)
            contrlSvcObj.restartService(nodeId, serviceName)
    except SOSError as e:
        common.format_err_msg_and_raise("restart-service",
                                        serviceName + " in node: " + nodeId,
                                        e.err_text, e.err_code)
Пример #23
0
def reboot_node(args):
    nodeId = args.nodeid

    try:
        response = common.ask_continue("reboot node:" + nodeId)
        if(str(response) == "y"):
            contrlSvcObj = ControlService(args.ip, args.port)
            contrlSvcObj.rebootNode(nodeId)
    except SOSError as e:
        common.format_err_msg_and_raise(
            "reboot-node",
            nodeId,
            e.err_text,
            e.err_code)
Пример #24
0
 def verify_directories_empty(self):
   if self.install_type == "rpm":
     return  # For RPM install we don't want to clean anything
   dirs = {}
   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])
   self.validate_needed_directories()
Пример #25
0
def reboot_node(args):
    nodeid = args.nodeid
    nodename = args.nodename

    try:
        if args.nodename is not None and args.nodeid is not None:
            print " Enter Either Nodename or Nodeid "
            return
        if args.nodename is None and args.nodeid is None:
            print "Error : Enter either Node name or Node ID "
            return
        response = common.ask_continue("reboot node:")
        if str(response) == "y":
            contrlSvcObj = ControlService(args.ip, args.port)
            contrlSvcObj.rebootNode(nodeid, nodename)
    except SOSError as e:
        common.format_err_msg_and_raise("reboot-node", "nodeid ", e.err_text, e.err_code)
Пример #26
0
def reboot_node(args):
    nodeid = args.nodeid
    nodename = args.nodename

    try:
        if (args.nodename is not None and args.nodeid is not None):
            print " Enter Either Nodename or Nodeid "
            return
        if (args.nodename is None and args.nodeid is None):
            print "Error : Enter either Node name or Node ID "
            return
        response = common.ask_continue("reboot node:")
        if (str(response) == "y"):
            contrlSvcObj = ControlService(args.ip, args.port)
            contrlSvcObj.rebootNode(nodeid, nodename)
    except SOSError as e:
        common.format_err_msg_and_raise("reboot-node", "nodeid ", e.err_text,
                                        e.err_code)
Пример #27
0
def restart_service(args):
    nodeId = args.nodeid
    serviceName = args.servicename

    try:
        response = common.ask_continue(
            "restart service:" +
            serviceName +
            " in node: " +
            nodeId)
        if(str(response) == "y"):
            contrlSvcObj = ControlService(args.ip, args.port)
            contrlSvcObj.restartService(nodeId, serviceName)
    except SOSError as e:
        common.format_err_msg_and_raise(
            "restart-service",
            serviceName +
            " in node: " +
            nodeId,
            e.err_text,
            e.err_code)
Пример #28
0
  def verify_directories_empty(self):
    """ This method attempts to clean up all directories so a fresh install
        can be accomplished successfully.  
        It is consoldiated in a single check so as to only ask once and
        not for each directory.
        When privilege separation is in effect, the condor_root_switchboard
        must be used to clean out the client log and proxy files 
        as the owners are different and permissions problems will occur.
    """
    instance_dir = "glidein_%(instance)s" % \
                     { "instance" : self.glidein.instance_name(), }
    dirs = {}
    dirs["logs.........."] = os.path.join(self.logs_dir(),instance_dir)
    dirs["install......."] = os.path.join(self.install_location(),instance_dir)
    dirs["config........"] = self.config_dir()
    for frontend in self.wms.frontend_users().keys():
      ## user = "******" + self.wms.frontend_users()[frontend]
      ## dirs["%s client logs..." % user] = os.path.join(self.client_log_dir(),user,instance_dir)
      ## dirs["%s client proxies" % user] = os.path.join(self.client_proxy_dir(),user,instance_dir)
      dirs["client logs"]    = self.client_log_dir()
      dirs["client proxies"] = self.client_proxy_dir()
    for subdir in ["monitor","stage"]:
      dirs["web %s " % subdir] = os.path.join(self.glidein.web_location(),subdir,instance_dir)

    #--- check them --
    for type in dirs.keys():
      if os.path.isdir(dirs[type]):
        if len(os.listdir(dirs[type])) == 0:
          if self.wms.privilege_separation() == "y":
            if type in ["client logs", "client proxies",]:
              del dirs[type]  # remove from dict
            else: # will have permission to delete it
              # os.rmdir(dirs[type])
              del dirs[type]  # remove from dict
          else: # will have permission to delete it
            #os.rmdir(dirs[type])
            for rootdir, dirlist, filelist in os.walk(dirs[type],topdown=False):
                for filename in filelist:
                        os.remove(os.path.join(rootdir, filename))
            del dirs[type]  # remove from dict
      else: # it does not exist, remove from dict
        del dirs[type]  

    #--- if all are empty, return 
    if len(dirs) == 0:
      os.system("sleep 3")
      return  # all directories are empty

    #--- See if we can remove them ---
    common.logit("""The following directories must be empty for the install to succeed: """)
    types = dirs.keys()
    types.sort()
    for type in types:
      common.logit("""  %(type)s: %(dir)s""" % \
                        { "type" : type, "dir" : dirs[type] })
    common.ask_continue("... can we remove their contents")
    for type in dirs.keys():
      if self.wms.privilege_separation() == "y":
        if type in ["client logs", "client proxies",]:
          #-- Factory create requires these 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) 
        else:  # not client logs or proxies
          common.remove_dir_contents(dirs[type])
          os.rmdir(dirs[type])
      else: #no privsep in effect
        common.remove_dir_contents(dirs[type])
        os.rmdir(dirs[type])