コード例 #1
0
ファイル: Certificates.py プロジェクト: Akel/glideinWMS
  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")
コード例 #2
0
ファイル: VOFrontend.py プロジェクト: Akel/glideinWMS
 def start(self):
   if self.install_type() == 'rpm':
     common.run_script("service frontend_startup start")
   else:
     startup_file = "%s/frontend_startup" % (self.frontend_dir())
     if os.path.isfile(startup_file): # indicates frontend has been created
       common.start_service(self.glideinwms_location(),self.ini_section,self.inifile) 
コード例 #3
0
ファイル: VOFrontend.py プロジェクト: Akel/glideinWMS
 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))
コード例 #4
0
ファイル: VDT.py プロジェクト: djw8605/glideinWMS
 def install_vdt_package(self,packages):
   """ Installs specified VDT packages. """
   self.install_pacman()
   common.logit("... validating vdt_location: %s" % self.vdt_location())
   common.check_for_value("vdt_location",self.vdt_location())
   common.make_directory(self.vdt_location(),self.username(),0755)
   #-- install vdt packages ---
   self.messagesDict["packages"] = packages
   common.logit("... installing VDT packages")
   common.run_script("export VDTSETUP_AGREE_TO_LICENSES=y; . %(pacman_location)s/setup.sh && cd %(vdt_location)s && pacman -trust-all-caches -get %(packages)s" % self.messagesDict)
   #--- vdt-post-install --
   common.run_script(". %(vdt_location)s/setup.sh && vdt-post-install" % self.messagesDict)
コード例 #5
0
ファイル: Condor.py プロジェクト: bbockelm/glideinWMS
 def __create_secondary_schedd_dirs__(self):
   if self.daemon_list.find("SCHEDD") < 0:
     return  # no schedds
   if self.number_of_schedds() == 1:
     return
   common.logit("")
   common.logit("Creating secondary schedd directories")
   cmd = ""
   if self.install_type() == "tarball":
     cmd = ". %s/condor.sh ;" % self.condor_location()
   cmd += "%s/install/services/init_schedd.sh" % self.glideinwms_location()
   common.run_script(cmd)
   common.logit("")
コード例 #6
0
ファイル: VDT.py プロジェクト: klarson1/master_test
    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")
コード例 #7
0
ファイル: Certificates.py プロジェクト: bbockelm/glideinWMS
  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("")
コード例 #8
0
ファイル: Certificates.py プロジェクト: djw8605/glideinWMS
  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")
コード例 #9
0
ファイル: backup.py プロジェクト: rampeer/virtualhosts
def mysql_dump(auth_data, user, folder):
    now_date = str(datetime.date.today())
    dump = run_script("mysqldump -u %s -p%s -h %s %s" %
                      (auth_data['mysql_username'],
                       auth_data['mysql_password'],
                       auth_data['mysql_host'],
                       user['name']), "")
    filename = user['name'] + "." + now_date + ".sql.gz"
    f = gzip.open(folder + filename, 'wb')
    f.write(dump)
    f.close()
    return filename
コード例 #10
0
ファイル: Condor.py プロジェクト: bbockelm/glideinWMS
 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")
コード例 #11
0
ファイル: Condor.py プロジェクト: bbockelm/glideinWMS
 def restart_condor(self):
   if self.client_only_install == True:
     common.logerr( "This is a client only install. Nothing to restart.")
   if self.install_type() == 'rpm':
     common.run_script("service condor restart")
   else:
     if os.path.isfile(self.initd_script()):
       common.logit( "... restarting condor as user %s" % self.username())
       common.run_script("%s restart" % self.initd_script())
     else:
       common.logerr("Condor startup script does not exist: " % self.initd_script())
   common.run_script("sleep 10")
