def _bond_hwaddr_should_be_enforced(bondname): """ Bond MAC address is to be enforced under these conditions: - Bond device exists already. - One of these conditions exists (OR): - Unowned by VDSM (not in running config). - Owned by VDSM and HWADDR is specified in the config. """ bond_dev = bond.Bond(bondname) if bond_dev.exists(): running_bonds = RunningConfig().bonds bondattr = running_bonds.get(bondname) return not bondattr or bondattr.get('hwaddr') return False
def net2vlan(network_name): # Using RunningConfig avoids the need to require root access. net_attr = RunningConfig().networks.get(network_name) return net_attr.get('vlan') if net_attr else None