VMware: clean up VNC console handling

Commit 61bfac8881 introduced
the VMwareVCVMOps class. This class specifcally treats VC methods.
The patch set moves the treatment for get_vnc_console to this
class.

The log message for the VNC console now has the instance as a
parameter.

Please note that there are already test cases for this.

Change-Id: I2b943558d96328580f5c8744945e5f5f1790c06f
This commit is contained in:
Gary Kotton 2014-02-02 05:44:22 -08:00
parent c032ab8696
commit fc27c5e3df
2 changed files with 27 additions and 22 deletions

View File

@ -473,7 +473,7 @@ class VMwareVCDriver(VMwareESXDriver):
# In specific, vCenter does not actually run the VNC service
# itself. You must talk to the VNC host underneath vCenter.
_vmops = self._get_vmops_for_compute_node(instance['node'])
return _vmops.get_vnc_console_vcenter(instance)
return _vmops.get_vnc_console(instance)
def _update_resources(self):
"""This method creates a dictionary of VMOps, VolumeOps and VCState.

View File

@ -1442,7 +1442,7 @@ class VMwareVMOps(object):
# Add a namespace to all of the diagnostsics
return dict([('vmware:' + k, v) for k, v in data.items()])
def get_vnc_console(self, instance):
def _get_vnc_console_connection(self, instance):
"""Return connection info for a vnc console."""
vm_ref = vm_util.get_vm_ref(self._session, instance)
opt_value = self._session._call_method(vim_util,
@ -1454,28 +1454,13 @@ class VMwareVMOps(object):
else:
raise exception.ConsoleTypeUnavailable(console_type='vnc')
return {'host': CONF.vmware.host_ip,
'port': port,
return {'port': port,
'internal_access_path': None}
def get_vnc_console_vcenter(self, instance):
"""Return connection info for a vnc console using vCenter logic."""
# vCenter does not run virtual machines and does not run
# a VNC proxy. Instead, you need to tell OpenStack to talk
# directly to the ESX host running the VM you are attempting
# to connect to via VNC.
vnc_console = self.get_vnc_console(instance)
host_name = vm_util.get_host_name_for_vm(
self._session,
instance)
vnc_console['host'] = host_name
# NOTE: VM can move hosts in some situations. Debug for admins.
LOG.debug(_("VM %(uuid)s is currently on host %(host_name)s"),
{'uuid': instance['name'], 'host_name': host_name})
def get_vnc_console(self, instance):
"""Return connection info for a vnc console using ESX logic."""
vnc_console = self._get_vnc_console_connection(instance)
vnc_console['host'] = CONF.vmware.host_ip
return vnc_console
@staticmethod
@ -1748,3 +1733,23 @@ class VMwareVCVMOps(VMwareVMOps):
LOG.debug(_("Got total of %s instances") % str(len(lst_vm_names)))
return lst_vm_names
def get_vnc_console(self, instance):
"""Return connection info for a vnc console using vCenter logic."""
# vCenter does not run virtual machines and does not run
# a VNC proxy. Instead, you need to tell OpenStack to talk
# directly to the ESX host running the VM you are attempting
# to connect to via VNC.
vnc_console = self._get_vnc_console_connection(instance)
host_name = vm_util.get_host_name_for_vm(
self._session,
instance)
vnc_console['host'] = host_name
# NOTE: VM can move hosts in some situations. Debug for admins.
LOG.debug(_("VM %(uuid)s is currently on host %(host_name)s"),
{'uuid': instance['name'], 'host_name': host_name},
instance=instance)
return vnc_console