Expose the API of getting console info
Change-Id: I41c95d924b29885148077e418e0453e3ed001c9e Partially-Implements: bp console-support
This commit is contained in:
parent
4119c0012d
commit
ddf694a7c8
35
api-ref/source/v1/instance_serial_console.inc
Normal file
35
api-ref/source/v1/instance_serial_console.inc
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
.. -*- rst -*-
|
||||||
|
|
||||||
|
========================
|
||||||
|
Instance Serial Console
|
||||||
|
========================
|
||||||
|
|
||||||
|
Instances Serial Console can be managed through serial_console sub-resource.
|
||||||
|
|
||||||
|
|
||||||
|
Instance Serial Console Summary
|
||||||
|
===============================
|
||||||
|
|
||||||
|
.. rest_method:: GET /v1/instances/{instance_uuid}/serial_console
|
||||||
|
|
||||||
|
Get the console url info of the Instance.
|
||||||
|
|
||||||
|
Normal response code: 200
|
||||||
|
|
||||||
|
Request
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. rest_parameters:: parameters.yaml
|
||||||
|
|
||||||
|
- instance_uuid: instance_ident
|
||||||
|
|
||||||
|
Response
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. rest_parameters:: parameters.yaml
|
||||||
|
|
||||||
|
- console: console_info
|
||||||
|
|
||||||
|
**Example instance network:**
|
||||||
|
|
||||||
|
.. literalinclude:: samples/instance_console/instance-serial-console-get.json
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"console": {
|
||||||
|
"url": "http://127.0.0.1:8866/?token=b4f5cb4a-8b01-40ea-ae46-67f0db4969b3"
|
||||||
|
}
|
||||||
|
}
|
@ -470,6 +470,29 @@ class InstanceCollection(base.APIBase):
|
|||||||
return collection
|
return collection
|
||||||
|
|
||||||
|
|
||||||
|
class InstanceConsole(base.APIBase):
|
||||||
|
"""API representation of the console of an instance."""
|
||||||
|
|
||||||
|
console = {wtypes.text: types.jsontype}
|
||||||
|
"""The console information of the instance"""
|
||||||
|
|
||||||
|
|
||||||
|
class InstanceSerialConsoleController(InstanceControllerBase):
|
||||||
|
"""REST controller for Instance."""
|
||||||
|
|
||||||
|
@policy.authorize_wsgi("mogan:instance", "get_serial_console")
|
||||||
|
@expose.expose(InstanceConsole, types.uuid)
|
||||||
|
def get(self, instance_uuid):
|
||||||
|
"""Get the serial console info of the instance.
|
||||||
|
|
||||||
|
:param instance_uuid: the UUID of a instance.
|
||||||
|
"""
|
||||||
|
instance_obj = self._resource or self._get_resource(instance_uuid)
|
||||||
|
console = pecan.request.engine_api.get_serial_console(
|
||||||
|
pecan.request.context, instance_obj)
|
||||||
|
return InstanceConsole(console=console)
|
||||||
|
|
||||||
|
|
||||||
class InstanceController(InstanceControllerBase):
|
class InstanceController(InstanceControllerBase):
|
||||||
"""REST controller for Instance."""
|
"""REST controller for Instance."""
|
||||||
|
|
||||||
@ -479,6 +502,9 @@ class InstanceController(InstanceControllerBase):
|
|||||||
networks = InstanceNetworksController()
|
networks = InstanceNetworksController()
|
||||||
"""Expose the network controller action as a sub-element of instances"""
|
"""Expose the network controller action as a sub-element of instances"""
|
||||||
|
|
||||||
|
serial_console = InstanceSerialConsoleController()
|
||||||
|
"""Expose the console controller of instances"""
|
||||||
|
|
||||||
_custom_actions = {
|
_custom_actions = {
|
||||||
'detail': ['GET']
|
'detail': ['GET']
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,7 @@ def main():
|
|||||||
# Parse config file and command line options, then start logging
|
# Parse config file and command line options, then start logging
|
||||||
mogan_service.prepare_service(sys.argv)
|
mogan_service.prepare_service(sys.argv)
|
||||||
|
|
||||||
mgr = mogan_service.RPCService(CONF.host,
|
mgr = mogan_service.RPCService('mogan.consoleauth.manager',
|
||||||
'mogan.consoleauth.manager',
|
|
||||||
'ConsoleAuthManager',
|
'ConsoleAuthManager',
|
||||||
constants.MANAGER_CONSOLEAUTH_TOPIC)
|
constants.MANAGER_CONSOLEAUTH_TOPIC)
|
||||||
|
|
||||||
|
@ -108,6 +108,9 @@ instance_policies = [
|
|||||||
policy.RuleDefault('mogan:instance:set_provision_state',
|
policy.RuleDefault('mogan:instance:set_provision_state',
|
||||||
'rule:default',
|
'rule:default',
|
||||||
description='Set the provision state of an instance'),
|
description='Set the provision state of an instance'),
|
||||||
|
policy.RuleDefault('mogan:instance:get_serial_console',
|
||||||
|
'rule:default',
|
||||||
|
description='Get serial console for an instance'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,4 +82,4 @@ class EngineAPI(object):
|
|||||||
def get_serial_console(self, context, instance):
|
def get_serial_console(self, context, instance):
|
||||||
cctxt = self.client.prepare(topic=self.topic, server=CONF.host)
|
cctxt = self.client.prepare(topic=self.topic, server=CONF.host)
|
||||||
return cctxt.call(context, 'get_serial_console',
|
return cctxt.call(context, 'get_serial_console',
|
||||||
instance_uuid=instance)
|
instance=instance)
|
||||||
|
Loading…
Reference in New Issue
Block a user