diff --git a/HACKING.rst b/HACKING.rst index fb9832f3..2acac58d 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -10,6 +10,8 @@ Nova-PowerVM Specific Commandments - Follow the Nova HACKING.rst - [P301] LOG.warn() is not allowed. Use LOG.warning() +- [P302] Deprecated library function os.popen() + Creating Unit Tests ------------------- diff --git a/nova_powervm/hacking/checks.py b/nova_powervm/hacking/checks.py index 63d47652..7c497f2c 100644 --- a/nova_powervm/hacking/checks.py +++ b/nova_powervm/hacking/checks.py @@ -25,6 +25,21 @@ def no_log_warn(logical_line, filename): yield(0, 'P301 Use LOG.warning() rather than LOG.warn()') +def no_os_popen(logical_line): + """Disallow 'os.popen(' + + Deprecated library function os.popen() Replace it using subprocess + https://bugs.launchpad.net/tempest/+bug/1529836 + + P302 + """ + + if 'os.popen(' in logical_line: + yield(0, 'P302 Deprecated library function os.popen(). ' + 'Replace it using subprocess module. ') + + def factory(register): register(no_log_warn) + register(no_os_popen) checks.factory(register)