예제 #1
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
 def _restartWhichNotReloaded(reload_result):
     for result in reload_result:
         if result:
             UInterface.informUser(result)
         else:
             process_name = result.value
             Zorpctl.restart([process_name])
예제 #2
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
 def restart(listofinstances):
     """
     Restarts Zorp instance(s) by instance name
     expects sequence of name(s)
     """
     UInterface.informUser("Restarting Zorp Firewall Suite:")
     Zorpctl.stop(listofinstances)
     Zorpctl.start(listofinstances)
예제 #3
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def log(listofinstances):
        """
        Displays log level of Zorp instance(s) by instance name
        expects sequence of name(s)
        """

        if not listofinstances:
            UInterface.informUser(ZorpHandler.getlog())
        else:
            algorithm = LogLevelAlgorithm()
            Zorpctl.runAlgorithmOnList(listofinstances, algorithm)
예제 #4
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def reload(listofinstances):
        """
        Reloads Zorp instance(s) by instance name
        expects sequence of name(s)
        """
        UInterface.informUser("Reloading Zorp Firewall Suite:")

        if not listofinstances:
            UInterface.informUser(ZorpHandler.reload())
        else:
            algorithm = ReloadAlgorithm()
            Zorpctl.runAlgorithmOnList(listofinstances, algorithm)
예제 #5
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def stop(listofinstances):
        """
        Stops Zorp instance(s) by instance name
        expects sequence of name(s)
        """
        UInterface.informUser("Stopping Zorp Firewall Suite:")

        if not listofinstances:
            UInterface.informUser(ZorpHandler.stop())
        else:
            algorithm = StopAlgorithm()
            Zorpctl.runAlgorithmOnList(listofinstances, algorithm)
예제 #6
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def declog(listofinstances):
        """
        Lowers log level of Zorp instance(s) by instance name
        expects sequence of name(s)
        """
        UInterface.informUser("Decreasing Zorp loglevel:")

        if not listofinstances:
            UInterface.informUser(ZorpHandler.declog())
        else:
            algorithm = LogLevelAlgorithm(LogLevelAlgorithm.DECREASE)
            Zorpctl.runAlgorithmOnList(listofinstances, algorithm)
예제 #7
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def inclog(listofinstances):
        """
        Raises log level of Zorp instance(s) by instance name
        expects sequence of name(s)
        """
        UInterface.informUser("Raising Zorp loglevel:")

        if not listofinstances:
            UInterface.informUser(ZorpHandler.inclog())
        else:
            algorithm = LogLevelAlgorithm(LogLevelAlgorithm.INCREMENT)
            Zorpctl.runAlgorithmOnList(listofinstances, algorithm)
예제 #8
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def coredump(listofinstances):
        """
        Instructs Zorp instance(s) to dump core by instance_name
        expects sequence of name(s)
        """

        UInterface.informUser("Creating Zorp core dumps:")
        if not listofinstances:
            UInterface.informUser(ZorpHandler.coredump())
        else:
            algorithm = CoredumpAlgorithm()
            Zorpctl.runAlgorithmOnList(listofinstances, algorithm)
예제 #9
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def force_start(listofinstances):
        """
        Starts Zorp instance(s) by instance name
        even if no-auto-start is set
        expects sequence of name(s)
        """
        UInterface.informUser("Starting Zorp Firewall Suite:")

        if not listofinstances:
            UInterface.informUser(ZorpHandler.force_start())
        else:
            algorithm = StartAlgorithm()
            algorithm.force
            Zorpctl.runAlgorithmOnList(listofinstances, algorithm)
예제 #10
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def status(params):
        """
        Displays status of Zorp instance(s) by instance name
        expects sequence of name(s)
        can display more detailed status with -v or --verbose option
        """
        s_parse = argparse.ArgumentParser(
             prog='zorpctl status',
             description="Displays status of the specified Zorp instance(s)." +
                  "For additional information use status -v or --verbose option")
        s_parse.add_argument('-v', '--verbose', action='store_true')
        s_parse.add_argument('listofinstances', nargs='*')
        s_args = s_parse.parse_args(params)

        if not s_args.listofinstances:
            UInterface.informUser(ZorpHandler.detailedStatus() if s_args.verbose else ZorpHandler.status())
        else:
            algorithm = DetailedStatusAlgorithm() if s_args.verbose else StatusAlgorithm()
            Zorpctl.runAlgorithmOnList(s_args.listofinstances, algorithm)
예제 #11
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def reload_or_restart(listofinstances):
        """
        Tries to reload Zorp instance(s) by instance name
        if not succeeded than tries to restart instance(s)
        expects sequence of name(s)
        """

        UInterface.informUser("Reloading or Restarting Zorp Firewall Suite:")
        if not listofinstances:
            reload_result = ZorpHandler.reload()
            Zorpctl._restartWhichNotReloaded(reload_result)
        else:
            for instance_name in listofinstances:
                reload_result = Zorpctl.runAlgorithmOnProcessOrInstance(instance_name, ReloadAlgorithm())
                if utils.isSequence(reload_result):
                    Zorpctl._restartWhichNotReloaded(reload_result)
                else:
                    if reload_result:
                        UInterface.informUser(reload_result)
                    else:
                        Zorpctl.restart([instance_name])
