diff --git a/tiramisu/api.py b/tiramisu/api.py index a273805..bc0e1ab 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -148,7 +148,7 @@ class _TiramisuOptionOptionDescription(CommonTiramisuOption): return self._option_bag.option def type(self): - return self._option_bag.option.get_display_type() + return self._option_bag.option.get_type() def isleadership(self): """Test if option is a leader or a follower""" diff --git a/tiramisu/option/booloption.py b/tiramisu/option/booloption.py index a2774d6..49244f0 100644 --- a/tiramisu/option/booloption.py +++ b/tiramisu/option/booloption.py @@ -27,6 +27,7 @@ from .option import Option class BoolOption(Option): "represents a choice between ``True`` and ``False``" __slots__ = tuple() + _type = 'boolean' _display_name = _('boolean') def _validate(self, diff --git a/tiramisu/option/broadcastoption.py b/tiramisu/option/broadcastoption.py index 5e2a1e1..cbb261f 100644 --- a/tiramisu/option/broadcastoption.py +++ b/tiramisu/option/broadcastoption.py @@ -28,6 +28,7 @@ from .option import Option class BroadcastOption(Option): __slots__ = tuple() + _type = 'broadcast_address' _display_name = _('broadcast address') def _validate(self, diff --git a/tiramisu/option/choiceoption.py b/tiramisu/option/choiceoption.py index f8afc75..63f9fcb 100644 --- a/tiramisu/option/choiceoption.py +++ b/tiramisu/option/choiceoption.py @@ -33,6 +33,7 @@ class ChoiceOption(Option): The option can also have the value ``None`` """ __slots__ = tuple() + _type = 'choice' _display_name = _('choice') def __init__(self, diff --git a/tiramisu/option/dateoption.py b/tiramisu/option/dateoption.py index b1ebeed..ad46427 100644 --- a/tiramisu/option/dateoption.py +++ b/tiramisu/option/dateoption.py @@ -27,6 +27,7 @@ from .option import Option class DateOption(Option): __slots__ = tuple() + _type = 'date' _display_name = _('date') def _validate(self, diff --git a/tiramisu/option/domainnameoption.py b/tiramisu/option/domainnameoption.py index 1fc4d58..e09f95a 100644 --- a/tiramisu/option/domainnameoption.py +++ b/tiramisu/option/domainnameoption.py @@ -35,6 +35,7 @@ class DomainnameOption(StrOption): fqdn: with tld, not supported yet """ __slots__ = tuple() + _type = 'domainname' _display_name = _('domain name') def __init__(self, diff --git a/tiramisu/option/emailoption.py b/tiramisu/option/emailoption.py index f8b24e3..6d70b95 100644 --- a/tiramisu/option/emailoption.py +++ b/tiramisu/option/emailoption.py @@ -28,4 +28,5 @@ class EmailOption(RegexpOption): __slots__ = tuple() #https://www.w3.org/TR/html-markup/input.email.html#input.email.attrs.value.single. _regexp = re.compile(r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$") + _type = 'email' _display_name = _('email address') diff --git a/tiramisu/option/filenameoption.py b/tiramisu/option/filenameoption.py index 9e8e35f..a75934f 100644 --- a/tiramisu/option/filenameoption.py +++ b/tiramisu/option/filenameoption.py @@ -27,4 +27,5 @@ from .stroption import RegexpOption class FilenameOption(RegexpOption): __slots__ = tuple() _regexp = re.compile(r"^[a-zA-Z0-9\-\._~/+]+$") + _type = 'filename' _display_name = _('file name') diff --git a/tiramisu/option/floatoption.py b/tiramisu/option/floatoption.py index 5cac8dc..b64b152 100644 --- a/tiramisu/option/floatoption.py +++ b/tiramisu/option/floatoption.py @@ -27,6 +27,7 @@ from .option import Option class FloatOption(Option): "represents a choice of a floating point number" __slots__ = tuple() + _type = 'float' _display_name = _('float') def _validate(self, diff --git a/tiramisu/option/intoption.py b/tiramisu/option/intoption.py index 2397de7..65d5bb5 100644 --- a/tiramisu/option/intoption.py +++ b/tiramisu/option/intoption.py @@ -27,6 +27,7 @@ from .option import Option class IntOption(Option): "represents a choice of an integer" __slots__ = tuple() + _type = 'integer' _display_name = _('integer') def __init__(self, diff --git a/tiramisu/option/ipoption.py b/tiramisu/option/ipoption.py index 1412d59..551ca91 100644 --- a/tiramisu/option/ipoption.py +++ b/tiramisu/option/ipoption.py @@ -32,6 +32,7 @@ from .networkoption import NetworkOption class IPOption(StrOption): "represents the choice of an ip" __slots__ = tuple() + _type = 'ip' _display_name = _('IP') def __init__(self, diff --git a/tiramisu/option/netmaskoption.py b/tiramisu/option/netmaskoption.py index 5fbfda5..3bdd0ca 100644 --- a/tiramisu/option/netmaskoption.py +++ b/tiramisu/option/netmaskoption.py @@ -31,6 +31,7 @@ from .stroption import StrOption class NetmaskOption(StrOption): "represents the choice of a netmask" __slots__ = tuple() + _type = 'netmask' _display_name = _('netmask address') def _validate(self, diff --git a/tiramisu/option/networkoption.py b/tiramisu/option/networkoption.py index 537021b..4544254 100644 --- a/tiramisu/option/networkoption.py +++ b/tiramisu/option/networkoption.py @@ -28,6 +28,7 @@ from .option import Option class NetworkOption(Option): "represents the choice of a network" __slots__ = tuple() + _type = 'network' _display_name = _('network address') def __init__(self, diff --git a/tiramisu/option/option.py b/tiramisu/option/option.py index b58b402..1ddcedb 100644 --- a/tiramisu/option/option.py +++ b/tiramisu/option/option.py @@ -179,6 +179,10 @@ class Option(BaseOption): def impl_is_dynsymlinkoption(self) -> bool: return False + def get_type(self) -> str: + # _display_name for compatibility with older version than 3.0rc3 + return getattr(self, '_type', self._display_name) + def get_display_type(self) -> str: return self._display_name diff --git a/tiramisu/option/passwordoption.py b/tiramisu/option/passwordoption.py index 7b281a3..78509b5 100644 --- a/tiramisu/option/passwordoption.py +++ b/tiramisu/option/passwordoption.py @@ -28,6 +28,7 @@ from .stroption import StrOption class PasswordOption(StrOption): "represents the choice of a password" __slots__ = tuple() + _type = 'password' _display_name = _('password') def _validate(self, diff --git a/tiramisu/option/portoption.py b/tiramisu/option/portoption.py index a506eaf..8e0fa0c 100644 --- a/tiramisu/option/portoption.py +++ b/tiramisu/option/portoption.py @@ -40,6 +40,7 @@ class PortOption(StrOption): """ __slots__ = tuple() port_re = re.compile(r"^[0-9]*$") + _type = 'port' _display_name = _('port') def __init__(self, diff --git a/tiramisu/option/stroption.py b/tiramisu/option/stroption.py index 6c53ce0..dfd678c 100644 --- a/tiramisu/option/stroption.py +++ b/tiramisu/option/stroption.py @@ -29,6 +29,7 @@ from .option import Option class StrOption(Option): "represents the choice of a string" __slots__ = tuple() + _type = 'string' _display_name = _('string') def _validate(self, diff --git a/tiramisu/option/urloption.py b/tiramisu/option/urloption.py index e22bcda..00bb24d 100644 --- a/tiramisu/option/urloption.py +++ b/tiramisu/option/urloption.py @@ -30,6 +30,7 @@ class URLOption(DomainnameOption): __slots__ = tuple() proto_re = re.compile(r'(http|https)://') path_re = re.compile(r"^[A-Za-z0-9\-\._~:/\?#\[\]@!%\$&\'\(\)\*\+,;=]+$") + _type = 'url' _display_name = _('URL') def _validate(self, diff --git a/tiramisu/option/usernameoption.py b/tiramisu/option/usernameoption.py index 557f09c..4da7d97 100644 --- a/tiramisu/option/usernameoption.py +++ b/tiramisu/option/usernameoption.py @@ -28,4 +28,5 @@ class UsernameOption(RegexpOption): __slots__ = tuple() #regexp build with 'man 8 adduser' informations _regexp = re.compile(r"^[a-z_][a-z0-9_-]{0,30}[$a-z0-9_-]{0,1}$") + _type = 'username' _display_name = _('username')