Browse Source

glusterfs_servername => glusterfs_servername_index

develop
Emmanuel Garette 5 months ago
parent
commit
cdc0468977
4 changed files with 33 additions and 27 deletions
  1. 2
    7
      dicos/80_gluster.xml
  2. 14
    9
      lib/eole/func_glust.sh
  3. 11
    2
      postservice/00-glusterfs
  4. 6
    9
      scripts/glusterfs_init

+ 2
- 7
dicos/80_gluster.xml View File

@@ -11,16 +11,11 @@
11 11
     </files>
12 12
     <variables>
13 13
         <family name='glusterfs'>
14
-            <variable name='glusterfs_servername' description='Nom du noeud du glusterfs' type="domain_strict" mandatory="True" auto_freeze="True"/>
15
-            <variable name='glusterfs_remote_servername' description='Nom des noeuds du glusterfs' multi="True" type="domain_strict" mandatory="True" auto_freeze="True"/>
14
+            <variable name='glusterfs_remote_servername' description='Nom des nœuds du glusterfs' multi="True" type="domain_strict" mandatory="True" auto_freeze="True"/>
15
+            <variable name="glusterfs_servername_index" description="Index du serveur dans la liste des nœuds du gluster" type="number" mandatory="True" auto_freeze="True"/>
16 16
             <variable name='glusterfs_name' description='Nom du volume' type="string" mandatory="True" auto_freeze="True"/>
17 17
             <variable name='glusterfs_dirname_data' description='Répertoire contenant les données du cluster' type="filename" mandatory="True" auto_freeze="True"/>
18 18
             <variable name='glusterfs_dirname' description='Point de montage du glusterfs' type="filename" mandatory="True" auto_freeze="True"/>
19 19
         </family>
20 20
     </variables>
21
-    <constraints>
22
-        <fill name='calc_val' target='glusterfs_servername'>
23
-            <param type='eole' name='valeur'>nom_domaine_machine</param>
24
-        </fill>
25
-    </constraints>
26 21
 </creole>

+ 14
- 9
lib/eole/func_glust.sh View File

@@ -1,12 +1,10 @@
1 1
 #!/bin/bash
2 2
 
