import ipaddress from pydantic import BaseSettings from gso import settings import _ipam class V4ServiceNetwork(BaseSettings): v4: ipaddress.IPv4Network class V6ServiceNetwork(BaseSettings): v6: ipaddress.IPv6Network class ServiceNetworks(BaseSettings): v4: V4ServiceNetwork v6: V6ServiceNetwork class V4HostAddress(BaseSettings): v4: ipaddress.IPv4Address class V6HostAddress(BaseSettings): v6: ipaddress.IPv6Address class HostAddresses(BaseSettings): v4: V4HostAddress v6: V6HostAddress def new_service_networks(service_type) -> ServiceNetworks: v4_service_network = _ipam.allocate_service_ipv4_network(service_type=service_type) v6_service_network = _ipam.allocate_service_ipv6_network(service_type=service_type) return ServiceNetworks( v4=v4_service_network, v6=v6_service_network) def new_service_host(hostname, service_type) -> HostAddresses: return _ipam.allocate_service_host(hostname=hostname, service_type=service_type) if __name__ == '__main__': new_service_networks('TRUNK') #new_service_host('newhost12', 'TRUNK')