Exemplo n.º 1
0
    def getCE(self, site, endpoint, image=""):

        result = getVMTypeConfig(site, endpoint, image)
        if not result["OK"]:
            return result

        return self.getCEObject(parameters=result["Value"])
    def createEndpoint(cls, uniqueID):

        result = cls.virtualMachineDB.getEndpointFromInstance(uniqueID)
        if not result["OK"]:
            return result
        site, endpoint = result["Value"].split("::")

        result = getVMTypeConfig(site, endpoint)
        if not result["OK"]:
            return result
        ceParams = result["Value"]
        ceFactory = EndpointFactory()
        return ceFactory.getCEObject(parameters=ceParams)
    def stopInstance(cls, site, endpoint, nodeID):

        result = getVMTypeConfig(site, endpoint)
        if not result["OK"]:
            return result
        ceParams = result["Value"]
        ceFactory = EndpointFactory()
        result = ceFactory.getCEObject(parameters=ceParams)
        if not result["OK"]:
            return result

        ce = result["Value"]
        return ce.stopVM(nodeID)
Exemplo n.º 4
0
    def do_connect(self, args):
        """Choose the specified cloud endpoint for connection

        usage:
          connect <site> [<endpoint> [project]]
        """

        self.site = None
        self.endpoint = None
        self.project = None

        argss = args.split()
        self.site = argss.pop(0)
        if argss:
            self.endpoint = argss.pop(0)
        if argss:
            self.project = argss.pop(0)

        result = getVMTypeConfig(self.site, self.endpoint)
        if not result["OK"]:
            print("ERROR: can not get the cloud endpoint configuration \n%s" %
                  result["Message"])
            return
        ceDict = result["Value"]
        if not self.project:
            self.project = ceDict.get("Project")
        if not self.endpoint:
            self.endpoint = ceDict["CEName"]
        # Check for authentication details
        authType = ceDict.get("Auth")
        if authType and authType in ["x509", "voms"]:
            # We need proxy to proceed
            self.proxyLocation = None
            proxy = getProxyLocation()
            if not proxy:
                print(
                    "ERROR: Requested endpoint requires proxy but it is not found"
                )
                return
            self.proxyLocation = proxy
        else:
            # We need user/login to proceed
            if not ceDict.get("User") or not ceDict.get("Password"):
                print("Endpoint requires user/password")
                self.user = input(["Login:"******"Password:"******"Connection: site=%s, endpoint=%s, project=%s" %
              (self.site, self.endpoint, self.project))
        self.prompt = "%s/%s/%s> " % (self.site, self.endpoint, self.project)