log.info(f"Generating a nic cnfvar")
nic_cnf = template("nic", "", instance=instance, defaults=nic_defaults, **kwargs)
nic_cnf.children.single_with_name("nic_comment").value = name
+ if nic_cnf.children.single_with_name("nic_type").value in ["NATLAN", "PUBLICLAN", "PROXYARP"]:
+ nic_cnf.add_child("nic_lan_ip", "192.168.1.1")
+ nic_cnf.add_child("nic_lan_netmask", "255.255.255.0")
+ nic_cnf.add_child("nic_lan_dns_relaying_allowed", "0")
+ nic_cnf.add_child("nic_lan_email_relaying_allowed", "0")
+ nic_cnf.add_child("nic_lan_nat_into", "0")
+ nic_cnf.add_child("nic_lan_proxy_profile_ref", "-1")
+ nic_cnf.add_child("nic_lan_firewall_ruleset_ref", "1")
return nic_cnf
log.info(f"Generating a provider {name} cnfvar")
provider_cnf = template("provider", name, instance=instance,
defaults=provider_defaults, **kwargs)
+ # the validation of the LOCALIP will not be ignored despite choosing a different mode
+ if provider_cnf.children.single_with_name("provider_mode").value not in ["ROUTER", "GWINLAN"]:
+ provider_cnf.children.remove_where(lambda c: c.name == "provider_ip")
+ provider_cnf.children.remove_where(lambda c: c.name == "provider_netmask")
+ if provider_cnf.children.single_with_name("provider_mode").value != "ROUTER":
+ provider_cnf.children.remove_where(lambda c: c.name == "provider_localip")
+ if provider_cnf.children.single_with_name("provider_dns_mode").value != "IP":
+ provider_cnf.children.remove_where(lambda c: c.name == "provider_dns")
return provider_cnf
log.info(f"Generating a port forwarding {name} cnfvar")
port_forwarding_cnf = template("port_forwarding", name, instance=instance,
defaults=port_forwarding_defaults, **kwargs)
+ if port_forwarding_cnf.children.single_with_name("port_forwarding_protocol_type").value == "OTHER":
+ port_forwarding_cnf.children.remove_where(lambda c: c.name == "port_forwarding_src_port")
+ port_forwarding_cnf.children.remove_where(lambda c: c.name == "port_forwarding_dst_port")
+ port_forwarding_cnf.children.remove_where(lambda c: c.name == "port_forwarding_src_port_end")
+ port_forwarding_cnf.children.remove_where(lambda c: c.name == "port_forwarding_dst_port_end")
+ port_forwarding_cnf.add_child("port_forwarding_protocol_num", "47")
return port_forwarding_cnf
log.info(f"Generating a vpn connection {name} cnfvar")
vpnconn_cnf = template("vpnconn", name, instance=instance,
defaults=vpnconn_defaults, **kwargs)
+ if vpnconn_cnf.children.single_with_name("vpnconn_lan_type").value not in ["NIC", "CUSTOM"]:
+ vpnconn_cnf.children.remove_where(lambda c: c.name == "vpnconn_lan_net")
+ if vpnconn_cnf.children.single_with_name("vpnconn_remote_type").value != "CUSTOM":
+ vpnconn_cnf.children.remove_where(lambda c: c.name == "vpnconn_remote_net")
+ if vpnconn_cnf.children.single_with_name("vpnconn_remote_type").value != "MODECONFIG":
+ vpnconn_cnf.children.remove_where(lambda c: c.name == "vpnconn_remote_modeconfig_ip")
return vpnconn_cnf