Drop the getting server state API

This API is redundant because all the status can be displayed in server
response.

Change-Id: I5013d6746d2f6c4380563f319b3bd1fba7671bd6
Closes-Bug: #1717406
This commit is contained in:
liusheng 2017-09-15 10:56:59 +08:00
parent 244f31f88c
commit 185e6e9302
7 changed files with 5 additions and 90 deletions

View File

@ -572,14 +572,6 @@ port_uuid:
in: body in: body
required: false required: false
type: string type: string
power_state:
description: |
The current power state of this Server. Usually, "power on" or
"power off", but may be "None" if Mogan is unable to determine the power
state (eg, due to hardware failure).
in: body
required: true
type: string
power_state_target: power_state_target:
description: | description: |
This field represents the requested state either "on", "off", "soft_off", This field represents the requested state either "on", "off", "soft_off",

View File

@ -1,5 +0,0 @@
{
"status": "active",
"locked": false,
"power_state": "power off"
}

View File

@ -10,36 +10,6 @@ A Server can be rebooted, turned on, or turned off by requesting a change to
its power state. its power state.
Server State Summary
======================
.. rest_method:: GET /v1/servers/{server_uuid}/states
Get a summary of the Server's current states.
Normal response code: 200
Request
-------
.. rest_parameters:: parameters.yaml
- server_uuid: server_ident
Response
--------
.. rest_parameters:: parameters.yaml
- power_state: power_state
- locked: lock_state
- status: server_status
**Example server state:**
.. literalinclude:: samples/server_states/server-get-state-response.json
Change Server Power State Change Server Power State
=========================== ===========================

View File

@ -51,25 +51,6 @@ _ONLY_ADMIN_VISIBLE_SEVER_FIELDS = ('node', 'affinity_zone',)
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class ServerStates(base.APIBase):
"""API representation of the states of a server."""
power_state = wtypes.text
"""Represent the current power state of the server"""
status = wtypes.text
"""Represent the current status of the server"""
locked = types.boolean
"""Represent the current lock state of the server"""
@classmethod
def sample(cls):
sample = cls(power_state=states.POWER_ON,
status=states.ACTIVE, locked=False)
return sample
class ServerControllerBase(rest.RestController): class ServerControllerBase(rest.RestController):
_resource = None _resource = None
@ -87,19 +68,6 @@ class ServerStatesController(ServerControllerBase):
'provision': ['PUT'], 'provision': ['PUT'],
} }
@policy.authorize_wsgi("mogan:server", "get_states")
@expose.expose(ServerStates, types.uuid)
def get(self, server_uuid):
"""List the states of the server, just support power state at present.
:param server_uuid: the UUID of a server.
"""
db_server = self._resource or self._get_resource(server_uuid)
return ServerStates(power_state=db_server.power_state,
status=db_server.status,
locked=db_server.locked)
@policy.authorize_wsgi("mogan:server", "set_power_state") @policy.authorize_wsgi("mogan:server", "set_power_state")
@expose.expose(None, types.uuid, wtypes.text, @expose.expose(None, types.uuid, wtypes.text,
status_code=http_client.ACCEPTED) status_code=http_client.ACCEPTED)

View File

@ -115,7 +115,7 @@ class BaseBaremetalComputeTest(tempest.test.BaseTestCase):
while not _condition(): while not _condition():
time.sleep(wait_interval) time.sleep(wait_interval)
try: try:
body = cls.baremetal_compute_client.server_get_state(server_id) body = cls.baremetal_compute_client.show_server(server_id)
server_status = body['status'] server_status = body['status']
server_power_state = body['power_state'] server_power_state = body['power_state']
server_locked = body['locked'] server_locked = body['locked']

View File

@ -81,14 +81,11 @@ class BaremetalComputeAPIServersTest(base.BaseBaremetalComputeTest):
pass pass
def _ensure_states_before_test(self): def _ensure_states_before_test(self):
resp = self.baremetal_compute_client.server_get_state( server = self.baremetal_compute_client.show_server(
self.server_ids[0]) self.server_ids[0])
self.assertEqual('active', resp['status']) self.assertEqual('active', server['status'])
self.assertFalse(resp['locked']) self.assertFalse(server['locked'])
self.assertEqual('power on', resp['power_state']) self.assertEqual('power on', server['power_state'])
def test_get_server_power_status(self):
self._ensure_states_before_test()
def test_server_stop_start(self): def test_server_stop_start(self):
self._ensure_states_before_test() self._ensure_states_before_test()

View File

@ -133,13 +133,6 @@ class BaremetalComputeClient(rest_client.RestClient):
body = self.deserialize(body) body = self.deserialize(body)
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
def server_get_state(self, server_id):
uri = '%s/servers/%s/states' % (self.uri_prefix, server_id)
resp, body = self.get(uri)
self.expected_success(200, resp.status)
body = self.deserialize(body)
return rest_client.ResponseBody(resp, body)
def server_set_power_state(self, server_id, target): def server_set_power_state(self, server_id, target):
uri = '%s/servers/%s/states/power' % (self.uri_prefix, server_id) uri = '%s/servers/%s/states/power' % (self.uri_prefix, server_id)
target_body = {'target': target} target_body = {'target': target}