Merge "Add compute microversion 2.6 and 2.8"
This commit is contained in:
@@ -23,6 +23,8 @@ from openstack.compute.v2 import server as _server
|
||||
from openstack.compute.v2 import server_diagnostics as _server_diagnostics
|
||||
from openstack.compute.v2 import server_group as _server_group
|
||||
from openstack.compute.v2 import server_interface as _server_interface
|
||||
from openstack.compute.v2 import (
|
||||
server_remote_console as _server_remote_console)
|
||||
from openstack.compute.v2 import server_ip
|
||||
from openstack.compute.v2 import service as _service
|
||||
from openstack.compute.v2 import volume_attachment as _volume_attachment
|
||||
@@ -1473,6 +1475,19 @@ class Proxy(proxy.Proxy):
|
||||
return self._get(_server_diagnostics.ServerDiagnostics,
|
||||
server_id=server_id, requires_id=False)
|
||||
|
||||
def create_server_remote_console(self, server, **attrs):
|
||||
"""Create a remote console on the server.
|
||||
|
||||
:param server: Either the ID of a server or a
|
||||
:class:`~openstack.compute.v2.server.Server` instance.
|
||||
:returns: One
|
||||
:class:`~openstack.compute.v2.server_remote_console.
|
||||
ServerRemoteConsole`
|
||||
"""
|
||||
server_id = resource.Resource._get_id(server)
|
||||
return self._create(_server_remote_console.ServerRemoteConsole,
|
||||
server_id=server_id, **attrs)
|
||||
|
||||
def _get_cleanup_dependencies(self):
|
||||
return {
|
||||
'compute': {
|
||||
|
36
openstack/compute/v2/server_remote_console.py
Normal file
36
openstack/compute/v2/server_remote_console.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class ServerRemoteConsole(resource.Resource):
|
||||
resource_key = 'remote_console'
|
||||
base_path = '/servers/%(server_id)s/remote-consoles'
|
||||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_fetch = False
|
||||
allow_commit = False
|
||||
allow_delete = False
|
||||
allow_list = False
|
||||
|
||||
_max_microversion = '2.8'
|
||||
|
||||
#: Protocol of the remote console.
|
||||
protocol = resource.Body('protocol')
|
||||
#: Type of the remote console.
|
||||
type = resource.Body('type')
|
||||
#: URL used to connect to the console.
|
||||
url = resource.Body('url')
|
||||
#: The ID for the server.
|
||||
server_id = resource.URI('server_id')
|
@@ -122,3 +122,10 @@ class TestServer(ft_base.BaseComputeTest):
|
||||
test_server, test_server.metadata.keys())
|
||||
test_server = self.conn.compute.get_server_metadata(test_server)
|
||||
self.assertFalse(test_server.metadata)
|
||||
|
||||
def test_server_remote_console(self):
|
||||
console = self.conn.compute.create_server_remote_console(
|
||||
self.server, protocol='vnc', type='novnc')
|
||||
self.assertEqual('vnc', console.protocol)
|
||||
self.assertEqual('novnc', console.type)
|
||||
self.assertTrue(console.url.startswith('http'))
|
||||
|
Reference in New Issue
Block a user