From: Frank Brehm Date: Wed, 8 Nov 2017 14:46:55 +0000 (+0100) Subject: Integrating RRSets X-Git-Tag: 0.1.2~101 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=889b27e86faa8aba0583c0cd6226cecac265e394;p=pixelpark%2Fadmin-tools.git Integrating RRSets --- diff --git a/pp_lib/pdns_zone.py b/pp_lib/pdns_zone.py index 69a739e..265dedc 100644 --- a/pp_lib/pdns_zone.py +++ b/pp_lib/pdns_zone.py @@ -21,8 +21,9 @@ from .common import pp, to_bytes, to_utf8 from .errors import PpError from .obj import PpBaseObjectError, PpBaseObject +from .pdns_record import PdnsApiRrset -__version__ = '0.3.1' +__version__ = '0.4.1' LOG = logging.getLogger(__name__) @@ -64,7 +65,7 @@ class PdnsApiZone(PpBaseObject): self._serial = serial self._url = url - self.records = [] + self.rrsets = [] self._soa_edit = soa_edit self._soa_edit_api = soa_edit_api @@ -91,8 +92,21 @@ class PdnsApiZone(PpBaseObject): if initialized is not None: params['initialized'] = initialized + rrsets = None + if 'rrsets' in data: + if data['rrsets']: + rrsets = data['rrsets'] + data['rrsets'] = None + params.update(data) zone = cls(**params) + + if rrsets: + for single_rrset in rrsets: + rrset = PdnsApiRrset.init_from_dict( + single_rrset, appname=appname, verbose=verbose, base_dir=base_dir) + zone.rrsets.append(rrset) + zone.initialized = True return zone @@ -230,11 +244,11 @@ class PdnsApiZone(PpBaseObject): @param short: don't include local properties in resulting dict. @type short: bool - + @return: structure as dict @rtype: dict """ - + res = super(PdnsApiZone, self).as_dict(short=short) res['account'] = self.account res['dnssec'] = copy.copy(self.dnssec) @@ -247,10 +261,16 @@ class PdnsApiZone(PpBaseObject): res['notified_serial'] = self.notified_serial res['serial'] = self.serial res['url'] = self.url - res['records'] = copy.copy(self.records) + res['rrsets'] = [] res['soa_edit'] = self.soa_edit res['soa_edit_api'] = self.soa_edit_api + for rrset in self.rrsets: + if isinstance(rrset, PpBaseObject): + res['rrsets'].append(rrset.as_dict(short)) + else: + res['rrsets'].append(rrset) + return res # ------------------------------------------------------------------------- @@ -318,4 +338,4 @@ if __name__ == "__main__": # ============================================================================= -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list