From: Plamen Dimitrov Date: Thu, 14 Nov 2019 11:11:31 +0000 (+0200) Subject: Increase the available arguments for all current mk_config methods X-Git-Tag: v1.6.3~5 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=93b1989150dc51875a628bcc45b49422a058578e;p=pyi2ncommon Increase the available arguments for all current mk_config methods The mk_config is a statistical hub for the way we do API calls to the fully dynamic set_cnf bindings so it seems like a good place to start implementing a more graspable unified cnfvar approach. --- diff --git a/src/mk_config.py b/src/mk_config.py index f04cea7..26def37 100644 --- a/src/mk_config.py +++ b/src/mk_config.py @@ -97,10 +97,11 @@ def user(username="admin", instance=1, suffix="host"): return user_cnf -def group_admins(activesync_enable=False, xauth_enable=False, suffix="host"): +def group_admins(proxy_profile="1", activesync_enable=False, xauth_enable=False, suffix="host"): """ Generate and save an Administrators group configuration file. + :param str proxy_profile: proxy profile instance reference :param bool activesync_enable: whether to enable ActiveSync for the group :param bool xauth_enable: whether to enable XAUTH for the group :param str suffix: optional suffix to use for config identification @@ -112,7 +113,7 @@ def group_admins(activesync_enable=False, xauth_enable=False, suffix="host"): instance=1), [(Update, ("GROUP_ACCESS_REMOTE_ADMINISTRATION_ALLOWED", 0, "1")), (Update, ("GROUP_EMAILFILTER_BAN_FILTERLIST_REF", 0, "-1")), - (Update, ("GROUP_PROXY_PROFILE_REF", 0, "1")), + (Update, ("GROUP_PROXY_PROFILE_REF", 0, proxy_profile)), (Update, ("GROUP_ACCESS_GO_ONLINE_ALLOWED", 0, "1")), (Update, ("GROUP_EMAIL_RELAY_RIGHTS", 0, "RELAY_FROM_INTRANET")), (Update, ("GROUP_ACTIVESYNC_ENABLE", 0, "1" if activesync_enable else "0")), @@ -159,10 +160,14 @@ def group_all(proxy_profile="1", suffix="host"): return group_cnf -def nic(ip="1.2.3.4", netmask="255.255.0.0", mac="00:00:00:00:00:00", suffix="host"): +def nic(instance=0, nictype="NATLAN", + ip="1.2.3.4", netmask="255.255.0.0", mac="00:00:00:00:00:00", + suffix="host"): """ Generate and save a nic configuration file. + :param int instance: instance number (for multiple nics, -1 for next available) + :param str nictype: type of the nic :param str ip: IP address of the nic :param str netmask: network mask of the nic :param str mac: MAC address of the nic @@ -172,8 +177,8 @@ def nic(ip="1.2.3.4", netmask="255.255.0.0", mac="00:00:00:00:00:00", suffix="ho """ log.info("Create arnied nic configuration") nic = batch_update_cnf( - build_nic.BuildNIC(data="", instance=2, line_no=1), - [(Update, ("NIC_TYPE", 0, "NATLAN")), + build_nic.BuildNIC(data="", instance=instance, line_no=1), + [(Update, ("NIC_TYPE", 0, nictype)), (Update, ("NIC_LAN_IP", 0, ip)), (Update, ("NIC_LAN_NETMASK", 0, netmask)), (Update, ("NIC_MAC", 0, mac))]) @@ -184,10 +189,14 @@ def nic(ip="1.2.3.4", netmask="255.255.0.0", mac="00:00:00:00:00:00", suffix="ho return nic_cnf -def intraclient(ip="1.2.3.4", mac="00:00:00:00:00:00", fwrules=5, suffix="host"): +def intraclient(name="intraclient", instance=1, + ip="1.2.3.4", mac="00:00:00:00:00:00", + fwrules=5, suffix="host"): """ Generate and save an intraclient configuration file. + :param str name: name of the intraclient + :param int instance: instance number (for multiple clients, -1 for next available) :param str ip: IP address of the intraclient :param str mac: MAC address of the intraclient :param int fwrules: instance of the firewall rules to use @@ -196,7 +205,8 @@ def intraclient(ip="1.2.3.4", mac="00:00:00:00:00:00", fwrules=5, suffix="host") :rtype: str """ log.info("Create arnied intraclient configuration") - intraclient = batch_update_cnf(build_intraclient.BuildIntraclient(instance=1, data="dmzserver"), + intraclient = batch_update_cnf(build_intraclient.BuildIntraclient(data=name, + instance=instance), [(Update, ("INTRACLIENT_IP", 0, ip)), (Update, ("INTRACLIENT_MAC", 0, mac)), (Update, ("INTRACLIENT_FIREWALL_RULESET_REF", 0, fwrules))]) @@ -208,21 +218,26 @@ def intraclient(ip="1.2.3.4", mac="00:00:00:00:00:00", fwrules=5, suffix="host") return intraclient_cnf -def provider(mode="ROUTER", ip="1.2.3.4", localip=None, +def provider(name="provider", instance=1, mode="ROUTER", ip="1.2.3.4", localip=None, netmask="255.255.0.0", dnsmode="IP", dns="1.2.3.4", fwrules=5, - dialretry=None, name=None, timeout="", mtumode="AUTO", + dialretry=None, timeout="", mtumode="AUTO", vlanid=None, mtusize=None, login=None, password=None, modemip=None, providerid=None, localdhcp=None, suffix="host"): """ Generate and save a provider configuration file. + :param str name: name of the provider + :param int instance: instance number (for multiple clients, -1 for next available) :param str mode: provider mode :param str ip: IP address of the provider :param localip: IP address of the configured machine (valid for some configurations) :type localip: str or None + :param str netmask: netmask of the provider + :param str dnsmode: dnsmode of the provider :param str dns: IP address of the DNS server :param int fwrules: instance of the firewall rules to use + :param any args: lots of detailed configuration :param str suffix: optional suffix to use for config identification :returns: generated config filename :rtype: str @@ -232,7 +247,7 @@ def provider(mode="ROUTER", ip="1.2.3.4", localip=None, if var is not None: return (Add, (field, 0, str(var))) return (Delete, field) - provider = batch_update_cnf(build_provider.BuildProvider(data=name), + provider = batch_update_cnf(build_provider.BuildProvider(data=name, instance=instance), [(Update, ("PROVIDER_MODE", 0, mode)), ip and (Update, ("PROVIDER_IP", 0, ip)) or (Delete, "PROVIDER_IP"), @@ -300,7 +315,8 @@ def provider_proxy(mode="ROUTER", ip="1.2.3.4", localip=None, proxy_port=3128, f def port_forwarding(src_port="1234", src_port_end="", dst_port="1234", dst_port_end="", - protocol_type="TCP", suffix="host"): + dst_ip_ref="1", protocol_type="TCP", + suffix="host"): """ Generate and save a port forwarding configuration file. @@ -308,6 +324,7 @@ def port_forwarding(src_port="1234", src_port_end="", :param str src_port_end: forwarded source port end for a port range :param str dst_port: forwarded destination port :param str dst_port_end: forwarded destination port end for a port range + :param str dst_ip_ref: destination nic instance for a port range :param str protocol_type: port forwarding protocol type :param str suffix: optional suffix to use for config identification :returns: generated config filename @@ -319,7 +336,7 @@ def port_forwarding(src_port="1234", src_port_end="", return build_cnf("PORT_FORWARDING", data=value_id, filename=portforward_client_cnf, - vals=[(Child, ("PORT_FORWARDING_DST_IP_REF", 0, "1")), + vals=[(Child, ("PORT_FORWARDING_DST_IP_REF", 0, dst_ip_ref)), (Child, ("PORT_FORWARDING_DST_PORT", 0, dst_port)), (Child, ("PORT_FORWARDING_DST_PORT_END", 0, dst_port_end)), (Child, ("PORT_FORWARDING_PROTOCOL_TYPE", 0, protocol_type)),