Merge "Initial seed of hacking rules"
This commit is contained in:
commit
111727c2f2
@ -9,6 +9,8 @@ Nova-PowerVM Specific Commandments
|
|||||||
----------------------------------
|
----------------------------------
|
||||||
- Follow the Nova HACKING.rst
|
- Follow the Nova HACKING.rst
|
||||||
|
|
||||||
|
- [P301] LOG.warn() is not allowed. Use LOG.warning()
|
||||||
|
|
||||||
Creating Unit Tests
|
Creating Unit Tests
|
||||||
-------------------
|
-------------------
|
||||||
For every new feature, unit tests should be created that both test and
|
For every new feature, unit tests should be created that both test and
|
||||||
|
0
nova_powervm/hacking/__init__.py
Normal file
0
nova_powervm/hacking/__init__.py
Normal file
30
nova_powervm/hacking/checks.py
Normal file
30
nova_powervm/hacking/checks.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Copyright 2016 IBM Corp.
|
||||||
|
#
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
from nova.hacking import checks
|
||||||
|
|
||||||
|
|
||||||
|
def no_log_warn(logical_line, filename):
|
||||||
|
"""Disallow 'LOG.warn('
|
||||||
|
|
||||||
|
"""
|
||||||
|
if logical_line.startswith('LOG.warn('):
|
||||||
|
yield(0, 'P301 Use LOG.warning() rather than LOG.warn()')
|
||||||
|
|
||||||
|
|
||||||
|
def factory(register):
|
||||||
|
register(no_log_warn)
|
||||||
|
checks.factory(register)
|
@ -115,7 +115,7 @@ class TestHostCPUStats(test.TestCase):
|
|||||||
# Make sure None is returned if there is no data.
|
# Make sure None is returned if there is no data.
|
||||||
host_stats.cur_phyp = None
|
host_stats.cur_phyp = None
|
||||||
host_stats._update_internal_metric()
|
host_stats._update_internal_metric()
|
||||||
self.assertEqual(None, host_stats.cur_data)
|
self.assertIsNone(host_stats.cur_data)
|
||||||
|
|
||||||
# Make the 'prev' the current...for the first pass
|
# Make the 'prev' the current...for the first pass
|
||||||
host_stats.cur_phyp = self.prev_phyp
|
host_stats.cur_phyp = self.prev_phyp
|
||||||
|
@ -222,7 +222,8 @@ class TestConfigDrivePowerVM(test.TestCase):
|
|||||||
|
|
||||||
self.apt.update_by_path.side_effect = validate_update
|
self.apt.update_by_path.side_effect = validate_update
|
||||||
|
|
||||||
def validate_remove_stor(vg_w, vopts=[]):
|
def validate_remove_stor(vg_w, vopts=None):
|
||||||
|
vopts = {} if vopts is None else vopts
|
||||||
self.assertIsInstance(vg_w, pvm_stor.VG)
|
self.assertIsInstance(vg_w, pvm_stor.VG)
|
||||||
self.assertEqual(1, len(vopts))
|
self.assertEqual(1, len(vopts))
|
||||||
self.assertIsInstance(vopts[0], pvm_stor.VOptMedia)
|
self.assertIsInstance(vopts[0], pvm_stor.VOptMedia)
|
||||||
@ -253,7 +254,8 @@ class TestConfigDrivePowerVM(test.TestCase):
|
|||||||
self.apt.read.side_effect = [self.vio_to_vg, self.vg_to_vio]
|
self.apt.read.side_effect = [self.vio_to_vg, self.vg_to_vio]
|
||||||
mock_vm_id.return_value = '2'
|
mock_vm_id.return_value = '2'
|
||||||
|
|
||||||
def validate_remove_stor(vg_w, vopts=[]):
|
def validate_remove_stor(vg_w, vopts=None):
|
||||||
|
vopts = {} if vopts is None else vopts
|
||||||
self.assertIsInstance(vg_w, pvm_stor.VG)
|
self.assertIsInstance(vg_w, pvm_stor.VG)
|
||||||
self.assertEqual(1, len(vopts))
|
self.assertEqual(1, len(vopts))
|
||||||
self.assertIsInstance(vopts[0], pvm_stor.VOptMedia)
|
self.assertIsInstance(vopts[0], pvm_stor.VOptMedia)
|
||||||
|
@ -534,10 +534,11 @@ class FindDisk(task.Task):
|
|||||||
LOG.info(_LI('Finding disk for instance: %s'), self.instance.name)
|
LOG.info(_LI('Finding disk for instance: %s'), self.instance.name)
|
||||||
disk = self.disk_dvr.get_disk_ref(self.instance, self.disk_type)
|
disk = self.disk_dvr.get_disk_ref(self.instance, self.disk_type)
|
||||||
if not disk:
|
if not disk:
|
||||||
LOG.warn(_LW('Disk not found: %(disk_name)s'),
|
LOG.warning(_LW('Disk not found: %(disk_name)s'),
|
||||||
{'disk_name': self.disk_dvr._get_disk_name(self.disk_type,
|
{'disk_name':
|
||||||
self.instance)
|
self.disk_dvr._get_disk_name(self.disk_type,
|
||||||
}, instance=self.instance)
|
self.instance),
|
||||||
|
}, instance=self.instance)
|
||||||
return disk
|
return disk
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
import re
|
import re
|
||||||
import six
|
import six
|
||||||
|
|
||||||
@ -470,7 +470,7 @@ def get_vm_qp(adapter, lpar_uuid, qprop=None, log_errors=True):
|
|||||||
LOG.exception(e)
|
LOG.exception(e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return json.loads(resp.body)
|
return jsonutils.loads(resp.body)
|
||||||
|
|
||||||
|
|
||||||
def crt_lpar(adapter, host_wrapper, instance, flavor):
|
def crt_lpar(adapter, host_wrapper, instance, flavor):
|
||||||
|
3
tox.ini
3
tox.ini
@ -34,3 +34,6 @@ whitelist_externals = bash
|
|||||||
[flake8]
|
[flake8]
|
||||||
ignore = E125,H405
|
ignore = E125,H405
|
||||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools
|
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools
|
||||||
|
|
||||||
|
[hacking]
|
||||||
|
local-check-factory = nova_powervm.hacking.checks.factory
|
Loading…
x
Reference in New Issue
Block a user