Merge pull request 'disabled a service (ref #4)' (#5) from fix/disabled_service into develop

Reviewed-on: https://forge.cadoles.com/Infra/rougail/pulls/5
This commit is contained in:
egarette 2021-05-01 18:13:10 +02:00
commit d7a1a52ebb
11 changed files with 79 additions and 1 deletions

View file

@ -29,6 +29,16 @@ Un service non géré ne peut conteneur que des fichiers.
## Désactiver la génération d'un service ## Désactiver la génération d'un service
Il est possible de désactiver un service. Pour cela il faut rajouter l'attribut "disabled" à True :
```
<services>
<service name="test" disabled="True"/>
</services>
```
Dans ce cas, tous les services et les éléments qu'il compose ([fichier](file.md), ...) seront désactivés.
Il est possible de définir une [condition](../condition/README.md) de type "disabled_if_in" ou "disabled_if_not_in" sur une balise service : Il est possible de définir une [condition](../condition/README.md) de type "disabled_if_in" ou "disabled_if_not_in" sur une balise service :
``` ```

View file

@ -76,10 +76,11 @@ class Annotator:
None, None,
None, None,
'activate', 'activate',
True, not service.disabled,
service, service,
'.'.join(['services', normalize_family(service_name), 'activate']), '.'.join(['services', normalize_family(service_name), 'activate']),
) )
service.disabled = None
for elttype, values in dict(vars(service)).items(): for elttype, values in dict(vars(service)).items():
if elttype == 'servicelist': if elttype == 'servicelist':
self.objectspace.list_conditions.setdefault('servicelist', self.objectspace.list_conditions.setdefault('servicelist',

View file

@ -50,6 +50,7 @@
<!ATTLIST service name CDATA #REQUIRED> <!ATTLIST service name CDATA #REQUIRED>
<!ATTLIST service manage (True|False) "True"> <!ATTLIST service manage (True|False) "True">
<!ATTLIST service servicelist CDATA #IMPLIED> <!ATTLIST service servicelist CDATA #IMPLIED>
<!ATTLIST service disabled (True|False) "False">
<!ELEMENT ip (#PCDATA)> <!ELEMENT ip (#PCDATA)>
<!ATTLIST ip iplist CDATA #IMPLIED> <!ATTLIST ip iplist CDATA #IMPLIED>

View file

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<services>
<service name="test" disabled="True">
</service>
</services>
<variables>
<variable name="condition">
<value>no</value>
</variable>
</variables>
</rougail>

View file

@ -0,0 +1,14 @@
{
"rougail.condition": {
"owner": "default",
"value": "no"
},
"services.test.activate": {
"owner": "default",
"value": false
},
"services.test.manage": {
"owner": "default",
"value": true
}
}

View file

@ -0,0 +1,5 @@
{
"rougail.condition": "no",
"services.test.activate": false,
"services.test.manage": true
}

View file

@ -0,0 +1,14 @@
{
"rougail.condition": {
"owner": "default",
"value": "no"
},
"services.test.activate": {
"owner": "default",
"value": false
},
"services.test.manage": {
"owner": "default",
"value": true
}
}

View file

@ -0,0 +1 @@
/dev/null

View file

@ -0,0 +1,20 @@
from importlib.machinery import SourceFileLoader
from importlib.util import spec_from_loader, module_from_spec
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 key, value in dict(locals()).items():
if key != ['SourceFileLoader', 'func']:
setattr(func, key, value)
try:
from tiramisu3 import *
except:
from tiramisu import *
option_2 = StrOption(name="condition", doc="condition", default="no", properties=frozenset({"mandatory", "normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
option_5 = BoolOption(name="activate", doc="activate", default=False)
option_6 = BoolOption(name="manage", doc="manage", default=True)
option_4 = OptionDescription(name="test", doc="test", children=[option_5, option_6])
option_3 = OptionDescription(name="services", doc="services", children=[option_4], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_3])