def action_acl(args, nitro): if args.action == "get": acl = NSAcl() acl.set_aclname(args.name) acl = NSAcl.get(nitro, acl) print "--- ACL: " + acl.get_aclname() + " ---" for k in sorted(acl.options.iterkeys(), key=lambda k: k): print "\t%s: %s" % (k, acl.options[k]) if args.action == "list": acls = NSAcl().get_all(nitro) print "-- Configured ACLs ---" for acl in sorted(acls, key=lambda k: k.get_aclname()): print "\t" + acl.get_aclname() if args.action == "apply": NSAcls.apply(nitro) print "Applied all ACLs to netscaler kernel." if args.action == "clear": NSAcls.clear(nitro) print "Cleared ACLs on the netscaler." if args.action == "renumber": NSAcls.renumber(nitro) print "Renumbered ACLs on the netscaler." if args.action == "delete": if not args.name: print("--name required for deletion") else: acl = NSAcl() acl.set_aclname(args.delacl) acl = NSAcl.delete(nitro, acl) print "ACL '%s' was deleted. Do not forget to run --applyacls to activate it." % ( args.name)
def action_acl(args, nitro): if args.action == "get": acl = NSAcl() acl.set_aclname(args.name) acl = NSAcl.get(nitro, acl) print "--- ACL: " + acl.get_aclname() + " ---" for k in sorted(acl.options.iterkeys(), key=lambda k: k): print "\t%s: %s" % (k, acl.options[k]) if args.action == "list": acls = NSAcl().get_all(nitro) print "-- Configured ACLs ---" for acl in sorted(acls, key=lambda k: k.get_aclname()): print "\t" + acl.get_aclname() if args.action == "apply": NSAcls.apply(nitro) print "Applied all ACLs to netscaler kernel." if args.action == "clear": NSAcls.clear(nitro) print "Cleared ACLs on the netscaler." if args.action == "renumber": NSAcls.renumber(nitro) print "Renumbered ACLs on the netscaler." if args.action == "delete": if not args.name: print("--name required for deletion") else: acl = NSAcl() acl.set_aclname(args.delacl) acl = NSAcl.delete(nitro, acl) print "ACL '%s' was deleted. Do not forget to run --applyacls to activate it." % (args.name)
for k in sorted(acl.options.iterkeys(), key=lambda k: k): print "\t%s: %s" % (k, acl.options[k]) nitro.logout() sys.exit(0) if args.getaclslist: acls = NSAcl().get_all(nitro) print "-- Configured ACLs ---" for acl in sorted(acls, key=lambda k: k.get_aclname()): print "\t" + acl.get_aclname() nitro.logout() sys.exit(0) if args.applyacls: NSAcls.apply(nitro) print "Applied all ACLs to netscaler kernel." nitro.logout() sys.exit(0) if args.clearacls: NSAcls.clear(nitro) print "Cleared ACLs on the netscaler." nitro.logout() sys.exit(0) if args.renumberacls: NSAcls.renumber(nitro) print "Renumbered ACLs on the netscaler." nitro.logout() sys.exit(0)