def main():
    params = Params()

    Script.registerSwitch("f:", "file=", "File to use as proxy", params.setProxyLocation)
    Script.registerSwitch("D", "DN", "Use DN as myproxy username", params.setDNAsUsername)
    Script.registerSwitch("i", "version", "Print version", params.showVersion)

    Script.addDefaultOptionValue("LogLevel", "always")
    Script.parseCommandLine()

    from DIRAC.Core.Security.MyProxy import MyProxy
    from DIRAC.Core.Security import Locations

    if not params.proxyLoc:
        params.proxyLoc = Locations.getProxyLocation()

    if not params.proxyLoc:
        print("Can't find any valid proxy")
        sys.exit(1)
    print("Uploading proxy file %s" % params.proxyLoc)

    mp = MyProxy()
    retVal = mp.uploadProxy(params.proxyLoc, params.dnAsUsername)
    if not retVal["OK"]:
        print("Can't upload proxy:")
        print(" ", retVal["Message"])
        sys.exit(1)
    print("Proxy uploaded")
    sys.exit(0)
Exemple #2
0
 def registerCLISwitches(self):
     Script.registerSwitch(
         "v:", "valid=", "Valid HH:MM for the proxy. By default is one month", self.setProxyLifeTime
     )
     Script.registerSwitch("C:", "Cert=", "File to use as user certificate", self.setCertLocation)
     Script.registerSwitch("K:", "Key=", "File to use as user key", self.setKeyLocation)
     Script.registerSwitch("P:", "Proxy=", "File to use as proxy", self.setProxyLocation)
     Script.registerSwitch("f", "onthefly", "Generate a proxy on the fly", self.setOnTheFly)
     Script.registerSwitch("p", "pwstdin", "Get passwd from stdin", self.setStdinPasswd)
     Script.registerSwitch("i", "version", "Print version", self.showVersion)
     Script.addDefaultOptionValue("LogLevel", "always")
Exemple #3
0
def main():
    cliParams = Params()

    Script.disableCS()
    Script.registerSwitch(
        "e", "exitOnError",
        "flag to exit on error of any component installation",
        cliParams.setExitOnError)

    Script.addDefaultOptionValue("/DIRAC/Security/UseServerCertificate", "yes")
    Script.addDefaultOptionValue("LogLevel", "INFO")
    Script.parseCommandLine()
    args = Script.getExtraCLICFGFiles()

    if len(args) > 1:
        Script.showHelp(exitCode=1)

    cfg = None
    if len(args):
        cfg = args[0]
    from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller

    gComponentInstaller.exitOnError = cliParams.exitOnError

    result = gComponentInstaller.setupSite(Script.localCfg, cfg)
    if not result["OK"]:
        print("ERROR:", result["Message"])
        exit(-1)

    result = gComponentInstaller.getStartupComponentStatus([])
    if not result["OK"]:
        print("ERROR:", result["Message"])
        exit(-1)

    print("\nStatus of installed components:\n")
    result = gComponentInstaller.printStartupStatus(result["Value"])
    if not result["OK"]:
        print("ERROR:", result["Message"])
        exit(-1)