Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
                if args.renameserver:
                        server = NSServer()
                        server.set_name(args.renameserver[0])
                        server.set_newname(args.renameserver[1])
                        NSServer.rename(nitro, server)
                        print "Renamed server from '%s' to '%s'." % (args.renameserver[0], args.renameserver[1])
                        nitro.logout()
                        sys.exit(0)

                if args.getacl:
                        acl = NSAcl()
                        acl.set_aclname(args.getacl)
                        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])

                        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: