Merge "rax-dns-backup: fix parsing"
This commit is contained in:
commit
37ff268a74
@ -124,16 +124,20 @@ def do_bind_export(session, token, domain_id, outfile):
|
|||||||
query = {'showDetails': 'true'}
|
query = {'showDetails': 'true'}
|
||||||
final_response = session.get(callback_url, params=query, headers=headers)
|
final_response = session.get(callback_url, params=query, headers=headers)
|
||||||
|
|
||||||
bind_output = final_response.json()['response']['contents']
|
bind_output = final_response.json()['response']['contents'].split('\n')
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
for line in bind_output.split('\n'):
|
|
||||||
|
# Read and parse the record lines for sorting; the skip is because
|
||||||
|
# the first 3 lines are comments and the rest are SOA records
|
||||||
|
# (written separately below).
|
||||||
|
for line in bind_output[10:]:
|
||||||
if line == '':
|
if line == '':
|
||||||
continue
|
continue
|
||||||
fields = line.split(' ')
|
fields = line.split(' ')
|
||||||
output.append(fields)
|
output.append(fields)
|
||||||
|
|
||||||
# find padding space for the first column
|
# find padding space for the first column so everything lines up nice
|
||||||
max_first = max([len(x[0]) for x in output])
|
max_first = max([len(x[0]) for x in output])
|
||||||
|
|
||||||
# create a dict keyed by domain with each record
|
# create a dict keyed by domain with each record
|
||||||
@ -143,10 +147,10 @@ def do_bind_export(session, token, domain_id, outfile):
|
|||||||
|
|
||||||
outstr = ''
|
outstr = ''
|
||||||
|
|
||||||
# first output SOA then get rid of it
|
# first output comments and SOA from original
|
||||||
outstr += ("%-*s\t%s\n\n" %
|
for line in bind_output[:10]:
|
||||||
(max_first+1, '@', '\t'.join(out_dict['@'][0]) ))
|
outstr += "%s\n" % line
|
||||||
del(out_dict['@'])
|
outstr += '\n'
|
||||||
|
|
||||||
# print out the rest of the entries, with individual records
|
# print out the rest of the entries, with individual records
|
||||||
# sorted and grouped
|
# sorted and grouped
|
||||||
|
Loading…
x
Reference in New Issue
Block a user