summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/api_samples/os-services/service-disable-put-req.json4
-rw-r--r--doc/api_samples/os-services/service-disable-put-resp.json10
-rw-r--r--doc/api_samples/os-services/service-enable-put-resp.json10
-rw-r--r--doc/api_samples/os-services/services-list-get-resp.json2
-rw-r--r--nova/api/openstack/compute/contrib/services.py21
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_services.py12
-rw-r--r--nova/tests/integrated/api_samples/os-services/service-disable-put-req.json.tpl2
-rw-r--r--nova/tests/integrated/api_samples/os-services/service-disable-put-resp.json.tpl8
-rw-r--r--nova/tests/integrated/api_samples/os-services/service-enable-put-req.json.tpl2
-rw-r--r--nova/tests/integrated/api_samples/os-services/service-enable-put-resp.json.tpl9
-rw-r--r--nova/tests/integrated/test_api_samples.py12
11 files changed, 51 insertions, 41 deletions
diff --git a/doc/api_samples/os-services/service-disable-put-req.json b/doc/api_samples/os-services/service-disable-put-req.json
index d11afaed9..f96d34536 100644
--- a/doc/api_samples/os-services/service-disable-put-req.json
+++ b/doc/api_samples/os-services/service-disable-put-req.json
@@ -1,4 +1,4 @@
{
"host": "host1",
- "service": "nova-compute"
-} \ No newline at end of file
+ "binary": "nova-compute"
+}
diff --git a/doc/api_samples/os-services/service-disable-put-resp.json b/doc/api_samples/os-services/service-disable-put-resp.json
index 2e461bc6d..2c21c547f 100644
--- a/doc/api_samples/os-services/service-disable-put-resp.json
+++ b/doc/api_samples/os-services/service-disable-put-resp.json
@@ -1,5 +1,7 @@
{
- "disabled": true,
- "host": "host1",
- "service": "nova-compute"
-} \ No newline at end of file
+ "service": {
+ "host": "host1",
+ "binary": "nova-compute",
+ "status": "disabled"
+ }
+}
diff --git a/doc/api_samples/os-services/service-enable-put-resp.json b/doc/api_samples/os-services/service-enable-put-resp.json
index 88b9dc7f9..75c4ebd55 100644
--- a/doc/api_samples/os-services/service-enable-put-resp.json
+++ b/doc/api_samples/os-services/service-enable-put-resp.json
@@ -1,5 +1,7 @@
{
- "disabled": false,
- "host": "host1",
- "service": "nova-compute"
-} \ No newline at end of file
+ "service": {
+ "host": "host1",
+ "binary": "nova-compute",
+ "status": "enabled"
+ }
+}
diff --git a/doc/api_samples/os-services/services-list-get-resp.json b/doc/api_samples/os-services/services-list-get-resp.json
index dcda1a46e..572d5d863 100644
--- a/doc/api_samples/os-services/services-list-get-resp.json
+++ b/doc/api_samples/os-services/services-list-get-resp.json
@@ -33,4 +33,4 @@
"zone": "nova"
}
]
-} \ No newline at end of file
+}
diff --git a/nova/api/openstack/compute/contrib/services.py b/nova/api/openstack/compute/contrib/services.py
index fb7b9d591..558c31586 100644
--- a/nova/api/openstack/compute/contrib/services.py
+++ b/nova/api/openstack/compute/contrib/services.py
@@ -51,8 +51,8 @@ class ServicesUpdateTemplate(xmlutil.TemplateBuilder):
def construct(self):
root = xmlutil.TemplateElement('host')
root.set('host')
- root.set('service')
- root.set('disabled')
+ root.set('binary')
+ root.set('status')
return xmlutil.MasterTemplate(root, 1)
@@ -76,13 +76,13 @@ class ServiceController(object):
host = ''
if 'host' in req.GET:
host = req.GET['host']
- service = ''
- if 'service' in req.GET:
- service = req.GET['service']
+ binary = ''
+ if 'binary' in req.GET:
+ binary = req.GET['binary']
if host:
services = [s for s in services if s['host'] == host]
- if service:
- services = [s for s in services if s['binary'] == service]
+ if binary:
+ services = [s for s in services if s['binary'] == binary]
svcs = []
for svc in services:
@@ -113,12 +113,12 @@ class ServiceController(object):
try:
host = body['host']
- service = body['service']
+ binary = body['binary']
except (TypeError, KeyError):
raise webob.exc.HTTPUnprocessableEntity()
try:
- svc = db.service_get_by_args(context, host, service)
+ svc = db.service_get_by_args(context, host, binary)
if not svc:
raise webob.exc.HTTPNotFound('Unknown service')
@@ -126,7 +126,8 @@ class ServiceController(object):
except exception.ServiceNotFound:
raise webob.exc.HTTPNotFound("service not found")
- return {'host': host, 'service': service, 'disabled': disabled}
+ status = id + 'd'
+ return {'service': {'host': host, 'binary': binary, 'status': status}}
class Services(extensions.ExtensionDescriptor):
diff --git a/nova/tests/api/openstack/compute/contrib/test_services.py b/nova/tests/api/openstack/compute/contrib/test_services.py
index cb7ce67cb..57dd056ee 100644
--- a/nova/tests/api/openstack/compute/contrib/test_services.py
+++ b/nova/tests/api/openstack/compute/contrib/test_services.py
@@ -64,7 +64,7 @@ class FakeRequest(object):
class FakeRequestWithService(object):
environ = {"nova.context": context.get_admin_context()}
- GET = {"service": "nova-compute"}
+ GET = {"binary": "nova-compute"}
class FakeRequestWithHost(object):
@@ -74,7 +74,7 @@ class FakeRequestWithHost(object):
class FakeRequestWithHostService(object):
environ = {"nova.context": context.get_admin_context()}
- GET = {"host": "host1", "service": "nova-compute"}
+ GET = {"host": "host1", "binary": "nova-compute"}
def fake_host_api_service_get_all(context, filters=None, set_zones=False):
@@ -190,15 +190,15 @@ class ServicesTest(test.TestCase):
self.assertEqual(res_dict, response)
def test_services_enable(self):
- body = {'host': 'host1', 'service': 'nova-compute'}
+ body = {'host': 'host1', 'binary': 'nova-compute'}
req = fakes.HTTPRequest.blank('/v2/fake/os-services/enable')
res_dict = self.controller.update(req, "enable", body)
- self.assertEqual(res_dict['disabled'], False)
+ self.assertEqual(res_dict['service']['status'], 'enabled')
def test_services_disable(self):
req = fakes.HTTPRequest.blank('/v2/fake/os-services/disable')
- body = {'host': 'host1', 'service': 'nova-compute'}
+ body = {'host': 'host1', 'binary': 'nova-compute'}
res_dict = self.controller.update(req, "disable", body)
- self.assertEqual(res_dict['disabled'], True)
+ self.assertEqual(res_dict['service']['status'], 'disabled')
diff --git a/nova/tests/integrated/api_samples/os-services/service-disable-put-req.json.tpl b/nova/tests/integrated/api_samples/os-services/service-disable-put-req.json.tpl
index 4d48af1b8..57182e935 100644
--- a/nova/tests/integrated/api_samples/os-services/service-disable-put-req.json.tpl
+++ b/nova/tests/integrated/api_samples/os-services/service-disable-put-req.json.tpl
@@ -1,4 +1,4 @@
{
"host": "%(host)s",
- "service": "%(service)s"
+ "binary": "%(binary)s"
}
diff --git a/nova/tests/integrated/api_samples/os-services/service-disable-put-resp.json.tpl b/nova/tests/integrated/api_samples/os-services/service-disable-put-resp.json.tpl
index 8219a43f6..47a8b3d81 100644
--- a/nova/tests/integrated/api_samples/os-services/service-disable-put-resp.json.tpl
+++ b/nova/tests/integrated/api_samples/os-services/service-disable-put-resp.json.tpl
@@ -1,5 +1,7 @@
{
- "disabled": true,
- "host": "%(host)s",
- "service": "%(service)s"
+ "service": {
+ "host": "%(host)s",
+ "binary": "%(binary)s",
+ "status": "disabled"
+ }
}
diff --git a/nova/tests/integrated/api_samples/os-services/service-enable-put-req.json.tpl b/nova/tests/integrated/api_samples/os-services/service-enable-put-req.json.tpl
index 4d48af1b8..57182e935 100644
--- a/nova/tests/integrated/api_samples/os-services/service-enable-put-req.json.tpl
+++ b/nova/tests/integrated/api_samples/os-services/service-enable-put-req.json.tpl
@@ -1,4 +1,4 @@
{
"host": "%(host)s",
- "service": "%(service)s"
+ "binary": "%(binary)s"
}
diff --git a/nova/tests/integrated/api_samples/os-services/service-enable-put-resp.json.tpl b/nova/tests/integrated/api_samples/os-services/service-enable-put-resp.json.tpl
index 079b9c76e..24f72311d 100644
--- a/nova/tests/integrated/api_samples/os-services/service-enable-put-resp.json.tpl
+++ b/nova/tests/integrated/api_samples/os-services/service-enable-put-resp.json.tpl
@@ -1,5 +1,8 @@
{
- "disabled": false,
- "host": "%(host)s",
- "service": "%(service)s"
+ "service": {
+ "host": "%(host)s",
+ "binary": "%(binary)s",
+ "status": "enabled"
+ }
}
+
diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py
index 1ca839b3f..c647e0292 100644
--- a/nova/tests/integrated/test_api_samples.py
+++ b/nova/tests/integrated/test_api_samples.py
@@ -1990,24 +1990,24 @@ class ServicesJsonTest(ApiSampleTestBase):
def test_service_enable(self):
"""Enable an existing agent build."""
subs = {"host": "host1",
- 'service': 'nova-compute'}
- response = self._do_put('/os-services/enable',
+ 'binary': 'nova-compute'}
+ response = self._do_put('os-services/enable',
'service-enable-put-req', subs)
self.assertEqual(response.status, 200)
subs = {"host": "host1",
- "service": "nova-compute"}
+ "binary": "nova-compute"}
return self._verify_response('service-enable-put-resp',
subs, response)
def test_service_disable(self):
"""Disable an existing agent build."""
subs = {"host": "host1",
- 'service': 'nova-compute'}
- response = self._do_put('/os-services/disable',
+ 'binary': 'nova-compute'}
+ response = self._do_put('os-services/disable',
'service-disable-put-req', subs)
self.assertEqual(response.status, 200)
subs = {"host": "host1",
- "service": "nova-compute"}
+ "binary": "nova-compute"}
return self._verify_response('service-disable-put-resp',
subs, response)