コード例 #12
0
ファイル: Condor.py プロジェクト: bbockelm/glideinWMS
        common.run_script(cmdline)
    except Exception,e:
        #shutil.rmtree(self.condor_location())
        common.logerr("Condor installation failed - %s" % (e))
    
    #--  installation files not needed anymore --
    shutil.rmtree(tar_dir)

    #-- Moving contents of condor_local/condor_config.local to the main config
    #-- and dereferencing it in the main condor_config
    common.logit("""... copying contents of the condor_config.local file to the main condor_config.""")
    cmd = """cat %(condor_local)s/condor_config.local >> %(condor_config)s; > %(condor_local)s/condor_config.local; echo "LOCAL_CONFIG_FILE =" >> %(condor_config)s""" % \
           { "condor_local"  : self.condor_local(),
             "condor_config" : self.condor_config(),
           }
    common.run_script(cmd)
    common.logit("\nCondor installation complete")

  #-----------------------------
  def __validate_needed_directories__(self):
    self.__validate_condor_location__()

  #-----------------------------
  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
コード例 #13
0
ファイル: VOFrontend.py プロジェクト: Akel/glideinWMS
 def stop(self):
   if self.install_type() == 'rpm':
     common.run_script("service frontend_startup stop")
コード例 #14
0
            '--whitelist',
            os.path.join(common.SRC_DIR, 'build',
                         'check_gn_headers_whitelist.txt'),
            '--json',
            tempfile_path,
            '--verbose',
        ],
                                cwd=common.SRC_DIR)

        with open(tempfile_path) as f:
            failures = json.load(f)

    json.dump({
        'valid': True,
        'failures': failures,
    }, args.output)

    return rc


def main_compile_targets(args):
    json.dump([], args.output)


if __name__ == '__main__':
    funcs = {
        'run': main_run,
        'compile_targets': main_compile_targets,
    }
    common.run_script(sys.argv[1:], funcs)
コード例 #15
0
    else:
      gtest_args.extend(['--xvfb'])
      gtest_args.extend(script_args)

    rc = common.run_runtest(args, gtest_args + filter_tests)

    with open(tempfile_path) as f:
      results = json.load(f)

  json.dump({
      'valid': bool(rc == 0),
      'failures': results['failed'],
  }, args.output)

  return rc


def main_compile_targets(args):
  if 'android' == args.properties.get('target_platform'):
    json.dump(['${name}_apk'], args.output)
  else:
    json.dump(['$name'], args.output)


if __name__ == '__main__':
  funcs = {
    'run': main_run,
    'compile_targets': main_compile_targets,
  }
  sys.exit(common.run_script(sys.argv[1:], funcs))
コード例 #16
0
ファイル: VOFrontend.py プロジェクト: Akel/glideinWMS
 def reconfig(self):
   if self.install_type() == 'rpm':
     common.run_script("/etc/init.d/frontend_startup reconfig")
コード例 #17
0
        if self._temp_filter_file:
            os.unlink(self._temp_filter_file.name)

    def run_test(self):
        return super(TypUnittestAdapter, self).run_test()


def main():
    if any(r in sys.argv[1] for r in KNOWN_ISOLATED_SCRIPT_TEST_RUNNERS):
        adapter = IsolatedScriptTestAdapter()
    else:
        adapter = TypUnittestAdapter()
    return adapter.run_test()


# This is not really a "script test" so does not need to manually add
# any additional compile targets.
def main_compile_targets(args):
    json.dump([], args.output)


if __name__ == '__main__':
    # Conform minimally to the protocol defined by ScriptTest.
    if 'compile_targets' in sys.argv:
        funcs = {
            'run': None,
            'compile_targets': main_compile_targets,
        }
        sys.exit(common.run_script(sys.argv[1:], funcs))
    sys.exit(main())
コード例 #18
0
        os.path.join(common.SRC_DIR, 'build', 'check_gn_headers.py'),
        '--out-dir',
        os.path.join(args.paths['checkout'], 'out', args.build_config_fs),
        '--whitelist',
        os.path.join(common.SRC_DIR, 'build', 'check_gn_headers_whitelist.txt'),
        '--json', tempfile_path,
        '--verbose',
    ], cwd=common.SRC_DIR)

    with open(tempfile_path) as f:
      failures = json.load(f)

  json.dump({
      'valid': True,
      'failures': failures,
  }, args.output)

  return rc


def main_compile_targets(args):
  json.dump([], args.output)


if __name__ == '__main__':
  funcs = {
    'run': main_run,
    'compile_targets': main_compile_targets,
  }
  common.run_script(sys.argv[1:], funcs)