From 200453838beec706f2a0b8bc7bb2000661273ed7 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Wed, 25 Nov 2015 14:12:14 -0800 Subject: [PATCH] ifupdown2: clagd: check clag service restart status and print warning if not running Ticket: CM-8211 Reviewed By: CCR-3876 Testing Done: Tested clagd parameters change from ifupdown2 $ifquery bond10.4094 auto bond10.4094 iface bond10.4094 address 169.254.0.27/24 clagd-peer-ip 169.254.0.28 clagd-sys-mac 44:38:39:ff:40:94 clagd-backup-ip 172.27.28.1 clagd-priority 4096 clagd-args --peerTimeout 4o $ifup -v bond10.4094 info: Executing /usr/sbin/service clagd restart info: executing /usr/sbin/service clagd status [FAIL] clagd is not running ... failed! warning: bond10.4094: clagd failed to start..Please check clagd log for details $tail -f /var/log/clagd.log 2015-11-25T22:14:44.014582+00:00 cel-redxp-06 clagd[30875]: Invoked with: /usr/sbin/clagd --daemon 169.254.0.28 bond10.4094 44:38:39:ff:40:94 --priority 4096 --backupIp 172.27.28.1 --peerTimeout 4o 2015-11-25T22:14:44.020579+00:00 cel-redxp-06 clagd[30875]: There was an error in the command line parameters. 2015-11-25T22:14:44.020609+00:00 cel-redxp-06 clagd[30875]: argument --peerTimeout/-t: invalid int value: '4o' 2015-11-25T22:14:44.020618+00:00 cel-redxp-06 clagd[30875]: exit with status -1 (cherry picked from commit ac4f4a129a9125eeaf17a48a200ad8ac44bf7ef6) Conflicts: packages/clag/ifupdown/clagd.py --- ifupdownaddons/systemutils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ifupdownaddons/systemutils.py b/ifupdownaddons/systemutils.py index 873306d..292af8d 100644 --- a/ifupdownaddons/systemutils.py +++ b/ifupdownaddons/systemutils.py @@ -29,3 +29,16 @@ class systemUtils(): return True return False + + @classmethod + def check_service_status(cls, servicename=None): + if not servicename: + return False + utilsobj = utilsBase() + try: + utilsobj.subprocess_check_call(['/usr/sbin/service', + '%s' %servicename, 'status']) + except Exception: + # XXX: check for subprocess errors vs os error + return False + return True