feat: update upgrade module

This commit is contained in:
egarette@silique.fr 2024-09-30 17:58:14 +02:00
parent d2195d31a9
commit e518abb734
490 changed files with 809 additions and 2437 deletions

View file

@ -1,4 +1,4 @@
"""Update Rougail XML file to new version
"""Update Rougail structure file to new version
Cadoles (http://www.cadoles.com)
Copyright (C) 2021
@ -23,7 +23,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
from os import listdir, makedirs
from os import listdir
from os.path import basename, isdir, isfile, join
from typing import Any, List, Optional, Tuple
@ -38,11 +38,11 @@ from json import dumps
from ruamel.yaml import YAML
from pathlib import Path
from .config import RougailConfig
from .error import UpgradeError
from .i18n import _
from .object_model import CONVERT_OPTION
from .utils import normalize_family
from ..config import RougailConfig
from ..error import UpgradeError
from ..i18n import _
from ..object_model import CONVERT_OPTION
from ..utils import normalize_family
VERSIONS = ["0.10", "1.0", "1.1"]
@ -63,7 +63,7 @@ class upgrade_010_to_10:
xmlsrc: str,
) -> None:
self.xmlsrc = xmlsrc
self.paths = {"family": {}, "variable": {}}
self.paths = {"family": {}, "variable": {}, 'dynamic': {}}
self.lists = {
"service": {},
"ip": {},
@ -71,7 +71,7 @@ class upgrade_010_to_10:
"file": {},
}
self.flatten_paths = {"family": {}, "variable": {}}
self.variables = self.parse_variables(dico, namespace)
self.variables = self.parse_variables(dico, namespace, namespace, root=True)
self.parse_variables_with_path()
self.parse_services(dico)
self.parse_constraints(dico)
@ -80,13 +80,20 @@ class upgrade_010_to_10:
self,
family: dict,
sub_path: str,
true_sub_path: str,
*,
root: bool=False,
is_dynamic: bool=False,
) -> dict:
new_families = {}
if root:
new_families['version'] = None
if "variables" in family:
for subelt in family["variables"]:
for typ, obj in subelt.items():
for subobj in obj:
getattr(self, f"convert_{typ}")(subobj, new_families, sub_path)
local_is_dynamic = is_dynamic or subobj.get('dynamic') is not None
getattr(self, f"convert_{typ}")(subobj, new_families, sub_path, true_sub_path, local_is_dynamic)
family.pop("variables")
return new_families
@ -95,9 +102,17 @@ class upgrade_010_to_10:
family: dict,
new_families: dict,
sub_path: str,
true_sub_path: str,
is_dynamic: bool,
) -> None:
# name is the key, do not let it in values
name = family.pop("name")
if true_sub_path:
true_sub_path = true_sub_path + "." + name
else:
true_sub_path = name
if is_dynamic:
name += '{{ suffix }}'
if sub_path:
sub_path = sub_path + "." + name
else:
@ -111,7 +126,7 @@ class upgrade_010_to_10:
if typ == "dynamic":
family["variable"] = self.get_variable_path(value)
# add sub families and sub variables
sub_families = self.parse_variables(family, sub_path)
sub_families = self.parse_variables(family, sub_path, true_sub_path, is_dynamic=is_dynamic)
for sub_name, sub_family in sub_families.copy().items():
if sub_name not in family:
continue
@ -127,12 +142,23 @@ class upgrade_010_to_10:
variable: dict,
new_families: dict,
sub_path: str,
true_sub_path: str,
is_dynamic: bool,
) -> dict:
name = variable.pop("name")
if is_dynamic:
if true_sub_path:
true_sub_path = true_sub_path + "." + name
else:
true_sub_path = name
self.flatten_paths["variable"][name] = true_sub_path
name += '{{ suffix }}'
if sub_path:
sub_path = sub_path + "." + name
else:
sub_path = name
if is_dynamic:
self.paths['dynamic'][true_sub_path] = sub_path
new_families[name] = variable
self.flatten_paths["variable"][name] = sub_path
self.paths["variable"][sub_path] = variable
@ -172,24 +198,32 @@ class upgrade_010_to_10:
)(test)
)
variable["test"] = tests
if variable.get('mandatory', False):
del variable["mandatory"]
CONVERT_TYPE = {'filename': 'unix_filename',
'password': 'secret',
}
if variable.get('type') in CONVERT_TYPE:
variable['type'] = CONVERT_TYPE[variable['type']]
def parse_variables_with_path(self):
for variable in self.paths["variable"].values():
multi = variable.get('multi', False)
if "value" in variable:
default = variable.pop("value")
if default is not None:
if not variable.get("multi", False) and len(default) == 1:
variable["default"] = self.get_value(default[0])
if not multi and len(default) == 1:
variable["default"] = self.get_value(default[0], multi)
else:
variable["default"] = [
self.get_value(value) for value in default
self.get_value(value, multi) for value in default
]
if "choice" in variable:
if not variable["choice"]:
variable["choices"] = variable.pop("choice")
else:
variable["choices"] = [
self.get_value(choice) for choice in variable.pop("choice")
self.get_value(choice, multi) for choice in variable.pop("choice")
]
def parse_services(
@ -305,15 +339,32 @@ class upgrade_010_to_10:
apply_on_fallback = False
source = self.get_variable_path(condition["source"])
if not source:
source = f'__{condition["source"]}'
source = condition["source"]
name = condition.pop("name")
prop = name.split("_", 1)[0]
multi = False
for target in condition["target"]:
typ = target.get("type", "variable")
if typ == "variable":
variable_path = self.get_variable_path(target["text"])
if variable_path is None:
continue
variable = self.paths["variable"][variable_path]
if variable.get('multi', False):
multi = True
if apply_on_fallback:
condition_value = True
else:
if "{{ suffix }}" in source:
force_param = {'__var': source}
source = '__var'
else:
force_param = None
condition_value = self.params_condition_to_jinja(
prop, source, condition["param"], name.endswith("if_in")
prop, source, condition["param"], name.endswith("if_in"), multi
)
if force_param:
condition_value.setdefault('params', {}).update(force_param)
for target in condition["target"]:
typ = target.get("type", "variable")
if typ == "variable":
@ -366,7 +417,7 @@ class upgrade_010_to_10:
check["param"] = [
{"text": variable_path, "type": "variable"}
] + check.get("param", [])
check_value = self.convert_param_function(check)
check_value = self.convert_param_function(check, variable.get('multi', False))
variable.setdefault("validators", []).append(check_value)
def parse_fill(
@ -376,17 +427,22 @@ class upgrade_010_to_10:
for target in fill.pop("target"):
params = []
variable_path = self.get_variable_path(target["text"])
if variable_path is None:
continue
variable = self.paths["variable"][variable_path]
if fill.get("type") == "jinja":
fill_value = {
"type": "jinja",
"jinja": fill["name"],
}
if variable_path in self.paths["dynamic"]:
variable_path = self.paths["dynamic"][variable_path]
if variable_path in self.paths["variable"]:
variable = self.paths["variable"][variable_path]
if fill.get("type") == "jinja":
fill_value = {
"type": "jinja",
"jinja": fill["name"],
}
else:
fill_value = self.convert_param_function(fill, variable.get('multi', False))
variable["default"] = fill_value
if variable.get('mandatory') is False:
del variable['mandatory']
else:
fill_value = self.convert_param_function(fill)
variable["default"] = fill_value
raise Exception(f'cannot set fill to unknown variable "{variable_path}"')
def params_condition_to_jinja(
self,
@ -394,6 +450,7 @@ class upgrade_010_to_10:
path: str,
params: List[dict],
if_in: bool,
multi: bool,
) -> str:
new_params = {}
jinja = "{% if "
@ -401,7 +458,7 @@ class upgrade_010_to_10:
if idx:
jinja += " or "
new_param, value = self.get_jinja_param_and_value(param)
new_param, value = self.get_jinja_param_and_value(param, multi)
if value:
jinja += path + " == " + value
if new_param:
@ -421,10 +478,11 @@ class upgrade_010_to_10:
def get_value(
self,
param: dict,
multi: bool,
) -> Any:
typ = param.get("type", "string")
if typ == "string":
value = param["text"]
value = param.get("text")
elif typ == "number":
value = int(param["text"])
elif typ == "nil":
@ -446,7 +504,7 @@ class upgrade_010_to_10:
if "propertyerror" in param:
value["propertyerror"] = param["propertyerror"]
elif typ == "function":
value = self.convert_param_function(param)
value = self.convert_param_function(param, multi)
elif typ == "information":
value = {
"type": "information",
@ -464,10 +522,11 @@ class upgrade_010_to_10:
def get_jinja_param_and_value(
self,
param,
multi: bool,
) -> Tuple[list, Any]:
new_param = None
typ = param.get("type", "string")
value = self.get_value(param)
value = self.get_value(param, multi)
if isinstance(value, dict):
if typ == "information":
key = normalize_family(value["information"])
@ -475,17 +534,25 @@ class upgrade_010_to_10:
attr_name = f'{value["variable"]}.{key}'
else:
attr_name = key
attr_name = f"__information.{attr_name}"
attr_name = f"__information_{attr_name}"
new_param = {attr_name: value}
value = attr_name
elif typ in ["index", "suffix"]:
attr_name = f"__{typ}"
new_param = {attr_name: value}
if 'name' in value:
attr_name = value['name']
else:
attr_name = f"__{typ}"
new_param = {attr_name: {"type": typ}}
value = attr_name
elif "propertyerror" in param or "optional" in param:
attr_name = value["variable"]
new_param = {attr_name: value}
value = value[typ]
elif "{{ suffix }}" in value[typ]:
path = value[typ]
attr_name = path.split('.')[-1][:-12] # remove {{ suffix }}
new_param = {attr_name: value}
value = attr_name
else:
value = value[typ]
if not value:
@ -497,22 +564,35 @@ class upgrade_010_to_10:
def convert_param_function(
self,
param: dict,
multi: bool,
) -> str:
text = param["name"]
params = {}
# multi = False
if "param" in param and param["param"]:
if text == 'calc_value' and len(param["param"]) == 1 and isinstance(param["param"][0], dict) and param["param"][0].get('type') == 'variable' and param["param"][0].get("text"):
value = param["param"][0]["text"]
path = self.get_variable_path(value)
if not path:
path = value
ret = {"type": "variable", "variable": path}
if 'optional' in param["param"][0]:
ret['optional'] = param["param"][0]["optional"]
return ret
first, *others = param["param"]
new_param, first = self.get_jinja_param_and_value(first)
new_param, first = self.get_jinja_param_and_value(first, multi)
text = f"{first} | {text}"
if new_param:
params |= new_param
if others:
values = []
for param in others:
new_param, value = self.get_jinja_param_and_value(param)
new_param, value = self.get_jinja_param_and_value(param, multi)
if new_param:
params |= new_param
if "name" in param:
if param["name"] == "multi" and value == "true":
multi = True
values.append(f'{param["name"]}={value}')
else:
values.append(value)
@ -521,7 +601,12 @@ class upgrade_010_to_10:
text += ")"
else:
text += "()"
text = "{{ " + text + " }}"
if not multi:
text = "{{ " + text + " }}"
else:
text = """{% for __variable in """ + text + """ %}
{{ __variable }}
{% endfor %}"""
ret = {"type": "jinja", "jinja": text}
if params:
ret["params"] = params
@ -536,8 +621,10 @@ class upgrade_010_to_10:
and path in self.flatten_paths["variable"]
):
path = self.flatten_paths["variable"][path]
if path in self.paths["dynamic"]:
path = self.paths["dynamic"][path]
if path not in self.paths["variable"]:
return
return path
return path
def get_family_path(
@ -569,43 +656,38 @@ class RougailUpgrade:
rougailconfig = RougailConfig
self.rougailconfig = rougailconfig
def load_dictionaries(
def run(
self,
dstfolder: str,
services_dstfolder: Optional[str] = None,
extra_dstfolder: Optional[str] = None,
):
if extra_dstfolder is None:
extra_dstfolder = dstfolder
dict_dirs = self.rougailconfig["main_dictionaries"]
if not isinstance(dict_dirs, list):
dict_dirs = [dict_dirs]
for dict_dir in dict_dirs:
for dict_dir, dest_dir in zip(self.rougailconfig["main_dictionaries"], self.rougailconfig["upgrade_options.main_dictionaries"]):
self._load_dictionaries(
dict_dir,
dstfolder,
services_dstfolder,
dest_dir,
normalize_family(self.rougailconfig["main_namespace"]),
)
for namespace, extra_dirs in self.rougailconfig["extra_dictionaries"].items():
extra_dstsubfolder = join(extra_dstfolder, namespace)
if not isdir(extra_dstsubfolder):
makedirs(extra_dstsubfolder)
for extra_dir in extra_dirs:
self._load_dictionaries(
extra_dir,
extra_dstsubfolder,
None,
normalize_family(namespace),
)
if self.rougailconfig['main_namespace']:
if self.rougailconfig["extra_dictionaries"]:
dst_extra_dir = self.rougailconfig["upgrade_options.extra_dictionary"]
for namespace, extra_dirs in self.rougailconfig["extra_dictionaries"].items():
extra_dstsubfolder = Path(dst_extra_dir) / namespace
if not extra_dstsubfolder.is_dir():
extra_dstsubfolder.mkdir()
for extra_dir in extra_dirs:
self._load_dictionaries(
str(extra_dir),
str(extra_dstsubfolder),
normalize_family(namespace),
)
def _load_dictionaries(
self,
srcfolder: str,
dstfolder: str,
services_dstfolder: Optional[str],
dstfolder: Optional[str],
namespace: str,
) -> None:
if dstfolder is None:
dstfolder = srcfolder
Path(dstfolder).mkdir(parents=True, exist_ok=True)
filenames = [
filename
for filename in listdir(srcfolder)
@ -614,18 +696,8 @@ class RougailUpgrade:
filenames.sort()
for filename in filenames:
xmlsrc = Path(srcfolder) / Path(filename)
ymlfile = filename[:-3] + "yml"
xmldst = Path(dstfolder) / Path(ymlfile)
if xmldst.is_file():
raise Exception(
f'cannot update "{xmlsrc}" destination file "{xmldst}" already exists'
)
if services_dstfolder:
ymldst_services = Path(services_dstfolder) / ymlfile
if ymldst_services.is_file():
raise Exception(
f'cannot update "{xmlsrc}" destination file "{ymldst_services}" already exists'
)
ymldst = Path(dstfolder) / (Path(filename).stem + '.yml')
if filename.endswith(".xml"):
if parse is None:
raise Exception("XML module is not installed")
@ -640,7 +712,7 @@ class RougailUpgrade:
)
ext = "xml"
else:
with xmlsrc.open() as xml_fh:
with xmlsrc.open() as file_fh:
root = YAML(typ="safe").load(file_fh)
search_function_name = get_function_name(str(root["version"]))
ext = "yml"
@ -660,24 +732,23 @@ class RougailUpgrade:
root_services = root_services_
if function_version == search_function_name:
function_found = True
if root:
root["version"] = version
xmldst.parent.mkdir(parents=True, exist_ok=True)
with xmldst.open("w") as ymlfh:
if root != {'version': None}:
root["version"] = float(version)
with ymldst.open("w") as ymlfh:
yaml = YAML()
yaml.dump(
root,
xmldst,
)
if root_services and services_dstfolder:
root_services["version"] = version
ymldst_services.parent.mkdir(parents=True, exist_ok=True)
with ymldst_services.open("w") as ymlfh:
yaml = YAML()
yaml.dump(
root_services,
ymlfh,
)
# if root_services and services_dstfolder:
# root_services["version"] = version
# ymldst_services.parent.mkdir(parents=True, exist_ok=True)
# with ymldst_services.open("w") as ymlfh:
# yaml = YAML()
# yaml.dump(
# root_services,
# ymlfh,
# )
def _attribut_to_bool(self, variable):
for prop in [
@ -833,23 +904,47 @@ class RougailUpgrade:
return dico
def _update_1_1(self, root):
if not isinstance(root, dict):
return
# migrate dynamic family
if (
("variable" in root and isinstance(root["variable"], str))
or ("_variable" in root and isinstance(root["_variable"], str))
) and (
("_type" in root and root["_type"] == "dynamic")
or ("type" in root and root["type"] == "dynamic")
):
root["dynamic"] = {
"type": "variable",
"variable": root.pop("variable"),
"propertyerror": False,
}
new_root = {}
update_root = False
for key, value in root.items():
new_root[key] = value
if not isinstance(value, dict):
continue
# migrate dynamic family
if (
("variable" in value and isinstance(value["variable"], str))
or ("_variable" in value and isinstance(value["_variable"], str))
) and (
("_type" in value and value["_type"] == "dynamic")
or ("type" in value and value["type"] == "dynamic")
):
value["dynamic"] = {
"type": "variable",
"variable": value.pop("variable"),
"propertyerror": False,
}
if '{{ suffix }}' not in key:
new_root[key + '{{ suffix }}'] = new_root.pop(key)
update_root = True
self._update_1_1(value)
for typ, obj in {'boolean': bool,
'number': int,
'string': str,
'float': float,
}.items():
if value.get('type') == typ:
default = value.get('default')
if default is None or default == []:
continue
if isinstance(default, obj):
del value['type']
elif isinstance(default, list) and isinstance(default[0], obj):
del value['type']
if value.get('multi') and isinstance(value.get('default'), list):
del value['multi']
if update_root:
root.clear()
root.update(new_root)
def update_1_1(
self,
@ -877,7 +972,7 @@ class RougailUpgrade:
objects = root.find(typ)
if objects is None:
objects = []
new_objects = self._xml_to_yaml(objects, typ, variables, "")
new_objects = self._xml_to_yaml(objects, typ, variables, namespace)
if new_objects[typ]:
new_root.update(new_objects)
else:
@ -927,7 +1022,6 @@ class RougailUpgrade:
if not has_value:
value = SubElement(variable, "value")
value.text = choices[0]
variable.attrib["mandatory"] = "True"
# convert group to leadership
groups = []

View file

@ -0,0 +1,25 @@
---
version: '1.1'
var: # a suffix variable
- val1
- val2
"my_dyn_family_{{ suffix }}":
description: a dynamic family
dynamic:
variable: _.var
var:
description: a variable inside a dynamic family
default:
type: suffix
mandatory: false
var2:
description: a variable
multi: true
default:
jinja: |-
{%- for v in var %}
{{ v }}
{%- endfor -%}
params:
var:
variable: rougail.my_dyn_family_{{ suffix }}.var

View file

@ -0,0 +1,24 @@
{
"rougail.var": {
"owner": "default",
"value": [
"val1",
"val2"
]
},
"rougail.my_dyn_family_val1.var": {
"owner": "default",
"value": "val1"
},
"rougail.my_dyn_family_val2.var": {
"owner": "default",
"value": "val2"
},
"rougail.var2": {
"owner": "default",
"value": [
"val1",
"val2"
]
}
}

View file

@ -0,0 +1,12 @@
{
"rougail.var": [
"val1",
"val2"
],
"rougail.my_dyn_family_val1.var": "val1",
"rougail.my_dyn_family_val2.var": "val2",
"rougail.var2": [
"val1",
"val2"
]
}

View file

@ -0,0 +1,24 @@
{
"rougail.var": {
"owner": "default",
"value": [
"val1",
"val2"
]
},
"rougail.my_dyn_family_val1.var": {
"owner": "default",
"value": "val1"
},
"rougail.my_dyn_family_val2.var": {
"owner": "default",
"value": "val2"
},
"rougail.var2": {
"owner": "default",
"value": [
"val1",
"val2"
]
}
}

View file

@ -0,0 +1,15 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('tests/dictionaries/../eosfunc/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
dict_env['default_rougail.var2'] = "{%- for v in var %}\n{{ v }}\n{%- endfor -%}"
option_2 = StrOption(name="var", doc="a suffix variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="var", doc="a variable inside a dynamic family", default=Calculation(func['calc_value'], Params((ParamSuffix()))), properties=frozenset({"standard"}), informations={'type': 'string'})
optiondescription_3 = ConvertDynOptionDescription(name="my_dyn_family_{{ suffix }}", doc="a dynamic family", suffixes=Calculation(func['calc_value'], Params((ParamOption(option_2)))), children=[option_4], properties=frozenset({"standard"}))
option_5 = StrOption(name="var2", doc="a variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/60_5family_dynamic_variable_outside_jinja/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.var2"), 'var': ParamOption(option_4)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, optiondescription_3, option_5], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,23 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('tests/dictionaries/../eosfunc/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
dict_env['default_1.rougail.var2'] = "{%- for v in var %}\n{{ v }}\n{%- endfor -%}"
dict_env['default_2.rougail.var2'] = "{%- for v in var %}\n{{ v }}\n{%- endfor -%}"
option_3 = StrOption(name="var", doc="a suffix variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_5 = StrOption(name="var", doc="a variable inside a dynamic family", default=Calculation(func['calc_value'], Params((ParamSuffix()))), properties=frozenset({"standard"}), informations={'type': 'string'})
optiondescription_4 = ConvertDynOptionDescription(name="my_dyn_family_{{ suffix }}", doc="a dynamic family", suffixes=Calculation(func['calc_value'], Params((ParamOption(option_3)))), children=[option_5], properties=frozenset({"standard"}))
option_6 = StrOption(name="var2", doc="a variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_1.rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/60_5family_dynamic_variable_outside_jinja/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("1.rougail.var2"), 'var': ParamOption(option_5)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, optiondescription_4, option_6], properties=frozenset({"standard"}))
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
option_9 = StrOption(name="var", doc="a suffix variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_11 = StrOption(name="var", doc="a variable inside a dynamic family", default=Calculation(func['calc_value'], Params((ParamSuffix()))), properties=frozenset({"standard"}), informations={'type': 'string'})
optiondescription_10 = ConvertDynOptionDescription(name="my_dyn_family_{{ suffix }}", doc="a dynamic family", suffixes=Calculation(func['calc_value'], Params((ParamOption(option_9)))), children=[option_11], properties=frozenset({"standard"}))
option_12 = StrOption(name="var2", doc="a variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_2.rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/60_5family_dynamic_variable_outside_jinja/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("2.rougail.var2"), 'var': ParamOption(option_11)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[option_9, optiondescription_10, option_12], properties=frozenset({"standard"}))
optiondescription_7 = OptionDescription(name="2", doc="2", children=[optiondescription_8], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_7])

View file

@ -1,2 +0,0 @@
tata.service: {}
version: '1.1'

View file

@ -1,10 +1,9 @@
version: 1.1
server_deployed:
type: boolean
general:
description: général
mode_conteneur_actif:
type: string
description: No change
auto_save: true
default: non
version: '1.1'

View file

@ -1,11 +1,10 @@
version: 1.1
server_deployed:
type: boolean
general:
description: général
mode_conteneur_actif:
type: string
description: No change
auto_save: true
mode: advanced
default: non
version: '1.1'

View file

@ -1,8 +1,7 @@
version: 1.1
general:
description: général
mode_conteneur_actif:
type: string
description: No change
hidden: true
default: non
version: '1.1'

View file

@ -1,10 +1,9 @@
version: 1.1
general:
description: général
mode_conteneur_actif:
type: string
description: No change
hidden: true
default: non
without_type:
default: non
version: '1.1'

View file

@ -1,8 +1,7 @@
version: 1.1
general:
description: général
mode_conteneur_actif:
type: string
description: No change
hidden: true
default: non
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
@ -7,7 +8,5 @@ general:
type: jinja
jinja: '{{ rougail.general.mode_conteneur_actif1 | calc_val }}'
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
@ -7,7 +8,5 @@ general:
type: jinja
jinja: '{{ rougail.general.mode_conteneur_actif1 }}'
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
@ -7,7 +8,5 @@ general:
type: jinja
jinja: '{{ rougail.general.mode_conteneur_actif1 }}'
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,22 +1,19 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: No change
hidden: true
mandatory: false
default:
type: jinja
jinja: "{% if mode_conteneur_actif1 == 'non' %}non{% else %}oui{% endif %}"
mode_conteneur_actif1:
type: string
description: No change
default: non
mode_conteneur_actif2:
type: string
description: No change
hidden: true
mandatory: false
default:
type: jinja
jinja: '{% if mode_conteneur_actif1 == "non" %}oui{% else %}non{% endif %}'
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
general:
bool:
type: boolean
@ -13,4 +14,3 @@ general:
default:
type: jinja
jinja: '{% if not rougail.general.bool %}True,False{% else %}False{% endif %}'
version: '1.1'

View file

@ -1,15 +1,13 @@
version: 1.1
bool:
type: boolean
int1:
type: number
mandatory: false
default:
type: jinja
jinja: '{% if bool %}1{% else %}2{% endif %}'
int2:
type: number
mandatory: false
default:
type: jinja
jinja: '{% if not bool %}3{% else %}4{% endif %}'
version: '1.1'

View file

@ -1,15 +1,13 @@
version: 1.1
bool:
type: boolean
int1:
type: number
mandatory: false
default:
type: jinja
jinja: '{%set bool1 = bool %}{% if bool1 %}1{% else %}2{% endif %}'
int2:
type: number
mandatory: false
default:
type: jinja
jinja: '{%set bool1 = bool %}{% if not bool1 %}3{% else %}4{% endif %}'
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
@ -7,7 +8,5 @@ general:
type: jinja
jinja: '{{ calc_val() }}'
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,4 +1,4 @@
version: 1.1
server_name:
type: domainname
default: example.net
version: '1.1'

View file

@ -1,6 +0,0 @@
test.service:
certificates:
certificate:
authority: authority
owner: example
version: '1.1'

View file

@ -1,7 +1,7 @@
version: 1.1
owner:
type: unix_user
default: example
server_name:
type: domainname
default: example.net
version: '1.1'

View file

@ -1,8 +0,0 @@
test.service:
certificates:
certificate:
authority: authority
owner:
name: rougail.owner
type: variable
version: '1.1'

View file

@ -1,6 +1,6 @@
version: 1.1
general:
domain:
type: domainname
description: Description
default: my.domain.name
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,6 +0,0 @@
test.service:
files:
/etc/file: {}
/etc/file2:
engine: jinja
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,8 +0,0 @@
test.service:
files:
/etc/file: {}
/etc/file2:
engine: jinja
/etc/file3:
disabled: true
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,6 +0,0 @@
test.service:
files:
/etc/file: {}
/etc/file2:
engine: jinja
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,8 +0,0 @@
test.service:
files:
/etc/file: {}
/etc/file2:
engine: jinja
/etc/dir/incfile:
included: content
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,8 +0,0 @@
test.service:
files:
/etc/file: {}
/etc/file2:
engine: jinja
/etc/dir/incfile:
included: name
version: '1.1'

View file

@ -1,5 +0,0 @@
test.service:
files:
/etc/file:
mode: 755
version: '1.1'

View file

@ -1,5 +0,0 @@
test.service:
files:
/etc/file:
mode: 1755
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,10 +0,0 @@
test.service:
files:
/etc/file:
owner: nobody
group: nobody
/etc/file2:
owner: nobody
group: nobody
engine: jinja
version: '1.1'

View file

@ -1,6 +1,6 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
owner:
@ -9,4 +9,3 @@ general:
group:
type: unix_user
default: nobody
version: '1.1'

View file

@ -1,18 +0,0 @@
test.service:
files:
/etc/file:
owner:
name: rougail.general.owner
type: variable
group:
name: rougail.general.group
type: variable
/etc/file2:
owner:
name: rougail.general.owner
type: variable
group:
name: rougail.general.group
type: variable
engine: jinja
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,6 +0,0 @@
test.service:
files:
/etc/file: {}
/etc/file2:
engine: jinja
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,6 +0,0 @@
test.service:
files:
/etc/file: {}
/etc/file2:
engine: jinja
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,6 +0,0 @@
test.service:
files:
/etc/file: {}
/etc/file2:
engine: jinja
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,6 +0,0 @@
test.service:
files:
/etc/systemd-makefs@dev-disk-by\x2dpartlabel: {}
/etc/systemd-makefs@dev-disk-by\x2dpartlabel2:
engine: jinja
version: '1.1'

View file

@ -1,10 +1,8 @@
version: 1.1
general:
source_var:
type: string
description: Description
default: file
mode_conteneur_actif:
type: string
description: Description
default: non
version: '1.1'

View file

@ -1,7 +0,0 @@
test.service:
files:
/etc/file:
source:
name: rougail.general.source_var
type: variable
version: '1.1'

View file

@ -1,12 +1,9 @@
version: 1.1
general:
float:
type: float
description: Description
default: 0.527
float_multi:
type: float
description: Description
multi: true
default:
- 0.527
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
@ -9,4 +10,3 @@ general:
description: Redefine description
help: message with "
mandatory: false
version: '1.1'

View file

@ -1,9 +1,7 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Redefine description
hidden: true
multi: true
default:
- non
version: '1.1'

View file

@ -1,10 +1,8 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Redefine description
hidden: true
multi: true
unique: false
default:
- non
version: '1.1'

View file

@ -1,10 +1,8 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Redefine description
hidden: true
multi: true
unique: true
default:
- non
version: '1.1'

View file

@ -1,13 +1,10 @@
version: 1.1
general:
float:
type: float
description: Description
provider: float
default: 0.527
float_multi:
type: float
description: Description
multi: true
default:
- 0.527
version: '1.1'

View file

@ -1,6 +1,6 @@
version: 1.1
example:
description:
type: string
provider: example
mandatory: false
version: '1.1'

View file

@ -1,5 +1,5 @@
version: 1.1
float:
type: float
description: Description
mandatory: false
version: '1.1'

View file

@ -1,14 +1,11 @@
version: 1.1
general:
float:
type: float
description: Description
provider: float
hidden: true
default: 0.527
float_multi:
type: float
description: Description
multi: true
default:
- 0.527
version: '1.1'

View file

@ -1,7 +1,6 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Redefine description
hidden: true
default: quote"
version: '1.1'

View file

@ -1,7 +1,6 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Redefine description
hidden: true
default: quote'"
version: '1.1'

View file

@ -1,7 +1,6 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Redefine description
hidden: true
default: quote\"\'
version: '1.1'

View file

@ -1,9 +1,7 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Redefine description
hidden: true
multi: true
default:
- quote"
version: '1.1'

View file

@ -1,9 +1,7 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Redefine description
hidden: true
multi: true
default:
- quote'"
version: '1.1'

View file

@ -1,9 +1,7 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Redefine description
hidden: true
multi: true
default:
- quote'
version: '1.1'

View file

@ -1,7 +1,6 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: Redefine description
hidden: true
default: quote'
version: '1.1'

View file

@ -1,6 +1,5 @@
version: 1.1
general:
general:
type: string
description: description
default: non
version: '1.1'

View file

@ -1,4 +1,4 @@
version: 1.1
my_variable:
type: boolean
mandatory: false
version: '1.1'

View file

@ -1,5 +1,5 @@
version: 1.1
general:
description: Other description
mode_conteneur_actif:
default: non
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
my_var1:
type: string
default:
@ -6,6 +7,4 @@ my_var1:
my_var2:
default: no
server_deployed:
type: boolean
default: false
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
server_deployed:
type: boolean
general:
@ -9,7 +10,5 @@ general:
type: jinja
jinja: '{{ rougail.general.mode_conteneur_actif1 | calc_val }}'
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,13 +1,11 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: No change
mandatory: false
default:
type: jinja
jinja: '{{ rougail.general.mode_conteneur_actif1 | calc_val }}'
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,15 +1,13 @@
version: 1.1
general:
mode: basic
mode_conteneur_actif:
type: string
description: No change
mandatory: true
mode: advanced
default:
type: jinja
jinja: '{{ rougail.general.mode_conteneur_actif1 | calc_val }}'
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,14 +1,12 @@
version: 1.1
general:
mode_conteneur_actif:
type: number
description: No change
hidden: true
mandatory: false
default:
type: jinja
jinja: '{{ 3 | calc_val }}'
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
@ -5,14 +6,12 @@ general:
hidden: true
default:
type: jinja
jinja: '{{ __mode_conteneur_actif4 | calc_val }}'
jinja: '{{ mode_conteneur_actif4 | calc_val }}'
params:
__mode_conteneur_actif4:
mode_conteneur_actif4:
type: variable
variable: __mode_conteneur_actif4
variable: mode_conteneur_actif4
optional: true
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
@ -5,19 +6,17 @@ general:
hidden: true
default:
type: jinja
jinja: '{{ __mode_conteneur_actif4 | calc_val(rougail.general.mode_conteneur_actif1,
__mode_conteneur_actif3) }}'
jinja: '{{ mode_conteneur_actif4 | calc_val(rougail.general.mode_conteneur_actif1,
mode_conteneur_actif3) }}'
params:
__mode_conteneur_actif4:
mode_conteneur_actif4:
type: variable
variable: __mode_conteneur_actif4
variable: mode_conteneur_actif4
optional: true
__mode_conteneur_actif3:
mode_conteneur_actif3:
type: variable
variable: __mode_conteneur_actif3
variable: mode_conteneur_actif3
optional: true
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,30 +1,26 @@
version: 1.1
general:
mode_conteneur_actif:
type: string
description: No change
mandatory: false
default:
type: jinja
jinja: "{{ \"quote'\" | calc_val }}"
mode_conteneur_actif1:
type: string
description: No change
mandatory: false
default:
type: jinja
jinja: '{{ "quote\"" | calc_val }}'
mode_conteneur_actif2:
type: string
description: No change
mandatory: false
default:
type: jinja
jinja: "{{ \"quote\\\"'\" | calc_val }}"
mode_conteneur_actif3:
type: string
description: No change
mandatory: false
default:
type: jinja
jinja: "{{ \"quote\\\"\\\\'\" | calc_val }}"
version: '1.1'

View file

@ -1,6 +0,0 @@
{
"rougail.general.mode_conteneur_actif1": {
"owner": "default",
"value": "non"
}
}

View file

@ -1,3 +0,0 @@
{
"rougail.general.mode_conteneur_actif1": "non"
}

View file

@ -1,6 +0,0 @@
{
"rougail.general.mode_conteneur_actif1": {
"owner": "default",
"value": "non"
}
}

View file

@ -1,6 +0,0 @@
general:
mode_conteneur_actif1:
type: string
description: No change
default: non
version: '1.1'

View file

@ -1,29 +0,0 @@
from importlib.machinery import SourceFileLoader as _SourceFileLoader
from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
class func:
pass
def _load_functions(path):
global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
loader = _SourceFileLoader('func', path)
spec = _spec_from_loader(loader.name, loader)
func_ = _module_from_spec(spec)
loader.exec_module(func_)
for function in dir(func_):
if function.startswith('_'):
continue
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries_old/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_3 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"}))
optiondescription_2 = OptionDescription(name="general", doc="general", children=[option_3], properties=frozenset({"normal"}))
optiondescription_1 = OptionDescription(name="rougail", doc="rougail", children=[optiondescription_2], properties=frozenset({"normal"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,34 +0,0 @@
from importlib.machinery import SourceFileLoader as _SourceFileLoader
from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
class func:
pass
def _load_functions(path):
global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
loader = _SourceFileLoader('func', path)
spec = _spec_from_loader(loader.name, loader)
func_ = _module_from_spec(spec)
loader.exec_module(func_)
for function in dir(func_):
if function.startswith('_'):
continue
setattr(func, function, getattr(func_, function))
_load_functions('tests/dictionaries/../eosfunc/test.py')
try:
from tiramisu4 import *
from tiramisu4.setting import ALLOWED_LEADER_PROPERTIES
except:
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("normal")
ALLOWED_LEADER_PROPERTIES.add("expert")
option_2 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"}))
optiondescription_1 = OptionDescription(name="general", doc="general", children=[option_2], properties=frozenset({"normal"}))
optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_1], properties=frozenset({"normal"}))
optiondescription_5 = OptionDescription(name="1", doc="1", children=[optiondescription_6])
option_4 = StrOption(name="mode_conteneur_actif1", doc="No change", default="non", properties=frozenset({"mandatory", "normal"}))
optiondescription_3 = OptionDescription(name="general", doc="general", children=[option_4], properties=frozenset({"normal"}))
optiondescription_8 = OptionDescription(name="rougail", doc="Rougail", children=[optiondescription_3], properties=frozenset({"normal"}))
optiondescription_7 = OptionDescription(name="2", doc="2", children=[optiondescription_8])
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_5, optiondescription_7])

View file

@ -1,16 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<variables>
<family name="general">
<variable name="mode_conteneur_actif1" type="string" description="No change">
<value>non</value>
</variable>
</family>
</variables>
<constraints>
<fill name="calc_val">
<param type="variable">mode_conteneur_actif1</param>
<target optional="True">mode_conteneur_actif</target>
</fill>
</constraints>
</rougail>

View file

@ -1,20 +0,0 @@
version: '0.10'
variables:
- family:
- name: general
variables:
- variable:
- name: mode_conteneur_actif1
type: string
description: No change
value:
- text: non
constraints:
- fill:
- name: calc_val
param:
- type: variable
text: mode_conteneur_actif1
target:
- optional: true
text: mode_conteneur_actif

View file

@ -1,5 +1,5 @@
version: 1.1
server_deployed:
type: boolean
default: false
my_var:
type: string
@ -9,4 +9,3 @@ my_var:
hidden:
type: jinja
jinja: '{% if rougail.server_deployed == true %}hidden{% endif %}'
version: '1.1'

View file

@ -1,6 +1,6 @@
version: 1.1
general:
mode_conteneur_actif:
test:
- test
default: non
version: '1.1'

View file

@ -1,7 +1,7 @@
version: 1.1
general:
mode_conteneur_actif:
test:
- test1
- test2
default: non
version: '1.1'

View file

@ -1,3 +1,4 @@
version: 1.1
general:
mode_conteneur_actif:
test:
@ -5,4 +6,3 @@ general:
- test1
- test2
default: non
version: '1.1'

View file

@ -1,6 +1,6 @@
version: 1.1
general:
mode_conteneur_actif:
test:
- test
default: non
version: '1.1'

View file

@ -1,6 +1,6 @@
version: 1.1
general:
mode_conteneur_actif:
redefine: true
test:
- test1
version: '1.1'

View file

@ -1,4 +1,4 @@
version: 1.1
my_variable:
type: string
mandatory: false
version: '1.1'

View file

@ -1,5 +1,5 @@
version: 1.1
my_variable:
redefine: true
test:
- test1
version: '1.1'

View file

@ -1,6 +1,6 @@
version: 1.1
general:
mode_conteneur_actif:
test:
- test
default: non
version: '1.1'

View file

@ -1,6 +1,6 @@
version: 1.1
general:
mode_conteneur_actif:
redefine: true
test:
-
version: '1.1'

View file

@ -1,9 +1,9 @@
version: 1.1
server_deployed:
type: boolean
general:
description: général
mode_conteneur_actif:
type: string
description: No change
hidden: true
default: non
@ -11,7 +11,6 @@ general:
type: string
description: autosave variable
auto_save: true
mandatory: false
hidden:
type: jinja
jinja: '{% if rougail.general.mode_conteneur_actif == "oui" %}hidden{% endif
@ -19,4 +18,3 @@ general:
default:
type: jinja
jinja: '{{ "oui" | calc_val }}'
version: '1.1'

Some files were not shown because too many files have changed in this diff Show more