def add_acl(ip):
'''
add an entry to the ACL. look at success or not of the commands
:param ip:
:return:
'''
UPDATE_ACL_COMMANDS = """
ip access-list extended %s
no deny ip any any
remark %s
permit ip any host %s
deny ip any any
"""
localtime = time.asctime(time.localtime(time.time()))
remark = "Added %s @%s" % (ip, localtime)
responses = configure(UPDATE_ACL_COMMANDS % (ACLNAME, remark, ip))
success = reduce(lambda x, y: x and y, [r.success for r in responses])
status = "Success" if success else "Fail"
log("adding IP: %s to ACL: status: %s" % (ip, status), 5)
评论列表
文章目录