add undisable attribut to service

This commit is contained in:
Emmanuel Garette 2021-11-26 22:46:34 +01:00
parent a1c3b2b19c
commit d41a879ed9
10 changed files with 81 additions and 1 deletions

View File

@ -94,3 +94,13 @@ Il est possible de définir une [condition](../condition/README.md) de type "dis
```
Dans ce cas, tous les services et les éléments qu'il compose avec un attribut servicelist à "test" seront désactivés si la variable "condition" est False.
## Ne pas désactiver le service dans systemd
La désactivation du service va créé un lien symbolique vers /dev/null.
Si vous ne voulez juste pas créé le fichier de service et ne pas faire de lien symbolique, il faut utiliser l'attribut undisable :
```
<service name="test" disabled="True" undisable="True"/>
```

View File

@ -54,6 +54,7 @@
<!ATTLIST service engine (none|creole|jinja2) #IMPLIED>
<!ATTLIST service target CDATA #IMPLIED>
<!ATTLIST service type (service|mount|swap) "service">
<!ATTLIST service undisable (True|False) "False">
<!ELEMENT ip (#PCDATA)>
<!ATTLIST ip iplist CDATA #IMPLIED>

View File

@ -343,7 +343,7 @@ class RougailBaseTemplate:
service_name = await service_obj.option.description()
service_type = await service_obj.information.get('type', 'service')
if await service_obj.option('activate').value.get() is False:
if included is False:
if included is False and not await service_obj.information.get('undisable', False):
self.desactive_service(service_name, service_type)
continue
if not included:

View File

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<services>
<service name="test" disabled="True" undisable="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,24 @@
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_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_4.impl_set_information('undisable', True)
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])