]> xenbits.xensource.com Git - xenrt-citrix/xenrt.git/commitdiff
Handle both response formats to the CLM download info API
authorAlex Brett <alex.brett@citrix.com>
Wed, 18 Nov 2015 16:01:24 +0000 (16:01 +0000)
committerAlex Brett <alex.brett@citrix.com>
Wed, 18 Nov 2015 16:01:24 +0000 (16:01 +0000)
exec/xenrt/lib/scalextreme/sxagent.py

index 64e6e80c458fae057ae72ce8b17370085bbf4262..d6897539a9db6aeef7777559c844c865013dbcde 100644 (file)
@@ -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()