Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bind-dnssec
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Valentin Samir
bind-dnssec
Commits
c28a4f3c
Commit
c28a4f3c
authored
Mar 14, 2016
by
Valentin Samir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User argparse for arguments
parent
946a04ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
routine.py
routine.py
+15
-9
No files found.
routine.py
View file @
c28a4f3c
...
@@ -4,7 +4,7 @@ import os
...
@@ -4,7 +4,7 @@ import os
import
sys
import
sys
import
datetime
import
datetime
import
subprocess
import
subprocess
import
argparse
from
functools
import
total_ordering
from
functools
import
total_ordering
BASE
=
"/etc/bind/keys"
BASE
=
"/etc/bind/keys"
...
@@ -258,23 +258,29 @@ class Key(object):
...
@@ -258,23 +258,29 @@ class Key(object):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
try
:
try
:
zones
=
[]
parser
=
argparse
.
ArgumentParser
()
for
arg
in
sys
.
argv
[
1
:]:
parser
.
add_argument
(
'zone'
,
nargs
=
'*'
,
help
=
'zone name'
)
if
not
arg
.
startswith
(
'-'
):
parser
.
add_argument
(
'--make'
,
'-m'
,
action
=
'store_true'
,
help
=
'Create keys for each supplied zone'
)
zones
.
append
(
arg
)
parser
.
add_argument
(
'--cron'
,
'-c'
,
action
=
'store_true'
,
help
=
'Perform maintenance for each supplied zone or for all zones if no zone supplied'
)
if
'-m'
in
sys
.
argv
and
zones
:
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
:
for
zone
in
zones
:
Zone
.
create
(
zone
)
Zone
.
create
(
zone
)
zones
=
get_zones
(
zones
if
zones
else
None
)
zones
=
get_zones
(
zones
if
zones
else
None
)
if
'-c'
in
sys
.
argv
:
if
args
.
cron
:
for
zone
in
zones
:
for
zone
in
zones
:
zone
.
do_zsk
()
zone
.
do_zsk
()
if
'-ds'
in
sys
.
argv
:
if
args
.
ds
:
for
zone
in
zones
:
for
zone
in
zones
:
zone
.
ds
()
zone
.
ds
()
if
'-key'
in
sys
.
argv
:
if
args
.
key
:
for
zone
in
zones
:
for
zone
in
zones
:
zone
.
key
()
zone
.
key
()
if
not
any
([
args
.
make
,
args
.
cron
,
args
.
ds
,
args
.
key
]):
parser
.
print_help
()
except
ValueError
as
error
:
except
ValueError
as
error
:
sys
.
stderr
.
write
(
"
%
s
\n
"
%
error
)
sys
.
stderr
.
write
(
"
%
s
\n
"
%
error
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
Write
Preview
Markdown
is supported
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