can disabled a file
This commit is contained in:
parent
703250c34f
commit
757d9ec5c2
14 changed files with 166 additions and 3 deletions
|
@ -107,7 +107,13 @@ Il est possible de personnaliser les droits par défaut dans la [configuration d
|
||||||
|
|
||||||
## Désactiver la génération d'un fichier
|
## Désactiver la génération d'un fichier
|
||||||
|
|
||||||
Il est possible de définir une [condition](../condition/README.md) de type "disabled_if_in" ou "disabled_if_not_in" sur une balise fichier :
|
Il est possible de désactiver la génération d'un fichier avec l'attribut "disabled" :
|
||||||
|
|
||||||
|
```
|
||||||
|
<file disabled="True">/etc/squid/squid.conf</file>
|
||||||
|
```
|
||||||
|
|
||||||
|
Il est aussi possible de définir une [condition](../condition/README.md) de type "disabled_if_in" ou "disabled_if_not_in" sur une balise fichier :
|
||||||
|
|
||||||
```
|
```
|
||||||
<services>
|
<services>
|
||||||
|
|
|
@ -33,7 +33,7 @@ from rougail.error import DictConsistencyError
|
||||||
# a object's attribute has some annotations
|
# a object's attribute has some annotations
|
||||||
# that shall not be present in the exported (flatened) XML
|
# that shall not be present in the exported (flatened) XML
|
||||||
ERASED_ATTRIBUTES = ('redefine', 'namespace', 'xmlfiles', 'disabled', 'name', 'manage')
|
ERASED_ATTRIBUTES = ('redefine', 'namespace', 'xmlfiles', 'disabled', 'name', 'manage')
|
||||||
ERASED_ATTRIBUTES2 = ('redefine', 'namespace', 'xmlfiles')
|
ERASED_ATTRIBUTES2 = ('redefine', 'namespace', 'xmlfiles', 'disabled')
|
||||||
ALLOW_ATTRIBUT_NOT_MANAGE = ['file', 'engine', 'target']
|
ALLOW_ATTRIBUT_NOT_MANAGE = ['file', 'engine', 'target']
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,11 +152,15 @@ class Annotator:
|
||||||
elt.xmlfiles,
|
elt.xmlfiles,
|
||||||
)
|
)
|
||||||
family.variable = []
|
family.variable = []
|
||||||
|
if hasattr(elt, 'disabled'):
|
||||||
|
disabled = elt.disabled
|
||||||
|
else:
|
||||||
|
disabled = False
|
||||||
activate_obj = self._generate_element('boolean',
|
activate_obj = self._generate_element('boolean',
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
'activate',
|
'activate',
|
||||||
True,
|
not disabled,
|
||||||
elt,
|
elt,
|
||||||
'.'.join([subpath, 'activate']),
|
'.'.join([subpath, 'activate']),
|
||||||
)
|
)
|
||||||
|
|
|
@ -74,6 +74,7 @@
|
||||||
<!ATTLIST file redefine (True|False) "False">
|
<!ATTLIST file redefine (True|False) "False">
|
||||||
<!ATTLIST file engine (none|creole|jinja2|creole_legacy) #IMPLIED>
|
<!ATTLIST file engine (none|creole|jinja2|creole_legacy) #IMPLIED>
|
||||||
<!ATTLIST file included (no|name|content) #IMPLIED>
|
<!ATTLIST file included (no|name|content) #IMPLIED>
|
||||||
|
<!ATTLIST file disabled (True|False) "False">
|
||||||
|
|
||||||
<!ELEMENT override EMPTY>
|
<!ELEMENT override EMPTY>
|
||||||
<!ATTLIST override source CDATA #IMPLIED>
|
<!ATTLIST override source CDATA #IMPLIED>
|
||||||
|
|
17
tests/dictionaries/01base_file_disabled/00-base.xml
Normal file
17
tests/dictionaries/01base_file_disabled/00-base.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<rougail version="0.10">
|
||||||
|
<services>
|
||||||
|
<service name="test">
|
||||||
|
<file>/etc/file</file>
|
||||||
|
<file engine="jinja2">/etc/file2</file>
|
||||||
|
<file disabled='True'>/etc/file3</file>
|
||||||
|
</service>
|
||||||
|
</services>
|
||||||
|
<variables>
|
||||||
|
<family name="general">
|
||||||
|
<variable name="mode_conteneur_actif" type="string" description="Description">
|
||||||
|
<value>non</value>
|
||||||
|
</variable>
|
||||||
|
</family>
|
||||||
|
</variables>
|
||||||
|
</rougail>
|
0
tests/dictionaries/01base_file_disabled/__init__.py
Normal file
0
tests/dictionaries/01base_file_disabled/__init__.py
Normal file
38
tests/dictionaries/01base_file_disabled/makedict/after.json
Normal file
38
tests/dictionaries/01base_file_disabled/makedict/after.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"rougail.general.mode_conteneur_actif": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "non"
|
||||||
|
},
|
||||||
|
"services.test.files.file.name": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "/etc/file"
|
||||||
|
},
|
||||||
|
"services.test.files.file.activate": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"services.test.files.file2.name": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "/etc/file2"
|
||||||
|
},
|
||||||
|
"services.test.files.file2.activate": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"services.test.files.file3.name": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "/etc/file3"
|
||||||
|
},
|
||||||
|
"services.test.files.file3.activate": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"services.test.activate": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"services.test.manage": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
}
|
11
tests/dictionaries/01base_file_disabled/makedict/base.json
Normal file
11
tests/dictionaries/01base_file_disabled/makedict/base.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"rougail.general.mode_conteneur_actif": "non",
|
||||||
|
"services.test.files.file.name": "/etc/file",
|
||||||
|
"services.test.files.file.activate": true,
|
||||||
|
"services.test.files.file2.name": "/etc/file2",
|
||||||
|
"services.test.files.file2.activate": true,
|
||||||
|
"services.test.files.file3.name": "/etc/file3",
|
||||||
|
"services.test.files.file3.activate": false,
|
||||||
|
"services.test.activate": true,
|
||||||
|
"services.test.manage": true
|
||||||
|
}
|
38
tests/dictionaries/01base_file_disabled/makedict/before.json
Normal file
38
tests/dictionaries/01base_file_disabled/makedict/before.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"rougail.general.mode_conteneur_actif": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "non"
|
||||||
|
},
|
||||||
|
"services.test.files.file.name": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "/etc/file"
|
||||||
|
},
|
||||||
|
"services.test.files.file.activate": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"services.test.files.file2.name": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "/etc/file2"
|
||||||
|
},
|
||||||
|
"services.test.files.file2.activate": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"services.test.files.file3.name": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": "/etc/file3"
|
||||||
|
},
|
||||||
|
"services.test.files.file3.activate": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"services.test.activate": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"services.test.manage": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
}
|
2
tests/dictionaries/01base_file_disabled/result/etc/file
Normal file
2
tests/dictionaries/01base_file_disabled/result/etc/file
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
non
|
||||||
|
non
|
2
tests/dictionaries/01base_file_disabled/result/etc/file2
Normal file
2
tests/dictionaries/01base_file_disabled/result/etc/file2
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
non
|
||||||
|
non
|
|
@ -0,0 +1,2 @@
|
||||||
|
C /etc/file 0644 root root - /usr/local/lib/etc/file
|
||||||
|
C /etc/file2 0644 root root - /usr/local/lib/etc/file2
|
38
tests/dictionaries/01base_file_disabled/tiramisu/base.py
Normal file
38
tests/dictionaries/01base_file_disabled/tiramisu/base.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
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
|
||||||
|
_loader = _SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py')
|
||||||
|
_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))
|
||||||
|
try:
|
||||||
|
from tiramisu3 import *
|
||||||
|
except:
|
||||||
|
from tiramisu import *
|
||||||
|
option_3 = StrOption(name="mode_conteneur_actif", doc="Description", default="non", properties=frozenset({"mandatory", "normal"}))
|
||||||
|
option_2 = OptionDescription(name="general", doc="general", children=[option_3], properties=frozenset({"normal"}))
|
||||||
|
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
|
||||||
|
option_8 = FilenameOption(name="name", doc="name", default="/etc/file")
|
||||||
|
option_9 = BoolOption(name="activate", doc="activate", default=True)
|
||||||
|
option_7 = OptionDescription(name="file", doc="file", children=[option_8, option_9])
|
||||||
|
option_7.impl_set_information('source', "file")
|
||||||
|
option_11 = FilenameOption(name="name", doc="name", default="/etc/file2")
|
||||||
|
option_12 = BoolOption(name="activate", doc="activate", default=True)
|
||||||
|
option_10 = OptionDescription(name="file2", doc="file2", children=[option_11, option_12])
|
||||||
|
option_10.impl_set_information('engine', "jinja2")
|
||||||
|
option_10.impl_set_information('source', "file2")
|
||||||
|
option_14 = FilenameOption(name="name", doc="name", default="/etc/file3")
|
||||||
|
option_15 = BoolOption(name="activate", doc="activate", default=False)
|
||||||
|
option_13 = OptionDescription(name="file3", doc="file3", children=[option_14, option_15])
|
||||||
|
option_13.impl_set_information('source', "file3")
|
||||||
|
option_6 = OptionDescription(name="files", doc="files", children=[option_7, option_10, option_13])
|
||||||
|
option_16 = BoolOption(name="activate", doc="activate", default=True)
|
||||||
|
option_17 = BoolOption(name="manage", doc="manage", default=True)
|
||||||
|
option_5 = OptionDescription(name="test", doc="test", children=[option_6, option_16, option_17])
|
||||||
|
option_4 = OptionDescription(name="services", doc="services", children=[option_5], properties=frozenset({"hidden"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_4])
|
2
tests/dictionaries/01base_file_disabled/tmpl/file
Normal file
2
tests/dictionaries/01base_file_disabled/tmpl/file
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
%%mode_conteneur_actif
|
||||||
|
%%rougail.general.mode_conteneur_actif
|
2
tests/dictionaries/01base_file_disabled/tmpl/file2
Normal file
2
tests/dictionaries/01base_file_disabled/tmpl/file2
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{{ mode_conteneur_actif }}
|
||||||
|
{{ rougail.general.mode_conteneur_actif }}
|
Loading…
Reference in a new issue