Password has been reset for all users, please set a new password by using "Forgot your password?" in gitlab login page.

If you have already done this step, please ignore this message.

Commit 48b261aa by Thomas Gambier Committed by Alain Takoudjou

promise: check_port_listening is now available with new promise mechanism

This promise will replace the old check_port_listening promise ( See for how to instantiate this promise in buildout.

/reviewed-on !42
parent a49f5374
from zope import interface as zope_interface
from slapos.grid.promise import interface
from slapos.grid.promise.generic import GenericPromise
import socket
import sys
class RunPromise(GenericPromise):
def __init__(self, config):
GenericPromise.__init__(self, config)
# check port is listening at least every 2 minutes
def sense(self):
Simply test if we can connect to specified host:port.
hostname = self.getConfig('hostname')
port = self.getConfig('port')
addr = (hostname , port)
# in case of any error, we call "logger.error"
# note that we could simply let the function raise an error, it would have the same effect
# in this case the following code would be enough:
# socket.create_connection(addr).close()
#"port connection OK")
except (socket.herror, socket.gaierror), e:
self.logger.error("ERROR hostname/port ({}) is not correct: {}".format(addr, e))
except (socket.error, socket.timeout), e:
self.logger.error("ERROR while connecting to {}: {}".format(addr, e))
else:"port connection OK ({})".format(addr))
# no need to define Test as it is the default implementation
#def test(self):
# """
# Test is failing if last sense was bad.
# """
# return self._test(result_count=1, failure_amount=1)
def anomaly(self):
There is an anomaly if last 3 senses were bad.
return self._anomaly(result_count=3, failure_amount=3)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment