| 96 | self.availIP.remove(allocatedIP) |
| 97 | |
| 98 | def allocateIP(self, mac): |
| 99 | newIP = self.getFreeIP() |
| 100 | dhcp_host = augtool.match("/files/etc/dnsmasq.conf/dhcp-host").stdout.decode('utf-8').strip() |
| 101 | cnt = len(dhcp_host.splitlines()) + 1 |
| 102 | script = """set %s %s |
| 103 | save"""%("/files/etc/dnsmasq.conf/dhcp-host[" + str(cnt) + "]", str(mac) + "," + newIP) |
| 104 | augtool < script |
| 105 | #reset dnsmasq |
| 106 | service("dnsmasq", "restart", stdout=None, stderr=None) |
| 107 | return newIP |
| 108 | |
| 109 | def releaseIP(self, ip): |
| 110 | dhcp_host = augtool.match("/files/etc/dnsmasq.conf/dhcp-host").stdout.decode('utf-8').strip() |