Update hacking and fix hacking violations

This does a few things:

* Update hacking to the version in global-requirements. Old hacking was
  installing a version of pbr that was breaking other packages.

* Fix all the hacking/pep8 rules that updating hacking raised.

* Do some general docstring cleanup, while already in there cleaning up
  a bunch of docstrings due to H405 violations.

Change-Id: I1fc1e59d4c3d7b14631f8b576e3f3854bc452188
Closes-Bug: #1461717
This commit is contained in:
Jim Rollenhagen
2015-06-03 16:56:50 -07:00
parent 141191bcfa
commit 601201d120
9 changed files with 44 additions and 47 deletions

View File

@@ -24,7 +24,7 @@ from ironic_python_agent.openstack.common import loopingcall
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
#TODO(JoshNang) move to oslo, i18n # TODO(JoshNang) move to oslo, i18n
class LoopingCallTimeOut(Exception): class LoopingCallTimeOut(Exception):
"""Exception for a timed out LoopingCall. """Exception for a timed out LoopingCall.
@@ -35,7 +35,9 @@ class LoopingCallTimeOut(Exception):
class BackOffLoopingCall(loopingcall.LoopingCallBase): class BackOffLoopingCall(loopingcall.LoopingCallBase):
"""The passed in function should return True (no error, return to """Run a method in a loop with backoff on error.
The passed in function should return True (no error, return to
initial_interval), initial_interval),
False (error, start backing off), or raise LoopingCallDone(retvalue=None) False (error, start backing off), or raise LoopingCallDone(retvalue=None)
(quit looping, return retvalue if set). (quit looping, return retvalue if set).

View File

@@ -42,8 +42,9 @@ class RESTJSONEncoder(json.JSONEncoder):
return super(RESTJSONEncoder, self).encode(o) + delimiter return super(RESTJSONEncoder, self).encode(o) + delimiter
def default(self, o): def default(self, o):
"""Turn an object into a serializable object. In particular, by """Turn an object into a serializable object.
calling :meth:`.Serializable.serialize`.
In particular, by calling :meth:`.Serializable.serialize` on `o`.
""" """
if isinstance(o, Serializable): if isinstance(o, Serializable):
return o.serialize() return o.serialize()

View File

