コード例 #1
0
ファイル: test_envelope.py プロジェクト: zwyw610/octavia
 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
ファイル: test_envelope.py プロジェクト: crc32a/octavia
 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
ファイル: test_envelope.py プロジェクト: zwyw610/octavia
    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
ファイル: test_envelope.py プロジェクト: openstack/octavia
    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 _send_msg(self, dest, msg):
     envelope_str = status_message.wrap_envelope(msg, self.key)
     # dest = (family, socktype, proto, canonname, sockaddr)
     # e.g. 0 = sock family, 4 = sockaddr - what we actually need
     try:
         if dest[0] == socket.AF_INET:
             self.v4sock.sendto(envelope_str, dest[4])
         elif dest[0] == socket.AF_INET6:
             self.v6sock.sendto(envelope_str, dest[4])
     except socket.error:
         # Pass here as on amp boot it will get one or more
         # error: [Errno 101] Network is unreachable
         # while the networks are coming up
         # No harm in trying to send as it will still failover
         # if the message isn't received
         pass
コード例 #6
0
ファイル: health_sender.py プロジェクト: openstack/octavia
 def _send_msg(self, dest, msg):
     # Note: heartbeat_key is mutable and must be looked up for each call
     envelope_str = status_message.wrap_envelope(
         msg, str(CONF.health_manager.heartbeat_key))
     # dest = (family, socktype, proto, canonname, sockaddr)
     # e.g. 0 = sock family, 4 = sockaddr - what we actually need
     try:
         if dest[0] == socket.AF_INET:
             self.v4sock.sendto(envelope_str, dest[4])
         elif dest[0] == socket.AF_INET6:
             self.v6sock.sendto(envelope_str, dest[4])
     except socket.error:
         # Pass here as on amp boot it will get one or more
         # error: [Errno 101] Network is unreachable
         # while the networks are coming up
         # No harm in trying to send as it will still failover
         # if the message isn't received
         pass
コード例 #7
0
ファイル: health_sender.py プロジェクト: xinhuoxing/octavia
 def dosend(self, obj):
     envelope_str = status_message.wrap_envelope(obj, self.key)
     addrinfo = round_robin_addr(self.dests)
     # dest = (family, socktype, proto, canonname, sockaddr)
     # e.g. 0 = sock family, 4 = sockaddr - what we actually need
     if addrinfo is None:
         LOG.error('No controller address found. Unable to send heartbeat.')
         return
     try:
         if addrinfo[0] == socket.AF_INET:
             self.v4sock.sendto(envelope_str, addrinfo[4])
         elif addrinfo[0] == socket.AF_INET6:
             self.v6sock.sendto(envelope_str, addrinfo[4])
     except socket.error:
         # Pass here as on amp boot it will get one or more
         # error: [Errno 101] Network is unreachable
         # while the networks are coming up
         # No harm in trying to send as it will still failover
         # if the message isn't received
         pass
コード例 #8
0
ファイル: health_sender.py プロジェクト: KevoTran/octavia
 def dosend(self, obj):
     envelope_str = status_message.wrap_envelope(obj, self.key)
     addrinfo = round_robin_addr(self.dests)
     # dest = (family, socktype, proto, canonname, sockaddr)
     # e.g. 0 = sock family, 4 = sockaddr - what we actually need
     if addrinfo is None:
         LOG.error(_LE('No controller address found. '
                       'Unable to send heartbeat.'))
         return
     try:
         if addrinfo[0] == socket.AF_INET:
             self.v4sock.sendto(envelope_str, addrinfo[4])
         elif addrinfo[0] == socket.AF_INET6:
             self.v6sock.sendto(envelope_str, addrinfo[4])
     except socket.error:
         # Pass here as on amp boot it will get one or more
         # error: [Errno 101] Network is unreachable
         # while the networks are coming up
         # No harm in trying to send as it will still failover
         # if the message isn't received
         pass