Change in vdsm[master]: pep8: clean few small files
danken at redhat.com
danken at redhat.com
Mon Oct 22 07:10:45 UTC 2012
Dan Kenigsberg has uploaded a new change for review.
Change subject: pep8: clean few small files
......................................................................
pep8: clean few small files
Change-Id: I5326e6fb6a22979ab7d6cd6d4e61af746e9a6dd8
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
---
M Makefile.am
M vdsm/ksm.py
M vdsm/lsblk.py
M vdsm/substitute_constants.py
M vdsm/vdsmDebugPlugin.py
5 files changed, 32 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/11/8711/1
diff --git a/Makefile.am b/Makefile.am
index cae272a..0982479 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,10 +57,13 @@
vdsm/guestIF.py \
vdsm/hooks.py \
vdsm/kaxmlrpclib.py \
+ vdsm/ksm.py \
vdsm/libvirtev.py \
vdsm/libvirtvm.py \
+ vdsm/lsblk.py \
vdsm/md_utils.py \
vdsm/momIF.py \
+ vdsm/neterrors.py \
vdsm/netinfo.py \
vdsm/parted_utils.py \
vdsm/rest/BindingREST.py \
@@ -90,6 +93,7 @@
vdsm/storage/task.py \
vdsm/storage/taskManager.py \
vdsm/storage/volume.py \
+ vdsm/substitute_constants.py \
vdsm/supervdsm.py \
vdsm/supervdsmServer.py \
vdsm/tc.py \
diff --git a/vdsm/ksm.py b/vdsm/ksm.py
index 7798dde..016736a 100644
--- a/vdsm/ksm.py
+++ b/vdsm/ksm.py
@@ -18,15 +18,18 @@
# Refer to the README and COPYING files for full details of the license
#
-import threading, time
+import threading
+import time
import os
+
from vdsm import constants
from vdsm import utils
from vdsm.config import config
+
class KsmMonitorThread(threading.Thread):
def __init__(self, cif):
- threading.Thread.__init__(self, name = 'KsmMonitor')
+ threading.Thread.__init__(self, name='KsmMonitor')
self.setDaemon(True)
self._cif = cif
self.state, self.pages = False, 0
@@ -42,7 +45,7 @@
else:
self._cif.log.error('failed to find ksmd thread')
else:
- self._cif.log.info('ksm monitor thread disabled, not starting')
+ self._cif.log.info('ksm monitor thread disabled, not starting')
self.cpuUsage = 0
def _getKsmdJiffies(self):
@@ -58,7 +61,7 @@
while True:
time.sleep(KSM_MONITOR_INTERVAL)
jiff1 = self._getKsmdJiffies()
- self.cpuUsage = (jiff1 - jiff0) % 2**32 * 100 / \
+ self.cpuUsage = (jiff1 - jiff0) % 2 ** 32 * 100 / \
os.sysconf('SC_CLK_TCK') / KSM_MONITOR_INTERVAL
jiff0 = jiff1
except:
@@ -68,12 +71,15 @@
return running(), npages()
def adjust(self):
- """adjust ksm state according to configuration and current memory stress
- return whether ksm is running"""
+ """Adjust ksm's vigor
+
+ according to configuration and current memory stress.
+ Return whether ksm is running"""
self._lock.acquire()
try:
- utils.execCmd([constants.EXT_SERVICE, 'ksmtuned', 'retune'], sudo=True)
+ utils.execCmd([constants.EXT_SERVICE, 'ksmtuned', 'retune'],
+ sudo=True)
self.state, self.pages = self.readState()
finally:
self._lock.release()
@@ -85,12 +91,14 @@
except:
return 0
+
def running():
try:
state = int(file('/sys/kernel/mm/ksm/run').read()) & 1 == 1
return state
except:
return False
+
def npages():
try:
@@ -99,10 +107,12 @@
except:
return 0
+
def start():
utils.execCmd([constants.EXT_SERVICE, 'ksmtuned', 'start'], sudo=True)
utils.execCmd([constants.EXT_SERVICE, 'ksm', 'start'], sudo=True)
+
def tune(params):
# For supervdsm
KSM_PARAMS = {'run': 3, 'sleep_millisecs': 0x100000000,
diff --git a/vdsm/lsblk.py b/vdsm/lsblk.py
index c2f9945..92745ee 100644
--- a/vdsm/lsblk.py
+++ b/vdsm/lsblk.py
@@ -21,6 +21,7 @@
from vdsm import utils
from vdsm import constants
+
class LsBlkException(Exception):
def __init__(self, rc):
self.rc = rc
diff --git a/vdsm/substitute_constants.py b/vdsm/substitute_constants.py
index f76c0c1..0dc750d 100644
--- a/vdsm/substitute_constants.py
+++ b/vdsm/substitute_constants.py
@@ -19,9 +19,12 @@
# Refer to the README and COPYING files for full details of the license
#
-import sys, re
+import sys
+import re
+
from vdsm import constants
+
def replacement(m):
s = m.group()
return getattr(constants, 'EXT_' + s[1:-1],
diff --git a/vdsm/vdsmDebugPlugin.py b/vdsm/vdsmDebugPlugin.py
index 5aae421..3f4e7b7 100644
--- a/vdsm/vdsmDebugPlugin.py
+++ b/vdsm/vdsmDebugPlugin.py
@@ -26,11 +26,15 @@
ADDRESS = "/var/run/vdsm/debugplugin.sock"
log = logging.getLogger("DebugInterpreter")
-class DebugInterpreterManager(BaseManager): pass
+
+class DebugInterpreterManager(BaseManager):
+ pass
+
class DebugInterpreter(object):
def execute(self, code):
exec(code)
+
def __turnOnDebugPlugin():
log.warn("Starting Debug Interpreter. Tread lightly!")
@@ -39,7 +43,7 @@
os.unlink(ADDRESS)
manager = DebugInterpreterManager(address=ADDRESS, authkey="KEY")
interpreter = DebugInterpreter()
- manager.register('interpreter', callable=lambda:interpreter)
+ manager.register('interpreter', callable=lambda: interpreter)
server = manager.get_server()
servThread = threading.Thread(target=server.serve_forever)
servThread.setDaemon(True)
@@ -48,4 +52,3 @@
log.error("Could not start debug plugin", exc_info=True)
__turnOnDebugPlugin()
-
--
To view, visit http://gerrit.ovirt.org/8711
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5326e6fb6a22979ab7d6cd6d4e61af746e9a6dd8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>
More information about the vdsm-patches
mailing list