summaryrefslogtreecommitdiffstats
path: root/extras/snap
AgeCommit message (Collapse)AuthorFilesLines
2021-10-13docs: convert extras doc md->rstNathan Skrzypczak2-86/+84
Type: improvement Change-Id: Ie3b25a86b99098d2b3a21a11fc73234c8ed589d6 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
2021-05-21doxygen: fix doxygen tagsDave Wallace1-0/+3
- Missing tags mess up doxygen TOC heirarchy Type: docs Signed-off-by: Dave Wallace <dwallacelf@gmail.com> Change-Id: I012d55c0ae90aecc665b56903f4212ddc0643943
2021-01-26misc: fix snap image buildDave Barach3-5/+92
Clean up snapcraft.yaml bit rot, switch to Ubuntu 20.04, add README.md Type: improvement Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I2e0d3925cf43541e70b59083f8c91af539aa34e6
2020-03-18build: add snap packaging (experimental)Dave Barach2-0/+66
Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I5a5efde5378f63d89d82d71ae009c7595aaa800c
'>rls2202 Integration testsGrokmirror user
aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/honeycomb/Notifications.py
blob: 512a6cbb08b0463cf7666b7e180da32d8cc15c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright (c) 2016 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Implementation of keywords for managing Honeycomb notifications."""

from robot.api import logger

from resources.libraries.python.honeycomb.HoneycombUtil import HoneycombError
from resources.libraries.python.honeycomb.Netconf import Netconf


class Notifications(Netconf):
    """Implements keywords for receiving Honeycomb notifications.

    The keywords implemented in this class make it possible to:
    - receive notifications from Honeycomb
    - read received notifications
    """

    def add_notification_listener(self, subscription, time_out=10):
        """Open a new channel on the SSH session, connect to Netconf subsystem
        and subscribe to receive Honeycomb notifications.

        :param subscription: RPC for subscription to notifications.
        :param time_out: Timeout value for each read operation in seconds.
        :type subscription: str
        :type time_out: int
        :raises HoneycombError: If subscription to notifications fails.
        """

        logger.debug(subscription)
        self.send(subscription)

        reply = self.get_response(
            time_out=time_out,
            err="Timeout on notifications subscription."
        )

        if "<ok/>" not in reply:
            raise HoneycombError("Notifications subscription failed with"
                                 " message: {0}".format(reply))

        logger.debug("Notifications subscription successful.")

    def get_notification(self, time_out=10):
        """Read and return the next notification message.

        :param time_out: Timeout value for the read operation in seconds.
        :type time_out: int
        :return: Data received from buffer.
        :rtype: str
        """

        logger.debug("Getting notification. Timeout set to {0} seconds."
                     .format(time_out))

        reply = self.get_response(
            time_out=time_out,
            err="Timeout on getting notification."
        )

        return reply