示例#1
0
def main():
    Script.disableCS()
    params = Params()
    if six.PY3 and len(sys.argv) < 2:
        runConfigurationWizard(params)
    else:
        return runDiracConfigure(params)
示例#2
0
def main():
    Script.disableCS()
    Script.parseCommandLine()

    from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller

    gComponentInstaller.exitOnError = True
    gComponentInstaller.setupPortal()
def main():
    Script.disableCS()

    Script.registerSwitch("t:", "type=",
                          "Installation type. 'server' by default.",
                          setInstallType)
    Script.parseCommandLine(ignoreErrors=True)

    # Collect all the requested python modules to install
    reqDict = {}
    for entry in os.listdir(rootPath):
        if len(entry) < 5 or entry.find("DIRAC") != len(entry) - 5:
            continue
        reqFile = os.path.join(rootPath, entry, "releases.cfg")
        try:
            with open(reqFile, "r") as extfd:
                reqCFG = CFG().loadFromBuffer(extfd.read())
        except Exception:
            gLogger.verbose("%s not found" % reqFile)
            continue
        reqList = reqCFG.getOption(
            "/RequiredExternals/%s" % instType.capitalize(), [])
        if not reqList:
            gLogger.verbose(
                "%s does not have requirements for %s installation" %
                (entry, instType))
            continue
        for req in reqList:
            reqName = False
            reqCond = ""
            for cond in ("==", ">="):
                iP = cond.find(req)
                if iP > 0:
                    reqName = req[:iP]
                    reqCond = req[iP:]
                    break
            if not reqName:
                reqName = req
            if reqName not in reqDict:
                reqDict[reqName] = (reqCond, entry)
            else:
                gLogger.notice("Skipping %s, it's already requested by %s" %
                               (reqName, reqDict[reqName][1]))

    if not reqDict:
        gLogger.notice("No extra python module requested to be installed")
        sys.exit(0)

    for reqName in reqDict:
        package = "%s%s" % (reqName, reqDict[reqName][0])
        gLogger.notice("Requesting installation of %s" % package)
        status, output = pipInstall(package)
        if status != 0:
            gLogger.error(output)
        else:
            gLogger.notice("Successfully installed %s" % package)
示例#4
0
def main():
    global piParams, pI
    piParams = Params()
    piParams.registerCLISwitches()

    Script.disableCS()
    Script.parseCommandLine(ignoreErrors=True)
    DIRAC.gConfig.setOptionValue("/DIRAC/Security/UseServerCertificate",
                                 "False")

    pI = ProxyInit(piParams)
    resultDoTheMagic = pI.doTheMagic()
    if not resultDoTheMagic["OK"]:
        gLogger.fatal(resultDoTheMagic["Message"])
        sys.exit(1)

    pI.printInfo()

    sys.exit(0)
示例#5
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)
示例#6
0
def main():
    Script.disableCS()
    # Registering arguments will automatically add their description to the help menu
    Script.registerArgument(
        " System:  Name of the system for the component (default *: all)", mandatory=False, default="*"
    )
    Script.registerArgument(
        (
            "Service: Name of the particular component (default *: all)",
            "Agent:   Name of the particular component (default *: all)",
        ),
        mandatory=False,
        default="*",
    )
    _, args = Script.parseCommandLine()
    system, component = Script.getPositionalArgs(group=True)

    from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller

    __RCSID__ = "$Id$"

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

    if len(args) > 0:
        system = args[0]
    if system != "*":
        if len(args) > 1:
            component = args[1]
    #
    gComponentInstaller.exitOnError = True
    #
    result = gComponentInstaller.getStartupComponentStatus([system, component])
    if not result["OK"]:
        print("ERROR:", result["Message"])
        exit(-1)

    gComponentInstaller.printStartupStatus(result["Value"])
