| 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() |
| 111 | path = None |
| 112 | for host in dhcp_host.splitlines(): |
| 113 | if host.find(ip) != -1: |
| 114 | path = host.split("=")[0].strip() |
| 115 | |
| 116 | if path == None: |
| 117 | print("Can't find " + str(ip) + " in conf file") |
| 118 | return None |
| 119 | |
| 120 | print(path) |
| 121 | script = """rm %s |
| 122 | save"""%(path) |
| 123 | augtool < script |
| 124 | |
| 125 | self.availIP.remove(ip) |
| 126 | |
| 127 | #reset dnsmasq |
| 128 | service("dnsmasq", "restart", stdout=None, stderr=None) |
| 129 | |
| 130 | class ipallocator: |
| 131 | def GET(self): |