Skip to content

Commit

Permalink
Merge "Deprecate os-hosts API"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Apr 25, 2017
2 parents ad6647a + aad4be2 commit 5450cea
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api-ref/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ the `API guide <http://developer.openstack.org/api-guide/compute/index.html>`_.
.. include:: os-availability-zone.inc
.. include:: os-cells.inc
.. include:: os-consoles.inc
.. include:: os-hosts.inc
.. include:: os-hypervisors.inc
.. include:: os-instance-usage-audit-log.inc
.. include:: os-migrations.inc
Expand Down Expand Up @@ -71,3 +70,4 @@ the `API guide <http://developer.openstack.org/api-guide/compute/index.html>`_.
.. include:: os-security-groups.inc
.. include:: os-security-group-default-rules.inc
.. include:: os-security-group-rules.inc
.. include:: os-hosts.inc
59 changes: 56 additions & 3 deletions api-ref/source/os-hosts.inc
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
.. -*- rst -*-
==================
Hosts (os-hosts)
==================
===============================
Hosts (os-hosts) (DEPRECATED)
===============================

.. warning::

The ``os-hosts`` API is deprecated as of the 2.43 microversion. Requests
made with microversion >= 2.43 will result in a 404 error. To list and show
host details, use the :ref:`os-hypervisors` API. To enable or disable a
service, use the :ref:`os-services` API. There is no replacement for the
`shutdown`, `startup`, `reboot`, or `maintenance_mode` actions as those are
system-level operations which should be outside of the control of the
compute service.

Manages physical hosts. Some virt drivers do not support all host
functions. For more information, see `nova virt support
Expand Down Expand Up @@ -81,6 +91,17 @@ Update Host status

Enables, disables a host or put a host in maintenance or normal mode.

.. warning::

Putting a host into maintenance mode is only implemented by the XenServer
compute driver and it has been reported that it does not actually evacuate
all of the guests from the host, it just sets a flag in the Xen management
console, and is therefore useless. There are other APIs that allow you to do
the same thing which are supported across all compute drivers, which would be
disabling a service and then migrating the instances off that host. See the
`Operations Guide <https://docs.openstack.org/ops-guide/ops-maintenance-compute.html>`_
for more information on maintenance.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
Expand Down Expand Up @@ -121,6 +142,19 @@ Reboot Host

Reboots a host.

.. warning::

This is only supported by the XenServer and Hyper-v drivers. The backing
drivers do no orchestration of dealing with guests in the nova database when
performing a reboot of the host. The nova-compute service for that host may
be temporarily disabled by the service group health check which would take it
out of scheduling decisions, and the guests would be down, but the periodic
task which checks for unexpectedly stopped instances runs in the nova-compute
service, which might be dead now so the nova API would show the instances as
running when in fact they are actually stopped. This API is also not tested
in a live running OpenStack environment. Needless to say, it is not
recommended to use this API and it is deprecated as of the 2.43 microversion.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
Expand Down Expand Up @@ -153,6 +187,19 @@ Shut Down Host

Shuts down a host.

.. warning::

This is only supported by the XenServer and Hyper-v drivers. The backing
drivers do no orchestration of dealing with guests in the nova database when
performing a shutdown of the host. The nova-compute service for that host may
be temporarily disabled by the service group health check which would take it
out of scheduling decisions, and the guests would be down, but the periodic
task which checks for unexpectedly stopped instances runs in the nova-compute
service, which might be dead now so the nova API would show the instances as
running when in fact they are actually stopped. This API is also not tested
in a live running OpenStack environment. Needless to say, it is not
recommended to use this API and it is deprecated as of the 2.43 microversion.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
Expand Down Expand Up @@ -185,6 +232,12 @@ Start Host

Starts a host.

.. warning::

This is not implemented by any in-tree compute drivers and therefore will
always fail with a `501 NotImplemented` error. Needless to say, it is not
recommended to use this API and it is deprecated as of the 2.43 microversion.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
Expand Down
2 changes: 2 additions & 0 deletions api-ref/source/os-hypervisors.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.. -*- rst -*-
.. _os-hypervisors:

==============================
Hypervisors (os-hypervisors)
==============================
Expand Down
2 changes: 2 additions & 0 deletions api-ref/source/os-services.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.. -*- rst -*-
.. _os-services:

