X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=xenserver%2Fusr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py;h=31a48c37dc47ac0586efdcabb2986a31c73c9f43;hb=c38cd4bc703054bb77a5261a6b934dfc8e52c0c6;hp=45231395df1e0cf5b9368789da663de35f6f1cc7;hpb=3dc6fca88bf43eceda6fe62c2f70eb5ec92ddd46;p=openvswitch diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index 45231395..31a48c37 100644 --- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py +++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py @@ -7,15 +7,13 @@ # Copyright (c) 2009 Nicira Networks. -import logging -log = logging.getLogger("vswitch-cfg-update") -logging.basicConfig(filename="/var/log/vswitch-xsplugin.log", level=logging.DEBUG) +from XSConsoleLog import * import os import socket import subprocess -cfg_mod="/root/vswitch/bin/ovs-cfg-mod" +cfg_mod="/usr/bin/ovs-cfg-mod" vswitchd_cfg_filename="/etc/ovs-vswitchd.conf" if __name__ == "__main__": @@ -32,20 +30,31 @@ class VSwitchService: if self.processname == None: self.processname = name + def version(self): + try: + output = ShellPipe(["service", self.name, "version"]).Stdout() + except StandardError, e: + XSLogError("vswitch 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() except StandardError, e: - log.error("status retrieval error: " + str(e)) + XSLogError("vswitch status retrieval error: " + str(e)) 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 "" @@ -55,7 +64,7 @@ class VSwitchService: try: ShellPipe(["service", self.name, "restart"]).Call() except StandardError, e: - log.error("restart error: " + str(e)) + XSLogError("vswitch restart error: " + str(e)) @classmethod def Inst(cls, name, processname=None): @@ -74,7 +83,7 @@ class VSwitchConfig: output = ShellPipe([cfg_mod, "-vANY:console:emer", "-F", vswitchd_cfg_filename, "-q", key]).Stdout() except StandardError, e: - log.error("config retrieval error: " + str(e)) + XSLogError("config retrieval error: " + str(e)) return "" if len(output) == 0: @@ -262,8 +271,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()