Skip to content

Commit

Permalink
remove non-standard GetManagerAttributes, SetManagerAttributes (ansib…
Browse files Browse the repository at this point in the history
…le#51898)

(cherry picked from commit 3b20b18)
  • Loading branch information
billdodd committed Feb 12, 2019
1 parent 7f33c7d commit 930e286
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 97 deletions.
35 changes: 0 additions & 35 deletions lib/ansible/module_utils/redfish_utils.py
Expand Up @@ -515,25 +515,6 @@ def get_firmware_inventory(self):
result['entries'].append(firmware)
return result

def get_manager_attributes(self):
result = {}
manager_attributes = {}
key = "Attributes"

response = self.get_request(self.root_uri + self.manager_uri + "/" + key)
if response['ret'] is False:
return response
result['ret'] = True
data = response['data']

if key not in data:
return {'ret': False, 'msg': "Key %s not found" % key}

for attribute in data[key].items():
manager_attributes[attribute[0]] = attribute[1]
result["entries"] = manager_attributes
return result

def get_bios_attributes(self):
result = {}
bios_attributes = {}
Expand Down Expand Up @@ -670,22 +651,6 @@ def set_one_time_boot_device(self, bootdevice):
return response
return {'ret': True}

def set_manager_attributes(self, attr):
attributes = "Attributes"

# Example: manager_attr = {\"name\":\"value\"}
# Check if value is a number. If so, convert to int.
if attr['mgr_attr_value'].isdigit():
manager_attr = "{\"%s\": %i}" % (attr['mgr_attr_name'], int(attr['mgr_attr_value']))
else:
manager_attr = "{\"%s\": \"%s\"}" % (attr['mgr_attr_name'], attr['mgr_attr_value'])

payload = {"Attributes": json.loads(manager_attr)}
response = self.patch_request(self.root_uri + self.manager_uri + "/" + attributes, payload, HEADERS)
if response['ret'] is False:
return response
return {'ret': True}

def set_bios_attributes(self, attr):
result = {}
key = "Bios"
Expand Down
58 changes: 1 addition & 57 deletions lib/ansible/modules/remote_management/redfish/redfish_config.py
Expand Up @@ -52,16 +52,6 @@
description:
- value of BIOS attribute to update
default: 'null'
mgr_attr_name:
required: false
description:
- name of Manager attribute to update
default: 'null'
mgr_attr_value:
required: false
description:
- value of Manager attribute to update
default: 'null'
author: "Jose Delarosa (github: jose-delarosa)"
'''
Expand Down Expand Up @@ -104,36 +94,6 @@
baseuri: "{{ baseuri }}"
user: "{{ user }}"
password: "{{ password }}"
- name: Enable NTP in the OOB Controller
redfish_config:
category: Manager
command: SetManagerAttributes
mgr_attr_name: NTPConfigGroup.1.NTPEnable
mgr_attr_value: Enabled
baseuri: "{{ baseuri }}"
user: "{{ user}}"
password: "{{ password }}"
- name: Set NTP server 1 to {{ ntpserver1 }} in the OOB Controller
redfish_config:
category: Manager
command: SetManagerAttributes
mgr_attr_name: NTPConfigGroup.1.NTP1
mgr_attr_value: "{{ ntpserver1 }}"
baseuri: "{{ baseuri }}"
user: "{{ user}}"
password: "{{ password }}"
- name: Set Timezone to {{ timezone }} in the OOB Controller
redfish_config:
category: Manager
command: SetManagerAttributes
mgr_attr_name: Time.1.Timezone
mgr_attr_value: "{{ timezone }}"
baseuri: "{{ baseuri }}"
user: "{{ user}}"
password: "{{ password }}"
'''

RETURN = '''
Expand All @@ -151,8 +111,7 @@

# More will be added as module features are expanded
CATEGORY_COMMANDS_ALL = {
"Systems": ["SetBiosDefaultSettings", "SetBiosAttributes"],
"Manager": ["SetManagerAttributes"],
"Systems": ["SetBiosDefaultSettings", "SetBiosAttributes"]
}


Expand All @@ -165,8 +124,6 @@ def main():
baseuri=dict(required=True),
user=dict(required=True),
password=dict(required=True, no_log=True),
mgr_attr_name=dict(default='null'),
mgr_attr_value=dict(default='null'),
bios_attr_name=dict(default='null'),
bios_attr_value=dict(default='null'),
),
Expand All @@ -180,9 +137,6 @@ def main():
creds = {'user': module.params['user'],
'pswd': module.params['password']}

# Manager attributes to update
mgr_attributes = {'mgr_attr_name': module.params['mgr_attr_name'],
'mgr_attr_value': module.params['mgr_attr_value']}
# BIOS attributes to update
bios_attributes = {'bios_attr_name': module.params['bios_attr_name'],
'bios_attr_value': module.params['bios_attr_value']}
Expand Down Expand Up @@ -215,16 +169,6 @@ def main():
elif command == "SetBiosAttributes":
result = rf_utils.set_bios_attributes(bios_attributes)

elif category == "Manager":
# execute only if we find a Manager service resource
result = rf_utils._find_managers_resource(rf_uri)
if result['ret'] is False:
module.fail_json(msg=to_native(result['msg']))

for command in command_list:
if command == "SetManagerAttributes":
result = rf_utils.set_manager_attributes(mgr_attributes)

# Return data back or fail with proper message
if result['ret'] is True:
module.exit_json(changed=result['changed'], msg=to_native(result['msg']))
Expand Down
Expand Up @@ -126,15 +126,15 @@
"Chassis": ["GetFanInventory"],
"Accounts": ["ListUsers"],
"Update": ["GetFirmwareInventory"],
"Manager": ["GetManagerAttributes", "GetLogs"],
"Manager": ["GetLogs"],
}

CATEGORY_COMMANDS_DEFAULT = {
"Systems": "GetSystemInventory",
"Chassis": "GetFanInventory",
"Accounts": "ListUsers",
"Update": "GetFirmwareInventory",
"Manager": "GetManagerAttributes"
"Manager": "GetManagerNicInventory"
}


Expand Down Expand Up @@ -254,9 +254,7 @@ def main():
module.fail_json(msg=resource['msg'])

for command in command_list:
if command == "GetManagerAttributes":
result["manager_attributes"] = rf_utils.get_manager_attributes()
elif command == "GetLogs":
if command == "GetLogs":
result["log"] = rf_utils.get_logs()

# Return data back
Expand Down

0 comments on commit 930e286

Please sign in to comment.