def get_vnc_console(self, context, instance): """Get connection info for a vnc console. :param context: security context :param instance: nova.objects.instance.Instance :return: An instance of console.type.ConsoleVNC """ self._log_operation('get_vnc_console', instance) lpar_uuid = vm.get_pvm_uuid(instance) # Build the connection to the VNC. host = CONF.vnc.server_proxyclient_address # TODO(thorst, efried) Add the x509 certificate support when it lands try: # Open up a remote vterm port = pvm_vterm.open_remotable_vnc_vterm(self.adapter, lpar_uuid, host, vnc_path=lpar_uuid) # Note that the VNC viewer will wrap the internal_access_path with # the HTTP content. return console_type.ConsoleVNC(host=host, port=port, internal_access_path=lpar_uuid) except pvm_exc.HttpError as e: with excutils.save_and_reraise_exception(logger=LOG) as sare: # If the LPAR was not found, raise a more descriptive error if e.response.status == 404: sare.reraise = False raise exc.InstanceNotFound(instance_id=instance.uuid)
def get_vnc_console(self, context, instance): ec2_id = self._get_ec2_id_from_instance(instance) LOG.info("VNC console connect to %s" % ec2_id) reservations = self.ec2_conn.get_all_instances() vnc_port = 5901 # Get the IP of the instance host_ip = None for reservation in reservations: if reservation.instances is not None: for instance in reservation.instances: if instance.id == ec2_id: if instance.ip_address is not None: host_ip = instance.ip_address if host_ip is not None: LOG.info("Found the IP of the instance IP:%s and port:%s" % (host_ip, vnc_port)) return ctype.ConsoleVNC(host=host_ip, port=vnc_port) else: LOG.info("Ip not Found for the instance") return { 'internal_access_path': 'EC2', 'host': 'EC2spiceconsole.com', 'port': 5901 }
def get_vnc_console(self, instance, get_opt): """ Get the vnc console information :param instance: the instance info :return: HuaweiConsoleVNC or ConsoleVNC """ LOG.debug(_("start to get %s vnc console"), instance['name']) fc_vm = FC_MGR.get_vm_by_uuid(instance) host_ip = fc_vm.vncAcessInfo.get('hostIp', None) host_port = fc_vm.vncAcessInfo.get('vncPort', None) # raise exception if no information is provided if not host_port or not host_ip: raise exception.ConsoleNotFoundForInstance\ (instance_uuid=instance['uuid']) if get_opt is False: LOG.debug( _("return vnc info is host: %s, port:%s," " internal_access_path: %s"), host_ip, host_port, 'None') return ctype.ConsoleVNC(host=host_ip, port=host_port) password = fc_vm.vncAcessInfo.get('vncPassword', None) LOG.debug( _("return get vnc info is host: %s, port:%s," " internal_access_path: %s"), host_ip, host_port, 'None') return hwtype.HuaweiConsoleVNC(host_ip, host_port, password, None)
def get_vnc_console(self, instance): """Get connection info for a vnc console.""" LOG.debug("get_vnc_console called", instance=instance) if self.remote_display and self.vrde_module == constants.EXTPACK_VNC: host = hostutils.get_ip() port = self._get_vrde_port(instance) if port: LOG.debug("VNC console: %(host)s:%(port)s", { "host": host, "port": port }) return console_type.ConsoleVNC(host=host, port=port) else: LOG.warning(i18n._LW("VNC port not found!"), instance=instance) else: LOG.warning(i18n._LW("VNC console is not available for this" " instance."), instance=instance) raise exception.ConsoleTypeUnavailable(console_type='vnc')
def get_vnc_console(self, context, instance): return ctype.ConsoleVNC(internal_access_path='FAKE', host='fakevncconsole.com', port=6969)
def test_console_vnc(self): c = ctype.ConsoleVNC(host='127.0.0.1', port=8945) self.assertIsInstance(c, ctype.Console)