<file> is not necessarily a template + add <override> tag to override systemd service

This commit is contained in:
Emmanuel Garette 2020-04-23 07:34:34 +02:00
parent d47d1fde62
commit 5b4b43d5f4
61 changed files with 438 additions and 57 deletions

View File

@ -242,8 +242,11 @@ class ServiceAnnotator:
)
return variable
def _update_override(self, file_, index, service_path):
self._update_file(file_, index, service_path)
def _update_file(self, file_, index, service_path):
if file_.file_type == "UnicodeOption":
if not hasattr(file_, 'file_type') or file_.file_type == "UnicodeOption":
if not hasattr(file_, 'source'):
file_.source = basename(file_.name)
elif not hasattr(file_, 'source'):

View File

@ -66,7 +66,7 @@
<!ELEMENT services (service*)>
<!ELEMENT service ((port* | tcpwrapper* | ip* | interface* | package* | file* | digitalcertificate*)*) >
<!ELEMENT service ((port* | tcpwrapper* | ip* | interface* | package* | file* | digitalcertificate* | override*)*) >
<!ATTLIST service name CDATA #REQUIRED>
<!ATTLIST service method (systemd|none) "systemd">
@ -109,6 +109,7 @@
<!ATTLIST file mkdir (True|False) "False">
<!ATTLIST file rm (True|False) "False">
<!ATTLIST file redefine (True|False) "False">
<!ATTLIST file templating (True|False) "True">
<!ELEMENT digitalcertificate EMPTY>
<!ATTLIST digitalcertificate name CDATA #REQUIRED >
@ -118,6 +119,10 @@
<!ATTLIST digitalcertificate type CDATA #REQUIRED >
<!ATTLIST digitalcertificate ca CDATA #REQUIRED >
<!ELEMENT override EMPTY>
<!ATTLIST override name CDATA #REQUIRED >
<!ATTLIST override templating (True|False) "True">
<!ELEMENT variables (family*, separators*)>
<!ELEMENT family (#PCDATA | variable)*>
<!ATTLIST family name CDATA #REQUIRED>

View File

@ -261,11 +261,14 @@ class CreoleTemplateEngine:
eosfunc_file: str,
distrib_dir: str,
tmp_dir: str,
dest_dir:str) -> None:
dest_dir: str,
tmpfile_name: str,
) -> None:
self.config = config
self.dest_dir = dest_dir
self.tmp_dir = tmp_dir
self.distrib_dir = distrib_dir
self.tmpfile_name = tmpfile_name
eos = {}
if eosfunc_file is not None:
eosfunc = imp.load_source('eosfunc', eosfunc_file)
@ -342,6 +345,7 @@ class CreoleTemplateEngine:
self.patch_template(filename)
def process(self,
source: str,
destfilename: str,
filevar: Dict,
variable: Any):
@ -350,8 +354,7 @@ class CreoleTemplateEngine:
# full path of the destination file
log.info(_(f"Cheetah processing: '{destfilename}'"))
try:
cheetah_template = CheetahTemplate(join(self.tmp_dir,
filevar['source']),
cheetah_template = CheetahTemplate(source,
self.creole_variables_dict,
self.eosfunc,
destfilename,
@ -368,15 +371,20 @@ class CreoleTemplateEngine:
def instance_file(self,
filevar: Dict,
systemd_rights: list) -> None:
systemd_rights: list,
override: bool,
service_name: str) -> None:
"""Run templatisation on one file
"""
log.info(_("Instantiating file '{filename}'"))
filenames = filevar['name']
if 'variable' in filevar:
variable = filevar['variable']
else:
variable = None
if override:
filenames = [f'/system/{service_name}.service.d/rougail.conf']
else:
filenames = filevar['name']
if not isinstance(filenames, list):
filenames = [filenames]
if variable:
@ -389,9 +397,15 @@ class CreoleTemplateEngine:
var = variable[idx]
else:
var = None
self.process(destfilename,
source = join(self.tmp_dir, filevar['source'])
if filevar['templating']:
self.process(source,
destfilename,
filevar,
var)
else:
copy(source, destfilename)
if not override and self.tmpfile_name:
systemd_rights.append(f'C {filename} {filevar["mode"]} {filevar["owner"]} {filevar["group"]} - -')
systemd_rights.append(f'z {filename} - - - - -')
@ -411,21 +425,27 @@ class CreoleTemplateEngine:
self.prepare_template(join(self.distrib_dir, template))
systemd_rights = []
for service_obj in await self.config.option('services').list('all'):
service_name = await service_obj.option.doc()
for fills in await service_obj.list('all'):
if await fills.option.name() == 'files':
if await fills.option.name() in ['files', 'overrides']:
for fill_obj in await fills.list('all'):
fill = await fill_obj.value.dict()
filename = fill['source']
distib_file = join(self.distrib_dir, filename)
if not isfile(distib_file):
raise FileNotFound(_(f"File {distib_file} does not exist."))
if fill.get('activate', False):
override = await fills.option.name() == 'overrides'
if override or fill.get('activate', False):
self.instance_file(fill,
systemd_rights)
systemd_rights,
override,
service_name,
)
else:
log.debug(_("Instantiation of file '{filename}' disabled"))
with open(join(self.dest_dir, 'rougail.conf'), 'w') as fh:
if self.tmpfile_name:
with open(self.tmpfile_name, 'w') as fh:
fh.write('\n'.join(systemd_rights))
fh.write('\n')
@ -434,10 +454,12 @@ async def generate(config: Config,
eosfunc_file: str,
distrib_dir: str,
tmp_dir: str,
dest_dir: str) -> None:
dest_dir: str,
tmpfile_name: str=None) -> None:
engine = CreoleTemplateEngine(config,
eosfunc_file,
distrib_dir,
tmp_dir,
dest_dir)
dest_dir,
tmpfile_name)
await engine.instance_files()