3 3
 function glusterTest {
4
-    hostname=$(CreoleGet glusterfs_servername)
4
+    hostname_idx=$(CreoleGet glusterfs_servername_index)
5
+    idx=0
5 6
     for remote_name in $(CreoleGet glusterfs_remote_servername); do
6
-        if [ -z $first_host ]; then
7
-            first_host=$remote_name
8
-        fi
9
-        if [[ $remote_name != $hostname ]]; then
7
+        if [[ $idx != $hostname_idx ]]; then
10 8
             tcpcheck 2 $remote_name:24007 > /dev/null 2>&1
11 9
             [[ $? != 0 ]] && echo "le port 24007 n'est pas accessible pour $remote_name" && exit 1
12 10
             if [[ $2 != 'remote' ]]; then
@@ -20,20 +18,27 @@ function glusterTest {
20 18
                     [[ $? != 0 ]] && echo "le test est en erreur sur $remote_name" && exit 1
21 19
                 fi
22 20
             fi
23
-            if [ $first_host = $hostname ]; then
21
+            if [ ! $hostname_idx = 0 ]; then
24 22
                 # if not primary, test only primary
25 23
                 break
26 24
             fi
25
+        else
26
+            hostname=$remote_name
27 27
         fi
28
+        idx=$((idx+1))
28 29
     done
30
+    if [ -z $hostname ]; then
31
+        echo "L'index du nœud est supérieur à la taille de la liste des nœuds"
32
+        exit 1
33
+    fi
29 34
     dirname_data=$(CreoleGet glusterfs_dirname_data)
30 35
     if [ ! -d "$dirname_data" ]; then
31 36
         echo "le répertoire $dirname_data n'existe pas"
32 37
         exit 1
33 38
     fi
34
-    if [[ $2 = 'remote' && $first_host = $hostname ]]; then
39
+    if [[ $2 = 'remote' && $hostname_idx = 0 ]]; then
35 40
         # we are in master node
36
-        mount_point="$(CreoleGet glusterfs_servername):/$(CreoleGet glusterfs_name)"
41
+        mount_point="$hostname:/$(CreoleGet glusterfs_name)"
37 42
         df|grep -q ^"$mount_point "
38 43
         if [ ! $? = 0 ]; then
39 44
             echo "$mount_point n'est pas monté sur $hostname"
@@ -41,7 +46,7 @@ function glusterTest {
41 46
         fi
42 47
     fi
43 48
     if [[ $2 != 'remote' ]]; then
44
-        echo "L'accès aux différents noeuds est ok"
49
+        echo "L'accès aux différents nœud est ok"
45 50
     fi
46 51
 }
47 52
 

+ 11
- 2
postservice/00-glusterfs View File

@@ -3,11 +3,20 @@
3 3
 . /usr/lib/eole/ihm.sh
4 4
 option=$1
5 5
 
6
-mount_point="$(CreoleGet glusterfs_servername):/$(CreoleGet glusterfs_name)"
6
+hostname_idx=$(CreoleGet glusterfs_servername_index)
7
+idx=0
8
+for name in $(CreoleGet glusterfs_remote_servername); do
9
+    if [ "$idx" = "$hostname_idx" ]; then
10
+        hostname=$name
11
+        break
12
+    fi
13
+    idx=$((idx+1))
14
+done
15
+mount_point="$hostname:/$(CreoleGet glusterfs_name)"
7 16
 df|grep -q ^"$mount_point "
8 17
 if [ ! $? = 0 ]; then
9 18
     if [ $option = 'instance' ]; then
10
-        Question_ouinon "Voulez vous initialiser les glusterfs (tous les noeuds doivent être accessible) ?" "True" "non" "warn"
19
+        Question_ouinon "Voulez vous initialiser les glusterfs (tous les nœuds doivent être accessible) ?" "True" "non" "warn"
11 20
         if [ $? = 0 ]; then
12 21
             glusterfs_init
13 22
             if [ ! $? = 0 ]; then

+ 6
- 9
scripts/glusterfs_init View File

@@ -1,29 +1,26 @@
1 1
 #!/bin/bash
2 2
 
3 3
 
4
-systemctl disable glustereventsd.service 2> /dev/null
4
+# masked during installation
5
+# systemctl disable glustereventsd.service 2> /dev/null
5 6
 
6 7
 if [ -f /etc/eole/config.eol ]; then
7
-    hostname=$(CreoleGet glusterfs_servername)
8
+    hostname_idx=$(CreoleGet glusterfs_servername_index)
8 9
     glusterfs_name=$(CreoleGet glusterfs_name)
9 10
     source /usr/lib/eole/func_glust.sh
10 11
     glusterTest $@
11 12
     if [[ $# != 0 ]] && [[ $1 = "test" ]]; then
12 13
         exit 0
13 14
     fi
14
-    found=0
15
-    for name in $(CreoleGet glusterfs_remote_servername); do
16
-        [ "$name" = "$hostname" ] && found=1 && break
17
-    done
18
-    [ $found = 0 ] && echo "Le noeud local doit faire partie de 'glusterfs_remote_servername'" && exit 1
19
-
20 15
     if [ "$(gluster volume info 2>&1)" = "No volumes present" ]; then
21 16
         CMD=''
22 17
         idx=0
23 18
         glusterfs_dirname_data=$(CreoleGet glusterfs_dirname_data)
24 19
         for name in $(CreoleGet glusterfs_remote_servername); do
25
-            if [ ! "$name" = "$hostname" ]; then
20
+            if [ ! "$idx" = "$hostname_idx" ]; then
26 21
                 gluster peer probe $name
22
+            else
23
+                hostname=$name
27 24
             fi
28 25
             CMD="$CMD $name:$glusterfs_dirname_data/$glusterfs_name"
29 26
             idx=$((idx+1))

Loading…
Cancel
Save