Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Samir
bind-dnssec
Commits
c28a4f3c
Commit
c28a4f3c
authored
Mar 14, 2016
by
Valentin Samir
Browse files
User argparse for arguments
parent
946a04ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
routine.py
View file @
c28a4f3c
...
...
@@ -4,7 +4,7 @@ import os
import
sys
import
datetime
import
subprocess
import
argparse
from
functools
import
total_ordering
BASE
=
"/etc/bind/keys"
...
...
@@ -258,23 +258,29 @@ class Key(object):
if
__name__
==
'__main__'
:
try
:
zones
=
[]
for
arg
in
sys
.
argv
[
1
:]:
if
not
arg
.
startswith
(
'-'
):
zones
.
append
(
arg
)
if
'-m'
in
sys
.
argv
and
zones
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'zone'
,
nargs
=
'*'
,
help
=
'zone name'
)
parser
.
add_argument
(
'--make'
,
'-m'
,
action
=
'store_true'
,
help
=
'Create keys for each supplied zone'
)
parser
.
add_argument
(
'--cron'
,
'-c'
,
action
=
'store_true'
,
help
=
'Perform maintenance for each supplied zone or for all zones if no zone supplied'
)
parser
.
add_argument
(
'-ds'
,
action
=
'store_true'
,
help
=
'Show DS for each supplied zone or for all zones if no zone supplied'
)
parser
.
add_argument
(
'-key'
,
action
=
'store_true'
,
help
=
'Show DNSKEY for each zone supplied zone or for all zones if no zone supplied'
)
args
=
parser
.
parse_args
()
zones
=
args
.
zone
if
args
.
make
:
for
zone
in
zones
:
Zone
.
create
(
zone
)
zones
=
get_zones
(
zones
if
zones
else
None
)
if
'-c'
in
sys
.
argv
:
if
args
.
cron
:
for
zone
in
zones
:
zone
.
do_zsk
()
if
'-ds'
in
sys
.
argv
:
if
args
.
ds
:
for
zone
in
zones
:
zone
.
ds
()
if
'-key'
in
sys
.
argv
:
if
args
.
key
:
for
zone
in
zones
:
zone
.
key
()
if
not
any
([
args
.
make
,
args
.
cron
,
args
.
ds
,
args
.
key
]):
parser
.
print_help
()
except
ValueError
as
error
:
sys
.
stderr
.
write
(
"%s
\n
"
%
error
)
sys
.
exit
(
1
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment