def mac_del(self, ip): """Del ip-mac association""" from mac_assoc import MacAssoc macs = MacAssoc(self.conf['mac_assoc']['arptype']) macs.ip = ip result = dict() try: status = macs.delete() except Exception as e: result['status'] = False result['data'] = (('error:', e.message), ) return result result['data'] = (('arptype', macs.arptype), ('ip', macs.ip), ) if status: try: macs.ethers_to_arp() except Exception as e: result['status'] = False result['data'] = (('error:', e.message), ) return result result['result'] = True #"OK: del association from '%s' for ip: '%s'" % (macs.arptype, macs.ip) else: result['result'] = False result['data'] = (('ip', macs.ip), ('error:', 'not found in {0}'.format(macs.ethers)), ) #"ERROR: del association from '%s' for ip: '%s'" % (macs.arptype, macs.ip) result['status'] = True return result