<gh_stars>10-100
#!/usr/bin/python

import sys
import os
try:
    import json
except:
    from django.utils import simplejson as json
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.base'

from django.test.client import Client

def main():
    client = Client()
    reverse_dns_zones = []
    reverse_dns_zones = json.loads(client.get('/api/v2/reverse_dns/1/get_reverse_dns_zones/').content)
    output_dir = "/etc/dnsconfig-autodeploy";
    for dns_zone in reverse_dns_zones:
        dir = dns_zone.split("-")[0]
        output_file = '-'.join(dns_zone.split("-")[1:])
        final_destination_file = "%s/%s/%s" % (output_dir,dir, output_file)
        output_text = client.get('/api/v2/reverse_dns/%s/view_hosts/' % dns_zone).content
        output_text = output_text[1:-1]
        #f = open(final_destination_file,"w")
        output_text =  output_text.replace("\\n","\n")
        output_text =  output_text.replace('\\"','"')
        #print output_text
        #f.write(output_text)
        #f.close()
    #if len(reverse_dns_zones) > 0:
    #    os.chdir(output_dir)
    #    os.system('/usr/bin/svn update')
    #    os.system('/usr/bin/svn add * --force')
    #    os.system('/usr/bin/svn commit -m "Autogenerated addition from inventory"')
    #os.system('/usr/bin/git push origin master')


if __name__ == '__main__':
    main()

#!/usr/bin/python

import sys
import os
try:
    import json
except:
    from django.utils import simplejson as json
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.base'

from django.test.client import Client

def main():
    client = Client()
    reverse_dns_zones = []
    reverse_dns_zones = json.loads(client.get('/api/v2/reverse_dns/1/get_reverse_dns_zones/').content)
    output_dir = "/etc/dnsconfig-autodeploy";
    for dns_zone in reverse_dns_zones:
        dir = dns_zone.split("-")[0]
        output_file = '-'.join(dns_zone.split("-")[1:])
        final_destination_file = "%s/%s/%s" % (output_dir,dir, output_file)
        output_text = client.get('/api/v2/reverse_dns/%s/view_hosts/' % dns_zone).content
        output_text = output_text[1:-1]
        #f = open(final_destination_file,"w")
        output_text =  output_text.replace("\\n","\n")
        output_text =  output_text.replace('\\"','"')
        #print output_text
        #f.write(output_text)
        #f.close()
    #if len(reverse_dns_zones) > 0:
    #    os.chdir(output_dir)
    #    os.system('/usr/bin/svn update')
    #    os.system('/usr/bin/svn add * --force')
    #    os.system('/usr/bin/svn commit -m "Autogenerated addition from inventory"')
    #os.system('/usr/bin/git push origin master')


if __name__ == '__main__':
    main()
#!/usr/bin/python #f = open(final_destination_file,"w") #print output_text #f.write(output_text) #f.close() #if len(reverse_dns_zones) > 0: #    os.chdir(output_dir) #    os.system('/usr/bin/svn update') #    os.system('/usr/bin/svn add * --force') #    os.system('/usr/bin/svn commit -m "Autogenerated addition from inventory"') #os.system('/usr/bin/git push origin master')