mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
This is a major update coming all at once from master-next branch master-next branch was started with --orphan option which is basically a new branch without history. The major changes are: - repackaging - cleanup the directory tree - rewritte setup.py to allow install from deb file or pypi (pip install) - add a Makefile to make things (like building a deb) easier - review all debian files Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
#!/usr/bin/python
|
|
#
|
|
# Copyright 2015-2017 Cumulus Networks, Inc. All rights reserved.
|
|
# Author: Roopa Prabhu, roopa@cumulusnetworks.com
|
|
#
|
|
|
|
import os
|
|
|
|
try:
|
|
from ifupdown2.ifupdown.utils import utils
|
|
from ifupdown2.ifupdownaddons.utilsbase import *
|
|
except ImportError:
|
|
from ifupdown.utils import utils
|
|
from ifupdownaddons.utilsbase import *
|
|
|
|
|
|
class systemUtils():
|
|
@classmethod
|
|
def is_service_running(cls, procname=None, pidfile=None):
|
|
utilsobj = utilsBase()
|
|
if pidfile:
|
|
if os.path.exists(pidfile):
|
|
pid = utilsobj.read_file_oneline(pidfile)
|
|
if not os.path.exists('/proc/%s' %pid):
|
|
return False
|
|
else:
|
|
return False
|
|
return True
|
|
|
|
if procname:
|
|
try:
|
|
utils.exec_command('%s %s' %
|
|
(utils.pidof_cmd, procname))
|
|
except:
|
|
return False
|
|
else:
|
|
return True
|
|
|
|
return False
|
|
|
|
@classmethod
|
|
def check_service_status(cls, servicename=None):
|
|
if not servicename:
|
|
return False
|
|
try:
|
|
utils.exec_commandl([utils.service_cmd,
|
|
servicename, 'status'])
|
|
except Exception:
|
|
# XXX: check for subprocess errors vs os error
|
|
return False
|
|
return True
|
|
|
|
@classmethod
|
|
def is_process_running(self, processname):
|
|
if not processname:
|
|
return False
|
|
try:
|
|
utils.exec_command('%s %s' %
|
|
(utils.pidof_cmd, processname))
|
|
except:
|
|
return False
|
|
else:
|
|
return True
|