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

Method GET

python/incubation/cloud-web-ipallocator.py:131–156  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

129
130class ipallocator:
131 def GET(self):
132 try:
133 user_data = web.input()
134 command = user_data.command
135 print("Processing: " + command)
136
137 dhcpInit = dhcp.getInstance()
138
139 if command == "getIpAddr":
140 mac = user_data.mac
141 zone_id = user_data.dc
142 pod_id = user_data.pod
143 print(mac, zone_id, pod_id)
144 freeIP = dhcpInit.allocateIP(mac)
145 if not freeIP:
146 return "0,0,0"
147 print("Find an available IP: " + freeIP)
148
149 return freeIP + "," + dhcpInit.getNetmask() + "," + dhcpInit.getRouter()
150 elif command == "releaseIpAddr":
151 ip = user_data.ip
152 zone_id = user_data.dc
153 pod_id = user_data.pod
154 dhcpInit.releaseIP(ip)
155 except:
156 return None
157
158if __name__ == "__main__":
159 app.run()

Callers

nothing calls this directly

Calls 5

getInstanceMethod · 0.65
allocateIPMethod · 0.65
getNetmaskMethod · 0.65
getRouterMethod · 0.45
releaseIPMethod · 0.45

Tested by

no test coverage detected