@@ -31,8 +31,9 @@ class RESTError(Exception, encoding.Serializable):
class InvalidContentError(RESTError): class InvalidContentError(RESTError):
"""Error which occurs when a user supplies invalid content, either """Error which occurs when a user supplies invalid content.
because that content cannot be parsed according to the advertised
Either because that content cannot be parsed according to the advertised
`Content-Type`, or due to a content validation error. `Content-Type`, or due to a content validation error.
""" """
message = 'Invalid request body' message = 'Invalid request body'
@@ -43,10 +44,7 @@ class InvalidContentError(RESTError):
class NotFound(RESTError): class NotFound(RESTError):
"""Error which occurs when a user supplies invalid content, either """Error which occurs if a non-existent API endpoint is called."""
because that content cannot be parsed according to the advertised
`Content-Type`, or due to a content validation error.
"""
message = 'Not found' message = 'Not found'
status_code = 404 status_code = 404
details = 'The requested URL was not found.' details = 'The requested URL was not found.'
@@ -104,9 +102,7 @@ class HeartbeatError(IronicAPIError):
class LookupNodeError(IronicAPIError): class LookupNodeError(IronicAPIError):
"""Error raised when the node configuration lookup to the Ironic API """Error raised when the node lookup to the Ironic API fails."""
fails.
"""
message = 'Error getting configuration from Ironic.' message = 'Error getting configuration from Ironic.'
@@ -167,6 +163,7 @@ class ImageWriteError(RESTError):
class ConfigDriveTooLargeError(RESTError): class ConfigDriveTooLargeError(RESTError):
"""Error raised when a configdrive is larger than the partition.""" """Error raised when a configdrive is larger than the partition."""
message = 'Configdrive is too large for intended partition.' message = 'Configdrive is too large for intended partition.'
def __init__(self, filename, filesize): def __init__(self, filename, filesize):
@@ -176,9 +173,7 @@ class ConfigDriveTooLargeError(RESTError):
class ConfigDriveWriteError(RESTError): class ConfigDriveWriteError(RESTError):
"""Error raised when a configdrive directory cannot be written to a """Error raised when a configdrive cannot be written to a device."""
device.
"""
message = 'Error writing configdrive to device.' message = 'Error writing configdrive to device.'
@@ -211,7 +206,8 @@ class BlockDeviceEraseError(RESTError):
class BlockDeviceError(RESTError): class BlockDeviceError(RESTError):
"""Error raised when a block devices causes an unknown error""" """Error raised when a block devices causes an unknown error."""
message = 'Block device caused unknown error' message = 'Block device caused unknown error'
def __init__(self, details): def __init__(self, details):
@@ -219,10 +215,9 @@ class BlockDeviceError(RESTError):
class VirtualMediaBootError(RESTError): class VirtualMediaBootError(RESTError):
"""Error raised when booting ironic-python-client from virtual media """Error raised when virtual media device cannot be found for config."""
fails.
""" message = 'Configuring agent from virtual media failed.'
message = 'Booting ironic-python-client from virtual media failed.'
def __init__(self, details): def __init__(self, details):
super(VirtualMediaBootError, self).__init__(details) super(VirtualMediaBootError, self).__init__(details)
@@ -270,9 +265,7 @@ class HardwareManagerMethodNotFound(RESTError):
class IncompatibleHardwareMethodError(RESTError): class IncompatibleHardwareMethodError(RESTError):
"""Error raised when HardwareManager method is incompatible with node """Error raised when HardwareManager method incompatible with hardware."""
hardware.
"""
message = 'HardwareManager method is not compatible with hardware.' message = 'HardwareManager method is not compatible with hardware.'
@@ -306,6 +299,7 @@ class CleanVersionMismatch(RESTError):
class CleaningError(RESTError): class CleaningError(RESTError):
"""Error raised when a cleaning step fails.""" """Error raised when a cleaning step fails."""
message = 'Clean step failed.' message = 'Clean step failed.'
def __init__(self, details=None): def __init__(self, details=None):
@@ -329,9 +323,7 @@ class ISCSIError(RESTError):
class DeviceNotFound(NotFound): class DeviceNotFound(NotFound):
"""Error raised when the disk or partition to deploy the image onto is """Error raised when the device to deploy the image onto is not found."""
not found.
"""
message = ('Error finding the disk or partition device to deploy ' message = ('Error finding the disk or partition device to deploy '
'the image onto.') 'the image onto.')

View File

@@ -249,6 +249,7 @@ class ExecuteCommandMixin(object):
def async_command(command_name, validator=None): def async_command(command_name, validator=None):
"""Will run the command in an AsyncCommandResult in its own thread. """Will run the command in an AsyncCommandResult in its own thread.
command_name is set based on the func name and command_params will command_name is set based on the func name and command_params will
be whatever args/kwargs you pass into the decorated command. be whatever args/kwargs you pass into the decorated command.
Return values of type `str` or `unicode` are prefixed with the Return values of type `str` or `unicode` are prefixed with the
@@ -277,8 +278,9 @@ def async_command(command_name, validator=None):
def sync_command(command_name, validator=None): def sync_command(command_name, validator=None):
"""Decorate a method in order to wrap up its return value in a """Decorate a method to wrap its return value in a SyncCommandResult.
SyncCommandResult. For consistency with @async_command() can also accept a
For consistency with @async_command() can also accept a
validator which will be used to validate input, although a synchronous validator which will be used to validate input, although a synchronous
command can also choose to implement validation inline. command can also choose to implement validation inline.
""" """

View File

