Unify the template arguments across various template cnfvars
[pyi2ncommon] / src / cnfvar / templates.py
index 8468c68..e36854b 100644 (file)
@@ -239,12 +239,11 @@ def template(name, value, instance=-1, defaults=None, **kwargs):
     return cnf
 
 
-def user(name, password, instance=-1, **kwargs):
+def user(name, instance=-1, **kwargs):
     """
     Generate a user cnf variable.
 
     :param str name: username for the user
-    :param str password: password for the user
     :param int instance: instance number for the user
     :returns: generated cnf variable
     :rtype: :py:class:`Cnf`
@@ -252,7 +251,6 @@ def user(name, password, instance=-1, **kwargs):
     log.info(f"Generating a user {name} cnfvar")
     user_cnf = template("user", name, instance=instance, defaults=user_defaults, **kwargs)
     user_cnf.children.single_with_name("user_fullname").value = name.capitalize()
-    user_cnf.children.single_with_name("user_password").value = password
     return user_cnf
 
 
@@ -270,16 +268,18 @@ def group(name, instance=-1, **kwargs):
     return group_cnf
 
 
-def nic(instance=-1, **kwargs):
+def nic(name, instance=-1, **kwargs):
     """
     Generate a nic cnf variable.
 
+    :param str name: tag or comment for the nic describing its use
     :param int instance: instance number for the nic
     :returns: generated cnf variable
     :rtype: :py:class:`Cnf`
     """
     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
     return nic_cnf
 
 
@@ -298,13 +298,11 @@ def intraclient(name, instance=-1, **kwargs):
     return intraclient_cnf
 
 
-def provider(name, ip, dns, instance=-1, **kwargs):
+def provider(name, instance=-1, **kwargs):
     """
     Generate a provider cnf variable.
 
     :param str name: name for the provider
-    :param str ip: IP address of the provider
-    :param str dns: IP address of the DNS server
     :param int instance: instance number for the provider
     :returns: generated cnf variable
     :rtype: :py:class:`Cnf`
@@ -312,18 +310,14 @@ def provider(name, ip, dns, instance=-1, **kwargs):
     log.info(f"Generating a provider {name} cnfvar")
     provider_cnf = template("provider", name, instance=instance,
                             defaults=provider_defaults, **kwargs)
-    provider_cnf.children.single_with_name("provider_ip").value = ip
-    provider_cnf.children.single_with_name("provider_dns").value = dns
     return provider_cnf
 
 
-def port_forwarding(name, src_port="1234", dst_port="1234", instance=-1, **kwargs):
+def port_forwarding(name, instance=-1, **kwargs):
     """
     Generate a port forwarding cnf variable.
 
     :param str name: name for the port forwarding mapping
-    :param str src_port: forwarded source port
-    :param str dst_port: forwarded destination port
     :param int instance: instance number for the port forwarding mapping
     :returns: generated cnf variable
     :rtype: :py:class:`Cnf`
@@ -331,8 +325,6 @@ def port_forwarding(name, src_port="1234", dst_port="1234", instance=-1, **kwarg
     log.info(f"Generating a port forwarding {name} cnfvar")
     port_forwarding_cnf = template("port_forwarding", name, instance=instance,
                                    defaults=port_forwarding_defaults, **kwargs)
-    port_forwarding_cnf.children.single_with_name("port_forwarding_src_port").value = src_port
-    port_forwarding_cnf.children.single_with_name("port_forwarding_dst_port").value = dst_port
     return port_forwarding_cnf