From a34ef12d731d721cd2dae5c60d87848934da6e2d Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Fri, 4 Aug 2017 11:52:31 +0200 Subject: [PATCH] hpilo modules: PEP8 fixes (#27739) --- .../remote_management/hpilo/hpilo_boot.py | 28 +++++++++---------- .../remote_management/hpilo/hpilo_facts.py | 18 ++++++------ .../remote_management/hpilo/hponcfg.py | 7 +++-- test/sanity/pep8/legacy-files.txt | 3 -- 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lib/ansible/modules/remote_management/hpilo/hpilo_boot.py b/lib/ansible/modules/remote_management/hpilo/hpilo_boot.py index 9e791340c6..b4ac103c9c 100755 --- a/lib/ansible/modules/remote_management/hpilo/hpilo_boot.py +++ b/lib/ansible/modules/remote_management/hpilo/hpilo_boot.py @@ -122,15 +122,15 @@ warnings.simplefilter('ignore') def main(): module = AnsibleModule( - argument_spec = dict( - host = dict(required=True, type='str'), - login = dict(default='Administrator', type='str'), - password = dict(default='admin', type='str', no_log=True), - media = dict(default=None, type='str', choices=['cdrom', 'floppy', 'rbsu', 'hdd', 'network', 'normal', 'usb']), - image = dict(default=None, type='str'), - state = dict(default='boot_once', type='str', choices=['boot_always', 'boot_once', 'connect', 'disconnect', 'no_boot', 'poweroff']), - force = dict(default=False, type='bool'), - ssl_version = dict(default='TLSv1', choices=['SSLv3', 'SSLv23', 'TLSv1', 'TLSv1_1', 'TLSv1_2']), + argument_spec=dict( + host=dict(type='str', required=True), + login=dict(type='str', default='Administrator'), + password=dict(type='str', default='admin', no_log=True), + media=dict(type='str', choices=['cdrom', 'floppy', 'rbsu', 'hdd', 'network', 'normal', 'usb']), + image=dict(type='str'), + state=dict(type='str', default='boot_once', choices=['boot_always', 'boot_once', 'connect', 'disconnect', 'no_boot', 'poweroff']), + force=dict(type='bool', default=False), + ssl_version=dict(type='str', default='TLSv1', choices=['SSLv3', 'SSLv23', 'TLSv1', 'TLSv1_1', 'TLSv1_2']), ) ) @@ -144,7 +144,7 @@ def main(): image = module.params['image'] state = module.params['state'] force = module.params['force'] - ssl_version = getattr(hpilo.ssl, 'PROTOCOL_' + module.params.get('ssl_version').upper().replace('V','v')) + ssl_version = getattr(hpilo.ssl, 'PROTOCOL_' + module.params.get('ssl_version').upper().replace('V', 'v')) ilo = hpilo.Ilo(host, login=login, password=password, ssl_version=ssl_version) changed = False @@ -183,13 +183,13 @@ def main(): module.fail_json(msg='HP iLO (%s) reports that the server is already powered on !' % host) if power_status == 'ON': - #ilo.cold_boot_server() ilo.warm_boot_server() +# ilo.cold_boot_server() changed = True else: ilo.press_pwr_btn() - #ilo.reset_server() - #ilo.set_host_power(host_power=True) +# ilo.reset_server() +# ilo.set_host_power(host_power=True) changed = True elif state in ('poweroff'): @@ -198,7 +198,7 @@ def main(): if not power_status == 'OFF': ilo.hold_pwr_btn() - #ilo.set_host_power(host_power=False) +# ilo.set_host_power(host_power=False) changed = True module.exit_json(changed=changed, power=power_status, **status) diff --git a/lib/ansible/modules/remote_management/hpilo/hpilo_facts.py b/lib/ansible/modules/remote_management/hpilo/hpilo_facts.py index ce42f46181..52a7d7e6d9 100755 --- a/lib/ansible/modules/remote_management/hpilo/hpilo_facts.py +++ b/lib/ansible/modules/remote_management/hpilo/hpilo_facts.py @@ -151,11 +151,11 @@ def parse_flat_interface(entry, non_numeric='hw_eth_ilo'): def main(): module = AnsibleModule( - argument_spec = dict( - host = dict(required=True, type='str'), - login = dict(default='Administrator', type='str'), - password = dict(default='admin', type='str', no_log=True), - ssl_version = dict(default='TLSv1', choices=['SSLv3', 'SSLv23', 'TLSv1', 'TLSv1_1', 'TLSv1_2']), + argument_spec=dict( + host=dict(type='str', required=True), + login=dict(type='str', default='Administrator'), + password=dict(type='str', default='admin', no_log=True), + ssl_version=dict(type='str', default='TLSv1', choices=['SSLv3', 'SSLv23', 'TLSv1', 'TLSv1_1', 'TLSv1_2']), ), supports_check_mode=True, ) @@ -179,17 +179,17 @@ def main(): for entry in data: if 'type' not in entry: continue - elif entry['type'] == 0: # BIOS Information + elif entry['type'] == 0: # BIOS Information facts['hw_bios_version'] = entry['Family'] facts['hw_bios_date'] = entry['Date'] - elif entry['type'] == 1: # System Information + elif entry['type'] == 1: # System Information facts['hw_uuid'] = entry['UUID'] facts['hw_system_serial'] = entry['Serial Number'].rstrip() facts['hw_product_name'] = entry['Product Name'] facts['hw_product_uuid'] = entry['cUUID'] - elif entry['type'] == 209: # Embedded NIC MAC Assignment + elif entry['type'] == 209: # Embedded NIC MAC Assignment if 'fields' in entry: - for (name, value) in [ (e['name'], e['value']) for e in entry['fields'] ]: + for (name, value) in [(e['name'], e['value']) for e in entry['fields']]: if name.startswith('Port'): try: factname = 'hw_eth' + str(int(value) - 1) diff --git a/lib/ansible/modules/remote_management/hpilo/hponcfg.py b/lib/ansible/modules/remote_management/hpilo/hponcfg.py index 09e9d7136a..ff9f30ac99 100644 --- a/lib/ansible/modules/remote_management/hpilo/hponcfg.py +++ b/lib/ansible/modules/remote_management/hpilo/hponcfg.py @@ -62,12 +62,13 @@ EXAMPLES = r''' from ansible.module_utils.basic import AnsibleModule + def main(): module = AnsibleModule( - argument_spec = dict( - src = dict(required=True, type='path', aliases=['path']), - minfw = dict(type='str'), + argument_spec=dict( + src=dict(type='path', required=True, aliases=['path']), + minfw=dict(type='str'), ) ) diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index 3e329e00e2..4ac40e9df4 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -431,9 +431,6 @@ lib/ansible/modules/packaging/os/zypper.py lib/ansible/modules/packaging/os/zypper_repository.py lib/ansible/modules/remote_management/foreman/foreman.py lib/ansible/modules/remote_management/foreman/katello.py -lib/ansible/modules/remote_management/hpilo/hpilo_boot.py -lib/ansible/modules/remote_management/hpilo/hpilo_facts.py -lib/ansible/modules/remote_management/hpilo/hponcfg.py lib/ansible/modules/remote_management/stacki/stacki_host.py lib/ansible/modules/source_control/bzr.py lib/ansible/modules/source_control/hg.py