Commit 651c5d8c authored by Antoine Millet's avatar Antoine Millet

PEP8

parent bfdd59db
......@@ -93,7 +93,6 @@ class NodeConfigParser(object):
'Configuration attribute "verbosity"'
' is invalid (section "node")')
self.debug = config.getboolean('node', 'debug', False)
self.logging_output = 'console' if self.debug else 'syslog'
......
......@@ -23,6 +23,7 @@ from cloudcontrol.common.jobs import JobsManagerInterface, Job, JobCancelError
from cloudcontrol.common.tql.db.helpers import taggify
from cloudcontrol.common.client.tags import TagDB, Tag
class NodeJobsManagerInterface(JobsManagerInterface):
TAG_ATTRIBUTES = ('title', 'status', 'state', 'owner', 'created', 'ended',
......@@ -42,6 +43,7 @@ class NodeJobsManagerInterface(JobsManagerInterface):
for tag in self.TAG_ATTRIBUTES),
'job',
)
def tag_duration(job):
if job.ended is None:
ended = datetime.fromtimestamp(self.handler.main.evloop.now())
......
......@@ -188,5 +188,6 @@ def load():
pass
return load_
def plugins(handler):
return ' '.join(handler.plugins) or None
......@@ -267,8 +267,7 @@ class Handler(HostHandler):
except libvirt.libvirtError as exc:
# Libvirt raises exception 'domain is not running' even if domain
# is running, might be a bug in libvirt
if 'domain is not running' not in str(exc) or (
self.hypervisor.domains[name].state != 'running'):
if 'domain is not running' not in str(exc) or (self.hypervisor.domains[name].state != 'running'):
logger.exception('Error while destroying VM %s', name)
raise
except KeyError:
......@@ -449,7 +448,6 @@ class Handler(HostHandler):
# update autostart value now instead of 10 seconds lag
vm.tag_db['__main__']['autostart'].update_value()
@libvirt_handler
def tag_add(self, name, tag, value):
"""Add a static tag on specified VM.
......@@ -483,7 +481,6 @@ class Handler(HostHandler):
vm = self.hypervisor.domains[name]
return vm.tags
@libvirt_handler
def vol_create(self, pool, name, size):
logger.debug('Volume create %s, pool %s, size %s', name, pool, size)
......
......@@ -84,8 +84,7 @@ class VirtualMachine(object):
Tag('disk%s_path' % i, v.path, 10),
Tag('disk%s_pool' % i, v.storage, 10), # FIXME: change
Tag('disk%s_vol' % i, v.name, 10),
Tag('disk%s_cache' %i,
lambda: self.cache_behaviour.get(v.path), 10)
Tag('disk%s_cache' % i, lambda: self.cache_behaviour.get(v.path), 10)
):
self.tag_db.add_tag(t)
......
......@@ -60,7 +60,7 @@ def status(dom):
def hv(dom):
#FIXME: what shoud be the value of this tag ?
# FIXME: what shoud be the value of this tag ?
return dom.hypervisor.name
......
......@@ -268,7 +268,6 @@ class ExportVolume(BaseIOJob):
self.clean_fds()
break
self.checksum = checksum.hexdigest()
self.clean_fds()
......@@ -643,8 +642,8 @@ class DRBDAllocator(object):
# is calling some drbd helpers that returns non 0 value and make the
# synchronisation halt.
self.subproc_call([self.MODPROBE, 'drbd',
'minor_count=%d' % self.MINOR_MAX,
'usermode_helper=/bin/true'])
'minor_count=%d' % self.MINOR_MAX,
'usermode_helper=/bin/true'])
except CalledProcessError:
logger.error('Cannot load drbd kernel module')
......@@ -783,8 +782,7 @@ class DRBD(object):
logger.debug('Create a copy DM of the LV')
# get LV table
try:
self.dm_table = self.subproc_call([self.DMSETUP, 'table',
'--showkeys', self.volume.path])
self.dm_table = self.subproc_call([self.DMSETUP, 'table', '--showkeys', self.volume.path])
except CalledProcessError:
logger.error('Cannot get DM table of VM LV')
raise DRBDError('Cannot get DM table of VM LV')
......@@ -804,20 +802,20 @@ class DRBD(object):
# wipe drbd metadata (just in case)
try:
self.subproc_call([self.DRBDMETA, '--force', self.drbd_path,
'v08', self.meta_volume.path, '0', 'wipe-md'])
'v08', self.meta_volume.path, '0', 'wipe-md'])
except CalledProcessError:
pass
try:
self.subproc_call([self.DRBDMETA, '--force', self.drbd_path,
'v08', self.meta_volume.path, '0', 'create-md'])
'v08', self.meta_volume.path, '0', 'create-md'])
except CalledProcessError:
logger.error('Cannot create DRBD external metadata on device')
raise DRBDError('Cannot create DRBD metadata')
try:
self.subproc_call([self.DRBDSETUP, self.drbd_path, 'disk',
'/dev/mapper/%s' % self.dm_copy,
self.meta_volume.path,
'0', '--create-device'])
'/dev/mapper/%s' % self.dm_copy,
self.meta_volume.path,
'0', '--create-device'])
except CalledProcessError:
logger.error('Error while creating DRBD device')
raise DRBDError('Cannot create DRBD device')
......@@ -834,9 +832,9 @@ class DRBD(object):
# connect to remote node
try:
self.subproc_call([self.DRBDSETUP, self.drbd_path, 'net',
'0.0.0.0:%d' % self.drbd_port,
'%s:%d' % (remote_addr, remote_port),
'C', '-m', '-S', '10000000'])
'0.0.0.0:%d' % self.drbd_port,
'%s:%d' % (remote_addr, remote_port),
'C', '-m', '-S', '10000000'])
except CalledProcessError:
logger.error('Error while setting up network facility for DRBD')
raise DRBDError('Cannot set up network for DRBD')
......@@ -844,8 +842,7 @@ class DRBD(object):
sleep(.5) # FIXME
logger.debug('Set up bandwidth limit')
try:
self.subproc_call([self.DRBDSETUP, self.drbd_path, 'syncer', '-r',
self.DRBD_RATE])
self.subproc_call([self.DRBDSETUP, self.drbd_path, 'syncer', '-r', self.DRBD_RATE])
except CalledProcessError:
logger.error('Cannot set bandwidth rate limit on DRBD')
raise DRBDError('Error while setting bandwidth limit')
......@@ -857,9 +854,9 @@ class DRBD(object):
sleep(.5) # FIXME
try:
self.subproc_call([self.DRBDSETUP, self.drbd_path, 'wait-connect',
'-t', self.DRBD_TIMEOUT,
'-d', self.DRBD_TIMEOUT,
'-o', self.DRBD_TIMEOUT])
'-t', self.DRBD_TIMEOUT,
'-d', self.DRBD_TIMEOUT,
'-o', self.DRBD_TIMEOUT])
except CalledProcessError:
logger.error('Error while waiting for remote DRBD to connect,'
' timeout = %s', self.DRBD_TIMEOUT)
......
......@@ -157,8 +157,7 @@ class KVM(object):
else:
raise
else:
logger.info('Domain change state from %s to %s', vm.state,
state)
logger.info('Domain change state from %s to %s', vm.state, state)
if event == 'Stopped' and vm.redefine_on_stop:
# if the vm was changed while it was running, then we
# need to recreate it now as stated above
......
......@@ -314,7 +314,6 @@ class StorageIndex(object):
self.paths = None
self.update_path_index()
def update(self):
"""Update storage pools and volumes."""
# go through all storage pools and check if it is already in the index
......@@ -466,7 +465,6 @@ class Storage(object):
StringIO(self.lv_storage.XMLDesc(0))).get('type')
class Volume(object):
"""Volume abstraction."""
def __init__(self, lv_volume):
......
......@@ -90,7 +90,7 @@ def hvm():
return result[and_(
set(
'vmx', # Intel VT
'svm', # AMD
'svm', # AMD
) & set(
l.split(': ')[-1].split()
) for l in open('/proc/cpuinfo').readline() if l.startswith('Tags')
......
......@@ -75,6 +75,7 @@ class JobManager(object):
def start(self):
pass
def stop(self):
logger.debug('Stopping all currently running jobs')
for job in self.jobs.itervalues():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment