Commit 5c596e0b authored by Sigmund Augdal's avatar Sigmund Augdal

Added a utility script to edit a record in our powerdns setup

parent 1d470182
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
import sys
from nova_router import dns_rr
from configparser import SafeConfigParser # pylint: disable=F0401
except ImportError:
from ConfigParser import SafeConfigParser # pylint: disable=F0401
DESCRIPTION = "Update DNS record"
def parse_args():
parser = argparse.ArgumentParser(description=DESCRIPTION)
parser.add_argument('--config', default="nova.cfg",
help="Config file to use")
parser.add_argument('name', help="name of record to remove")
parser.add_argument('id', help="id of record to remove")
parser.add_argument('content', help="Record content")
return parser.parse_args()
def main(args):
conf = SafeConfigParser()
dns = dns_rr.client_from_conf(conf)
records = dns.get_records()
for record in records:
if record['name'] == and int(record['id']) == int(
record['content'] = args.content
print("Record updated")
print("No record found matching name and id")
if __name__ == '__main__':
args = parse_args()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment