-
Notifications
You must be signed in to change notification settings - Fork 681
/
Copy pathdns.py
30 lines (23 loc) · 824 Bytes
/
dns.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import click
import utilities_common.cli as clicommon
from natsort import natsorted
from tabulate import tabulate
from swsscommon.swsscommon import ConfigDBConnector
from utilities_common.cli import pass_db
# 'dns' group ("show dns ...")
@click.group(cls=clicommon.AliasedGroup)
@click.pass_context
def dns(ctx):
"""Show details of the static DNS configuration """
config_db = ConfigDBConnector()
config_db.connect()
ctx.obj = {'db': config_db}
# 'nameserver' subcommand ("show dns nameserver")
@dns.command()
@click.pass_context
def nameserver(ctx):
""" Show static DNS configuration """
header = ["Nameserver"]
db = ctx.obj['db']
nameservers = db.get_table('DNS_NAMESERVER')
click.echo(tabulate([(ns,) for ns in nameservers.keys()], header, tablefmt='simple', stralign='right'))