diff --git a/cyborg/api/controllers/v2/arqs.py b/cyborg/api/controllers/v2/arqs.py index c1c74a4e..c1c98717 100644 --- a/cyborg/api/controllers/v2/arqs.py +++ b/cyborg/api/controllers/v2/arqs.py @@ -344,5 +344,5 @@ class ARQsController(base.CyborgController): if patch[0]['op'] == 'add': self._check_if_already_bound(context, valid_fields) - # TODO(Sundar) Defer to conductor and do all concurently. - objects.ExtARQ.apply_patch(context, patch_list, valid_fields) + pecan.request.conductor_api.arq_apply_patch( + context, patch_list, valid_fields) diff --git a/cyborg/conductor/manager.py b/cyborg/conductor/manager.py index edd017c3..315c205f 100644 --- a/cyborg/conductor/manager.py +++ b/cyborg/conductor/manager.py @@ -97,6 +97,15 @@ class ConductorManager(object): """ ExtARQ.delete_by_instance(context, instance) + def arq_apply_patch(self, context, patch_list, valid_fields): + """Signal to conductor service to apply patch accelerator requests. + + :param context: request context. + :param patch_list: A map from ARQ UUIDs to their JSON patches + :param valid_fields: Dict of valid fields + """ + ExtARQ.apply_patch(context, patch_list, valid_fields) + def report_data(self, context, hostname, driver_device_list): """Update the Cyborg DB in one hostname according to the discovered device list. diff --git a/cyborg/conductor/rpcapi.py b/cyborg/conductor/rpcapi.py index 7d38f868..93c2034d 100644 --- a/cyborg/conductor/rpcapi.py +++ b/cyborg/conductor/rpcapi.py @@ -107,3 +107,14 @@ class ConductorAPI(object): """ cctxt = self.client.prepare(topic=self.topic) cctxt.call(context, 'arq_delete_by_instance_uuid', instance=instance) + + def arq_apply_patch(self, context, patch_list, valid_fields): + """Signal to conductor service to apply patch accelerator requests. + + :param context: request context. + :param patch_list: A map from ARQ UUIDs to their JSON patches + :param valid_fields: Dict of valid fields + """ + cctxt = self.client.prepare(topic=self.topic) + return cctxt.call(context, 'arq_apply_patch', patch_list=patch_list, + valid_fields=valid_fields) diff --git a/cyborg/tests/unit/api/controllers/v2/test_arqs.py b/cyborg/tests/unit/api/controllers/v2/test_arqs.py index f5e840f9..ea555db6 100644 --- a/cyborg/tests/unit/api/controllers/v2/test_arqs.py +++ b/cyborg/tests/unit/api/controllers/v2/test_arqs.py @@ -254,7 +254,7 @@ class TestARQsController(v2_test.APITestV2): self.assertIn("Bad response: 403 Forbidden", exc.args[0]) @mock.patch.object(arqs.ARQsController, '_check_if_already_bound') - @mock.patch('cyborg.objects.ExtARQ.apply_patch') + @mock.patch('cyborg.conductor.rpcapi.ConductorAPI.arq_apply_patch') def test_apply_patch(self, mock_apply_patch, mock_check_if_bound): """Test the happy path.""" patch_list, device_rp_uuid = fake_extarq.get_patch_list() @@ -275,7 +275,7 @@ class TestARQsController(v2_test.APITestV2): mock_check_if_bound.assert_called_once_with(mock.ANY, valid_fields) @mock.patch.object(arqs.ARQsController, '_check_if_already_bound') - @mock.patch('cyborg.objects.ExtARQ.apply_patch') + @mock.patch('cyborg.conductor.rpcapi.ConductorAPI.arq_apply_patch') def test_apply_patch_allow_project_id( self, mock_apply_patch, mock_check_if_bound): patch_list, _ = fake_extarq.get_patch_list()