Handle the case when get_by_host_and_binary return None
This patch adds the code for get_by_host_and_binary return None in service delete. Change-Id: I37f8fcbcc4786f0b0a886b00784d635e9b8607f8
This commit is contained in:
@@ -83,5 +83,10 @@ class ZunServiceController(base.Controller):
|
||||
context = pecan.request.context
|
||||
policy.enforce(context, "zun-service:delete",
|
||||
action="zun-service:delete")
|
||||
objects.ZunService.get_by_host_and_binary(
|
||||
context, host, binary).destroy(context)
|
||||
svc = objects.ZunService.get_by_host_and_binary(
|
||||
context, host, binary)
|
||||
if svc is None:
|
||||
raise exception.ZunServiceNotFound(
|
||||
binary=binary, host=host)
|
||||
else:
|
||||
svc.destroy(context)
|
||||
|
||||
Reference in New Issue
Block a user