From: Justin Pettit Date: Tue, 28 Jul 2009 22:24:32 +0000 (-0700) Subject: xenserver: Retrieve vSwitch version from binary in xsconsole X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3cdc31a4c3a;p=openvswitch xenserver: Retrieve vSwitch version from binary in xsconsole The xsconsole plugin shows status information about Open vSwitch. The version information was retrieved from XAPI, but this could cause problems. The most easily reproduced is to make a XenServer part of a pool, then remove it. The version string is no longer in the XenServer's local XAPI view, so it reports "". A more direct way to get the information is to directly query the binary, which is what this commit does. Bug #1626 --- diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index 45231395..dbd00a45 100644 --- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py +++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py @@ -32,6 +32,17 @@ class VSwitchService: if self.processname == None: self.processname = name + def version(self): + try: + output = ShellPipe(["service", self.name, "version"]).Stdout() + except StandardError, e: + log.error("version retrieval error: " + str(e)) + return "" + for line in output: + if self.processname in line: + return line.split()[-1] + return "" + def status(self): try: output = ShellPipe(["service", self.name, "status"]).Stdout() @@ -40,12 +51,12 @@ class VSwitchService: return "" if len(output) == 0: return "" - for l in output: - if self.processname not in l: + for line in output: + if self.processname not in line: continue - elif "running" in l: + elif "running" in line: return "Running" - elif "stop" in l: + elif "stop" in line: return "Stopped" else: return "" @@ -262,8 +273,8 @@ class XSFeatureVSwitch: inPane.NewLine() - versionStr = data.host.other_config({}).get("vSwitchVersion", "") - inPane.AddStatusField(Lang("Version", 20), versionStr) + inPane.AddStatusField(Lang("Version", 20), + VSwitchService.Inst("vswitch", "ovs-vswitchd").version()) inPane.NewLine()