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

Method releaseIP

python/incubation/cloud-web-ipallocator.py:109–128  ·  view source on GitHub ↗
(self, ip)

Source from the content-addressed store, hash-verified

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
130class ipallocator:
131 def GET(self):

Callers 1

GETMethod · 0.45

Calls 5

findMethod · 0.65
removeMethod · 0.65
serviceFunction · 0.50
decodeMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected