From: Alex Brett Date: Wed, 18 Nov 2015 16:01:24 +0000 (+0000) Subject: Handle both response formats to the CLM download info API X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8743bad3d95cd08a70a2d184961a4bef87432b29;p=xenrt-citrix%2Fxenrt.git Handle both response formats to the CLM download info API --- diff --git a/exec/xenrt/lib/scalextreme/sxagent.py b/exec/xenrt/lib/scalextreme/sxagent.py index 64e6e80c4..d6897539a 100644 --- a/exec/xenrt/lib/scalextreme/sxagent.py +++ b/exec/xenrt/lib/scalextreme/sxagent.py @@ -21,11 +21,18 @@ class SXAgent(object): def __getAgentURL(self): """Get the URL to download agent using Rest API""" info = self.apiHandler.execute(category="download", command="info") - if not "data" in info or not "deb64" in info["data"]: - raise xenrt.XRTError("Cannot retrieve download URL.") - url = info["data"]["deb64"].replace("\\", "") - return url + if "data" in info and type(info["data"]) is list: + deb64 = filter(lambda d: d["arch"] == "deb64", info["data"]) + if len(deb64) != 1: + raise xenrt.XRTError("Could not find deb64 entry in download info") + return deb64[0]["link"] + + elif "data" in info and type(info["data"]) is dict and "deb64" in info["data"]: + return info["data"]["deb64"].replace("\\", "") + + else: + raise xenrt.XRTError("Cannot retrieve download URL.") def __executeOnAgent(self, command): """Execute a command on agent Linux VM via SSH""" @@ -88,13 +95,24 @@ class SXAgent(object): self.__agentVM.setState("UP") url = self.__getAgentURL() - try: + if url.endswith(".deb"): self.__executeOnAgent("wget %s -O agent.deb" % url) - self.__executeOnAgent("dpkg -i agent.deb") - except: - # SSH command failure can be ignored. - # installation will be verified in code below. - pass + try: + self.__executeOnAgent("dpkg -i agent.deb") + except: + # SSH command failure can be ignored. + # installation will be verified in code below. + pass + elif url.endswith(".bin"): + self.__executeOnAgent("wget %s -O agent.bin" % url) + try: + self.__executeOnAgent("chmod +x agent.bin; ./agent.bin") + except: + # SSH command failure can be ignored. + # installation will be verified in code below. + pass + else: + raise xenrt.XRTError("Unknown agent format") # Try and find the nodeid (this may take some time) starttime = xenrt.util.timenow()