예제 #1
0
    def run_down(self, args):
        log.debug('args = %s' % str(args))

        try:
            iflist = args.iflist
            log.debug('creating ifupdown object ..')
            ifupdown_handle = ifupdownMain(
                daemon=self.daemon,
                args=args,
                config=configmap_g,
                force=args.force,
                withdepends=args.withdepends,
                perfmode=args.perfmode,
                dryrun=args.noact,
                addons_enable=not args.noaddons,
                statemanager_enable=not args.noaddons,
                interfacesfile=self.interfaces_filename,
                interfacesfileiobuf=self.interfaces_file_iobuf,
                interfacesfileformat=args.interfacesfileformat)

            ifupdown_handle.down(['pre-down', 'down', 'post-down'],
                                 args.all,
                                 args.CLASS,
                                 iflist,
                                 excludepats=args.excludepats,
                                 printdependency=args.printdependency,
                                 usecurrentconfig=args.usecurrentconfig,
                                 type=args.type)
        except:
            raise
예제 #2
0
    def run_query(self, args):
        log.debug('args = %s' % str(args))

        try:
            iflist = args.iflist
            if args.checkcurr:
                qop = 'query-checkcurr'
            elif args.running:
                qop = 'query-running'
            elif args.raw:
                qop = 'query-raw'
            elif args.syntaxhelp:
                qop = 'query-syntax'
            elif args.printdependency:
                qop = 'query-dependency'
            elif args.printsavedstate:
                qop = 'query-savedstate'
            else:
                qop = 'query'
            cachearg = (False if
                        (iflist or args.nocache or args.syntaxhelp or
                         (qop != 'query-checkcurr' and qop != 'query-running'))
                        else True)
            if not iflist and qop == 'query-running':
                iflist = [
                    i for i in os.listdir('/sys/class/net/')
                    if os.path.isdir('/sys/class/net/%s' % i)
                ]
            log.debug('creating ifupdown object ..')
            ifupdown_handle = ifupdownMain(
                daemon=self.daemon,
                args=args,
                config=configmap_g,
                withdepends=args.withdepends,
                perfmode=args.perfmode,
                cache=cachearg,
                interfacesfile=self.interfaces_filename,
                interfacesfileiobuf=self.interfaces_file_iobuf,
                interfacesfileformat=args.interfacesfileformat,
                withdefaults=args.withdefaults)
            # list implies all auto interfaces (this is how ifupdown behaves)
            if args.list:
                args.all = True
            ifupdown_handle.query([qop],
                                  args.all,
                                  args.list,
                                  args.CLASS,
                                  iflist,
                                  excludepats=args.excludepats,
                                  printdependency=args.printdependency,
                                  format=args.format,
                                  type=args.type)
        except:
            raise
예제 #3
0
    def run_up(self, args):
        log.debug('args = %s' % str(args))

        try:
            iflist = args.iflist
            if len(args.iflist) == 0:
                iflist = None
            log.debug('creating ifupdown object ..')
            cachearg = (False if
                        (iflist or args.nocache or args.noact) else True)
            ifupdown_handle = ifupdownMain(
                daemon=self.daemon,
                args=args,
                config=configmap_g,
                force=args.force,
                withdepends=args.withdepends,
                perfmode=args.perfmode,
                dryrun=args.noact,
                cache=cachearg,
                addons_enable=not args.noaddons,
                statemanager_enable=not args.noaddons,
                interfacesfile=self.interfaces_filename,
                interfacesfileiobuf=self.interfaces_file_iobuf,
                interfacesfileformat=args.interfacesfileformat)
            if args.noaddons:
                ifupdown_handle.up(['up'],
                                   args.all,
                                   args.CLASS,
                                   iflist,
                                   excludepats=args.excludepats,
                                   printdependency=args.printdependency,
                                   syntaxcheck=args.syntaxcheck,
                                   type=args.type,
                                   skipupperifaces=args.skipupperifaces)
            else:
                ifupdown_handle.up(['pre-up', 'up', 'post-up'],
                                   args.all,
                                   args.CLASS,
                                   iflist,
                                   excludepats=args.excludepats,
                                   printdependency=args.printdependency,
                                   syntaxcheck=args.syntaxcheck,
                                   type=args.type,
                                   skipupperifaces=args.skipupperifaces)
        except:
            raise
예제 #4
0
파일: main.py 프로젝트: anlaneg/ifupdown2
    def run_reload(self, args):
        log.debug('args = %s' % str(args))

        try:
            log.debug('creating ifupdown object ..')
            ifupdown_handle = ifupdownMain(daemon=self.daemon,
                                                                 config=configmap_g,
                                                                 interfacesfile=self.interfaces_filename,
                                                                 withdepends=args.withdepends,
                                                                 perfmode=args.perfmode,
                                                                 dryrun=args.noact)
            ifupdown_handle.reload(['pre-up', 'up', 'post-up'],
                                   ['pre-down', 'down', 'post-down'],
                                   auto=args.all, allow=args.CLASS, ifacenames=None,
                                   excludepats=args.excludepats,
                                   usecurrentconfig=args.usecurrentconfig,
                                   syntaxcheck=args.syntaxcheck,
                                   currentlyup=args.currentlyup)
        except:
            raise