disabled a service (ref #4)

This commit is contained in:
Emmanuel Garette 2021-04-29 18:20:05 +02:00
parent a87485abd2
commit d3008dc217
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
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 :
```

View File

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

View File

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