示例#1
0
 def test_message_hmac(self):
     seq = 42
     for i in range(0, 16):
         statusMsg = {'seq': seq, 'status': 'OK', 'id': str(uuid.uuid4())}
         envelope = status_message.wrap_envelope(statusMsg, 'samplekey1')
         obj = status_message.unwrap_envelope(envelope, 'samplekey1')
         self.assertEqual('OK', obj['status'])
         self.assertEqual(seq, obj['seq'])
         seq += 1
         args = (envelope, 'samplekey?')
         self.assertRaises(exceptions.InvalidHMACException,
                           status_message.unwrap_envelope, *args)
示例#2
0
 def test_message_hmac(self):
     seq = 42
     for i in range(0, 16):
         statusMsg = {'seq': seq,
                      'status': 'OK',
                      'id': str(uuid.uuid4())}
         envelope = status_message.wrap_envelope(statusMsg, 'samplekey1')
         obj = status_message.unwrap_envelope(envelope, 'samplekey1')
         self.assertEqual(obj['status'], 'OK')
         self.assertEqual(obj['seq'], seq)
         seq += 1
         args = (envelope, 'samplekey?')
         self.assertRaises(exceptions.InvalidHMACException,
                           status_message.unwrap_envelope, *args)
示例#3
0
    def test_message_hmac_compatibility(self):
        seq = 42
        statusMsg = {'seq': seq, 'status': 'OK', 'id': str(uuid.uuid4())}

        envelope = status_message.wrap_envelope(statusMsg,
                                                'samplekey1',
                                                hex=False)
        obj = status_message.unwrap_envelope(envelope, 'samplekey1')

        self.assertEqual('OK', obj['status'])
        self.assertEqual(seq, obj['seq'])

        args = (envelope, 'samplekey?')
        self.assertRaises(exceptions.InvalidHMACException,
                          status_message.unwrap_envelope, *args)
示例#4
0
    def test_message_hmac_compatibility(self):
        seq = 42
        statusMsg = {'seq': seq,
                     'status': 'OK',
                     'id': str(uuid.uuid4())}

        envelope = status_message.wrap_envelope(statusMsg, 'samplekey1',
                                                hex=False)
        obj = status_message.unwrap_envelope(envelope, 'samplekey1')

        self.assertEqual('OK', obj['status'])
        self.assertEqual(seq, obj['seq'])

        args = (envelope, 'samplekey?')
        self.assertRaises(exceptions.InvalidHMACException,
                          status_message.unwrap_envelope, *args)
示例#5
0
    def dorecv(self, *args, **kw):
        """Waits for a UDP heart beat to be sent.

        :return: Returns the unwrapped payload and addr that sent the
                 heartbeat.
        """
        (data, srcaddr) = self.sock.recvfrom(UDP_MAX_SIZE)
        LOG.debug('Received packet from %s', srcaddr)
        try:
            obj = status_message.unwrap_envelope(data, self.key)
        except Exception as e:
            LOG.warning('Health Manager experienced an exception processing a '
                        'heartbeat message from %s. Ignoring this packet. '
                        'Exception: %s', srcaddr, str(e))
            raise exceptions.InvalidHMACException()
        obj['recv_time'] = time.time()
        return obj, srcaddr[0]
示例#6
0
    def dorecv(self, *args, **kw):
        """Waits for a UDP heart beat to be sent.

        :return: Returns the unwrapped payload and addr that sent the
                 heartbeat. The format of the obj from the UDP sender
                 can be seen below. Note that listener_1 has no pools
                 and listener_4 has no members.

        Example::

            {
              "listeners": {
                "listener_uuid_1": {
                  "pools": {},
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                },
                "listener_uuid_2": {
                  "pools": {
                    "pool_uuid_1": {
                      "members": [{
                          "member_uuid_1": "DOWN"
                        },
                        {
                          "member_uuid_2": "DOWN"
                        },
                        {
                          "member_uuid_3": "DOWN"
                        },
                        {
                          "member_uuid_4": "DOWN"
                        }
                      ]
                    }
                  },
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                },
                "listener_uuid_3": {
                  "pools": {
                    "pool_uuid_2": {
                      "members": [{
                          "member_uuid_5": "DOWN"
                        },
                        {
                          "member_uuid_6": "DOWN"
                        },
                        {
                          "member_uuid_7": "DOWN"
                        },
                        {
                          "member_uuid_8": "DOWN"
                        }
                      ]
                    }
                  },
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                },
                "listener_uuid_4": {
                  "pools": {
                    "pool_uuid_3": {
                      "members": []
                    }
                  },
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                }
              },
              "id": "amphora_uuid",
              "seq": 1033
            }

        """
        (data, srcaddr) = self.sock.recvfrom(UDP_MAX_SIZE)
        LOG.debug('Received packet from %s', srcaddr)
        obj = status_message.unwrap_envelope(data, self.key)
        return obj, srcaddr
