We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b892409 commit 188d126Copy full SHA for 188d126
ip_pool/ip_pool.py
@@ -39,6 +39,17 @@ def initialize(self, ipv4_cidr_address: str):
39
self._prefix_len = prefix_len
40
self._save()
41
42
+ def new_address(self, hostname: str):
43
+ if hostname in self._hostnames:
44
+ raise IPAddressPoolException(f"Hostname {hostname}")
45
+ try:
46
+ addr = self._ipaddr_pool.pop(0)
47
+ except IndexError:
48
+ raise IPAddressPoolException("Uninitialized address pool")
49
+ self._hostnames[hostname] = addr
50
+ self._save()
51
+ return addr
52
+
53
def _to_dict(self):
54
_dict = {
55
"ip_version": self._ip_version,
0 commit comments