VMware: implement get_mks_console()
This patch implements get_mks_console in the VMware driver. Implements: blueprint vmware-webmks-console Change-Id: Icecc3f69e01bb8799a7d2364f0cc7a81cb2ac36b
This commit is contained in:
parent
14ca7c37ba
commit
9a7a3cd401
|
@ -15,6 +15,7 @@
|
|||
import contextlib
|
||||
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import units
|
||||
from oslo_utils import uuidutils
|
||||
from oslo_vmware import exceptions as vexc
|
||||
|
@ -2095,3 +2096,21 @@ class VMwareVMOpsTestCase(test.NoDBTestCase):
|
|||
mock_reconfigure_vm.assert_called_once_with(self._session,
|
||||
'fake-ref',
|
||||
'fake-detach-spec')
|
||||
|
||||
@mock.patch.object(vm_util, 'get_vm_ref', return_value='fake-ref')
|
||||
def test_get_mks_console(self, mock_get_vm_ref):
|
||||
ticket = mock.MagicMock()
|
||||
ticket.host = 'esx1'
|
||||
ticket.port = 902
|
||||
ticket.ticket = 'fira'
|
||||
ticket.sslThumbprint = 'aa:bb:cc:dd:ee:ff'
|
||||
ticket.cfgFile = '[ds1] fira/foo.vmx'
|
||||
with mock.patch.object(self._session, '_call_method',
|
||||
return_value=ticket):
|
||||
console = self._vmops.get_mks_console(self._instance)
|
||||
self.assertEqual('esx1', console.host)
|
||||
self.assertEqual(902, console.port)
|
||||
path = jsonutils.loads(console.internal_access_path)
|
||||
self.assertEqual('fira', path['ticket'])
|
||||
self.assertEqual('aabbccddeeff', path['thumbprint'])
|
||||
self.assertEqual('[ds1] fira/foo.vmx', path['cfgFile'])
|
||||
|
|
|
@ -360,6 +360,9 @@ class VMwareVCDriver(driver.ComputeDriver):
|
|||
# itself. You must talk to the VNC host underneath vCenter.
|
||||
return self._vmops.get_vnc_console(instance)
|
||||
|
||||
def get_mks_console(self, context, instance):
|
||||
return self._vmops.get_mks_console(instance)
|
||||
|
||||
def _update_resources(self):
|
||||
"""This method creates a dictionary of VMOps, VolumeOps and VCState.
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import decorator
|
|||
from oslo_concurrency import lockutils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import units
|
||||
|
@ -1847,3 +1848,16 @@ class VMwareVMOps(object):
|
|||
{'uuid': instance.uuid, 'host_name': host_name},
|
||||
instance=instance)
|
||||
return ctype.ConsoleVNC(**vnc_console)
|
||||
|
||||
def get_mks_console(self, instance):
|
||||
vm_ref = vm_util.get_vm_ref(self._session, instance)
|
||||
ticket = self._session._call_method(self._session.vim,
|
||||
'AcquireTicket',
|
||||
vm_ref,
|
||||
ticketType='mks')
|
||||
thumbprint = ticket.sslThumbprint.replace(':', '').lower()
|
||||
mks_auth = {'ticket': ticket.ticket,
|
||||
'cfgFile': ticket.cfgFile,
|
||||
'thumbprint': thumbprint}
|
||||
internal_access_path = jsonutils.dumps(mks_auth)
|
||||
return ctype.ConsoleMKS(ticket.host, ticket.port, internal_access_path)
|
||||
|
|
Loading…
Reference in New Issue