Fix update_persistent_boot for Gen9 servers

Change update_persistent_boot helper methods
to grep for strings that work on both Gen8 and
Gen9 servers.
This commit is contained in:
Anusha Ramineni 2014-10-29 22:08:26 +05:30 committed by Ramakrishnan G
parent 268ad1fd13
commit 1251334e4d
1 changed files with 37 additions and 53 deletions

View File

@ -110,7 +110,6 @@ class IloClient:
else: else:
urlstr = 'https://%s/ribcl' % (self.host) urlstr = 'https://%s/ribcl' % (self.host)
xml = self._serialize_xml(root) xml = self._serialize_xml(root)
# print xml
try: try:
req = urllib2.Request(url=urlstr, data=xml) req = urllib2.Request(url=urlstr, data=xml)
req.add_header("Content-length", len(xml)) req.add_header("Content-length", len(xml))
@ -178,7 +177,6 @@ class IloClient:
then the string is returned back. then the string is returned back.
""" """
# print xml_response
count = 0 count = 0
xml_dict = {} xml_dict = {}
resp_message = None resp_message = None
@ -439,10 +437,11 @@ class IloClient:
boot_mode = self._check_boot_mode(result) boot_mode = self._check_boot_mode(result)
if boot_mode == 'bios': if boot_mode == 'bios':
self.set_persistent_boot(device_type) self.set_persistent_boot(device_type)
return
device_list = [] device_list = []
for item in device_type: for item in device_type:
dev=item.upper() dev=item.upper()
if dev == 'NETWORK': if dev == 'NETWORK':
nic_list = self._get_nic_boot_devices(result) nic_list = self._get_nic_boot_devices(result)
device_list += nic_list device_list += nic_list
@ -455,58 +454,43 @@ class IloClient:
def _check_boot_mode(self, result): def _check_boot_mode(self, result):
boot_mode = None if 'DESCRIPTION' in result[0]:
key_list = ['DESCRIPTION'] return 'uefi'
for item in result: else:
for key, val in item.iteritems(): return 'bios'
if key in key_list:
boot_mode = 'uefi'
return boot_mode
else:
boot_mode = 'bios'
return boot_mode
def _get_nic_boot_devices(self, result): def _get_nic_boot_devices(self, result):
nic_ipv4="NIC (IPv4)" nw_identifier = "NIC"
nic_ipv6="NIC (IPv6)" pxe_enabled = "PXE"
key_desc="DESCRIPTION" nic_list = []
key_value="value" pxe_nic_list = []
nic_values_ipv4=[] try:
nic_values_ipv6=[] for item in result:
found_nic_ipv4 = 0 if nw_identifier in item["DESCRIPTION"]:
found_nic_ipv6 = 0 # Check if it is PXE enabled, to add it to starting of list
for item in result: if pxe_enabled in item["DESCRIPTION"]:
for key,val in item.iteritems(): pxe_nic_list.append(item["value"])
""" Check if we have IPv4/IPv6 NICS""" else:
if key == key_desc: nic_list.append(item["value"])
if val.find(nic_ipv4)!= -1: except KeyError as e:
found_nic_ipv4=1 msg = "_get_nic_boot_devices failed with the KeyError:%s"
if val.find(nic_ipv6)!= -1: raise IloError((msg)% e)
found_nic_ipv6=1
if key == key_value: all_nics = pxe_nic_list + nic_list
if found_nic_ipv4: return all_nics
nic_values_ipv4.append(val)
found_nic_ipv4=0 def _isDisk(self, result):
if found_nic_ipv6: disk_identifier = ["Logical Drive", "HDD", "Storage", "LogVol"]
nic_values_ipv6.append(val) return any(e in result for e in disk_identifier)
found_nic_ipv6=0
nic_list = nic_values_ipv4 + nic_values_ipv6
return nic_list
def _get_disk_boot_devices(self, result): def _get_disk_boot_devices(self, result):
disk_str="Logical Drive"
key_desc="DESCRIPTION"
key_value="value"
disk_list=[] disk_list=[]
found_disk = 0 try:
for item in result: for item in result:
for key,val in item.iteritems(): if self._isDisk(item["DESCRIPTION"]):
if key == key_desc: disk_list.append(item["value"])
if val.find(disk_str)!= -1: except KeyError:
found_disk=1 msg = "_get_disk_boot_devices failed with the KeyError:%s"
if key == key_value: raise IloError((msg)% e)
if found_disk:
disk_list.append(val)
found_disk=0
return disk_list return disk_list