View File

@ -3,7 +3,7 @@
<services>
<service name="test">
<file name="/tmp/file" filelist="afilllist"/>
<file name="/etc/file" filelist="afilllist"/>
</service>
</services>

View File

@ -1 +1 @@
{"creole.general.condition": "non", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.activate": true}
{"creole.general.condition": "non", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true}

View File

@ -18,7 +18,7 @@
</variable>
<variable doc="" multi="False" name="name" type="string">
<property>mandatory</property>
<value>/tmp/file</value>
<value>/etc/file</value>
</variable>
<variable doc="" multi="False" name="owner" type="string">
<property>mandatory</property>
@ -32,6 +32,10 @@
<property>mandatory</property>
<value>file</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property>

View File

@ -3,7 +3,7 @@
<services>
<service name="test">
<file name="/tmp/file" filelist="afilllist"/>
<file name="/etc/file" filelist="afilllist"/>
</service>
</services>

View File

@ -1 +1 @@
{"creole.general.condition": "oui", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file"}
{"creole.general.condition": "oui", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true}

View File

@ -18,7 +18,7 @@
</variable>
<variable doc="" multi="False" name="name" type="string">
<property>mandatory</property>
<value>/tmp/file</value>
<value>/etc/file</value>
</variable>
<variable doc="" multi="False" name="owner" type="string">
<property>mandatory</property>
@ -32,6 +32,10 @@
<property>mandatory</property>
<value>file</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property>

View File

@ -1 +1 @@
{"creole.general.condition": "non", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file1", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file1", "services.service0.files.file0.activate": true, "services.service0.files.file1.group": "root", "services.service0.files.file1.mkdir": false, "services.service0.files.file1.mode": "0644", "services.service0.files.file1.name": "/tmp/file2", "services.service0.files.file1.owner": "root", "services.service0.files.file1.rm": false, "services.service0.files.file1.source": "file2", "services.service0.files.file1.activate": true}
{"creole.general.condition": "non", "creole.general.mode_conteneur_actif": "non", "creole.general.mode_conteneur_actif2": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file1", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file1", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true, "services.service0.files.file1.group": "root", "services.service0.files.file1.mkdir": false, "services.service0.files.file1.mode": "0644", "services.service0.files.file1.name": "/tmp/file2", "services.service0.files.file1.owner": "root", "services.service0.files.file1.rm": false, "services.service0.files.file1.source": "file2", "services.service0.files.file1.templating": true, "services.service0.files.file1.activate": true}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>file1</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property>
@ -67,6 +71,10 @@
<property>mandatory</property>
<value>file2</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property>

View File

@ -1 +1 @@
{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file"}
{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>file</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>disabled</property>
<property>mandatory</property>

View File

@ -1 +1 @@
{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file"}
{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>file</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>disabled</property>
<property>mandatory</property>

View File

@ -1 +1 @@
{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file"}
{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>file</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>disabled</property>
<property>mandatory</property>

View File

@ -1 +1 @@
{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file"}
{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": true}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>file</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<property expected="statique" inverse="True" source="creole.general.condition" type="calculation">disabled</property>

View File

@ -1 +1 @@
{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file1", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file1"}
{"creole.general.condition": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/tmp/file1", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file1", "services.service0.files.file0.templating": true}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>file1</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>disabled</property>
<property>mandatory</property>

View File

@ -0,0 +1,20 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services>
<service name="test">
<file name="/etc/file" templating="False"/>
</service>
</services>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
</family>
<separators/>
</variables>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1 @@
{"creole.general.mode_conteneur_actif": "non", "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/file", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "file", "services.service0.files.file0.templating": false, "services.service0.files.file0.activate": true}

View File

@ -0,0 +1,61 @@
<?xml version='1.0' encoding='UTF-8'?>
<creole>
<family name="services">
<family name="service0" doc="test">
<family doc="files" name="files">
<family doc="file0" name="file0">
<variable doc="" multi="False" name="group" type="string">
<property>mandatory</property>
<value>root</value>
</variable>
<variable doc="" multi="False" name="mkdir" type="boolean">
<property>mandatory</property>
<value>False</value>
</variable>
<variable doc="" multi="False" name="mode" type="string">
<property>mandatory</property>
<value>0644</value>
</variable>
<variable doc="" multi="False" name="name" type="string">
<property>mandatory</property>
<value>/etc/file</value>
</variable>
<variable doc="" multi="False" name="owner" type="string">
<property>mandatory</property>
<value>root</value>
</variable>
<variable doc="" multi="False" name="rm" type="boolean">
<property>mandatory</property>
<value>False</value>
</variable>
<variable doc="" multi="False" name="source" type="string">
<property>mandatory</property>
<value>file</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>False</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
</family>
</family>
<property>basic</property>
</family>
</family>
<family doc="" name="creole">
<family doc="general" name="general">
<property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice>
<choice type="string">non</choice>
<property>mandatory</property>
<property>normal</property>
<value type="string">non</value>
</variable>
</family>
<separators/>
</family>
</creole>

View File

@ -0,0 +1,20 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<services>
<service name="test">
<override name="test.service"/>
</service>
</services>
<variables>
<family name="general">
<variable name="mode_conteneur_actif" type="oui/non" description="No change">
<value>non</value>
</variable>
</family>
<separators/>
</variables>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->

View File

@ -0,0 +1 @@
{"creole.general.mode_conteneur_actif": "non", "services.service0.overrides.override0.name": "test.service", "services.service0.overrides.override0.source": "test.service", "services.service0.overrides.override0.templating": true, "services.service0.overrides.override0.activate": true}

View File

@ -0,0 +1,41 @@
<?xml version='1.0' encoding='UTF-8'?>
<creole>
<family name="services">
<family name="service0" doc="test">
<family doc="overrides" name="overrides">
<family doc="override0" name="override0">
<variable doc="" multi="False" name="name" type="string">
<property>mandatory</property>
<value>test.service</value>
</variable>
<variable doc="" multi="False" name="source" type="string">
<property>mandatory</property>
<value>test.service</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
</family>
</family>
<property>basic</property>
</family>
</family>
<family doc="" name="creole">
<family doc="general" name="general">
<property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice>
<choice type="string">non</choice>
<property>mandatory</property>
<property>normal</property>
<value type="string">non</value>
</variable>
</family>
<separators/>
</family>
</creole>

View File

@ -1 +1 @@
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true, "extra.ejabberd.description.description": ["test"], "extra.ejabberd.description.mode": ["pre"]}
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true, "extra.ejabberd.description.description": ["test"], "extra.ejabberd.description.mode": ["pre"]}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>

View File

@ -1 +1 @@
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true, "extra.ejabberd.description": "Exportation de la base de ejabberd", "extra.ejabberd.day": null, "extra.ejabberd.mode": "pre"}
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true, "extra.ejabberd.description": "Exportation de la base de ejabberd", "extra.ejabberd.day": null, "extra.ejabberd.mode": "pre"}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>

View File

@ -1 +1 @@
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true}
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>

View File

@ -1 +1 @@
{"creole.general.file_name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true}
{"creole.general.file_name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true}

View File

@ -31,6 +31,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>

View File

@ -1 +1 @@
{"creole.general.file_name": ["/etc/mailname", "/etc/mailname2"], "creole.general.var": ["mailname", "mailname2"], "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.variable": ["mailname", "mailname2"], "services.service0.files.file0.activate": true}
{"creole.general.file_name": ["/etc/mailname", "/etc/mailname2"], "creole.general.var": ["mailname", "mailname2"], "services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": ["/etc/mailname", "/etc/mailname2"], "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.variable": ["mailname", "mailname2"], "services.service0.files.file0.activate": true}

View File

@ -31,6 +31,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable multi="False" name="variable" opt="creole.general.var" type="symlink">
<property>mandatory</property>
</variable>

View File

@ -1 +1 @@
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true, "services.service0.files.file1.group": "root", "services.service0.files.file1.mkdir": false, "services.service0.files.file1.mode": "0644", "services.service0.files.file1.name": "/etc/mailname2", "services.service0.files.file1.owner": "root", "services.service0.files.file1.rm": false, "services.service0.files.file1.source": "mailname2", "services.service0.files.file1.activate": true}
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true, "services.service0.files.file1.group": "root", "services.service0.files.file1.mkdir": false, "services.service0.files.file1.mode": "0644", "services.service0.files.file1.name": "/etc/mailname2", "services.service0.files.file1.owner": "root", "services.service0.files.file1.rm": false, "services.service0.files.file1.source": "mailname2", "services.service0.files.file1.templating": true, "services.service0.files.file1.activate": true}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>
@ -66,6 +70,10 @@
<property>mandatory</property>
<value>mailname2</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>

View File

@ -1 +1 @@
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname.new", "services.service0.files.file0.activate": true}
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": false, "services.service0.files.file0.source": "mailname.new", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>mailname.new</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>

View File

@ -1 +1 @@
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": true, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.activate": true}
{"services.service0.files.file0.group": "root", "services.service0.files.file0.mkdir": false, "services.service0.files.file0.mode": "0644", "services.service0.files.file0.name": "/etc/mailname", "services.service0.files.file0.owner": "root", "services.service0.files.file0.rm": true, "services.service0.files.file0.source": "mailname", "services.service0.files.file0.templating": true, "services.service0.files.file0.activate": true}

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>file</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property>

View File

@ -18,7 +18,7 @@
</variable>
<variable doc="" multi="False" name="name" type="string">
<property>mandatory</property>
<value>/tmp/file</value>
<value>/etc/file</value>
</variable>
<variable doc="" multi="False" name="owner" type="string">
<property>mandatory</property>
@ -32,6 +32,10 @@
<property>mandatory</property>
<value>file</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<property expected="oui" inverse="False" source="creole.general.condition" type="calculation">disabled</property>

View File

@ -0,0 +1,61 @@
<?xml version='1.0' encoding='UTF-8'?>
<creole>
<family name="services">
<family name="service0" doc="test">
<family doc="files" name="files">
<family doc="file0" name="file0">
<variable doc="" multi="False" name="group" type="string">
<property>mandatory</property>
<value>root</value>
</variable>
<variable doc="" multi="False" name="mkdir" type="boolean">
<property>mandatory</property>
<value>False</value>
</variable>
<variable doc="" multi="False" name="mode" type="string">
<property>mandatory</property>
<value>0644</value>
</variable>
<variable doc="" multi="False" name="name" type="string">
<property>mandatory</property>
<value>/etc/file</value>
</variable>
<variable doc="" multi="False" name="owner" type="string">
<property>mandatory</property>
<value>root</value>
</variable>
<variable doc="" multi="False" name="rm" type="boolean">
<property>mandatory</property>
<value>False</value>
</variable>
<variable doc="" multi="False" name="source" type="string">
<property>mandatory</property>
<value>file</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>False</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
</family>
</family>
<property>basic</property>
</family>
</family>
<family doc="" name="creole">
<family doc="general" name="general">
<property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice>
<choice type="string">non</choice>
<property>mandatory</property>
<property>normal</property>
<value type="string">non</value>
</variable>
</family>
<separators/>
</family>
</creole>

View File

@ -0,0 +1 @@
%%condition

View File

@ -0,0 +1,2 @@
C /etc/file 0644 root root - -
z /etc/file - - - - -

View File

@ -0,0 +1 @@
%%condition

View File

@ -0,0 +1,41 @@
<?xml version='1.0' encoding='UTF-8'?>
<creole>
<family name="services">
<family name="service0" doc="test">
<family doc="overrides" name="overrides">
<family doc="override0" name="override0">
<variable doc="" multi="False" name="name" type="string">
<property>mandatory</property>
<value>test.service</value>
</variable>
<variable doc="" multi="False" name="source" type="string">
<property>mandatory</property>
<value>test.service</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
</family>
</family>
<property>basic</property>
</family>
</family>
<family doc="" name="creole">
<family doc="general" name="general">
<property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice>
<choice type="string">non</choice>
<property>mandatory</property>
<property>normal</property>
<value type="string">non</value>
</variable>
</family>
<separators/>
</family>
</creole>

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
%%mode_conteneur_actif

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>

View File

@ -32,6 +32,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>

View File

@ -31,6 +31,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<property>mandatory</property>
<value>True</value>

View File

@ -31,6 +31,10 @@
<property>mandatory</property>
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="templating" type="boolean">
<property>mandatory</property>
<value>True</value>
</variable>
<variable multi="False" name="variable" opt="creole.general.var" type="symlink">
<property>mandatory</property>
</variable>

View File

@ -83,7 +83,7 @@ def launch_flattener(test_dir, test_ok=False):
eolobj.save(destfile)
result_file = join(test_dir, 'result/00-base.xml')
if isfile(result_file):
# eolobj.save(result_file)
eolobj.save(result_file)
compare_xml(destfile, result_file)
elif test_ok:
raise Exception(f'no test found for {test_dir}')

View File

@ -50,12 +50,12 @@ async def launch_flattener(test_dir):
await config.property.read_write()
config_dict = await config.value.dict()
# if not isfile(makedict_file) and config_dict:
#if config_dict:
# if not isdir(makedict_dir):
# mkdir(makedict_dir)
# with open(makedict_file, 'w') as fh:
# dump(config_dict, fh)
# fh.write('\n')
if config_dict:
if not isdir(makedict_dir):
mkdir(makedict_dir)
with open(makedict_file, 'w') as fh:
dump(config_dict, fh)
fh.write('\n')
if not isfile(makedict_file):
if config_dict:
raise Exception('dict is not empty')

View File

@ -54,10 +54,11 @@ async def test_dictionary(test_dir):
funcs_file,
distrib_dir,
tmp_dir,
dest_dir)
dest_dir,
join(dest_dir, 'rougail.conf'))
list_templates = set()
if isdir(join(dest_dir, 'etc')):
if isdir(dest_dir):
find_files(join(dest_dir), [], list_templates)
list_results = set()
if isdir(join(test_dir, 'result')):