diff --git a/etc/zun/policy.json b/etc/zun/policy.json index 2f453782c..1a7f0b6a1 100644 --- a/etc/zun/policy.json +++ b/etc/zun/policy.json @@ -32,5 +32,6 @@ "image:search": "rule:default", + "zun-service:delete": "rule:admin_api", "zun-service:get_all": "rule:admin_api" } diff --git a/zun/api/controllers/v1/zun_services.py b/zun/api/controllers/v1/zun_services.py index c10b97b4d..6b3dc0b51 100644 --- a/zun/api/controllers/v1/zun_services.py +++ b/zun/api/controllers/v1/zun_services.py @@ -71,3 +71,17 @@ class ZunServiceController(base.Controller): sort_dir='asc') return ZunServiceCollection.convert_db_rec_list_to_collection( self.servicegroup_api, hsvcs) + + @pecan.expose('json') + @exception.wrap_pecan_controller_exception + def delete(self, host, binary): + """Delete the specified service. + + :param host: The host on which the binary is running. + :param binary: The name of the binary. + """ + 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)