Changeset 773

Show
Ignore:
Timestamp:
09/04/08 12:49:15 (3 months ago)
Author:
free
Message:

Added _Hosts class

Location:
ares/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • ares/trunk/ares.py

    r771 r773  
    5353        self.hostname = _Hostname(self) 
    5454        self.dnsmasq  = _Dnsmasq(self) 
     55        self.hosts    = _Hosts(self) 
    5556 
    5657if __name__ == '__main__': 
     
    254255                aug.move(key, cfg + '/conf-dir') 
    255256        aug.set(cfg + '/conf-dir', '/etc/dnsmasq.d') 
     257 
     258# 
     259# Hosts 
     260# 
     261class _Hosts: 
     262 
     263    def __init__(self, ares): 
     264        self._ares = ares 
     265        self._cfg  = '/files/etc/hosts' 
     266 
     267    def setup(self): 
     268        cfg = self._cfg 
     269        aug = self._ares.aug 
     270        ip  = '.'.join(self._ares.net.split('.')[0:3]) + '.1' 
     271        key = cfg + '/1000' 
     272        for k in aug.match(cfg + '/*/ipaddr'): 
     273            if aug.get(k) == ip: 
     274                key = k.rstrip('/ipaddr') 
     275        aug.set(key + '/ipaddr', ip) 
     276        aug.set(key + '/canonical', 'ares') 
  • ares/trunk/tests/TestAres.py

    r771 r773  
    1919        ares.hostname.setup() 
    2020        ares.dnsmasq.setup() 
     21        ares.hosts.setup() 
    2122        ares.aug.save() 
    2223