Fix active/standby under python3
Changes in diskimage-builder switched the amphora image to use python3. The active/standby code was not python3 compatible. This patch corrects that issue. Change-Id: I81db0e52f1a21d1e3ceea6a4ec2467145f761e55 Closes-Bug: #1659116
This commit is contained in:
parent
e8c2ea8d6c
commit
eebd2d4e33
@ -50,7 +50,7 @@ class Keepalived(object):
|
||||
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
|
||||
# mode 00644
|
||||
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
|
||||
with os.fdopen(os.open(conf_file, flags, mode), 'w') as f:
|
||||
with os.fdopen(os.open(conf_file, flags, mode), 'wb') as f:
|
||||
b = stream.read(BUFFER)
|
||||
while b:
|
||||
f.write(b)
|
||||
|
@ -29,8 +29,8 @@ def get_status(sock_address):
|
||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
s.settimeout(SOCKET_TIMEOUT)
|
||||
s.connect(sock_address)
|
||||
s.send('show stat -1 -1 -1\n')
|
||||
data = ''
|
||||
s.send(b'show stat -1 -1 -1\n')
|
||||
data = b''
|
||||
while True:
|
||||
x = s.recv(1024)
|
||||
if not x:
|
||||
|
@ -1450,7 +1450,7 @@ class TestServerTestCase(base.TestCase):
|
||||
|
||||
mode = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
|
||||
mock_open.assert_called_with(cfg_path, flags, mode)
|
||||
mock_fdopen.assert_called_with(123, 'w')
|
||||
mock_fdopen.assert_called_with(123, 'wb')
|
||||
self.assertEqual(200, rv.status_code)
|
||||
|
||||
mock_exists.return_value = False
|
||||
|
@ -28,7 +28,7 @@ class TestHAproxyVRRPCheckCMD(base.TestCase):
|
||||
socket_mock = mock.MagicMock()
|
||||
mock_socket.return_value = socket_mock
|
||||
recv_mock = mock.MagicMock()
|
||||
recv_mock.side_effect = ['1', Exception('BREAK')]
|
||||
recv_mock.side_effect = [b'1', Exception('BREAK')]
|
||||
socket_mock.recv = recv_mock
|
||||
|
||||
self.assertRaisesRegexp(Exception, 'BREAK',
|
||||
|
Loading…
Reference in New Issue
Block a user