@@ -91,8 +91,9 @@ class APIClient(object):
return node_content return node_content
def _do_lookup(self, hardware_info): def _do_lookup(self, hardware_info):
"""The actual call to lookup a node. Should be called inside """The actual call to lookup a node.
loopingcall.BackOffLoopingCall.
Should be called as a `loopingcall.BackOffLoopingCall`.
""" """
path = '/{api_version}/drivers/{driver}/vendor_passthru/lookup'.format( path = '/{api_version}/drivers/{driver}/vendor_passthru/lookup'.format(
api_version=self.api_version, api_version=self.api_version,

View File

@@ -113,7 +113,11 @@ HDPARM_INFO_TEMPLATE = (
'\t24min for SECURITY ERASE UNIT. 24min for ENHANCED SECURITY ' '\t24min for SECURITY ERASE UNIT. 24min for ENHANCED SECURITY '
'ERASE UNIT.\n' 'ERASE UNIT.\n'
'Checksum: correct\n' 'Checksum: correct\n'
) ) # noqa
# NOTE(jroll) noqa here is to dodge E131 (indent rules). Since this is a
# massive multi-line string (with specific whitespace formatting), it's easier
# for a human to parse it with indentations on line continuations. The other
# option would be to ignore the 79-character limit here. Ew.
BLK_DEVICE_TEMPLATE = ( BLK_DEVICE_TEMPLATE = (
'KNAME="sda" MODEL="TinyUSB Drive" SIZE="3116853504" ' 'KNAME="sda" MODEL="TinyUSB Drive" SIZE="3116853504" '

View File

@@ -140,18 +140,16 @@ class TestMultipleHardwareManagerLoading(test_base.BaseTestCase):
self.assertEqual(1, self.generic_hwm.obj._call_counts['generic_only']) self.assertEqual(1, self.generic_hwm.obj._call_counts['generic_only'])
def test_both_succeed(self): def test_both_succeed(self):
"""In the case where both managers will work; only the most specific # In the case where both managers will work; only the most specific
manager should have it's function called. # manager should have it's function called.
"""
hardware.dispatch_to_managers('both_succeed') hardware.dispatch_to_managers('both_succeed')
self.assertEqual(1, self.mainline_hwm.obj._call_counts['both_succeed']) self.assertEqual(1, self.mainline_hwm.obj._call_counts['both_succeed'])
self.assertEqual(0, self.generic_hwm.obj._call_counts['both_succeed']) self.assertEqual(0, self.generic_hwm.obj._call_counts['both_succeed'])
def test_mainline_fails(self): def test_mainline_fails(self):
"""Ensure that if the mainline manager is unable to run the method # Ensure that if the mainline manager is unable to run the method
that we properly fall back to generic. # that we properly fall back to generic.
"""
hardware.dispatch_to_managers('mainline_fail') hardware.dispatch_to_managers('mainline_fail')
self.assertEqual( self.assertEqual(
@@ -184,9 +182,8 @@ class TestMultipleHardwareManagerLoading(test_base.BaseTestCase):
'FakeMainlineHardwareManager': None}, results) 'FakeMainlineHardwareManager': None}, results)
def test_dispatch_to_all_managers_both_succeed(self): def test_dispatch_to_all_managers_both_succeed(self):
"""In the case where both managers will work; only the most specific # In the case where both managers will work; only the most specific
manager should have it's function called. # manager should have it's function called.
"""
results = hardware.dispatch_to_all_managers('both_succeed') results = hardware.dispatch_to_all_managers('both_succeed')
self.assertEqual({'FakeGenericHardwareManager': 'generic_both', self.assertEqual({'FakeGenericHardwareManager': 'generic_both',
@@ -196,9 +193,8 @@ class TestMultipleHardwareManagerLoading(test_base.BaseTestCase):
self.assertEqual(1, self.generic_hwm.obj._call_counts['both_succeed']) self.assertEqual(1, self.generic_hwm.obj._call_counts['both_succeed'])
def test_dispatch_to_all_managers_mainline_fails(self): def test_dispatch_to_all_managers_mainline_fails(self):
"""Ensure that if the mainline manager is unable to run the method # Ensure that if the mainline manager is unable to run the method
that we properly fall back to generic. # that we properly fall back to generic.
"""
hardware.dispatch_to_all_managers('mainline_fail') hardware.dispatch_to_all_managers('mainline_fail')
self.assertEqual( self.assertEqual(

View File

@@ -105,8 +105,7 @@ def _get_vmedia_device():
def _get_vmedia_params(): def _get_vmedia_params():
"""This method returns the parameters passed to the agent through virtual """This method returns the parameters passed through virtual media floppy.
media floppy.
:returns: a partial dict of potential agent configuration parameters :returns: a partial dict of potential agent configuration parameters
:raises: VirtualMediaBootError when it cannot find the virtual media device :raises: VirtualMediaBootError when it cannot find the virtual media device

View File

@@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order # The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
hacking>=0.8.0,<0.9 hacking>=0.10.0,<0.11
coverage>=3.6 coverage>=3.6
discover discover
mock>=1.0 mock>=1.0