예제 #12
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def authorize(params):
        """
        Lists and manages authorizations of Zorp instance(s) by instance name
        expects sequence of name(s)
        """
        a_parse = argparse.ArgumentParser(
             prog='zorpctl authorize',
             description="Lists and manages authorizations")
        a_parse.add_argument('--accept', dest='value', action='store_true', default=None)
        a_parse.add_argument('--reject', dest='value', action='store_false', default=None)
        a_parse.add_argument('description')
        a_parse.add_argument('listofinstances', nargs=argparse.REMAINDER)
        a_args = a_parse.parse_args(params)
        if a_args.value == None:
            UInterface.informUser("usage: zorpctl authorize [-h] [--accept] [--reject] description ...\n" +
                                  "zorpctl authorize: either the '--accept' or '--reject' option has to be specified")
            return

        if not a_args.listofinstances:
            UInterface.informUser(ZorpHandler.authorize(a_args.value, a_args.description))
        else:
            manner = AuthorizeAlgorithm.ACCEPT if a_args.value else AuthorizeAlgorithm.REJECT
            algorithm = AuthorizeAlgorithm(manner, descriptioni)
            Zorpctl.runAlgorithmOnList(a_args.listofinstances, algorithm)
예제 #13
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def szig(params):
        sz_parser = argparse.ArgumentParser(
                        prog='zorpctl szig',
                        description="Display internal information from the given Zorp instance(s)")
        sz_parser.add_argument('-w', '--walk', help='Walk the specified tree', nargs='*')
        sz_parser.add_argument('-r', '--root', help='Set the root node of the walk operation', type=str)
        sz_args = sz_parser.parse_args(params)

        if not sz_args.walk:
            for result in ZorpHandler.szig_walk(sz_args.root):
                UInterface.informUser(json.dumps(result.value, indent=4) if result else result)
        else:
            algorithm = SzigWalkAlgorithm(sz_args.root)
            for instance in sz_args.walk:
                results = Zorpctl.runAlgorithmOnProcessOrInstance(instance, algorithm)
                if utils.isSequence(results):
                    for result in results:
                        UInterface.informUser(json.dumps(result.value, indent=4) if result else result)
                else:
                    UInterface.informUser(json.dumps(results.value, indent=4) if results else results)
예제 #14
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
    def deadlockcheck(params):
        d_parse = argparse.ArgumentParser(
             prog='zorpctl deadlockcheck',
             description="Change and query Zorp deadlock checking settings")
        d_parse.add_argument('-d', '--disable', dest='value', action='store_false', default=None)
        d_parse.add_argument('-e', '--enable', dest='value', action='store_true', default=None)
        d_parse.add_argument('listofinstances', nargs=argparse.REMAINDER)
        d_args = d_parse.parse_args(params)

        if d_args.value != None:
            UInterface.informUser("Changing Zorp deadlock checking settings:")
            if not d_args.listofinstances:
                UInterface.informUser(ZorpHandler.deadlockcheck(d_args.value))
            else:
                algorithm = DeadlockCheckAlgorithm(d_args.value)
                Zorpctl.runAlgorithmOnList(d_args.listofinstances, algorithm)
        else:
            if not d_args.listofinstances:
                UInterface.informUser(ZorpHandler.deadlockcheck())
            else:
                algorithm = DeadlockCheckAlgorithm()
                Zorpctl.runAlgorithmOnList(d_args.listofinstances, algorithm)
예제 #15
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
 def runAlgorithmOnList(listofinstances, algorithm):
     for instance in listofinstances:
         result = Zorpctl.runAlgorithmOnProcessOrInstance(instance, algorithm)
         UInterface.informUser(result)
예제 #16
0
파일: Zorpctl.py 프로젝트: kmarcell/zorp
            'start' : Zorpctl.start,
            'stop' : Zorpctl.stop,
            'restart' : Zorpctl.restart,
            'reload' : Zorpctl.reload,
            'force-start' : Zorpctl.force_start,
            'force-stop' : Zorpctl.force_stop,
            'force-restart' : Zorpctl.force_restart,
            'reload-or-restart' : Zorpctl.reload_or_restart,
            #'stop-session' : Zorpctl.stop_session,
            'coredump' : Zorpctl.coredump,
            'status' : Zorpctl.status,
            'authorize' : Zorpctl.authorize,
            #'gui-status' : Zorpctl.gui_status,
            'version' : Zorpctl.version,
            'inclog' : Zorpctl.inclog,
            'declog' : Zorpctl.declog,
            'log' : Zorpctl.log,
            'deadlockcheck' : Zorpctl.deadlockcheck,
            'szig' : Zorpctl.szig,
            }

parser.add_argument('command', choices=Commands.keys())
parser.add_argument('params', nargs=argparse.REMAINDER)
args = parser.parse_args()

command_function = Commands.get(args.command)
try:
    command_function(args.params)
except BaseException as e:
    UInterface.informUser(e.strerror)