def getent_ethers(database, keys=None): if not keys: write_ethers(NslcdClient(constants.NSLCD_ACTION_ETHER_ALL)) return for key in keys: if re.match('^[0-9a-fA-F]{1,2}(:[0-9a-fA-F]{1,2}){5}$', key): con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYETHER) con.write_ether(key) else: con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYNAME) con.write_string(key) write_ethers(con)
def getent_ethers(database, key=None): if not key: con = NslcdClient(constants.NSLCD_ACTION_ETHER_ALL) elif re.match('^[0-9a-fA-F]{1,2}(:[0-9a-fA-F]{1,2}){5}$', key): con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYETHER) con.write_ether(key) else: con = NslcdClient(constants.NSLCD_ACTION_ETHER_BYNAME) con.write_string(key) while con.get_response() == constants.NSLCD_RESULT_BEGIN: name = con.read_string() ether = con.read_ether() print '%s %s' % (ether, name)