Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No TTL in host cname_show #151

Open
paalbra opened this issue Nov 2, 2021 · 1 comment
Open

No TTL in host cname_show #151

paalbra opened this issue Nov 2, 2021 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@paalbra
Copy link
Contributor

paalbra commented Nov 2, 2021

It is impossible to display the TTL of a CNAME, as far as I can tell... (?)

host info will display TTL of A-record.

host cname_show only display the target of the CNAME.

IMO host cname_show should display the TTL as well.

mreg-cli/mreg_cli/host.py

Lines 426 to 428 in 5e6bda6

def print_cname(cname: str, host: str, padding: int = 14) -> None:
"""Pretty print given cname"""
print("{1:<{0}}{2} -> {3}".format(padding, "Cname:", cname, host))

mreg-cli/mreg_cli/host.py

Lines 1386 to 1429 in 5e6bda6

################################################
# Implementation of sub command 'cname_show' #
################################################
def cname_show(args):
"""Show CNAME records for host. If <name> is an alias the cname hosts
aliases are shown.
"""
try:
info = host_info_by_name(args.name)
for cname in info["cnames"]:
print_cname(cname["name"], info["name"])
cli_info("showed cname aliases for {}".format(info["name"]))
return
except HostNotFoundWarning:
# Try again with the alias
pass
name = clean_hostname(args.name)
path = "/api/v1/hosts/"
params = {
"cnames__name": name,
}
history.record_get(path)
hosts = get_list(path, params=params)
if len(hosts):
print_cname(name, hosts[0]["name"])
else:
cli_warning("No cname found for {}".format(name))
# Add 'cname_show' as a sub command to the 'host' command
host.add_command(
prog='cname_show',
description='Show CNAME records for host. If NAME is an alias the cname '
'hosts aliases are shown.',
short_desc='Show CNAME records.',
callback=cname_show,
flags=[
Flag('name',
description='Name of the target host.',
metavar='NAME'),
],
)

PS.
You are able to set the TTL with host set_ttl <cname> <ttl>

@paalbra
Copy link
Contributor Author

paalbra commented Nov 2, 2021

Oh. Wait. host ttl_show does the trick.

But maybe display it through host cname_show as well?

@paalbra paalbra added enhancement New feature or request good first issue Good for newcomers labels Nov 3, 2021
@paalbra paalbra changed the title Unable to display TTL of CNAME No TTL in host cname_show Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant