Skip to content

Commit bf8f8dd

Browse files
committed
Linting 1.0.41
1 parent 737e3cf commit bf8f8dd

File tree

121 files changed

+193
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+193
-203
lines changed

CHANGELOG.md

Whitespace-only changes.

README.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,4 @@ pip install paramiko
4141
```
4242
```
4343
pip install certifi
44-
```
45-
46-
## License
47-
48-
This project is licensed under the Apache 2.0 license. Please see the [LICENSE](LICENSE) for more information.
49-
50-
## Contributing and feature requests
51-
52-
**Contributing:** We welcome your contributions to the Ansible Modules for HPE OneView. See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
53-
54-
**Feature Requests:** If you have a need that is not met by the current implementation, please let us know (via a new issue).
55-
This feedback is crucial for us to deliver a useful product. Do not assume that we have already thought of everything, because we assure you that is not the case.
56-
57-
## Features
58-
59-
The HPE.Oneview collection includes
60-
[roles](https://github.com/HewlettPackard/ilo-ansible-collection/tree/master/roles/),
61-
[modules](https://github.com/HewlettPackard/ilo-ansible-collection/tree/master/plugins/modules),
62-
[sample playbooks](https://github.com/HewlettPackard/ilo-ansible-collection/tree/master/playbooks),
63-
[module_utils](https://github.com/HewlettPackard/ilo-ansible-collection/tree/master/plugins/module_utils)
64-
65-
66-
## Copyright
67-
68-
© Copyright 2022-24 Hewlett Packard Enterprise Development LP
44+
```

galaxy.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ namespace: hpe
99
name: ilo
1010

1111
# The version of the collection. Must be compatible with semantic versioning
12-
version: 1.0.13
12+
version: 1.0.41
1313

1414
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
1515
readme: README.md
1616

1717
# A list of the collection's content authors. Can be just the name or in the format 'Full Name <email> (url)
1818
# @nicks:irc/im.site#channel'
1919
authors:
20-
- Rajeevalochana Kallur <[email protected]>
21-
- Bhavya B <[email protected]>
22-
20+
- Rajeevalochana Kallur <[email protected]>
21+
- Bhavya B <[email protected]>
22+
- Gayathiri devi Ramasamy [email protected]
23+
- Nagendra M [email protected]
24+
- T S Kushal [email protected]
2325

2426
### OPTIONAL but strongly recommended
2527

@@ -33,16 +35,16 @@ license_file: LICENSE
3335
# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
3436
# requirements as 'namespace' and 'name'
3537
tags:
36-
- ansible
37-
- devops
38-
- hpe_ilo
39-
- infrastructure_as_code
40-
- bare_metal
41-
- linux
42-
- infrastructure
43-
- networking
44-
- storage
45-
- security
38+
- ansible
39+
- devops
40+
- hpe_ilo
41+
- infrastructure_as_code
42+
- bare_metal
43+
- linux
44+
- infrastructure
45+
- networking
46+
- storage
47+
- security
4648

4749
# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
4850
# collection label 'namespace.name'. The value is a version range

plugins/module_utils/ilo_oem_utils.py

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ def __init__(self, creds, root_uri, timeout, module):
153153
'urllib3'), exception=URLLIB3_IMP_ERR)
154154

155155
if not HAS_REDFISH:
156-
self.module.warn(f"missing redfish library")
156+
self.module.warn("missing redfish library")
157157

158158
if not HAS_PARAMIKO:
159-
self.module.warn(f"missing paramiko library")
159+
self.module.warn("missing paramiko library")
160160

