Merge "Change arq delete to cyborg-conductor service write db"

This commit is contained in:
Zuul 2020-09-16 11:52:09 +00:00 committed by Gerrit Code Review
commit 58be956842
4 changed files with 48 additions and 7 deletions

View File

@ -234,21 +234,21 @@ class ARQsController(base.CyborgController):
an error. Nova uses the second form: so repeated calls do not cause
issues.
:param arq: List of ARQ UUIDs
:param arqs: List of ARQ UUIDs
:param instance: UUID of instance whose ARQs need to be deleted
"""
context = pecan.request.context
if (arqs and instance) or ((not arqs) and (not instance)):
if (arqs and instance) or (not arqs and not instance):
raise exception.ObjectActionError(
action='delete',
reason='Provide either an ARQ uuid list or an instance UUID')
elif arqs:
LOG.info("[arqs] delete. arqs=(%s)", arqs)
arqlist = arqs.split(',')
objects.ExtARQ.delete_by_uuid(context, arqlist)
pecan.request.conductor_api.arq_delete_by_uuid(context, arqs)
else: # instance is not None
LOG.info("[arqs] delete. instance=(%s)", instance)
objects.ExtARQ.delete_by_instance(context, instance)
pecan.request.conductor_api.arq_delete_by_instance_uuid(
context, instance)
def _validate_arq_patch(self, patch):
"""Validate a single patch for an ARQ.

View File

@ -29,6 +29,7 @@ from cyborg.objects.deployable import Deployable
from cyborg.objects.device import Device
from cyborg.objects.driver_objects.driver_device import DriverDeployable
from cyborg.objects.driver_objects.driver_device import DriverDevice
from cyborg.objects.ext_arq import ExtARQ
LOG = logging.getLogger(__name__)
@ -77,6 +78,25 @@ class ConductorManager(object):
obj_extarq.create(context, devprof_id)
return obj_extarq
def arq_delete_by_uuid(self, context, arqs):
"""Signal to conductor service to delete accelerator requests by
ARQ UUIDs.
:param context: request context.
:param arqs: ARQ UUIDs joined with ','
"""
arqlist = arqs.split(',')
ExtARQ.delete_by_uuid(context, arqlist)
def arq_delete_by_instance_uuid(self, context, instance):
"""Signal to conductor service to delete accelerator requests by
instance UUID.
:param context: request context.
:param instance: UUID of instance whose ARQs need to be deleted
"""
ExtARQ.delete_by_instance(context, instance)
def report_data(self, context, hostname, driver_device_list):
"""Update the Cyborg DB in one hostname according to the
discovered device list.

View File

@ -87,3 +87,23 @@ class ConductorAPI(object):
cctxt = self.client.prepare(topic=self.topic)
return cctxt.call(context, 'arq_create', obj_extarq=obj_extarq,
devprof_id=devprof_id)
def arq_delete_by_uuid(self, context, arqs):
"""Signal to conductor service to delete accelerator requests by
ARQ UUIDs.
:param context: request context.
:param arqs: ARQ UUIDs joined with ','
"""
cctxt = self.client.prepare(topic=self.topic)
cctxt.call(context, 'arq_delete_by_uuid', arqs=arqs)
def arq_delete_by_instance_uuid(self, context, instance):
"""Signal to conductor service to delete accelerator requests by
instance UUID.
:param context: request context.
:param instance: UUID of instance whose ARQs need to be deleted
"""
cctxt = self.client.prepare(topic=self.topic)
cctxt.call(context, 'arq_delete_by_instance_uuid', instance=instance)

View File

@ -218,8 +218,9 @@ class TestARQsController(v2_test.APITestV2):
"Device Profile not found with "
"name=wrong_device_profile_name", exc.args[0])
@mock.patch('cyborg.objects.ExtARQ.delete_by_uuid')
@mock.patch('cyborg.objects.ExtARQ.delete_by_instance')
@mock.patch('cyborg.conductor.rpcapi.ConductorAPI.arq_delete_by_uuid')
@mock.patch('cyborg.conductor.rpcapi.ConductorAPI.'
'arq_delete_by_instance_uuid')
def test_delete(self, mock_by_inst, mock_by_arq):
url = self.ARQ_URL
arq = self.fake_extarqs[0].arq