================================
Compute services (os-services)
================================
Expand Down
2 changes: 1 addition & 1 deletion doc/api_samples/versions/v21-version-get-resp.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"status": "CURRENT",
"version": "2.42",
"version": "2.43",
"min_version": "2.1",
"updated": "2013-07-23T11:33:21Z"
}
Expand Down
2 changes: 1 addition & 1 deletion doc/api_samples/versions/versions-get-resp.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
],
"status": "CURRENT",
"version": "2.42",
"version": "2.43",
"min_version": "2.1",
"updated": "2013-07-23T11:33:21Z"
}
Expand Down
3 changes: 2 additions & 1 deletion nova/api/openstack/api_version_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
re-introduce the tag attribute that, due to bugs, was lost
starting with version 2.33 for block devices and starting with
version 2.37 for network interfaces.
* 2.43 - Deprecate os-hosts API
"""

# The minimum and maximum versions of the API supported
Expand All @@ -110,7 +111,7 @@
# Note(cyeoh): This only applies for the v2.1 API once microversions
# support is fully merged. It does not affect the V2 API.
_MIN_API_VERSION = "2.1"
_MAX_API_VERSION = "2.42"
_MAX_API_VERSION = "2.43"
DEFAULT_API_VERSION = _MIN_API_VERSION

# Almost all proxy APIs which related to network, images and baremetal
Expand Down
6 changes: 6 additions & 0 deletions nova/api/openstack/compute/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self):
self.api = compute.HostAPI()
super(HostController, self).__init__()

@wsgi.Controller.api_version("2.1", "2.42")
@extensions.expected_errors(())
def index(self, req):
"""Returns a dict in the format
Expand Down Expand Up @@ -96,6 +97,7 @@ def index(self, req):
'zone': service['availability_zone']})
return {'hosts': hosts}

@wsgi.Controller.api_version("2.1", "2.42")
@extensions.expected_errors((400, 404, 501))
@validation.schema(hosts.update)
def update(self, req, id, body):
Expand Down Expand Up @@ -187,14 +189,17 @@ def _host_power_action(self, req, host_name, action):
raise webob.exc.HTTPBadRequest(explanation=e.format_message())
return {"host": host_name, "power_action": result}

@wsgi.Controller.api_version("2.1", "2.42")
@extensions.expected_errors((400, 404, 501))
def startup(self, req, id):
return self._host_power_action(req, host_name=id, action="startup")

@wsgi.Controller.api_version("2.1", "2.42")
@extensions.expected_errors((400, 404, 501))
def shutdown(self, req, id):
return self._host_power_action(req, host_name=id, action="shutdown")

@wsgi.Controller.api_version("2.1", "2.42")
@extensions.expected_errors((400, 404, 501))
def reboot(self, req, id):
return self._host_power_action(req, host_name=id, action="reboot")
Expand Down Expand Up @@ -248,6 +253,7 @@ def _get_resources_by_project(host_name, instances):
instance['ephemeral_gb'])
return project_map

@wsgi.Controller.api_version("2.1", "2.42")
@extensions.expected_errors(404)
def show(self, req, id):
"""Shows the physical/usage resource given by hosts.
Expand Down
11 changes: 11 additions & 0 deletions nova/api/openstack/compute/rest_api_version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,14 @@ user documentation.
2.37 and for block_device_mapping_v2 starting with version 2.33. Microversion
2.42 restores the tag parameter to both networks and block_device_mapping_v2,
allowing networks and block devices to be tagged again.

2.43
----

The ``os-hosts`` API is deprecated as of the 2.43 microversion. Requests
made with microversion >= 2.43 will result in a 404 error. To list and show
host details, use the ``os-hypervisors`` API. To enable or disable a
service, use the ``os-services`` API. There is no replacement for the
`shutdown`, `startup`, `reboot`, or `maintenance_mode` actions as those are
system-level operations which should be outside of the control of the
compute service.
25 changes: 25 additions & 0 deletions nova/tests/unit/api/openstack/compute/test_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import testtools
import webob.exc

from nova.api.openstack import api_version_request as api_version
from nova.api.openstack.compute import hosts as os_hosts_v21
from nova.compute import power_state
from nova.compute import vm_states
Expand Down Expand Up @@ -131,6 +132,7 @@ def _create_instance_dict(**kwargs):
class FakeRequestWithNovaZone(object):
environ = {"nova.context": context_maker.get_admin_context()}
GET = {"zone": "nova"}
api_version_request = api_version.APIVersionRequest('2.1')


class HostTestCaseV21(test.TestCase):
Expand Down Expand Up @@ -413,3 +415,26 @@ def test_show_policy_failed(self):
self.assertEqual(
"Policy doesn't allow %s to be performed." % rule_name,
exc.format_message())


class HostControllerDeprecationTest(test.NoDBTestCase):

def setUp(self):
super(HostControllerDeprecationTest, self).setUp()
self.controller = os_hosts_v21.HostController()
self.req = fakes.HTTPRequest.blank('', version='2.43')

def test_not_found_for_all_host_api(self):
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.show, self.req, fakes.FAKE_UUID)
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.startup, self.req, fakes.FAKE_UUID)
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.shutdown, self.req, fakes.FAKE_UUID)
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.reboot, self.req, fakes.FAKE_UUID)
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.index, self.req)
self.assertRaises(exception.VersionNotFoundForAPIMethod,
self.controller.update, self.req, fakes.FAKE_UUID,
body={})
10 changes: 10 additions & 0 deletions releasenotes/notes/microversion-2.43-77d63cae38695fd1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
deprecations:
- |
The ``os-hosts`` API is deprecated as of the 2.43 microversion. Requests
made with microversion >= 2.43 will result in a 404 error. To list and show
host details, use the ``os-hypervisors`` API. To enable or disable a
service, use the ``os-services`` API. There is no replacement for the
`shutdown`, `startup`, `reboot`, or `maintenance_mode` actions as those are
system-level operations which should be outside of the control of the
compute service.

0 comments on commit 5450cea

Please sign in to comment.