#!/usr/bin/python
+# PYTHON_ARGCOMPLETE_OK
import sys
import os
+import argcomplete
import argparse
from ifupdown.ifupdownmain import *
perfmode=args.perfmode,
njobs=args.jobs,
dryrun=args.noact,
- cache=cachearg)
+ cache=cachearg,
+ addons_enable=not args.noaddons,
+ statemanager_enable=not args.noaddons)
- ifupdown_handle.up(['pre-up', 'up', 'post-up'],
+ if args.noaddons:
+ ifupdown_handle.up(['up'], args.all, args.CLASS, iflist,
+ excludepats=args.excludepats,
+ printdependency=args.printdependency)
+ else:
+ ifupdown_handle.up(['pre-up', 'up', 'post-up'],
args.all, args.CLASS, iflist,
excludepats=args.excludepats,
printdependency=args.printdependency)
perfmode=args.perfmode,
njobs=args.jobs,
dryrun=args.noact,
- cache=cachearg)
+ cache=cachearg,
+ addons_enable=not args.noaddons,
+ statemanager_enable=not args.noaddons)
ifupdown_handle.down(['pre-down', 'down', 'post-down'],
args.all, args.CLASS, iflist,
excludepats=args.excludepats,
- printdependency=args.printdependency)
+ printdependency=args.printdependency,
+ usecurrentconfig=args.usecurrentconfig)
except:
raise
if args.checkcurr:
qop='query-checkcurr'
elif args.running:
- if not iflist:
- iflist = [i for i in os.listdir('/sys/class/net/')
- if os.path.isdir('/sys/class/net/%s' %i)]
qop='query-running'
elif args.raw:
qop='query-raw'
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.perfmode 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)]
logger.debug('creating ifupdown object ..')
ifupdown_handle = ifupdownMain(withdepends=args.withdepends,
perfmode=args.perfmode,
except:
raise
-
def run_reload(args):
logger.debug('args = %s' %str(args))
perfmode=args.perfmode,
njobs=args.jobs,
cache=cachearg)
- ifupdown_handle.reload(args.all, None, None,
+ ifupdown_handle.reload(['pre-up', 'up', 'post-up'],
+ ['pre-down', 'down', 'post-down'],
+ args.all, None, None,
excludepats=args.excludepats,
downchangediface=args.downchangediface)
except:
argparser.add_argument('-f', '--force', dest='force',
action='store_true',
help='force run all operations')
- argparser.add_argument('-n', '--no-act', dest='noact',
+ group = argparser.add_mutually_exclusive_group(required=False)
+ group.add_argument('-n', '--no-act', dest='noact',
action='store_true', help='print out what would happen,' +
'but don\'t do it')
- argparser.add_argument('--print-dependency',
+ group.add_argument('--print-dependency',
dest='printdependency', choices=['list', 'dot'],
help='print iface dependency')
+ group.add_argument('--no-scripts', '--no-addons',
+ dest='noaddons', action='store_true',
+ help='dont run any addon modules or scripts. Runs only link ' +
+ 'up/down')
def update_ifup_argparser(argparser):
update_ifupdown_argparser(argparser)
def update_ifdown_argparser(argparser):
update_ifupdown_argparser(argparser)
+ argparser.add_argument('--use-current-config',
+ dest='usecurrentconfig', action='store_true',
+ help=argparse.SUPPRESS)
+ #help='By default ifdown looks at the saved state for ' +
+ #'interfaces to bring down. This option allows ifdown to ' +
+ #'look at the current interfaces file. Useful when your ' +
+ #'state file is corrupted or you want down to use the latest '
+ #'from the interfaces file')
def update_ifquery_argparser(argparser):
""" arg parser for ifquery options """
'running state of an interface')
group.add_argument('--raw', action='store_true', dest='raw',
help='print raw config file entries')
+ group.add_argument('--print-savedstate', action='store_true',
+ dest='printsavedstate',
+ help=argparse.SUPPRESS)
argparser.add_argument('--format', dest='format', default='native',
choices=['native', 'json'], help=argparse.SUPPRESS)
argparser.add_argument('--print-dependency',
update_ifquery_argparser(argparser)
elif op == 'reload':
update_ifreload_argparser(argparser)
+
+ argcomplete.autocomplete(argparser)
+
return argparser.parse_args(argsv)
handlers = {'up' : run_up,