summaryrefslogtreecommitdiffstats
path: root/pyinventorymgr
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2016-11-01 12:57:55 -0500
committerPatrick Williams <patrick@stwcx.xyz>2016-11-21 19:40:35 +0000
commitf9deaa0f2ee0ef2abc0610aa41397d7b47defd3a (patch)
tree36f68eaf1838e5815253dec49c88d8c96c769006 /pyinventorymgr
parentd560aac633d16d8a9a3112afe9adcbcabbfb3a19 (diff)
downloadtalos-skeleton-f9deaa0f2ee0ef2abc0610aa41397d7b47defd3a.tar.gz
talos-skeleton-f9deaa0f2ee0ef2abc0610aa41397d7b47defd3a.zip
skeleton: Read mac from u-boot instead of net settings
The system mac should be read from u-boot, not from the network settings, since the network settings one can be the random mac set by the system, and if the random mac happens to have the locally managed bit turned on, it'll prevent the mac from vpd from being written into the system. Fixes openbmc/openbmc#627 Change-Id: I70ffaeb165881a2b83455f2953a4143cb471d688 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Diffstat (limited to 'pyinventorymgr')
-rw-r--r--pyinventorymgr/sync_inventory_items.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/pyinventorymgr/sync_inventory_items.py b/pyinventorymgr/sync_inventory_items.py
index 1354b5a..d92c3df 100644
--- a/pyinventorymgr/sync_inventory_items.py
+++ b/pyinventorymgr/sync_inventory_items.py
@@ -57,11 +57,14 @@ def get_inv_value(obj, prop_name):
return value
-# Get the value of the mac on the system without ':' separators
+# Get the value of the mac on the system (from u-boot) without ':' separators
def get_sys_mac(obj):
sys_mac = ''
- dbus_method = obj.get_dbus_method("GetHwAddress", NET_DBUS_NAME)
- sys_mac = dbus_method("eth0")
+ try:
+ sys_mac = subprocess.check_output(["fw_printenv", "-n", "ethaddr"])
+ except:
+ # Handle when mac does not exist in u-boot
+ return sys_mac
sys_mac = sys_mac.replace(":", "")
return sys_mac
@@ -70,8 +73,12 @@ def get_sys_mac(obj):
# MAC if the system MAC is not locally administered because this means
# the system admin has purposely set the MAC
def sync_mac(obj, inv_mac, sys_mac):
- # Convert sys MAC to int to perform bitwise '&'
- int_sys_mac = int(sys_mac, 16)
+ if sys_mac:
+ # Convert sys MAC to int to perform bitwise '&'
+ int_sys_mac = int(sys_mac, 16)
+ else:
+ # Set mac to 0 for when u-boot mac is not present
+ int_sys_mac = 0
if not int_sys_mac & MAC_LOCALLY_ADMIN_MASK:
# Sys MAC is not locally administered, go replace it with inv value
# Add the ':' separators
OpenPOWER on IntegriCloud