Upgrade hacking rules and fix new issues

Change-Id: I5a1a6b20198dc13b28698ac9b9e28dbb9a2ddddb
Implements: blueprint volume-manager-refactoring
This commit is contained in:
Sebastian Kalinowski 2015-06-24 13:34:18 +02:00 committed by Sebastian Kalinowski
parent b937cf3ccf
commit 3c19dba792
18 changed files with 54 additions and 102 deletions

View File

@ -1,13 +0,0 @@
# Copyright 2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -1,13 +0,0 @@
# Copyright 2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -1,13 +0,0 @@
# Copyright 2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -18,7 +18,8 @@ import six
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
class BaseDataDriver(object): class BaseDataDriver(object):
"""Data driver API is to be put here. """Data driver API
For example, data validation methods, For example, data validation methods,
methods for getting object schemes, etc. methods for getting object schemes, etc.
""" """

View File

@ -35,7 +35,9 @@ LOG = logging.getLogger(__name__)
def match_device(hu_disk, ks_disk): def match_device(hu_disk, ks_disk):
"""Tries to figure out if hu_disk got from hu.list_block_devices """Check if hu_disk and ks_disk are the same device
Tries to figure out if hu_disk got from hu.list_block_devices
and ks_spaces_disk given correspond to the same disk device. This and ks_spaces_disk given correspond to the same disk device. This
is the simplified version of hu.match_device is the simplified version of hu.match_device
@ -88,24 +90,26 @@ class Nailgun(BaseDataDriver):
@property @property
def ks_disks(self): def ks_disks(self):
disk_filter = lambda x: x['type'] == 'disk' and x['size'] > 0 return filter(
return filter(disk_filter, self.partition_data()) lambda x: x['type'] == 'disk' and x['size'] > 0,
self.partition_data())
@property @property
def small_ks_disks(self): def small_ks_disks(self):
"""Get those disks which are smaller than 2T """Get those disks which are smaller than 2T"""
"""
return [d for d in self.ks_disks if d['size'] <= 2097152] return [d for d in self.ks_disks if d['size'] <= 2097152]
@property @property
def ks_vgs(self): def ks_vgs(self):
vg_filter = lambda x: x['type'] == 'vg' return filter(
return filter(vg_filter, self.partition_data()) lambda x: x['type'] == 'vg',
self.partition_data())
@property @property
def hu_disks(self): def hu_disks(self):
"""Actual disks which are available on this node """Actual disks which are available on this node
it is a list of dicts which are formatted other way than
It is a list of dicts which are formatted other way than
ks_spaces disks. To match both of those formats use ks_spaces disks. To match both of those formats use
_match_device method. _match_device method.
""" """

View File

@ -475,7 +475,9 @@ class Manager(object):
# into a set of smaller ones # into a set of smaller ones
# https://bugs.launchpad.net/fuel/+bug/1444090 # https://bugs.launchpad.net/fuel/+bug/1444090
def do_build_image(self): def do_build_image(self):
"""Building OS images includes the following steps """Building OS images
Includes the following steps
1) create temporary sparse files for all images (truncate) 1) create temporary sparse files for all images (truncate)
2) attach temporary files to loop devices (losetup) 2) attach temporary files to loop devices (losetup)
3) create file systems on these loop devices 3) create file systems on these loop devices

View File

@ -291,7 +291,9 @@ class PartitionScheme(object):
return found[0] return found[0]
def fs_sorted_by_depth(self, reverse=False): def fs_sorted_by_depth(self, reverse=False):
"""Getting file systems sorted by path length. Shorter paths earlier. """Getting file systems sorted by path length.
Shorter paths earlier.
['/', '/boot', '/var', '/var/lib/mysql'] ['/', '/boot', '/var', '/var/lib/mysql']
:param reverse: Sort backward (Default: False) :param reverse: Sort backward (Default: False)
""" """

View File

@ -1,13 +0,0 @@
# Copyright 2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -881,8 +881,8 @@ class TestNailgun(test_base.BaseTestCase):
self.assertEqual(2, len(p_scheme.vgs)) self.assertEqual(2, len(p_scheme.vgs))
self.assertEqual(3, len(p_scheme.parteds)) self.assertEqual(3, len(p_scheme.parteds))
self.assertEqual(3, drv._get_partition_count('ceph')) self.assertEqual(3, drv._get_partition_count('ceph'))
#NOTE(agordeev): (-2, -1, -1) is the list of ceph data partition counts # NOTE(agordeev): (-2, -1, -1) is the list of ceph data partition
# corresponding to (sda, sdb, sdc) disks respectively. # counts corresponding to (sda, sdb, sdc) disks respectively.
for disk, part in enumerate((-2, -1, -1)): for disk, part in enumerate((-2, -1, -1)):
self.assertEqual(CEPH_DATA['partition_guid'], self.assertEqual(CEPH_DATA['partition_guid'],
p_scheme.parteds[disk].partitions[part].guid) p_scheme.parteds[disk].partitions[part].guid)

View File

@ -1,13 +0,0 @@
# Copyright 2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -19,6 +19,7 @@ import tempfile
import zlib import zlib
from oslo.config import cfg from oslo.config import cfg
import six
from fuel_agent import errors from fuel_agent import errors
from fuel_agent.openstack.common import log as logging from fuel_agent.openstack.common import log as logging
@ -38,8 +39,8 @@ CONF = cfg.CONF
CONF.register_opts(au_opts) CONF.register_opts(au_opts)
@six.add_metaclass(abc.ABCMeta)
class Target(object): class Target(object):
__metaclass__ = abc.ABCMeta
def __iter__(self): def __iter__(self):
return self return self

