Skip to content
Snippets Groups Projects

Ipam service

Merged JORGE SASIAIN requested to merge ipam-service into develop
3 unresolved threads
2 files
+ 26
11
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 9
4
@@ -147,6 +147,7 @@ def _allocate_network(
infoblox_params: settings.InfoBloxParams,
network_params: Union[settings.V4NetworkParams, settings.V6NetworkParams],
ip_version=4,
comment="",
extattrs={}
) -> Union[V4ServiceNetwork, V6ServiceNetwork]:
assert ip_version in [4, 6]
@@ -168,6 +169,7 @@ def _allocate_network(
},
"_result_field": "networks",
},
"comment": comment,
"extattrs": extattrs
}
@@ -203,7 +205,7 @@ def _allocate_network(
return V6ServiceNetwork(v6=allocated_network)
def allocate_service_ipv4_network(service_type, extattrs={}
def allocate_service_ipv4_network(service_type, comment="", extattrs={}
) -> V4ServiceNetwork:
"""
Allocate IPv4 network within the container of the specified service type.
@@ -216,10 +218,11 @@ def allocate_service_ipv4_network(service_type, extattrs={}
return _allocate_network(ipam_params.INFOBLOX,
getattr(ipam_params, service_type).V4,
4,
comment,
extattrs)
def allocate_service_ipv6_network(service_type, extattrs={}
def allocate_service_ipv6_network(service_type, comment="", extattrs={}
) -> V6ServiceNetwork:
"""
Allocate IPv6 network within the container of the specified service type.
@@ -232,6 +235,7 @@ def allocate_service_ipv6_network(service_type, extattrs={}
return _allocate_network(ipam_params.INFOBLOX,
getattr(ipam_params, service_type).V6,
6,
comment,
extattrs)
@@ -619,13 +623,14 @@ if __name__ == '__main__':
elif choice == '4':
service_type = input("Enter service type: ")
comment = input("Enter a comment for the network: ")
ip_version = int(input("Enter IP version (4 or 6): "))
if ip_version == 4:
new_network = allocate_service_ipv4_network(
service_type=service_type)
comment=comment, service_type=service_type)
elif ip_version == 6:
new_network = allocate_service_ipv6_network(
service_type=service_type)
comment=comment, service_type=service_type)
else:
print("Invalid IP version. Please enter either 4 or 6.")
continue
Loading