Beispiel #1
0
    def launchServer(self):
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.socket.bind((self.host, self.port))
        self.socket.listen()
        print('server started at %s:%s' % (self.host, self.port))
        while True:
            print('waiting for a new connection...')
            conn, addr = self.socket.accept()

            u = UserThread(conn, addr, self)
            u.start()
            self.userlist.append(u)
Beispiel #2
0
    def __init__(self):
        self._complete = gevent.event.Event()


        #1 
        self.notifier = NotificationThread(self)
        self.user = UserThread(self)
        self.web = WebThread(self)
        
        self.vms = {}
        self.ternimals = {}
Beispiel #3
0
class Manager(object):
    """
    Manage 
    """

    def __init__(self):
        self._complete = gevent.event.Event()


        #1 
        self.notifier = NotificationThread(self)
        self.user = UserThread(self)
        self.web = WebThread(self)
        
        self.vms = {}
        self.ternimals = {}

    def delete_cluster(self, fs_id):
        """
        Note that the cluster will pop right back again if it's
        still sending heartbeats.
        """
        pass
        # victim = self.clusters[fs_id]
        # victim.stop()
        # victim.done.wait()
        # del self.clusters[fs_id]
        #
        # self._expunge(fs_id)

    def stop(self):
        log.info("%s stopping" % self.__class__.__name__)
        #2
        self.notifier.stop()
        self.user.stop()
        self.web.stop()
 

    def _expunge(self, fsid):

        pass


    def _recover(self):
        pass
        

    def start(self):
        log.info("%s starting" % self.__class__.__name__)

        # Before we start listening to the outside world, recover
        # our last known state from persistent storage
        try:
            self._recover()
        except:
            log.exception("Recovery failed")
            os._exit(-1)

        #3
        self.notifier.start()
        self.user.start()
        self.web.start()
        

    def join(self):
        log.info("%s joining" % self.__class__.__name__)
        #4
        self.notifier.join()
        self.user.join()
        self.web.join()
        

    def on_discovery(self, minion_id, heartbeat_data):
        log.info("on_discovery: {0}/{1}".format(minion_id, heartbeat_data['fsid']))