From mboxrd@z Thu Jan 1 00:00:00 1970 From: lhh@sourceware.org Date: 2 May 2007 18:26:27 -0000 Subject: [Cluster-devel] cluster/rgmanager/src/resources ip.sh ocf-shel ... Message-ID: <20070502182627.15879.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Branch: RHEL5 Changes by: lhh at sourceware.org 2007-05-02 18:26:27 Modified files: rgmanager/src/resources: ip.sh ocf-shellfuncs service.sh vm.sh Log message: Fix error in status intervals for vm.sh Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/ip.sh.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.21.2.1&r2=1.21.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/ocf-shellfuncs.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3.2.1&r2=1.3.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/service.sh.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.7.2.2&r2=1.7.2.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/vm.sh.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.1&r2=1.1.2.2 --- cluster/rgmanager/src/resources/ip.sh 2007/01/26 20:45:25 1.21.2.1 +++ cluster/rgmanager/src/resources/ip.sh 2007/05/02 18:26:26 1.21.2.2 @@ -86,6 +86,21 @@ + + + If set, forces the use of the specified ethernet + device for IP address assignment. Usually, + an interface is picked which has an IP in the + same subnet as the specified IP address. + + + + Ethernet device + + + + + Enabling this causes the status check to fail if @@ -397,7 +412,7 @@ { declare idx dev ifaddr declare ifaddr_exp - + while read idx dev ifaddr; do isSlave $dev @@ -413,6 +428,11 @@ done < <(/sbin/ip -o -f inet6 addr | awk '{print $1,$2,$4}') + if [ -n "$OCF_RESKEY_ethernet_device" ]; then + ip_list_interfaces + return $? + fi + return 0 } @@ -579,6 +599,25 @@ } +# +# When a user wants to use a specific device, just list all +# devices to make sure the device exists on the system +# +ip_list_interfaces() +{ + while read idx dev; do + dev=${dev/:/} + + isSlave $dev + if [ $? -ne 2 ]; then + continue + fi + + echo $dev none none + done < <(/sbin/ip -o -f link addr | awk '{print $1,$2}') +} + + ipv4_list_interfaces() { declare idx dev ifaddr @@ -590,12 +629,15 @@ continue fi - idx=${idx/:/} - echo $dev ${ifaddr/\/*/} ${ifaddr/*\//} done < <(/sbin/ip -o -f inet addr | awk '{print $1,$2,$4}') - + + if [ -n "$OCF_RESKEY_ethernet_device" ]; then + ip_list_interfaces + return $? + fi + return 0 } @@ -614,19 +656,30 @@ continue fi + if [ -n "$OCF_RESKEY_ethernet_device" ] && \ + [ "$dev" != "$OCF_RESKEY_ethernet_device" ]; then + continue + fi + if [ "$1" = "add" ]; then - ipv6_same_subnet $ifaddr_exp/$maskbits $addr_exp - if [ $? -ne 0 ]; then - continue - fi + if [ -z "$OCF_RESKEY_ethernet_device" ]; then + ipv6_same_subnet $ifaddr/$maskbits $addr + if [ $? -ne 0 ]; then + continue + fi + fi + interface_up $dev if [ $? -ne 0 ]; then continue fi - network_link_up $dev - if [ $? -ne 0 ]; then - continue - fi + + if [ "$monitor_link" = "yes" ]; then + network_link_up $dev + if [ $? -ne 0 ]; then + continue + fi + fi ocf_log info "Adding IPv6 address $addr to $dev" fi if [ "$1" = "del" ]; then @@ -672,30 +725,51 @@ ipv4() { declare dev ifaddr maskbits + declare op=$1 declare addr=$2 + declare monitor_link=$3 while read dev ifaddr maskbits; do if [ -z "$dev" ]; then continue fi - if [ "$1" = "add" ]; then - ipv4_same_subnet $ifaddr/$maskbits $addr - if [ $? -ne 0 ]; then - continue + if [ -n "$OCF_RESKEY_ethernet_device" ] && \ + [ "$dev" != "$OCF_RESKEY_ethernet_device" ]; then + continue + fi + + if [ "$op" = "add" ]; then + if [ -z "$OCF_RESKEY_ethernet_device" ]; then + ipv4_same_subnet $ifaddr/$maskbits $addr + if [ $? -ne 0 ]; then + continue + fi fi + interface_up $dev if [ $? -ne 0 ]; then - continue + ocf_log warn "Enabling $dev" + /sbin/ip link $dev up + interface_up $dev + if [ $? -ne 0 ]; then + ocf_log warn "Failed to enable $dev" + continue + fi fi - network_link_up $dev - if [ $? -ne 0 ]; then - continue + + if [ "$monitor_link" = "yes" ]; then + network_link_up $dev + if [ $? -ne 0 ]; then + continue + fi fi ocf_log info "Adding IPv4 address $addr to $dev" fi - if [ "$1" = "del" ]; then + + if [ "$op" = "del" ]; then if [ "${addr/\/*/}" != "$ifaddr" ]; then + echo "${addr/\/*/} != $ifaddr" continue fi ocf_log info "Removing IPv4 address $addr from $dev" @@ -841,11 +915,11 @@ case $1 in inet) - ipv4 $2 $3 + ipv4 $2 $3 $monitor_link return $? ;; inet6) - ipv6 $2 $3 + ipv6 $2 $3 $monitor_link return $? ;; esac @@ -867,6 +941,11 @@ ;; esac +if [ -n "$OCF_RESKEY_ethernet_device" ]; then + ocf_log debug "Forcing use of $OCF_RESKEY_ethernet_device" +else + ocf_log debug "Using default autoplacement of IP addresses" +fi if [ -z "$OCF_CHECK_LEVEL" ]; then OCF_CHECK_LEVEL=0 --- cluster/rgmanager/src/resources/ocf-shellfuncs 2007/01/23 15:23:40 1.3.2.1 +++ cluster/rgmanager/src/resources/ocf-shellfuncs 2007/05/02 18:26:26 1.3.2.2 @@ -1,5 +1,5 @@ # -# $Id: ocf-shellfuncs,v 1.3.2.1 2007/01/23 15:23:40 lhh Exp $ +# $Id: ocf-shellfuncs,v 1.3.2.2 2007/05/02 18:26:26 lhh Exp $ # # Common helper functions for the OCF Resource Agents supplied by # heartbeat. @@ -174,6 +174,10 @@ esac pretty_echo $__OCF_PRIO "$__OCF_MSG" + + if [ -z "`which clulog 2> /dev/null`" ]; then + return 0 + fi clulog -p $__LOG_PID -n $__LOG_NAME \ -s $__OCF_PRIO_N "$__OCF_MSG" } --- cluster/rgmanager/src/resources/service.sh 2007/02/14 16:20:26 1.7.2.2 +++ cluster/rgmanager/src/resources/service.sh 2007/05/02 18:26:26 1.7.2.3 @@ -172,17 +172,16 @@ - - - - - + + + + - + - - - + + + EOT --- cluster/rgmanager/src/resources/vm.sh 2007/03/20 17:09:12 1.1.2.1 +++ cluster/rgmanager/src/resources/vm.sh 2007/05/02 18:26:26 1.1.2.2 @@ -181,8 +181,8 @@ - - + + @@ -367,15 +367,14 @@ { declare target=$1 - xm migrate $OCF_RESKEY_name $target - return $? + # XXX TODO + return 1 } # # A Resource group is abstract, but the OCF RA API doesn't allow for abstract # resources, so here it is. # - case $1 in start) start