pluginmanager.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:son-mano-framework 作者: sonata-nfv 项目源码 文件源码
def _on_heartbeat(self, ch, method, properties, message):
        message = json.loads(str(message))
        pid = message.get("uuid")

        try:
            p = model.Plugin.objects.get(uuid=pid)

            # update heartbeat timestamp
            p.last_heartbeat_at = datetime.datetime.now()

            change = False

            # TODO ugly: state management of plugins should be hidden with plugin class
            if message.get("state") == "READY" and p.state != "READY":
                # a plugin just announced that it is ready, lets start it
                self.send_start_notification(p)
                change = True
            elif message.get("state") != p.state:
                # lets keep track of the reported state update
                p.state = message.get("state")
                change = True

            p.save()
            if change:
                # there was a state change lets schedule an plugin status update notification
                self.send_plugin_status_update()
        except DoesNotExist:
            LOG.debug("Couldn't find plugin with UUID %r in DB" % pid)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号