• R/O
  • SSH

vm-ctl: Commit

※ リポジトリはhttps://github.com/linux-ha-japan/vm-ctl-1.0 へ移行しました。
仮想マシンリソース制御機能


Commit MetaInfo

Revision3ed7d1d70d6d8d70ee6edd912be42996f8568cba (tree)
Time2012-02-09 18:23:58
AuthorYuusuke Iida <iidayuus@inte...>
CommiterYuusuke Iida

Log Message

By grep, plural letters revised a searched problem.

Change Summary

Incremental Difference

diff -r a05fb253890d -r 3ed7d1d70d6d configure.in
--- a/configure.in Thu Sep 15 17:11:48 2011 +0900
+++ b/configure.in Thu Feb 09 18:23:58 2012 +0900
@@ -1,6 +1,6 @@
11 AC_PREREQ(2.59)
2-AC_INIT(vm-ctl, 1.0)
3-AM_INIT_AUTOMAKE(vm-ctl, 1.0)
2+AC_INIT(vm-ctl, 1.1)
3+AM_INIT_AUTOMAKE(vm-ctl, 1.1)
44 AC_PREFIX_DEFAULT(/usr)
55 PM_PKG="pacemaker"
66 AM_MAINTAINER_MODE
diff -r a05fb253890d -r 3ed7d1d70d6d vm-ctl
--- a/vm-ctl Thu Sep 15 17:11:48 2011 +0900
+++ b/vm-ctl Thu Feb 09 18:23:58 2012 +0900
@@ -36,8 +36,6 @@
3636 BACKUP_CRMFILE="/var/run/.vm-ctl.crm.bk"
3737 TMP_CRMFILE="/tmp/.vm-ctl.crm"
3838 VMCTL_LOGFILE="/tmp/.vm-ctl.log"
39-PLUS_INFINITY="1000000"
40-MINUS_INFINITY="-1000000"
4139 DEF_VALUE=""
4240 DC_NODE=""
4341 DEL_ID_LIST=""
@@ -132,7 +130,7 @@
132130 local _cnt
133131 for _domain_name in ${DOMAIN_LIST}
134132 do
135- _cnt=$(virsh list --all 2>/dev/null | grep -w ${_domain_name} 2>/dev/null | wc -l 2>/dev/null)
133+ _cnt=$(virsh list --all 2>/dev/null | grep "[[:blank:]]${_domain_name}[[:blank:]]" 2>/dev/null | wc -l 2>/dev/null)
136134 if [ ${_cnt} -eq 0 ] ; then
137135 echo ${VMCTL_MSG03}
138136 exit 1
@@ -154,7 +152,7 @@
154152 local _cnt
155153 for _domain_name in ${DOMAIN_LIST}
156154 do
157- _cnt=$(grep "primitive ${PRM_NM}_${_domain_name}" ${BACKUP_CRMFILE} 2>/dev/null | wc -l 2>/dev/null)
155+ _cnt=$(grep "primitive ${PRM_NM}_${_domain_name}[[:blank:]]" ${BACKUP_CRMFILE} 2>/dev/null | wc -l 2>/dev/null)
158156 if [ ${_cnt} -ne ${1} ] ; then
159157 echo ${2}
160158 exit 1
@@ -238,7 +236,7 @@
238236 chk_crm_error()
239237 {
240238 local _cnt
241- _cnt=$(egrep 'ERROR|error' ${VMCTL_LOGFILE} 2>/dev/null | wc -l 2>/dev/null)
239+ _cnt=$(egrep "(ERROR|error): " ${VMCTL_LOGFILE} 2>/dev/null | wc -l 2>/dev/null)
242240 if [ ${_cnt} -ne 0 -o ${1} -ne 0 ] ; then
243241 echo ${VMCTL_MSG05}
244242 cat ${VMCTL_LOGFILE}
@@ -415,7 +413,7 @@
415413 fi
416414
417415 if [ ! "${vm_start_op}" -o ${#vm_start_op[@]} -ne 3 ] ; then
418- DEF_VALUE="vm_start_op=(0 120s restart)"
416+ DEF_VALUE="vm_start_op=(0 90s restart)"
419417 eval echo "${VMCTL_MSG22}"
420418 eval ${DEF_VALUE}
421419 fi
@@ -529,7 +527,7 @@
529527 while read _line
530528 do
531529 _migrate=$(echo ${_line} 2>/dev/null \
532- | grep "primitive ${1}" 2>/dev/null \
530+ | grep "primitive ${1}[[:blank:]]" 2>/dev/null \
533531 | sed -e 's/.*allow-migrate=\"\(true\|false\)\" .*/\1/' 2>/dev/null)
534532 if [ "${_migrate}" ] ; then
535533 if [ "${_migrate}" = "true" ] ; then
@@ -556,7 +554,7 @@
556554 while read _line
557555 do
558556 _act=$(echo ${_line} 2>/dev/null \
559- | grep "location ${LOC_NM}_${1}.*ACT" 2>/dev/null \
557+ | grep "location ${LOC_NM}_.*_ACT ${PRM_NM}_${1}[[:blank:]]" 2>/dev/null \
560558 | awk '{print $5}')
561559 if [ "${_act}" ] ; then
562560 RET_VALUE=${_act}
@@ -578,9 +576,10 @@
578576 while read _line
579577 do
580578 _migrate=$(echo ${_line} 2>/dev/null \
581- | egrep "location cli-standby-${1}|location cli-prefer-${1}" 2>/dev/null)
579+ | egrep "^location cli-(standby|prefer)-${1}[[:blank:]]" 2>/dev/null)
582580 if [ ${?} -eq 0 ] ; then
583581 RET_VALUE="yes"
582+ break
584583 fi
585584 done < ${BACKUP_CRMFILE}
586585 }
@@ -930,7 +929,7 @@
930929 RET_VALUE=""
931930 chk_cluster
932931 RET_VALUE=$(crm status inactive 2>/dev/null \
933- | grep ${1}.*VirtualDomain 2>/dev/null \
932+ | grep "${1}[[:blank:]].*VirtualDomain" 2>/dev/null \
934933 | awk '{print $4}' 2>/dev/null)
935934 }
936935
@@ -950,7 +949,7 @@
950949 RET_VALUE=""
951950 chk_cluster
952951 RET_VALUE=$(crm status inactive 2>/dev/null \
953- | grep VirtualDomain.*${1} 2>/dev/null \
952+ | egrep "VirtualDomain.*[[:blank:]]${1}($|[[:blank:]])" 2>/dev/null \
954953 | awk '{print $1}' 2>/dev/null \
955954 | awk '{print substr($1,length("'${PRM_NM}'_")+1)}' 2>/dev/null)
956955 }
@@ -1006,41 +1005,48 @@
10061005 local _scores
10071006 local _flg=0
10081007
1008+ chk_cluster
10091009 if [ ${3} ] ; then
1010- chk_cluster
1011- _cnt=$(crm status 2>/dev/null \
1012- | grep -v VirtualDomain 2>/dev/null \
1013- | grep "Online" 2>/dev/null \
1014- | grep ${3} 2>/dev/null \
1015- | wc -l 2>/dev/null)
1016- if [ ${_cnt} -eq 0 ] ; then
1017- echo ${VMCTL_MSG14}
1018- return 1
1019- fi
1010+ _cnt=$(crm status bynode 2>/dev/null \
1011+ | egrep "^Node ${3}([[:blank:]].*|): online$" 2>/dev/null \
1012+ | wc -l 2>/dev/null)
1013+ else
1014+ _cnt=$(crm status bynode 2>/dev/null \
1015+ | grep "^Node .*: online$" 2>/dev/null \
1016+ | egrep -v "^Node ${2}(|:)[[:blank:]]" 2>/dev/null \
1017+ | wc -l 2>/dev/null)
10201018 fi
1019+ if [ ${_cnt} -eq 0 ] ; then
1020+ echo ${VMCTL_MSG14}
1021+ return 1
1022+ fi
1023+
10211024 chk_cluster
10221025 crm status inactive 2>/dev/null \
1023- | grep ${PRM_NM}_${1}.*VirtualDomain 2>/dev/null \
1024- | egrep 'unmanaged' >/dev/null 2>&1
1026+ | grep "${PRM_NM}_${1}[[:blank:]].*VirtualDomain" 2>/dev/null \
1027+ | egrep '[[:blank:]]\(unmanaged\)' >/dev/null 2>&1
10251028 if [ ${?} -eq 0 ] ; then
10261029 echo ${VMCTL_MSG25}
10271030 return 1
10281031 fi
1032+
10291033 chk_cluster
1030- _scores=$(crm configure ptest scores 2>/dev/null \
1031- | grep "native_color: ${PRM_NM}_${1} allocation score on ${3}" 2>/dev/null \
1032- | grep -v ${2} 2>/dev/null \
1033- | awk '{print $7}' 2>/dev/null)
1034-
10351034 if [ ${3} ] ; then
1036- if [ "${_scores}" = "${MINUS_INFINITY}" ] ; then
1035+ _scores=$(crm configure ptest scores 2>/dev/null \
1036+ | grep "native_color: ${PRM_NM}_${1} allocation score on ${3}:" 2>/dev/null \
1037+ | awk '{print $7}' 2>/dev/null)
1038+ if [ "${_scores}" = "-1000000" -o "${_scores}" = "-INFINITY" ] ; then
10371039 eval echo "${VMCTL_MSG19}"
10381040 return 1
10391041 fi
10401042 else
1043+ _scores=$(crm configure ptest scores 2>/dev/null \
1044+ | grep "native_color: ${PRM_NM}_${1} allocation score on " 2>/dev/null \
1045+ | grep -v "[[:blank:]]${2}:" 2>/dev/null \
1046+ | awk '{print $7}' 2>/dev/null)
10411047 for _score in ${_scores}
10421048 do
1043- if [ "${_score}" != "${MINUS_INFINITY}" ] ; then
1049+ if [ "${_score}" != "-1000000" -a "${_score}" != "-INFINITY" ] ; then
10441050 _flg=1
10451051 fi
10461052 done
@@ -1144,7 +1150,7 @@
11441150 fi
11451151 crm_get_actrsc_node ${PRM_NM}_${1}
11461152 if [ ! ${3} ] ; then
1147- if [ ${RET_VALUE} -a "${RET_VALUE}" != "${2}" ] ; then
1153+ if [ "${RET_VALUE}" -a "${RET_VALUE}" != "${2}" ] ; then
11481154 break
11491155 fi
11501156 else
diff -r a05fb253890d -r 3ed7d1d70d6d vm-ctl.conf
--- a/vm-ctl.conf Thu Sep 15 17:11:48 2011 +0900
+++ b/vm-ctl.conf Thu Feb 09 18:23:58 2012 +0900
@@ -35,7 +35,9 @@
3535 vm_migration_transport="ssh"
3636
3737 # VMリソースオペレーション(interval timeout on-fail)
38-vm_start_op=(0 120s restart)
38+# 2011/10/04: 以下のバグにより、現在startとstopのタイムアウトは揃える必要あり
39+# http://developerbugs.linux-foundation.org/show_bug.cgi?id=2560
40+vm_start_op=(0 90s restart)
3941 vm_stop_op=(0 90s)
4042 vm_monitor_op=(10s 30s restart)
4143 vm_migrate_to_op=(0 300s)
diff -r a05fb253890d -r 3ed7d1d70d6d vm-ctl.spec
--- a/vm-ctl.spec Thu Sep 15 17:11:48 2011 +0900
+++ b/vm-ctl.spec Thu Feb 09 18:23:58 2012 +0900
@@ -2,7 +2,7 @@
22 # Derived definitions
33 ########################################
44 %define name vm-ctl
5-%define version 1.0
5+%define version 1.1
66 %define release 1
77 %define prefix /usr
88 %define vmctldir vm-ctl
Show on old repository browser