コード例 #1
0
    def notify(self,
               topic,
               message,
               cluster_id=None,
               node_id=None,
               task_uuid=None):
        if topic == 'discover' and node_id is None:
            raise Exception("No node id in discover notification")
        task = None
        if task_uuid:
            task = orm().query(Task).filter_by(uuid=task_uuid).first()

        exist = None
        if node_id and task:
            exist = orm().query(Notification).filter_by(node_id=node_id,
                                                        message=message,
                                                        task=task).first()

        if not exist:
            notification = Notification()
            notification.topic = topic
            notification.message = message
            notification.cluster_id = cluster_id
            notification.node_id = node_id
            if task:
                notification.task_id = task.id
            notification.datetime = datetime.now()
            orm().add(notification)
            orm().commit()
            logger.info("Notification: topic: %s message: %s" %
                        (topic, message))
コード例 #2
0
ファイル: base.py プロジェクト: adanin/fuel-web
 def create_notification(self, **kwargs):
     notif_data = {
         "topic": "discover",
         "message": "Test message",
         "status": "unread",
         "datetime": datetime.now()
     }
     if kwargs:
         notif_data.update(kwargs)
     notification = Notification()
     notification.cluster_id = notif_data.get("cluster_id")
     for f, v in notif_data.iteritems():
         setattr(notification, f, v)
     self.db.add(notification)
     self.db.commit()
     return notification
コード例 #3
0
ファイル: base.py プロジェクト: tleontovich/fuelweb
 def create_notification(self, **kwargs):
     notif_data = {
         "topic": "discover",
         "message": "Test message",
         "status": "unread",
         "datetime": datetime.now()
     }
     if kwargs:
         notif_data.update(kwargs)
     notification = Notification()
     notification.cluster_id = notif_data.get("cluster_id")
     for f, v in notif_data.iteritems():
         setattr(notification, f, v)
     self.db.add(notification)
     self.db.commit()
     return notification
コード例 #4
0
ファイル: notifier.py プロジェクト: akolinko/product
    def notify(self, topic, message,
               cluster_id=None, node_id=None, task_uuid=None):
        if topic == 'discover' and node_id is None:
            raise Exception("No node id in discover notification")
        task = None
        if task_uuid:
            task = orm().query(Task).filter_by(uuid=task_uuid).first()

        exist = None
        if node_id and task:
            exist = orm().query(Notification).filter_by(
                node_id=node_id,
                message=message,
                task=task
            ).first()

        if not exist:
            notification = Notification()
            notification.topic = topic
            notification.message = message
            notification.cluster_id = cluster_id
            notification.node_id = node_id
            if task:
                notification.task_id = task.id
            notification.datetime = datetime.now()
            orm().add(notification)
            orm().commit()
            logger.info(
                "Notification: topic: %s message: %s" % (topic, message)
            )