示例#7
0
def main():
    params = Params()

    Script.registerSwitch("f:", "file=", "File to use as user key", params.setProxyLocation)
    Script.registerSwitch("i", "version", "Print version", params.showVersion)
    Script.registerSwitch("n", "novoms", "Disable VOMS", params.disableVOMS)
    Script.registerSwitch("v", "checkvalid", "Return error if the proxy is invalid", params.validityCheck)
    Script.registerSwitch("x", "nocs", "Disable CS", params.disableCS)
    Script.registerSwitch("e", "steps", "Show steps info", params.showSteps)
    Script.registerSwitch("j", "noclockcheck", "Disable checking if time is ok", params.disableClockCheck)
    Script.registerSwitch("m", "uploadedinfo", "Show uploaded proxies info", params.setManagerInfo)

    Script.disableCS()
    Script.parseCommandLine()

    from DIRAC.Core.Utilities.NTP import getClockDeviation
    from DIRAC import gLogger
    from DIRAC.Core.Security.ProxyInfo import getProxyInfo, getProxyStepsInfo
    from DIRAC.Core.Security.ProxyInfo import formatProxyInfoAsString, formatProxyStepsInfoAsString
    from DIRAC.Core.Security import VOMS
    from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
    from DIRAC.ConfigurationSystem.Client.Helpers import Registry

    if params.csEnabled:
        retVal = Script.enableCS()
        if not retVal["OK"]:
            print("Cannot contact CS to get user list")

    if params.checkClock:
        result = getClockDeviation()
        if result["OK"]:
            deviation = result["Value"]
            if deviation > 600:
                gLogger.error("Your host clock seems to be off by more than TEN MINUTES! Thats really bad.")
            elif deviation > 180:
                gLogger.error("Your host clock seems to be off by more than THREE minutes! Thats bad.")
            elif deviation > 60:
                gLogger.error("Your host clock seems to be off by more than a minute! Thats not good.")

    result = getProxyInfo(params.proxyLoc, not params.vomsEnabled)
    if not result["OK"]:
        gLogger.error(result["Message"])
        sys.exit(1)
    infoDict = result["Value"]
    gLogger.notice(formatProxyInfoAsString(infoDict))
    if not infoDict["isProxy"]:
        gLogger.error("==============================\n!!! The proxy is not valid !!!")

    if params.steps:
        gLogger.notice("== Steps extended info ==")
        chain = infoDict["chain"]
        stepInfo = getProxyStepsInfo(chain)["Value"]
        gLogger.notice(formatProxyStepsInfoAsString(stepInfo))

    def invalidProxy(msg):
        gLogger.error("Invalid proxy:", msg)
        sys.exit(1)

    if params.uploadedInfo:
        result = gProxyManager.getUserProxiesInfo()
        if not result["OK"]:
            gLogger.error("Could not retrieve the uploaded proxies info", result["Message"])
        else:
            uploadedInfo = result["Value"]
            if not uploadedInfo:
                gLogger.notice("== No proxies uploaded ==")
            if uploadedInfo:
                gLogger.notice("== Proxies uploaded ==")
                maxDNLen = 0
                maxGroupLen = 0
                for userDN in uploadedInfo:
                    maxDNLen = max(maxDNLen, len(userDN))
                    for group in uploadedInfo[userDN]:
                        maxGroupLen = max(maxGroupLen, len(group))
                gLogger.notice(" %s | %s | Until (GMT)" % ("DN".ljust(maxDNLen), "Group".ljust(maxGroupLen)))
                for userDN in uploadedInfo:
                    for group in uploadedInfo[userDN]:
                        gLogger.notice(
                            " %s | %s | %s"
                            % (
                                userDN.ljust(maxDNLen),
                                group.ljust(maxGroupLen),
                                uploadedInfo[userDN][group].strftime("%Y/%m/%d %H:%M"),
                            )
                        )

    if params.checkValid:
        if infoDict["secondsLeft"] == 0:
            invalidProxy("Proxy is expired")
        if params.csEnabled and not infoDict["validGroup"]:
            invalidProxy("Group %s is not valid" % infoDict["group"])
        if "hasVOMS" in infoDict and infoDict["hasVOMS"]:
            requiredVOMS = Registry.getVOMSAttributeForGroup(infoDict["group"])
            if "VOMS" not in infoDict or not infoDict["VOMS"]:
                invalidProxy("Unable to retrieve VOMS extension")
            if len(infoDict["VOMS"]) > 1:
                invalidProxy("More than one voms attribute found")
            if requiredVOMS not in infoDict["VOMS"]:
                invalidProxy(
                    "Unexpected VOMS extension %s. Extension expected for DIRAC group is %s"
                    % (infoDict["VOMS"][0], requiredVOMS)
                )
            result = VOMS.VOMS().getVOMSProxyInfo(infoDict["chain"], "actimeleft")
            if not result["OK"]:
                invalidProxy("Cannot determine life time of VOMS attributes: %s" % result["Message"])
            if int(result["Value"].strip()) == 0:
                invalidProxy("VOMS attributes are expired")

    sys.exit(0)
示例#8
0
 def platform(arg):
     Script.disableCS()
     print(DIRAC.getPlatform())
     DIRAC.exit(0)
示例#9
0
 def version(arg):
     Script.disableCS()
     print(DIRAC.version)
     DIRAC.exit(0)