Fixed communicator method names in ConsumerLocator

This commit is contained in:
Scharnitzky Donát 2020-03-29 16:48:59 +02:00
parent 98b1bb8e56
commit 25d582cccc

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import datetime import datetime
import communicator
""" """
Main Flask RESTful API Main Flask RESTful API
@ -29,7 +30,7 @@ class ConsumerLocator:
"""" """"
Learns the list of consumers. Learns the list of consumers.
""" """
recievedConsumerList = communicator.getConsumerList() recievedConsumerList = communicator.discoveravailableconsumers()
for consumer in recievedConsumerList: for consumer in recievedConsumerList:
self.consumerList.append({"Host": consumer, "State": True, "LastOk": datetime.datetime.now()}) self.consumerList.append({"Host": consumer, "State": True, "LastOk": datetime.datetime.now()})
self.updateConsumerList() self.updateConsumerList()
@ -40,7 +41,7 @@ class ConsumerLocator:
""" """
removeList = [] removeList = []
for consumer in self.consumerList: for consumer in self.consumerList:
if not communicator.ping(consumer["Host"]): if not communicator.isconsumeravailable(consumer["Host"]):
consumer["State"] = False consumer["State"] = False
if datetime.datetime.now() - consumer["LastOk"] > datetime.timedelta(hours=1): if datetime.datetime.now() - consumer["LastOk"] > datetime.timedelta(hours=1):
removeList.append(consumer) removeList.append(consumer)
@ -84,7 +85,7 @@ class ConsumerLocator:
Check the consumers health. Check the consumers health.
:return: True if OK, False if fail :return: True if OK, False if fail
""" """
if communicator.ping(self.currentConsumer["Host"]): if communicator.isconsumeravailable(self.currentConsumer["Host"]):
return True return True
else: else:
return False return False