Correct port that is exposed for management

For rabbitmq-server version 3+ (Trusty and above) the managment
port is 15672, however the charm exposes the old port 55672. This
change fixes that behaviour. Fwiw the amulet tests are already
expecting the managment interface to be 15672 but tests run with the
OpenStack providor and would have missed that this port was not
being exposed.

Change-Id: Ia61d1c12df9300408d33a1768f546c38b33c5677
Closes-Bug: 1651195
This commit is contained in:
Liam Young 2017-02-02 16:09:09 +00:00
parent 21b6015210
commit 82a92a6d5d
3 changed files with 22 additions and 1 deletions

View File

@ -506,6 +506,13 @@ def disable_plugin(plugin):
_manage_plugin(plugin, 'disable')
def get_managment_port():
if get_upstream_version(VERSION_PACKAGE) >= '3':
return 15672
else:
return 55672
def execute(cmd, die=False, echo=False):
""" Executes a command

View File

@ -594,9 +594,13 @@ def config_changed():
if config('management_plugin') is True:
rabbit.enable_plugin(MAN_PLUGIN)
open_port(55672)
open_port(rabbit.get_managment_port())
else:
rabbit.disable_plugin(MAN_PLUGIN)
close_port(rabbit.get_managment_port())
# LY: Close the old managment port since it may have been opened in a
# previous version of the charm. close_port is a noop if the port
# is not open
close_port(55672)
rabbit.ConfigRenderer(

View File

@ -571,3 +571,13 @@ class UtilsTests(CharmTestCase):
self.network_get_primary_address.return_value = AMQP_IP
self.network_get_primary_address.side_effect = NotImplementedError
self.assertEqual(DEFAULT_IP, rabbit_utils.get_unit_ip())
@mock.patch.object(rabbit_utils, 'get_upstream_version')
def test_get_managment_port_legacy(self, mock_get_upstream_version):
mock_get_upstream_version.return_value = '2.7.1'
self.assertEqual(rabbit_utils.get_managment_port(), 55672)
@mock.patch.object(rabbit_utils, 'get_upstream_version')
def test_get_managment_port(self, mock_get_upstream_version):
mock_get_upstream_version.return_value = '3.5.7'
self.assertEqual(rabbit_utils.get_managment_port(), 15672)