diff options
| author | Matthew Sherborne <msherborne@gmail.com> | 2013-03-15 13:46:12 +1000 |
|---|---|---|
| committer | Matthew Sherborne <msherborne@gmail.com> | 2013-04-23 22:04:01 +1000 |
| commit | 732bcdb9502aca5c6b38966bd1e53c79236300da (patch) | |
| tree | e7a5ab2c4fd2fad84c66d64548833f3bc2309236 /nova/compute | |
| parent | bfc3a3ccb2811cc8a96a15987528e6639ec029bf (diff) | |
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
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 9 | ||||
| -rw-r--r-- | nova/compute/cells_api.py | 13 |
2 files changed, 22 insertions, 0 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 1b1a3c506..73d9a652c 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -41,6 +41,7 @@ from nova.compute import utils as compute_utils from nova.compute import vm_states from nova.consoleauth import rpcapi as consoleauth_rpcapi from nova import crypto +from nova import db from nova.db import base from nova import exception from nova import hooks @@ -2564,6 +2565,14 @@ class HostAPI(base.Base): """Get service entry for the given compute hostname.""" return self.db.service_get_by_compute_host(context, host_name) + def service_update(self, context, host_name, binary, params_to_update): + """ + Enable / Disable a service. + For compute services, this stops new builds and migrations going to + the host.""" + service = db.service_get_by_args(context, host_name, binary) + return db.service_update(context, service['id'], params_to_update) + def instance_get_all_by_host(self, context, host_name): """Return all instances on the given host.""" return self.db.instance_get_all_by_host(context, host_name) diff --git a/nova/compute/cells_api.py b/nova/compute/cells_api.py index f5ded45ec..9c0f72c97 100644 --- a/nova/compute/cells_api.py +++ b/nova/compute/cells_api.py @@ -603,6 +603,19 @@ class HostAPI(compute_api.HostAPI): return self.cells_rpcapi.service_get_by_compute_host(context, host_name) + def service_update(self, context, host_name, binary, params_to_update): + """ + Used to enable/disable a service. For compute services, setting to + disabled stops new builds arriving on that host. + + :param host_name: the name of the host machine that the service is + running + :param binary: The name of the executable that the service runs as + :param params_to_update: eg. {'disabled': True} + """ + return self.cells_rpcapi.service_update( + context, host_name, binary, params_to_update) + def instance_get_all_by_host(self, context, host_name): """Get all instances by host. Host might have a cell prepended to it, so we'll need to strip it out. We don't need to proxy |
