MCPcopy Create free account
hub / github.com/apache/cloudstack / allocateIP

Method allocateIP

python/incubation/cloud-web-ipallocator.py:98–107  ·  view source on GitHub ↗
(self, mac)

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls 4

getFreeIPMethod · 0.95
serviceFunction · 0.50
decodeMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected