diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_bmcconfig.py b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_bmcconfig.py index 9524b0d1b..aa91a56be 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_bmcconfig.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_bmcconfig.py @@ -328,10 +328,10 @@ rmdir \"/tmp/$userid\" \n") if not netinfo: return self.callback.error("%s: No network information get" % node) - nic = None - for k,v in netinfo.items(): - if 'ip' in v and v['ip'] == node_info['bmcip']: - nic = k + bmcip = node_info['bmcip'] + nic = self._get_facing_nic(bmcip, netinfo) + if not nic: + return self.callback.error('%s: Can not get facing NIC for %s' % (node, bmcip)) try: obmc.set_ntp_servers(nic, servers) @@ -346,6 +346,12 @@ rmdir \"/tmp/$userid\" \n") ntpservers = netinfo[nic]['ntpservers'] self.callback.info('%s: BMC NTP Servers: %s' % (node, ntpservers)) + def _get_facing_nic(self, bmcip, netinfo): + for k,v in netinfo.items(): + if 'ip' in v and v['ip'] == bmcip: + return k + return None + def _set_admin_password(self, admin_passwd, **kw): node = kw['node'] node_info = kw['nodeinfo']