2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-13 01:40:26 +00:00

Additional info display for rspconfig (#5803)

* Additional info display for rspconfig

* Changes for review comments

* Better message suggestions

* Fix tidy look
This commit is contained in:
Mark Gurevich
2018-11-28 22:33:43 -05:00
committed by Bin Xu
parent e7239786fd
commit 6146a30acc
2 changed files with 19 additions and 11 deletions

View File

@ -379,6 +379,8 @@ rmdir \"/tmp/$userid\" \n")
except (SelfServerException, SelfClientException) as e:
self.callback.error(e.message, node)
self.callback.info("%s: BMC password changed. Update 'bmcpasswd' for the node or the 'passwd' table with the new password." % node)
def _set_apis_values(self, key, value, **kw):
node = kw['node']
obmc = openbmc.OpenBMCRest(name=node, nodeinfo=kw['nodeinfo'], messager=self.callback,
@ -430,8 +432,8 @@ rmdir \"/tmp/$userid\" \n")
def _print_bmc_netinfo(self, node, ip, netmask, gateway, vlan):
self.callback.info('%s: BMC IP: %s'% (node, ip))
self.callback.info('%s: BMC Netmask: %s' % (node, netmask))
self.callback.info('%s: BMC IP: %s' % (node, ip))
self.callback.info('%s: BMC Netmask: %s' % (node, netmask))
self.callback.info('%s: BMC Gateway: %s' % (node, gateway))
if vlan:
self.callback.info('%s: BMC VLAN ID: %s' % (node, vlan))
@ -440,6 +442,7 @@ rmdir \"/tmp/$userid\" \n")
node = kw['node']
node_info = kw['nodeinfo']
zeroconf = "Unknown"
obmc = openbmc.OpenBMCRest(name=node, nodeinfo=node_info, messager=self.callback,
debugmode=self.debugmode, verbose=self.verbose)
@ -451,7 +454,7 @@ rmdir \"/tmp/$userid\" \n")
return
if not netinfo:
return self.callback.error("No network information get", node)
return self.callback.error("Can not get network information", node)
if 'error' in netinfo:
return self.callback.info('%s: %s' % (node, netinfo['error']))
@ -470,6 +473,7 @@ rmdir \"/tmp/$userid\" \n")
origin_type = netinfo[origin_nic]['ipsrc']
origin_ip_obj = netinfo[origin_nic]['ipobj']
zeroconf = netinfo[origin_nic]['zeroconf']
if vlan:
pre_nic = nic.split('_')[0]
@ -482,6 +486,8 @@ rmdir \"/tmp/$userid\" \n")
nic = pre_nic + '_' + vlan
try:
# Display Zero Config information in case IP setting fails or set IP is not accessible
self.callback.info('%s: Setting BMC IP configuration... [Zero Config IP: %s]' % (node, zeroconf))
obmc.set_netinfo(nic, ip, prefix, gateway)
sleep( 5 )
nic_netinfo = obmc.get_nic_netinfo(nic)
@ -490,7 +496,7 @@ rmdir \"/tmp/$userid\" \n")
return
if not nic_netinfo:
return self.callback.error('Did not get info for NIC %s' % nic, node)
return self.callback.error('Can not get info for NIC %s' % nic, node)
set_success = False
for net_id, attr in nic_netinfo.items():
@ -500,7 +506,7 @@ rmdir \"/tmp/$userid\" \n")
set_success = True
if not set_success:
return self.callback.error('Config BMC IP failed', node)
return self.callback.error('Setting BMC IP configuration failed. [Zero Config IP: %s]' % zeroconf, node)
try:
if origin_type == 'DHCP':
@ -508,7 +514,7 @@ rmdir \"/tmp/$userid\" \n")
elif origin_type == 'Static':
obmc.delete_ip_object(origin_nic, origin_ip_obj)
else:
self.callback.error('Get wrong Origin type %s for NIC %s IP object %s' % (origin_type, nic, origin_ip_obj), node)
self.callback.error('Got wrong origin type %s for NIC %s IP object %s' % (origin_type, nic, origin_ip_obj), node)
except (SelfServerException, SelfClientException) as e:
self.callback.error(e.message, node)
@ -525,7 +531,7 @@ rmdir \"/tmp/$userid\" \n")
self.callback.error(e.message, node)
return
if not netinfo:
return self.callback.error("No network information get", node)
return self.callback.error("Can not get network information", node)
defaultgateway = "n/a"
bmchostname = ""
if 'defaultgateway' in netinfo:

View File

@ -900,13 +900,15 @@ class OpenBMCRest(object):
continue
dev,match,netid = k.partition("/ipv4/")
if netid:
if 'LinkLocal' in v["Origin"] or v["Address"].startswith("169.254"):
msg = "Found LinkLocal address %s for interface %s, Ignoring..." % (v["Address"], dev)
self._print_record_log(msg, 'get_netinfo')
continue
nicid = dev.split('/')[-1]
if nicid not in netinfo:
netinfo[nicid] = {}
if 'LinkLocal' in v["Origin"] or v["Address"].startswith("169.254"):
msg = "Found LinkLocal address %s for interface %s, Ignoring..." % (v["Address"], dev)
self._print_record_log(msg, 'get_netinfo')
# Save Zero Conf information
netinfo[nicid]["zeroconf"] = v["Address"]
continue
if 'ip' in netinfo[nicid]:
msg = "%s: Another valid ip %s found." % (node, v["Address"])
self._print_record_log(msg, 'get_netinfo')