161161
def get_ilo_generation(self):
162162
# Get the firmware version
@@ -170,7 +170,7 @@ def get_ilo_generation(self):
170170
"msg": "Key 'FirmwareVersion' not found in response: %s" % (resp)
171171
}
172172
fw_version = resp['FirmwareVersion']
173-
ilo_gen = re.sub("\D", "", fw_version).strip()[0]
173+
ilo_gen = re.sub(r"\D", "", fw_version).strip()[0]
174174
return {
175175
"ret": True,
176176
"ilo_gen": int(ilo_gen)
@@ -1031,7 +1031,8 @@ def verify_logical_drives(self, raid_details, check_length=False):
10311031
% (str(raid["Raid"]), ("Raid" + str(drive["Raid"])))
10321032
if len(drive["data_drives"]) != raid["DataDrives"]["DataDriveCount"]:
10331033
fail = True
1034-
fail_message += "Physical drive count present in the input (%s) does not match with the physical drive count present in the server (%s). " \
1034+
fail_message += "Physical drive count present in the input (%s) "\
1035+
"does not match with the physical drive count present in the server (%s). " \
10351036
% (str(raid["DataDrives"]["DataDriveCount"]), str(len(drive["data_drives"])))
10361037
if drive["MediaType"] != raid["DataDrives"]["DataDriveMediaType"]:
10371038
fail = True
@@ -1044,8 +1045,9 @@ def verify_logical_drives(self, raid_details, check_length=False):
10441045
for data_drive in drive["data_drives"]:
10451046
if data_drive["CapacityGB"] < raid["DataDrives"]["DataDriveMinimumSizeGiB"]:
10461047
fail = True
1047-
fail_message += "Data drive minimum size present in the input (%s) does not satisfied by drive with ID (%s) with the data drive minimum size (%s). " \
1048-
% (str(raid["DataDrives"]["DataDriveMinimumSizeGiB"]), str(data_drive["Id"]), str(data_drive["CapacityGB"]))
1048+
fail_message += "Data drive minimum size present in the input (%s) does not satisfied "\
1049+
"by drive with ID (%s) with the data drive minimum size (%s). " \
1050+
% (str(raid["DataDrives"]["DataDriveMinimumSizeGiB"]), str(data_drive["Id"]), str(data_drive["CapacityGB"]))
10491051
if fail:
10501052
return {
10511053
"ret": False,
@@ -1084,7 +1086,7 @@ def verify_uefi_boot_order(self, uefi_boot_order):
10841086
if not response["ret"]:
10851087
return response
10861088

1087-
# Get the model
1089+
# Get the model
10881090
sys_response = self.get_request(self.root_uri + self.systems_uri)
10891091
if not sys_response["ret"]:
10901092
return sys_response
@@ -1106,7 +1108,9 @@ def verify_uefi_boot_order(self, uefi_boot_order):
11061108
return {
11071109
"ret": False,
11081110
"changed": False,
1109-
"msg": "The current server Boot Order contains fewer elements (%s) than the provided input Boot Order (%s)" % (str(len(server_boot_order)), str(len(input_boot_order)))
1111+
"msg": "The current server Boot Order contains fewer elements "
1112+
"(%s) than the provided input Boot Order (%s)" %
1113+
(str(len(server_boot_order)), str(len(input_boot_order)))
11101114
}
11111115

11121116
for i in range(0, len(input_boot_order)):
@@ -1854,7 +1858,7 @@ def delete_all_snmp_alert_destinations(self):
18541858
def delete_snmpv3_users(self, snmpv3_users):
18551859
# This method deletes provided SNMPv3 users
18561860

1857-
if snmpv3_users == None or len(snmpv3_users) == 0:
1861+
if snmpv3_users is None or len(snmpv3_users) == 0:
18581862
return {
18591863
"ret": False,
18601864
"msg": "The provided input SNMPv3 users is empty. Hence deleting SNMPv3 users failed"
@@ -3189,7 +3193,7 @@ def get_phy_nic_info(self):
31893193
return {
31903194
"ret": False,
31913195
"changed": False,
3192-
"msg": "'@odata.id' not found in NetworkAdapters response, %s" % (rsp_data)
3196+
"msg": "'@odata.id' not found in NetworkAdapters response, %s" % (nwk_adapt_rsp_data["Members"])
31933197
}
31943198
# Get on each member eg : self.root_uri + self.service_root + /chassis/1 + /NetworkAdapters/<ID>
31953199
item_rsp = self.get_request(self.root_uri + item["@odata.id"])
@@ -3469,7 +3473,7 @@ def get_drive_operating_mode(self, ip_addr):
34693473
if response["data"]["[email protected]"] == 0:
34703474
return {
34713475
"ret": False,
3472-
"msg": "No drive found in %s. Check the iLO" % res["data"]
3476+
"msg": "No drive found in %s. Check the iLO" % response["data"]
34733477
}
34743478
# Get Members of ArrayControllers
34753479
for mem in init_data["Members"]:
@@ -3510,7 +3514,7 @@ def import_trusted_ca(self, ca_file):
35103514
ca_file_data = cafile.readlines()
35113515

35123516
ca_file_data = ca_file_data[ca_file_data.index(
3513-
"-----BEGIN CERTIFICATE-----\n"):ca_file_data.index("-----END CERTIFICATE-----\n")+1]
3517+
"-----BEGIN CERTIFICATE-----\n"):ca_file_data.index("-----END CERTIFICATE-----\n") + 1]
35143518
ca_file_data = "".join(ca_file_data)
35153519

35163520
payload = {
@@ -3523,7 +3527,9 @@ def import_trusted_ca(self, ca_file):
35233527
return {
35243528
"ret": False,
35253529
"changed": False,
3526-
"msg": "Importing trusted CA Certificate failed with response: " + res["msg"] + ". Certificate storage might be full, try again after cleaning up existing Trusted CA Certificates."
3530+
"msg": "Importing trusted CA Certificate failed with response: "
3531+
+ res["msg"] + ". Certificate storage might be full,"
3532+
" try again after cleaning up existing Trusted CA Certificates."
35273533
}
35283534
else:
35293535
return res
@@ -3567,7 +3573,7 @@ def map_user_certificate(self, user_cert_file, username):
35673573
cert_file_data = cert_file.readlines()
35683574

35693575
cert_file_data = cert_file_data[cert_file_data.index(
3570-
"-----BEGIN CERTIFICATE-----\n"):cert_file_data.index("-----END CERTIFICATE-----\n")+1]
3576+
"-----BEGIN CERTIFICATE-----\n"):cert_file_data.index("-----END CERTIFICATE-----\n") + 1]
35713577
cert_file_data = "".join(cert_file_data)
35723578

