Changeset 1437


Ignore:
Timestamp:
May 9, 2016, 12:53:52 PM (3 years ago)
Author:
kbut
Message:

add function to redirect web services to master server

Location:
n4d-dnsmasq/trunk/fuentes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • n4d-dnsmasq/trunk/fuentes/debian/changelog

    r797 r1437  
     1n4d-dnsmasq (1.52.3) xenial; urgency=high
     2
     3  * Add function to redirect web services to master server
     4
     5 -- Raul Rodrigo Segura <raurodse@gmail.com>  Mon, 09 May 2016 12:51:46 +0200
     6
    17n4d-dnsmasq (1.52.2) xenial; urgency=high
    28
  • n4d-dnsmasq/trunk/fuentes/install-dnsmasq/etc/n4d/conf.d/DnsmasqManager

    r196 r1437  
    1818add_alias=adm,admins
    1919remove_alias=adm,admins
     20set_dns_master_services=adm,admins
     21set_dns_entry=adm,admins
  • n4d-dnsmasq/trunk/fuentes/install-dnsmasq/usr/share/n4d/python-plugins/DnsmasqManager.py

    r196 r1437  
    1515                #Load template file
    1616                self.tpl_env = Environment(loader=FileSystemLoader('/usr/share/n4d/templates/dnsmasq'))
    17                 self.dnsfile = "/var/lib/dnsmasq/hosts/reg" # Format file =====> HOSTIP {HOST_PREFIX}NUMBER_PC_REGISTERED{INTERNAL_DOMAIN}
    18                 self.pathfile = "/var/lib/dnsmasq/macs/all-hosts" # Format file ======> dhcp-host=MAC_PC,HOSTIP,{HOST_PREFIX}NUMBER_PC_REGISTERED{INTERNAL_DOMAIN}
     17                self.dynamicconfpath = "/var/lib/dnsmasq/"
     18                self.dnsfile = self.dynamicconfpath+"hosts/reg" # Format file =====> HOSTIP {HOST_PREFIX}NUMBER_PC_REGISTERED{INTERNAL_DOMAIN}
     19                self.pathfile = self.dynamicconfpath+"macs/all-hosts" # Format file ======> dhcp-host=MAC_PC,HOSTIP,{HOST_PREFIX}NUMBER_PC_REGISTERED{INTERNAL_DOMAIN}
    1920                self.locktocken = "/tmp/lockmacregister"
    2021                self.leases = "/var/lib/misc/dnsmasq.leases"
    2122                self.backup_files=["/etc/dnsmasq.conf"]
    22                 self.backup_dirs=["/var/lib/dnsmasq/","/etc/dnsmasq.d/"]
     23                self.backup_dirs=[self.dynamicconfpath,"/etc/dnsmasq.d/"]
    2324               
    2425        #def init
     
    439440                return {'status':True,'msg':'Service configured'}
    440441        #def load_exports
     442       
     443        def set_dns_master_services(self):
     444
     445                ip = '10.3.0.254'
     446                listservices = []
     447                listnames = objects['VariablesManager'].get_variable('SLAVE_BLACKLIST')#{'':['']}
     448                allok = True
     449                msg=[]
     450
     451                for x in listnames.keys():
     452                        listservices.extend(listnames[x])
     453
     454                for service in listservices:
     455                        result = self.set_dns_entry(service,ip)
     456                        if not result['status']:
     457                                allok = False
     458                                msg.append(result['msg'])
     459                return {'status':allok,'msg':msg}
     460
     461        #def set_dns_master_services
     462
     463        def set_dns_entry(self,name,ip):
     464                try:
     465                        f = open(self.dynamicconfpath+'hosts/'+name,'w')
     466                        f.write(ip + ' '+ name)
     467                        f.close()
     468                        return {'status':True,'msg':e}
     469                except Exception as e:
     470                        return {'status':False,'msg':e}
     471
     472        #def set_dns_entry
    441473
    442474        def reboot_dhcpd(self):
Note: See TracChangeset for help on using the changeset viewer.