summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.server.scripts
diff options
context:
space:
mode:
authorTim <timothyasir@gluster.com>2011-04-29 09:31:55 +0530
committerTim <timothyasir@gluster.com>2011-04-29 09:31:55 +0530
commit536e96b51ae8f7ad9edb69265933625c9e407e81 (patch)
tree02351876e5d103aa3bba428840bb3d472a0d3dc7 /src/com.gluster.storage.management.server.scripts
parent1500ca7e13074b2bc394ac4feb73e596d1203283 (diff)
Updated multicast_response.py to response only if the server is not part of peer list.
Diffstat (limited to 'src/com.gluster.storage.management.server.scripts')
-rw-r--r--src/com.gluster.storage.management.server.scripts/src/nodes/multicast_response.py19
1 files changed, 19 insertions, 0 deletions
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
# <http://www.gnu.org/licenses/>.
+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))