View File

@ -153,8 +153,7 @@ def suppress_services_start(chroot):
def clean_dirs(chroot, dirs, delete=False): def clean_dirs(chroot, dirs, delete=False):
"""Method is used to clean directories content """Removes dirs and recreates them
or remove directories themselfs.
:param chroot: Root directory where to look for subdirectories :param chroot: Root directory where to look for subdirectories
:param dirs: List of directories to clean/remove (Relative to chroot) :param dirs: List of directories to clean/remove (Relative to chroot)
@ -218,6 +217,7 @@ def do_post_inst(chroot):
def stop_chrooted_processes(chroot, signal=sig.SIGTERM, def stop_chrooted_processes(chroot, signal=sig.SIGTERM,
attempts=10, attempts_delay=2): attempts=10, attempts_delay=2):
"""Sends signal to all processes, which are running inside chroot. """Sends signal to all processes, which are running inside chroot.
It tries several times until all processes die. If at some point there It tries several times until all processes die. If at some point there
are no running processes found, it returns True. are no running processes found, it returns True.
@ -354,8 +354,9 @@ def strip_filename(name):
def get_release_file(uri, suite, section): def get_release_file(uri, suite, section):
"""Download repo's Release file, parse it and returns an apt """Download and parse repo's Release file
preferences line for this repo.
It and returns an apt preferences line for specified repo.
:param repo: a repo as dict :param repo: a repo as dict
:returns: a string with apt preferences rules :returns: a string with apt preferences rules

View File

@ -98,6 +98,7 @@ def guess_grub1_datadir(chroot='', arch='x86_64'):
def guess_kernel(chroot='', regexp=None): def guess_kernel(chroot='', regexp=None):
"""Tries to guess kernel by regexp """Tries to guess kernel by regexp
:param chroot: Path to chroot :param chroot: Path to chroot
:param regexp: (String) Regular expression (must have python syntax). :param regexp: (String) Regular expression (must have python syntax).
Default is r'^vmlinuz.*' Default is r'^vmlinuz.*'
@ -115,6 +116,7 @@ def guess_kernel(chroot='', regexp=None):
def guess_initrd(chroot='', regexp=None): def guess_initrd(chroot='', regexp=None):
"""Tries to guess initrd by regexp """Tries to guess initrd by regexp
:param chroot: Path to chroot :param chroot: Path to chroot
:param regexp: (String) Regular expression (must have python syntax). :param regexp: (String) Regular expression (must have python syntax).
Default is r'^(initrd|initramfs).*' Default is r'^(initrd|initramfs).*'

View File

@ -270,7 +270,9 @@ def get_block_devices_from_udev_db():
def list_block_devices(disks=True): def list_block_devices(disks=True):
"""Gets list of block devices, tries to guess which of them are disks """Gets list of block devices
Tries to guess which of them are disks
and returns list of dicts representing those disks. and returns list of dicts representing those disks.
:returns: A list of dict representing disks available on a node. :returns: A list of dict representing disks available on a node.
@ -316,7 +318,8 @@ def list_block_devices(disks=True):
def match_device(uspec1, uspec2): def match_device(uspec1, uspec2):
"""Tries to find out if uspec1 and uspec2 are uspecs from the same device. """Tries to find out if uspec1 and uspec2 are uspecs from the same device
It compares only some fields in uspecs (not all of them) which, we believe, It compares only some fields in uspecs (not all of them) which, we believe,
is enough to say exactly whether uspecs belong to the same device or not. is enough to say exactly whether uspecs belong to the same device or not.

View File

@ -137,8 +137,10 @@ def execute(*cmd, **kwargs):
def parse_unit(s, unit, ceil=True): def parse_unit(s, unit, ceil=True):
"""Converts '123.1unit' string into 124 if ceil is True """Converts '123.1unit' string into ints
and converts '123.9unit' into 123 if ceil is False.
If ceil is True it will be rounded up (124)
and and down (123) if ceil is False.
""" """
flt = locale.atof(s.split(unit)[0]) flt = locale.atof(s.split(unit)[0])
@ -227,6 +229,7 @@ def init_http_request(url, byte_range=0):
def makedirs_if_not_exists(path, mode=0o755): def makedirs_if_not_exists(path, mode=0o755):
"""Create directory if it does not exist """Create directory if it does not exist
:param path: Directory path :param path: Directory path
:param mode: Directory mode (Default: 0o755) :param mode: Directory mode (Default: 0o755)
""" """
@ -235,8 +238,7 @@ def makedirs_if_not_exists(path, mode=0o755):
def grouper(iterable, n, fillvalue=None): def grouper(iterable, n, fillvalue=None):
"""Collect data into fixed-length chunks or blocks """Collect data into fixed-length chunks or blocks"""
"""
args = [iter(iterable)] * n args = [iter(iterable)] * n
return zip_longest(*args, fillvalue=fillvalue) return zip_longest(*args, fillvalue=fillvalue)

View File

@ -16,7 +16,7 @@ commands =
downloadcache = ~/cache/pip downloadcache = ~/cache/pip
[testenv:pep8] [testenv:pep8]
deps = hacking==0.7 deps = hacking==0.10.2
commands = commands =
flake8 {posargs:fuel_agent} flake8 {posargs:fuel_agent}
@ -33,7 +33,6 @@ envdir = devenv
usedevelop = True usedevelop = True
[flake8] [flake8]
ignore = H234,H302,H802
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,docs exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,docs
show-pep8 = True show-pep8 = True
show-source = True show-source = True