Commit 59315ae move some functions related multipath to mpath.sh

2 files Authored and Committed by lilin 11 months ago
move some functions related multipath to mpath.sh

    
  1 @@ -1,124 +0,0 @@
  2 - #!/bin/bash
  3 - 
  4 - # Copyright (c) 2016 Red Hat, Inc.
  5 - #
  6 - # This program is free software: you can redistribute it and/or modify
  7 - # it under the terms of the GNU General Public License as published by
  8 - # the Free Software Foundation, either version 3 of the License, or
  9 - # (at your option) any later version.
 10 - #
 11 - # This program is distributed in the hope that it will be useful,
 12 - # but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14 - # GNU General Public License for more details.
 15 - #
 16 - # You should have received a copy of the GNU General Public License
 17 - # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 18 - 
 19 - # Author: Lin Li   <lilin@redhat.com>
 20 - 
 21 - 
 22 - 
 23 - #----------------------------------------------------------------------------#
 24 - # Mp_Conf_Up_Def ()
 25 - # Usage:
 26 - #   Update default section of /etc/multipath.conf, will also reload conf.
 27 - # Parameter:
 28 - #   $config_change #config string want to change, like 'polling_interval 5'
 29 - # Returns:
 30 - #   Return code:
 31 - #       0 on success
 32 - #       1 if something went wrong.
 33 - #   Return string:
 34 - #       NULL
 35 - #----------------------------------------------------------------------------#
 36 - 
 37 - function Mp_Conf_Up_Def (){
 38 -     EX_USAGE=64 # Bad arg format
 39 -     if [ $# -lt 1 ]; then
 40 -         echo 'Usage: Mp_Conf_Up_Def $config_change'
 41 -         exit "${EX_USAGE}"
 42 -     fi
 43 -     RETURN_STR=''
 44 -     local multipath_conf_filename="/etc/multipath.conf"
 45 -     local config_change="$1"
 46 -     echo ${config_change}
 47 -     if [ "CHK${config_change}" == "CHK" ];then
 48 -         echo 'Usage: Mp_Conf_Up_Def $config_change'
 49 -         exit "${EX_USAGE}"
 50 -     fi
 51 -     python2 -c "
 52 - import sys
 53 - sys.path.append('"${MP_INCLUDE_PATH}"')
 54 - from mpconf import *
 55 - update_df_section('""${config_change}""')
 56 - "
 57 - #TODO: we need to check configuration before we return 0
 58 -     RETURN_STR=""
 59 -     return 0
 60 - } #end of functoin Mp_Conf_Up_Def
 61 - 
 62 - 
 63 - # ---------------------------------------------------------#
 64 - # Print_multipath_pkginfo()()
 65 - # Usage:
 66 - # print the multipath pacakge information
 67 - # Parameter:
 68 - #   NULL
 69 - # Returns:
 70 - #   Return code:
 71 - #       0 on success
 72 - #       1 if something went wrong.
 73 - # ---------------------------------------------------------#
 74 - function Print_multipath_pkginfo (){
 75 -     Cmd "rpm -qi device-mapper-multipath"
 76 -     Cmd "rpm -qi kpartx"
 77 - }
 78 - 
 79 - # ---------------------------------------------------------#
 80 - # Mutipathd_stop()
 81 - # Usage:
 82 - # check if multipathd stops, if not stop it
 83 - # Parameter:
 84 - #   NULL
 85 - # Returns:
 86 - #   Return code:
 87 - #       0 on success
 88 - #       1 if something went wrong.
 89 - # ---------------------------------------------------------#
 90 - function Multipathd_stop (){
 91 - #    { ! Cmd pidof multipathd ; } || Cmd "service multipathd stop"
 92 -     { ! Cmd pidof multipathd ; } || Cmd "kill -9 `pidof multipathd`"
 93 - }
 94 - 
 95 - # ---------------------------------------------------------#
 96 - # Mutipathd_start()
 97 - # Usage:
 98 - # check if multipathd is installed, if not start it
 99 - # Parameter:
100 - #   NULL
101 - # Returns:
102 - #   Return code:
103 - #       0 on success
104 - #       1 if something went wrong.
105 - # ---------------------------------------------------------#
106 - function Multipathd_start (){
107 - #    { Cmd pidof multipathd ; } || Cmd "service multipathd start"
108 -     { Cmd pidof multipathd ; } || Cmd "multipathd"
109 - }
110 - 
111 - # ---------------------------------------------------------#
112 - # Mutipath_installation()
113 - # Usage:
114 - # check if multipath starts, if not install it with yum
115 - # Parameter:
116 - #   NULL
117 - # Returns:
118 - #   Return code:
119 - #       0 on success
120 - #       1 if something went wrong.
121 - # ---------------------------------------------------------#
122 - function Multipath_installation (){
123 -     Cmd "rpm -qi device-mapper-multipath" && return 0
124 -     Cmd "yum install -y device-mapper-multipath" 
125 - } 
 1 @@ -135,3 +135,68 @@
 2       echo $maps
 3   }
 4   
 5 + 
 6 + # ---------------------------------------------------------#
 7 + # Print_multipath_pkginfo()()
 8 + # Usage:
 9 + # print the multipath pacakge information
10 + # Parameter:
11 + #   NULL
12 + # Returns:
13 + #   Return code:
14 + #       0 on success
15 + #       1 if something went wrong.
16 + # ---------------------------------------------------------#
17 + function Print_multipath_pkginfo (){
18 +     Cmd "rpm -qi device-mapper-multipath"
19 +     Cmd "rpm -qi kpartx"
20 + }
21 + 
22 + # ---------------------------------------------------------#
23 + # Mutipathd_stop()
24 + # Usage:
25 + # check if multipathd stops, if not stop it
26 + # Parameter:
27 + #   NULL
28 + # Returns:
29 + #   Return code:
30 + #       0 on success
31 + #       1 if something went wrong.
32 + # ---------------------------------------------------------#
33 + function Multipathd_stop (){
34 + #    { ! Cmd pidof multipathd ; } || Cmd "service multipathd stop"
35 +     { ! Cmd pidof multipathd ; } || Cmd "kill -9 `pidof multipathd`"
36 + }
37 + 
38 + # ---------------------------------------------------------#
39 + # Mutipathd_start()
40 + # Usage:
41 + # check if multipathd is installed, if not start it
42 + # Parameter:
43 + #   NULL
44 + # Returns:
45 + #   Return code:
46 + #       0 on success
47 + #       1 if something went wrong.
48 + # ---------------------------------------------------------#
49 + function Multipathd_start (){
50 + #    { Cmd pidof multipathd ; } || Cmd "service multipathd start"
51 +     { Cmd pidof multipathd ; } || Cmd "multipathd"
52 + }
53 + 
54 + # ---------------------------------------------------------#
55 + # Mutipath_installation()
56 + # Usage:
57 + # check if multipath starts, if not install it with yum
58 + # Parameter:
59 + #   NULL
60 + # Returns:
61 + #   Return code:
62 + #       0 on success
63 + #       1 if something went wrong.
64 + # ---------------------------------------------------------#
65 + function Multipath_installation (){
66 +     Cmd "rpm -qi device-mapper-multipath" && return 0
67 +     Cmd "yum install -y device-mapper-multipath"
68 + }
69 +