Set ARQ get_all return 423 when any ARQ for vm is not resolved
When nova or some user call ARQ get_all with url like: accelerator/v2/accelerator_requests?instance=f0fbe76c-1923-4758-ae54-e57631c98711&bind_state=resolved If any ARQ for this instance is not resolved, the return code should be 423(Locked) which will alert the user that the current arq is being operated. Change-Id: If95d39e5c326d70e17a9649bd281514e2ccf9abe
This commit is contained in:
parent
f647059215
commit
d4704429fb
|
@ -194,12 +194,9 @@ class ARQsController(base.CyborgController):
|
|||
arq['state'] != 'BindFailed'):
|
||||
unbound_flag = True
|
||||
if instance is not None and unbound_flag:
|
||||
# Return HTTP code 'Locked'
|
||||
# TODO(Sundar) This should return HTTP code 423
|
||||
# if any ARQ for this instance is not resolved.
|
||||
LOG.warning('HTTP Response should be 423')
|
||||
pecan.response.status = http_client.LOCKED
|
||||
return None
|
||||
# Return HTTP code '423 Locked'
|
||||
return wsme.api.Response(None, status_code=http_client.LOCKED)
|
||||
|
||||
ret = ARQCollection.convert_with_links(arqs)
|
||||
LOG.info('[arqs:get_all] Returned: %s', ret)
|
||||
|
|
|
@ -75,6 +75,16 @@ class TestARQsController(v2_test.APITestV2):
|
|||
for in_extarq, out_arq in zip(self.fake_extarqs, out_arqs):
|
||||
self._validate_arq(in_extarq.arq, out_arq)
|
||||
|
||||
# test get_all response "423 Locked"
|
||||
instance_uuid = self.fake_extarqs[0].arq.instance_uuid
|
||||
# set ARQ state to 'BindStarted'
|
||||
self.fake_extarqs[0].arq.state = 'BindStarted'
|
||||
mock_extarqs.return_value = self.fake_extarqs
|
||||
url = '%s?instance=%s&bind_state=resolved' % (
|
||||
self.ARQ_URL, instance_uuid)
|
||||
response = self.get_json(url, self.headers)
|
||||
self.assertEqual(http_client.LOCKED, response.status_int)
|
||||
|
||||
@mock.patch('cyborg.objects.DeviceProfile.get_by_name')
|
||||
@mock.patch('cyborg.objects.ExtARQ.create')
|
||||
def test_create(self, mock_obj_extarq, mock_obj_dp):
|
||||
|
|
Loading…
Reference in New Issue