Package: python-powerdns
python-powerdns -- PowerDNS web api python client and interfaceContact:Denis 'jawa' Pompiliodenis.pompilio@gmail.comSources:https://github.com/outini/python-powerdnsAboutThis package provides intuitive and easy to use python client and interface
for the PowerDNS web API.Installationpythonsetup.pyinstallorpipinstallpython-powerdnsHelperspdns-zone-creatorusage:pdns-create-zone[-h]-AAPI-KAPIKEY-zZONE-oORIGIN-cZONE-dDNS[-tTIMERS]PowerDNSzonecreator

optionalarguments:-h,--helpshowthishelpmessageandexit-AAPI,--apiAPIPowerDNSapi(eg.https://api.domain.tld/api/v1-KAPIKEY,--keyAPIKEYPowerDNSapikey-zZONE,--zoneZONEZonename(canonical)-oORIGIN,--originORIGINZoneorigin(forSOA)-cZONE,--contactZONEZonecontact(forSOA)-dDNS,--dnsDNSZonenameserverscommaseparated-tTIMERS,--timersTIMERSZonetimers(eg.'28800 7200 604800 86400')./bin/pdns-create-zone-A"https://api.domain.tld/api/v1"-K"xxxxxxxxx"\-z"myzone.domain.tld."\-o"ns01.domain.tld."-c"admin.domain.tld."\-d"nsd01.domain.tld.,nsd02.domain.tld."powerdns.interfaceINFO:listingavailablePowerDNSservers
powerdns.interfaceINFO:gettingavailableserversfromAPI
powerdns.clientINFO:request:GEThttps://api.domain.tld/api/v1/servers
powerdns.clientINFO:requestresponsecode:200powerdns.interfaceINFO:1server(s)listed
powerdns.interfaceINFO:creationofzone:myzone.domain.tld.
powerdns.clientINFO:request:POSThttps://api.domain.tld/api/v1/servers/localhost/zones
powerdns.clientINFO:requestresponsecode:201powerdns.interfaceINFO:zonemyzone.domain.tld.successfullycreatedExamplesBasic initializationimportpowerdnsPDNS_API="https://my.pdns.api.domain.tld/api/v1"PDNS_KEY="mysupersecretbase64key"api_client=powerdns.PDNSApiClient(api_endpoint=PDNS_API,api_key=PDNS_KEY)api=powerdns.PDNSEndpoint(api_client)Creation and deletion of zonesfromdatetimeimportdate# Creating new zone on first PowerDNS serverserial=date.today().strftime("%Y%m%d00")soa="ns0.domain.tld. admin.domain.tld.%s28800 7200 604800 86400"%serialsoa_r=powerdns.RRSet(name='test.python-powerdns.domain.tld.',rtype="SOA",records=[(soa,False)],ttl=86400)zone=api.servers[0].create_zone(name="test.python-powerdns.domain.tld.",kind="Native",rrsets=[soa_r],nameservers=["ns1.domain.tld.","ns2.domain.tld."])# Getting new zone infoprint(zone)print(zone.details)# Deleting newly created zoneapi.servers[0].delete_zone(zone.name)Creation and deletion of DNS recordszone=api.servers[0].get_zone("test.python-powerdns.domain.tld.")comments=[powerdns.Comment("test comment","admin")]zone.create_records([powerdns.RRSet('a','A',[('1.1.1.1',False)],comments=comments),powerdns.RRSet('b','A',['1.1.1.2','1.1.1.3']),powerdns.RRSet('c','A',[('1.1.1.4',False)]),powerdns.RRSet('d','CNAME',['a'])])zone.delete_records([powerdns.RRSet('a','A',[('1.1.1.1',False)]),powerdns.RRSet('d','CNAME',['a'])])Where (for the first RRSet):ais the NAME of the recordAis the TYPE of the record[('1.1.1.1', False)]is a list of RDATA entries (tuples or just strings), where:'1.1.1.1'is the RDATAFalsetells that this RDATA entry is NOT disabledBackup and restoration of zones# Backup every zone of every PowerDNS serverforserverinapi.servers:backup_dir="backups/%s"%server.idforzoneinserver.zones:zone.backup(backup_dir)# Restore a single zone on first PowerDNS serverzone_file="backups/pdns-server-01/my.domain.tld.json"api.servers[0].restore_zone(zone_file)TestsPowerDNS serviceA simpleDockerfileis provided to spawn a basic powerdns service for tests
purposes. The container is built using:dockerbuild--tagpdns.And started using:dockerrun--rm-itpdnsPython Unit-TestsPython unit-tests are available in thetestsdirectory. Based onunittests,
those are run usingcoverage run -m unittest discoveror integrated in your
IDE for development purposes. Those tests require a PDNS service to connect to
(seePowerDNS servicesection above).Those tests are very limited at the moment and will be improved in the future.LicenseMIT LICENSE(see LICENSE file)Miscellaneous╚⊙ ⊙╝
  ╚═(███)═╝
 ╚═(███)═╝
╚═(███)═╝
 ╚═(███)═╝
  ╚═(███)═╝
   ╚═(███)═╝