diff --git a/magnum/objects/magnum_service.py b/magnum/objects/magnum_service.py index 2160b499f5..bde0d634bd 100644 --- a/magnum/objects/magnum_service.py +++ b/magnum/objects/magnum_service.py @@ -90,7 +90,12 @@ class MagnumService(base.MagnumPersistentObject, base.MagnumObject, def create(self, context=None): """Create a MagnumService record in the DB. - :param context: Security context. + :param context: Security context. NOTE: This should only + be used internally by the indirection_api. + Unfortunately, RPC requires context as the first + argument, even though we don't use it. + A context should be set when instantiating the + object, e.g.: MagnumService(context) """ values = self.obj_get_changes() db_magnum_service = self.dbapi.create_magnum_service(values) @@ -100,7 +105,12 @@ class MagnumService(base.MagnumPersistentObject, base.MagnumObject, def destroy(self, context=None): """Delete the MagnumService from the DB. - :param context: Security context. + :param context: Security context. NOTE: This should only + be used internally by the indirection_api. + Unfortunately, RPC requires context as the first + argument, even though we don't use it. + A context should be set when instantiating the + object, e.g.: MagnumService(context) """ self.dbapi.destroy_magnum_service(self.id) self.obj_reset_changes() @@ -112,7 +122,12 @@ class MagnumService(base.MagnumPersistentObject, base.MagnumObject, Updates will be made column by column based on the result of self.what_changed(). - :param context: Security context. + :param context: Security context. NOTE: This should only + be used internally by the indirection_api. + Unfortunately, RPC requires context as the first + argument, even though we don't use it. + A context should be set when instantiating the + object, e.g.: MagnumService(context) """ updates = self.obj_get_changes() self.dbapi.update_magnum_service(self.id, updates) @@ -122,7 +137,12 @@ class MagnumService(base.MagnumPersistentObject, base.MagnumObject, def report_state_up(self, context=None): """Touching the magnum_service record to show aliveness. - :param context: Security context. + :param context: Security context. NOTE: This should only + be used internally by the indirection_api. + Unfortunately, RPC requires context as the first + argument, even though we don't use it. + A context should be set when instantiating the + object, e.g.: MagnumService(context) """ self.report_count += 1 - self.save(context) + self.save() diff --git a/magnum/servicegroup/magnum_service_periodic.py b/magnum/servicegroup/magnum_service_periodic.py index b18407df62..f6d55b2bbf 100644 --- a/magnum/servicegroup/magnum_service_periodic.py +++ b/magnum/servicegroup/magnum_service_periodic.py @@ -51,8 +51,8 @@ class MagnumServicePeriodicTasks(periodic_task.PeriodicTasks): } self.magnum_service_ref = objects.MagnumService( ctx, **magnum_service_dict) - self.magnum_service_ref.create(ctx) - self.magnum_service_ref.report_state_up(ctx) + self.magnum_service_ref.create() + self.magnum_service_ref.report_state_up() def setup(conf, binary, tg): diff --git a/magnum/tests/unit/servicegroup/test_magnum_service.py b/magnum/tests/unit/servicegroup/test_magnum_service.py index ef0b5745d3..161603addd 100644 --- a/magnum/tests/unit/servicegroup/test_magnum_service.py +++ b/magnum/tests/unit/servicegroup/test_magnum_service.py @@ -48,8 +48,8 @@ class MagnumServicePeriodicTestCase(base.TestCase): mock_ms_get.assert_called_once_with(mock.ANY, p_task.host, p_task.binary) - mock_ms_create.assert_called_once_with(mock.ANY) - mock_ms_refresh.assert_called_once_with(mock.ANY) + mock_ms_create.assert_called_once_with() + mock_ms_refresh.assert_called_once_with() @mock.patch.object(objects.MagnumService, 'get_by_host_and_binary') @mock.patch.object(objects.MagnumService, 'create') @@ -64,7 +64,7 @@ class MagnumServicePeriodicTestCase(base.TestCase): mock_ms_get.assert_called_once_with(mock.ANY, p_task.host, p_task.binary) - self.fake_ms_refresh.assert_called_once_with(mock.ANY) + self.fake_ms_refresh.assert_called_once_with() def test_update_magnum_service_regular(self): p_task = periodic.MagnumServicePeriodicTasks(CONF, @@ -73,4 +73,4 @@ class MagnumServicePeriodicTestCase(base.TestCase): p_task.update_magnum_service(None) - self.fake_ms_refresh.assert_called_once_with(mock.ANY) + self.fake_ms_refresh.assert_called_once_with()