35733579
payload = {
@@ -3664,7 +3670,7 @@ def enable_certificate_login(self):
36643670

36653671
certificate_authentication_data = certificate_authentication["data"]
36663672

3667-
if certificate_authentication_data["CertificateLoginEnabled"] == True:
3673+
if certificate_authentication_data["CertificateLoginEnabled"] is True:
36683674
return {
36693675
"ret": True,
36703676
"changed": False,
@@ -3807,7 +3813,7 @@ def install_helper(self, client, sudo_password, filename, remote, op_sys, archit
38073813
nodir = False
38083814
error_output = ""
38093815

3810-
command = f"ls /usr/lib/{architecture}/"
3816+
command = "ls /usr/lib/{}/".format(architecture)
38113817
stdin, stdout, stderr = client.exec_command(command)
38123818
error_output = stderr.read().decode('utf-8')
38133819
if len(error_output) > 0:
@@ -3826,7 +3832,7 @@ def install_helper(self, client, sudo_password, filename, remote, op_sys, archit
38263832
if pack in package:
38273833
if op_sys == "apt":
38283834
package = package.split("_")[0]
3829-
command = f'sudo -p "" {op_sys} remove -y {package}'
3835+
command = 'sudo -p "" {} remove -y {}'.format(op_sys, package)
38303836
stdin, stdout, stderr = client.exec_command(
38313837
command, get_pty=True)
38323838
stdin.write(sudo_password + '\n')
@@ -3840,7 +3846,7 @@ def install_helper(self, client, sudo_password, filename, remote, op_sys, archit
38403846
break
38413847

38423848
if found:
3843-
command = f'sudo -p "" rm -f /usr/lib/{architecture}/scexe-compat/*'
3849+
command = 'sudo -p "" rm -f /usr/lib/{}/scexe-compat/*'.format(architecture)
38443850
stdin, stdout, stderr = client.exec_command(
38453851
command, get_pty=True)
38463852
stdin.write(sudo_password + '\n')
@@ -3852,7 +3858,7 @@ def install_helper(self, client, sudo_password, filename, remote, op_sys, archit
38523858
return result
38533859
found = False
38543860

3855-
command = f'sudo -p "" {op_sys} install -y {remote}{filename}'
3861+
command = 'sudo -p "" {} install -y {}{}'.format(op_sys, remote, filename)
38563862
stdin, stdout, stderr = client.exec_command(command, get_pty=True)
38573863
stdin.write(sudo_password + '\n')
38583864
stdin.flush()
@@ -3979,7 +3985,7 @@ def install_smartcomp(self, rpm_info):
39793985
result["msg"] = "Architecture not supported."
39803986
return result
39813987

3982-
command = "ls /usr/lib/"+smcp_file+"/scexe-compat"
3988+
command = "ls /usr/lib/" + smcp_file + "/scexe-compat"
39833989
stdin, stdout, stderr = client.exec_command(command)
39843990
smart_component = stdout.read().decode('utf-8')
39853991
error_output = stderr.read().decode('utf-8')
@@ -4059,11 +4065,15 @@ def firmware_upgrade_with_upload(self, image_uri, file_name, upgrade=True):
40594065
return ilo_repo_rsp
40604066

40614067
for each_file_name in ilo_repo_rsp["msg"]["Members"]:
4062-
if((each_file_name["Filename"] == file_name or (file_name == '' and each_file_name["Filename"] == image_uri.split('/')[-1])) and each_file_name["Locked"]):
4068+
if ((each_file_name["Filename"] == file_name or
4069+
(file_name == '' and each_file_name["Filename"] == image_uri.split('/')[-1]))
4070+
and each_file_name["Locked"]):
40634071
return {
40644072
"ret": False,
40654073
"changed": False,
4066-
"msg": "The file with name '%s' already exists in the repository and is locked. Remove the install set or task that is locking the component and try again." % (each_file_name["Filename"])
4074+
"msg": "The file with name '%s' already exists in the repository and is locked."
4075+
" Remove the install set or task that is locking the component and try again."
4076+
% (each_file_name["Filename"])
40674077
}
40684078

40694079
update_url = self.root_uri + \
@@ -4075,7 +4085,7 @@ def firmware_upgrade_with_upload(self, image_uri, file_name, upgrade=True):
40754085
"TPMOverrideFlag": True
40764086
}
40774087

4078-
if(file_name != ''):
4088+
if (file_name != ''):
40794089
body["ComponentFileName"] = file_name
40804090

40814091
response = self.post_request(update_url, body)
@@ -4164,7 +4174,7 @@ def create_maintenance_window(self, maintenance_window_data):
41644174
end_time = datetime.strptime(
41654175
maintenance_window_data["Expire"], "%Y-%m-%dT%H:%M:%SZ")
41664176

4167-
if(start_time > end_time):
4177+
if (start_time > end_time):
41684178
return {
41694179
"ret": False,
41704180
"changed": False,
@@ -4312,7 +4322,7 @@ def create_install_set(self, install_set_url, install_set_attributes):
43124322
"Name": str(install_set_attributes["Name"]),
43134323
"Sequence": install_set_attributes["Install_set_sequence"]
43144324
}
4315-
if(install_set_attributes["Description"] != ''):
4325+
if (install_set_attributes["Description"] != ''):
43164326
install_set_body["Description"] = install_set_attributes["Description"]
43174327

43184328
response = self.post_request(
@@ -4404,7 +4414,8 @@ def get_maintenance_window_id(self, maintenance_window_details):
44044414
return {
44054415
"ret": False,
44064416
"changed": False,
4407-
"msg": "Maintenance window with same name with different start and expire time already exists in the server. Hence provide unique name for maintenance window"
4417+
"msg": "Maintenance window with same name with different start and expire time"
4418+
"already exists in the server. Hence provide unique name for maintenance window"
44084419
}
44094420
else:
44104421
end_time = datetime.strptime(
@@ -4507,7 +4518,7 @@ def get_install_set_url(self, install_set_attributes):
45074518
if each_filename["Filename"] == each["Filename"]:
45084519
file_found = True
45094520
if not file_found:
4510-
return{
4521+
return {
45114522
"ret": False,
45124523
"changed": False,
45134524
"msg": "Provided filename %s doesn't exist in ilo repository" % (each_filename["Filename"])

plugins/modules/ilo_boot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33
###
44
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP

plugins/modules/ilo_device.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33
###
44
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
@@ -203,7 +203,7 @@ def main():
203203
module.fail_json(msg="Invalid Category: %s" % category)
204204

205205
# Organize by Categories / Commands
206-
if category == "Chassis":
206+
if category == "Chassis":
207207
for command in command_list:
208208
result[command] = {}
209209
if command == "GetDeviceInventoryInfo":
@@ -222,7 +222,7 @@ def main():
222222
'ret': False, 'msg': "Only one IndicatorLed command should be sent at a time."}
223223
else:
224224
response = rf_utils.get_request(
225-
root_uri+"/redfish/v1/Managers/1")
225+
root_uri + "/redfish/v1/Managers/1")
226226
if response['ret'] is False:
227227
module.fail_json(msg=to_native(response))
228228
version = float(response['data']['FirmwareVersion'][4] + "." + response['data']

0 commit comments

Comments
 (0)