Ajout des variables Creole pour la gestion des hooks de VM

Création d'une famille "Hook" pour contenir tous les types de hook

Ajout des variables hapy_vm_hook* pour la gestion des hook de VM perso

Utilisation des variables dans le template oned.conf

fixes #12522 @2h
This commit is contained in:
Philippe Caseiro 2015-08-12 10:39:15 +02:00
parent b4f5544a25
commit 85492585ae
2 changed files with 65 additions and 1 deletions

View File

@ -65,6 +65,21 @@
</variable>
<variable name='one_nodes' type='string' description='Noeud voisin du Cluster' multi='True'/>
<variable name='node_ip' type='ip' description='Adresse IP du noeud' multi='True'/>
<variable name='activer_vm_hooks' type='oui/non' description="Utiliser des hook de vm personnalisés" mode='expert'>
<value>non</value>
</variable>
</family>
<family name='Hooks'>
<variable name='hapy_vm_hook' type='string' description="Nom du hook de VM" multi='True' mode='expert'/>
<variable name='hapy_vm_hook_on' type='string' description="Déclancheur (on)" mode='expert'/>
<variable name='hapy_vm_hook_command' type='string' description="Script a déclancher (command)" mode='expert'/>
<variable name='hapy_vm_hook_arguments' type='string' description="Arguments a passer au script (arguments)" mode='expert'/>
<variable name='hapy_vm_hook_remote' type='oui/non' description="Exécuter sur les noeuds (remote)" mode='expert'>
<value>non</value>
</variable>
<variable name='hapy_vm_hook_on' type='string' description="Déclancheur (ON)" mode='expert'/>
<variable name='hapy_vm_hook_state' type='string' description="Etat attendus en déclancheur 'custom' (STATE)" mode='expert'/>
<variable name='hapy_vm_hook_lcm_state' type='string' description="Etat 'lcm' attendus en déclancheur 'custom' (LCM_STATE)" mode='expert'/>
</family>
</variables>
@ -158,10 +173,36 @@
<target type='variable'>l2_vnet_vlan_trunk</target>
<target type='variable'>arp_cache_poisoning</target>
</condition>
<condition name='disabled_if_in' source='activer_vm_hooks'>
<param>non</param>
<target type='family'>Hooks</target>
</condition>
<check name="valid_enum" target="hapy_vm_hook_on">
<param>['CREATE','RUNNING','SHUTDOWN','STOP','DONE','UNKNOWN','FAILED','CUSTOM']</param>
</check>
<group master='hapy_vm_hook'>
<slave>hapy_vm_hook_on</slave>
<slave>hapy_vm_hook_command</slave>
<slave>hapy_vm_hook_arguments</slave>
<slave>hapy_vm_hook_remote</slave>
<slave>hapy_vm_hook_state</slave>
<slave>hapy_vm_hook_lcm_state</slave>
</group>
</constraints>
<help>
<variable name='activer_onesinglenode'>Interface d'administration du Cluster OpenNebula.</variable>
<variable name='arp_cache_poisoning'>Active la protection contre les attaques par empoisonnement ARP. Non compatible avec les réseaux de Niveau 2</variable>
<variable name='activer_vm_hooks'>Activer la création de hook personnalisée sur le serveur Hâpy (cf: http://docs.opennebula.org/4.8/integration/infrastructure_integration/hooks.html)</variable>
<variable name='hapy_vm_hook'>Nom du Hook de machine virtuelle (cf: http://docs.opennebula.org/4.8/integration/infrastructure_integration/hooks.html)</variable>
<variable name='hapy_vm_hook_on'>Déclancheur du Hook (cf: http://docs.opennebula.org/4.8/integration/infrastructure_integration/hooks.html)</variable>
<variable name='hapy_vm_hook_command'>Script lancé par le Hook (cf: http://docs.opennebula.org/4.8/integration/infrastructure_integration/hooks.html)</variable>
<variable name='hapy_vm_hook_arguments'>Arguments passés au script lancé par le Hook de machine virtuelle (cf: http://docs.opennebula.org/4.8/integration/infrastructure_integration/hooks.html)</variable>
<variable name='hapy_vm_hook_remote'>Exécuter le script sur le noeud plutôt que sur le maitre (cf: http://docs.opennebula.org/4.8/integration/infrastructure_integration/hooks.html)</variable>
<variable name='hapy_vm_hook_state'>État attendus par le hook lorsque le déclancheur est "CUSTOM" (cf: http://docs.opennebula.org/4.8/integration/infrastructure_integration/hooks.html)</variable>
<variable name='hapy_vm_hook_lcm_state'>État LCM attendus par le hook lorsque le déclancheur est "CUSTOM" (cf: http://docs.opennebula.org/4.8/integration/infrastructure_integration/hooks.html)</variable>
</help>
</creole>

View File

@ -596,6 +596,29 @@ VM_HOOK = [
remote = "YES"
]
%if %%getVar('activer_vm_hooks', 'non') == 'oui'
#*******************************************************************************
# Personal Hooks
#*******************************************************************************
%for %%hook in %%hapy_vm_hook
VM_HOOK = [
name = "%%hook"
on = "%%hook.hapy_vm_hook_on"
%if %%hook.hapy_vm_hook_on == "CUSTOM"
state = %%hook.hapy_vm_hook_state
lcm_state = %%hook.hapy_vm_hook_lcm_state
%end if
command = "%%hook.hapy_vm_hook_command"
arguments = "%%hook.hapy_vm_hook_arguments"
%if %%hook.hapy_vm_hook_remote == 'oui'
remote = "YES"
%else
remote = "NO"
%end if
]
%end for
%end if
HM_MAD = [
executable = "one_hm" ]