示例#7
0
    def dorecv(self, *args, **kw):
        """Waits for a UDP heart beat to be sent.

        :return: Returns the unwrapped payload and addr that sent the
                 heartbeat. The format of the obj from the UDP sender
                 can be seen below. Note that listener_1 has no pools
                 and listener_4 has no members.

        Example::

            {
              "listeners": {
                "listener_uuid_1": {
                  "pools": {},
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                },
                "listener_uuid_2": {
                  "pools": {
                    "pool_uuid_1": {
                      "members": [{
                          "member_uuid_1": "DOWN"
                        },
                        {
                          "member_uuid_2": "DOWN"
                        },
                        {
                          "member_uuid_3": "DOWN"
                        },
                        {
                          "member_uuid_4": "DOWN"
                        }
                      ]
                    }
                  },
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                },
                "listener_uuid_3": {
                  "pools": {
                    "pool_uuid_2": {
                      "members": [{
                          "member_uuid_5": "DOWN"
                        },
                        {
                          "member_uuid_6": "DOWN"
                        },
                        {
                          "member_uuid_7": "DOWN"
                        },
                        {
                          "member_uuid_8": "DOWN"
                        }
                      ]
                    }
                  },
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                },
                "listener_uuid_4": {
                  "pools": {
                    "pool_uuid_3": {
                      "members": []
                    }
                  },
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                }
              },
              "id": "amphora_uuid",
              "seq": 1033
            }

        """
        (data, srcaddr) = self.sock.recvfrom(UDP_MAX_SIZE)
        LOG.debug('Received packet from %s', srcaddr)
        try:
            obj = status_message.unwrap_envelope(data, self.key)
        except Exception as e:
            LOG.warning(
                'Health Manager experienced an exception processing a '
                'heartbeat message from %s. Ignoring this packet. '
                'Exception: %s', srcaddr, e)
            raise exceptions.InvalidHMACException()
        obj['recv_time'] = time.time()
        return obj, srcaddr
示例#8
0
    def dorecv(self, *args, **kw):
        """Waits for a UDP heart beat to be sent.

        :return: Returns the unwrapped payload and addr that sent the
                 heartbeat. The format of the obj from the UDP sender
                 can be seen below. Note that listener_1 has no pools
                 and listener_4 has no members.

        {"listeners": {
        "listener_uuid_1": {
            "pools": {},
            "status": "OPEN",
            "stats": {
                "conns": 0,
                "rx": 0,
                "tx": 0
            }
        },
        "listener_uuid_2": {
            "pools": {
                "pool_uuid_1": {
                    "members": [
                        {
                            "member_uuid_1": "DOWN"
                        },
                        {
                            "member_uuid_2": "DOWN"
                        },
                        {
                            "member_uuid_3": "DOWN"
                        },
                        {
                            "member_uuid_4": "DOWN"
                        }
                    ]
                }
            },
            "status": "OPEN",
            "stats": {
                "conns": 0,
                "rx": 0,
                "tx": 0
            }
        },
        "listener_uuid_3": {
            "pools": {
                "pool_uuid_2": {
                    "members": [
                        {
                            "member_uuid_5": "DOWN"
                        },
                        {
                            "member_uuid_6": "DOWN"
                        },
                        {
                            "member_uuid_7": "DOWN"
                        },
                        {
                            "member_uuid_8": "DOWN"
                        }
                    ]
                }
            },
            "status": "OPEN",
            "stats": {
                "conns": 0,
                "rx": 0,
                "tx": 0
            }
        },
        "listener_uuid_4": {
            "pools": {
                "pool_uuid_3": {
                    "members": []
                }
            },
            "status": "OPEN",
            "stats": {
                "conns": 0,
                "rx": 0,
                "tx": 0
            }
        }
    },
    "id": "amphora_uuid",
    "seq": 1033
}

        """
        (data, srcaddr) = self.sock.recvfrom(UDP_MAX_SIZE)
        obj = status_message.unwrap_envelope(data, self.key)
        return obj, srcaddr
示例#9
0
    def dorecv(self, *args, **kw):
        """Waits for a UDP heart beat to be sent.

        :return: Returns the unwrapped payload and addr that sent the
                 heartbeat. The format of the obj from the UDP sender
                 can be seen below. Note that listener_1 has no pools
                 and listener_4 has no members.

        Example::

            {
              "listeners": {
                "listener_uuid_1": {
                  "pools": {},
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                },
                "listener_uuid_2": {
                  "pools": {
                    "pool_uuid_1": {
                      "members": [{
                          "member_uuid_1": "DOWN"
                        },
                        {
                          "member_uuid_2": "DOWN"
                        },
                        {
                          "member_uuid_3": "DOWN"
                        },
                        {
                          "member_uuid_4": "DOWN"
                        }
                      ]
                    }
                  },
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                },
                "listener_uuid_3": {
                  "pools": {
                    "pool_uuid_2": {
                      "members": [{
                          "member_uuid_5": "DOWN"
                        },
                        {
                          "member_uuid_6": "DOWN"
                        },
                        {
                          "member_uuid_7": "DOWN"
                        },
                        {
                          "member_uuid_8": "DOWN"
                        }
                      ]
                    }
                  },
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                },
                "listener_uuid_4": {
                  "pools": {
                    "pool_uuid_3": {
                      "members": []
                    }
                  },
                  "status": "OPEN",
                  "stats": {
                    "conns": 0,
                    "rx": 0,
                    "tx": 0
                  }
                }
              },
              "id": "amphora_uuid",
              "seq": 1033
            }

        """
        (data, srcaddr) = self.sock.recvfrom(UDP_MAX_SIZE)
        LOG.debug('Received packet from %s', srcaddr)
        try:
            obj = status_message.unwrap_envelope(data, self.key)
        except Exception as e:
            LOG.warning('Health Manager experienced an exception processing a '
                        'heartbeat message from %s. Ignoring this packet. '
                        'Exception: %s', srcaddr, e)
            raise exceptions.InvalidHMACException()
        obj['recv_time'] = time.time()
        return obj, srcaddr[0]