Skip to content

Commit a09187a

Browse files
committed
add "address_for()" method
1 parent 1185bcc commit a09187a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ip_pool/ip_pool.py

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ def new_address(self, hostname: str):
5050
self._save()
5151
return addr
5252

53+
def address_for(self, hostname: str) -> IPv4Address:
54+
try:
55+
addr = self._hostnames[hostname]
56+
except KeyError:
57+
raise IPAddressPoolException(f"No address for hostname {hostname}")
58+
return addr
59+
5360
def release_address(self, hostname):
5461
addr = self._hostnames.pop(hostname)
5562
self._ipaddr_pool.append(addr)

0 commit comments

Comments
 (0)