From: Jason Dillaman Date: Tue, 22 Oct 2019 18:29:45 +0000 (-0400) Subject: mgr/dashboard: add site name to mirroring summary collection X-Git-Tag: v15.1.0~633^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ba30ef2f8f217f1ef723d9565d6c53052b20b117;p=ceph-ci.git mgr/dashboard: add site name to mirroring summary collection The summary is periodically polled by the UI so it can now reflect changes to the site name w/o specifically needing to poll just the site name. Signed-off-by: Jason Dillaman --- diff --git a/src/pybind/mgr/dashboard/controllers/rbd_mirroring.py b/src/pybind/mgr/dashboard/controllers/rbd_mirroring.py index 3cd9bb298b0..05301277d19 100644 --- a/src/pybind/mgr/dashboard/controllers/rbd_mirroring.py +++ b/src/pybind/mgr/dashboard/controllers/rbd_mirroring.py @@ -356,8 +356,12 @@ class RbdMirroringSummary(BaseController): @handle_rbd_mirror_error() @ReadPermission def __call__(self): + site_name = rbd.RBD().mirror_site_name_get(mgr.rados) + status, content_data = _get_content_data() - return {'status': status, 'content_data': content_data} + return {'site_name': site_name, + 'status': status, + 'content_data': content_data} @ApiController('/block/mirroring/pool', Scope.RBD_MIRRORING) diff --git a/src/pybind/mgr/dashboard/tests/test_rbd_mirroring.py b/src/pybind/mgr/dashboard/tests/test_rbd_mirroring.py index 9a0142b4b2c..ecb4856dc19 100644 --- a/src/pybind/mgr/dashboard/tests/test_rbd_mirroring.py +++ b/src/pybind/mgr/dashboard/tests/test_rbd_mirroring.py @@ -157,19 +157,26 @@ class RbdMirroringSummaryControllerTest(ControllerTestCase): cls.setup_controllers([RbdMirroringSummary, Summary], '/test') - @mock.patch('dashboard.controllers.rbd_mirroring.rbd') - def test_default(self, rbd_mock): # pylint: disable=W0613 + @mock.patch('dashboard.controllers.rbd_mirroring.rbd.RBD') + def test_default(self, mock_rbd): + mock_rbd_instance = mock_rbd.return_value + mock_rbd_instance.mirror_site_name_get.return_value = 'site-a' + self._get('/test/api/block/mirroring/summary') result = self.json_body() self.assertStatus(200) + self.assertEqual(result['site_name'], 'site-a') self.assertEqual(result['status'], 0) for k in ['daemons', 'pools', 'image_error', 'image_syncing', 'image_ready']: self.assertIn(k, result['content_data']) @mock.patch('dashboard.controllers.BaseController._has_permissions') - @mock.patch('dashboard.controllers.rbd_mirroring.rbd') - def test_summary(self, rbd_mock, has_perms_mock): # pylint: disable=W0613 + @mock.patch('dashboard.controllers.rbd_mirroring.rbd.RBD') + def test_summary(self, mock_rbd, has_perms_mock): """We're also testing `summary`, as it also uses code from `rbd_mirroring.py`""" + mock_rbd_instance = mock_rbd.return_value + mock_rbd_instance.mirror_site_name_get.return_value = 'site-a' + has_perms_mock.return_value = True self._get('/test/api/summary') self.assertStatus(200)