From 536e96b51ae8f7ad9edb69265933625c9e407e81 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 29 Apr 2011 09:31:55 +0530 Subject: Updated multicast_response.py to response only if the server is not part of peer list. --- .../src/nodes/multicast_response.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/com.gluster.storage.management.server.scripts') diff --git a/src/com.gluster.storage.management.server.scripts/src/nodes/multicast_response.py b/src/com.gluster.storage.management.server.scripts/src/nodes/multicast_response.py index 64bc0899..dba65c07 100644 --- a/src/com.gluster.storage.management.server.scripts/src/nodes/multicast_response.py +++ b/src/com.gluster.storage.management.server.scripts/src/nodes/multicast_response.py @@ -16,10 +16,26 @@ # along with this program. If not, see # . +import os +import string +import time +import Utils import socket import struct import Globals +def isinpeer(): + command = "gluster peer status" + status = Utils.runCommand(command, output=True, root=True) + if status["Status"] == 0: + return True + #lines = status["Stdout"].split("\n") + #for line in lines: + # if string.upper(line).startswith("HOSTNAME: %s" % string.upper(socket.gethostname)): + # return True + Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) + return False + def response(multiCastGroup, port): # waiting for the request! socketRequest = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) @@ -33,6 +49,9 @@ def response(multiCastGroup, port): #TODO: Remove infinite loop and make this as a deamon (service) while True: + if isinpeer(): + time.sleep(5) + continue request = socketRequest.recvfrom(1024) if request and request[0].upper() == "SERVERDISCOVERY": socketSend.sendto(socket.gethostname(), (multiCastGroup, port)) -- cgit