From 732bcdb9502aca5c6b38966bd1e53c79236300da Mon Sep 17 00:00:00 2001 From: Matthew Sherborne Date: Fri, 15 Mar 2013 13:46:12 +1000 Subject: Make os.services.update work with cells In the nova.api.openstack.compute.contrib.services: * Make update (enable/disable) service work In nova.compute.api.api.HostAPI: Add - service_update - Used by openstack api's services.py In nova.compute.api.cells_api.HostAPI: Add - service_update - Used by openstack api's services.py In cells: * Increase API version from 1.6 to 1.7 * Add service_update Fixes bug #1150499 Change-Id: I5651bd5bc328692df82f4d9da27d390a8c95e03f --- nova/api/openstack/compute/contrib/services.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/services.py b/nova/api/openstack/compute/contrib/services.py index d948c8bc5..9952484f7 100644 --- a/nova/api/openstack/compute/contrib/services.py +++ b/nova/api/openstack/compute/contrib/services.py @@ -21,7 +21,6 @@ from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api.openstack import xmlutil from nova import compute -from nova import db from nova import exception from nova.openstack.common import timeutils from nova import utils @@ -121,7 +120,10 @@ class ServiceController(object): elif id == "disable": disabled = True else: - raise webob.exc.HTTPNotFound("Unknown action") + raise webob.exc.HTTPNotFound(_("Unknown action")) + + status = id + 'd' + try: host = body['host'] binary = body['binary'] @@ -129,15 +131,11 @@ class ServiceController(object): raise webob.exc.HTTPUnprocessableEntity() try: - svc = db.service_get_by_args(context, host, binary) - if not svc: - raise webob.exc.HTTPNotFound('Unknown service') + svc = self.host_api.service_update(context, host, binary, + {'disabled': disabled}) + except exception.ServiceNotFound as exc: + raise webob.exc.HTTPNotFound(_("Unknown service")) - db.service_update(context, svc['id'], {'disabled': disabled}) - except exception.ServiceNotFound: - raise webob.exc.HTTPNotFound("service not found") - - status = id + 'd' return {'service': {'host': host, 'binary': binary, 'status': status}} -- cgit