Skip to content

Commit

Permalink
DNS: add -all to cmdeploy dns
Browse files Browse the repository at this point in the history
  • Loading branch information
missytake committed Dec 17, 2024
1 parent 16fa253 commit 637bc58
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 7 additions & 1 deletion cmdeploy/src/cmdeploy/cmdeploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ def dns_cmd_options(parser):
default=None,
help="write out a zonefile",
)
parser.add_argument(
"--all",
dest="all",
action="store_true",
help="check both required and recommended DNS records"
)


def dns_cmd(args, out):
Expand All @@ -131,7 +137,7 @@ def dns_cmd(args, out):
return 0

retcode = dns.check_full_zone(
sshexec, remote_data=remote_data, zonefile=zonefile, out=out
sshexec, remote_data=remote_data, zonefile=zonefile, out=out, all=args.all
)
return retcode

Expand Down
14 changes: 8 additions & 6 deletions cmdeploy/src/cmdeploy/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_filled_zone_file(remote_data):
return zonefile


def check_full_zone(sshexec, remote_data, out, zonefile) -> int:
def check_full_zone(sshexec, remote_data, out, zonefile, all) -> int:
"""Check existing DNS records, optionally write them to zone file
and return (exitcode, remote_data) tuple."""

Expand All @@ -49,16 +49,18 @@ def check_full_zone(sshexec, remote_data, out, zonefile) -> int:
kwargs=dict(zonefile=zonefile, mail_domain=remote_data["mail_domain"]),
)

returncode = 0
if required_diff:
out.red("Please set required DNS entries at your DNS provider:\n")
for line in required_diff:
out(line)
return 1
elif recommended_diff:
print()
returncode += 1
if recommended_diff and (all or not required_diff):
out("WARNING: these recommended DNS entries are not set:\n")
for line in recommended_diff:
out(line)
return 0

out.green("Great! All your DNS entries are verified and correct.")
return 0
if not (recommended_diff or required_diff):
out.green("Great! All your DNS entries are verified and correct.")
return returncode

0 comments on commit 637bc58

Please sign in to comment.