# Info: KCL IP alias task schemas for provisioning (Provisioning)
# Author: JesusPerezLorenzo 
# Release: 0.0.4
# Date: 4-08-2024

import regex

schema IPalias:
   setup_mode: "system" | "alias" = "alias"
   address: str 
   hostname: str = ""
   main_hostname: bool = False
   interface: str
   dev_interface: str
   netmask: str = "255.255.255.0"
   nameservers: str = ""
   search: str = ""
   check:
      address == Undefined or regex.match(address,"^\$.*$") or regex.match(address,"^((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])$"), "'address = ${address}' check value definition (use $vaule or xx.xx.xx.xx)"
      netmask == Undefined or regex.match(netmask,"^((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])$"), "'netmask = ${netmask}' check value definition (use $vaule or xx.xx.xx.xx)"

schema IPaliases:
    name: str = "IPaliases"
    aliases: [IPalias] 

