Beispiel #1
0
    def _checkProxy(self):
        """checks if the proxy has the ProductionManagement property and belongs to a VO"""
        proxyInfo = getProxyInfo()
        if not proxyInfo["OK"]:
            self.errorMessages.append("ERROR: No Proxy present")
            return False
        proxyValues = proxyInfo.get("Value", {})
        group = proxyValues.get("group", "")
        vomsvo = getVOMSVOForGroup(group)
        if not vomsvo:
            self.errorMessages.append(
                "ERROR: ProxyGroup not associated to VOMS VO, get a different proxy"
            )
            return False

        groupProperties = proxyValues.get("groupProperties", [])

        if groupProperties:
            if "ProductionManagement" not in groupProperties:
                self.errorMessages.append(
                    "ERROR: Not allowed to create production, you need a ProductionManagement proxy."
                )
                return False
        else:
            self.errorMessages.append(
                "ERROR: Could not determine Proxy properties, you do not have the right proxy."
            )
            return False
        return True
  def _checkProxy(self):
    """checks if the proxy has the ProductionManagement property and belongs to a VO"""
    proxyInfo = getProxyInfo()
    if not proxyInfo['OK']:
      self.errorMessages.append("ERROR: No Proxy present")
      return False
    proxyValues = proxyInfo.get('Value', {})
    group = proxyValues.get('group', '')
    vomsvo = getVOMSVOForGroup(group)
    if not vomsvo:
      self.errorMessages.append("ERROR: ProxyGroup not associated to VOMS VO, get a different proxy")
      return False

    groupProperties = proxyValues.get('groupProperties', [])

    if groupProperties:
      if 'ProductionManagement' not in groupProperties:
        self.errorMessages.append("ERROR: Not allowed to create production, you need a ProductionManagement proxy.")
        return False
    else:
      self.errorMessages.append("ERROR: Could not determine Proxy properties, you do not have the right proxy.")
      return False
    return True
Beispiel #3
0
        proxy = copy.copy(chain)

        # Create local proxy with group
        self.outputFile = self.outputFile or getDefaultProxyLocation()
        parameters = (self.outputFile, int(self.lifetime or 12) * 3600, self.group)

        # Add a VOMS extension if the group requires it
        if (result := chain.generateProxyToFile(*parameters))["OK"] and (result := self.__enableCS())["OK"]:
            if not self.group and (result := findDefaultGroupForDN(credentials["DN"]))["OK"]:
                self.group = result["Value"]  # Use default group if user don't set it
            # based on the configuration we decide whether to add VOMS extensions
            if getGroupOption(self.group, "AutoAddVOMS", False):
                if not (vomsAttr := getVOMSAttributeForGroup(self.group)):
                    print(HTML(f"<yellow>No VOMS attribute foud for {self.group}</yellow>"))
                else:
                    vo = getVOMSVOForGroup(self.group)
                    if not (result := VOMS().setVOMSAttributes(self.outputFile, attribute=vomsAttr, vo=vo))["OK"]:
                        return S_ERROR(f"Failed adding VOMS attribute: {result['Message']}")
                    chain = result["Value"]
                    result = chain.generateProxyToFile(*parameters)
        if not result["OK"]:
            return S_ERROR(f"Couldn't generate proxy: {result['Message']}")

        if self.enableCS:
            # After creating the proxy, we can try to connect to the server
            if not (result := self.__enableCS())["OK"]:
                return result

            # Step 2: Upload proxy to DIRAC server
            result = gProxyManager.getUploadedProxyLifeTime(credentials["subject"])
            if not result["OK"]: