VNC local interface to xenserver individual VMS via a xencenter approach

Source: Internet
Author: User
Tags ssh


Get list of local VMS

The code is as follows Copy Code

Usage:./getvnc vm_name "
VMs found:
Iad2-pdb1
Iad2-rdb2

Gets the VNC port number of the specified VM

The code is as follows Copy Code

Run this in laptop and connect via VNC to localhost:5903
--> ssh-l 5903:localhost:5903 root@172.16.4.30

Next, directly in the local run "ssh-l 5903:localhost:5903 root@172.16.4.30";
Then connect "localhost:5903" to the VNC client.

Scripting code:

The code is as follows Copy Code

#!/bin/ Bash

Vm=$1
If [-Z ${VM}]; then
  echo "Usage: $ vm_name"
  echo "VMs found:"
  XL LIST-VM | awk ' {print $} ' | GREP-VW name
  Exit 1
Fi

Xe vm-list Params=name-label NAME-LABEL=${VM} | grep ${VM} >/DEV/NULL
If [$-gt 0]; Then
  echo "error:invalid VM name"
  exit 1
Fi

host=$ (Xe vm-list params=resident-on Name-la BEL=${VM} | grep resident-on | awk ' {print $NF} ')
dom=$ (Xe vm-list params=dom-id NAME-LABEL=${VM} | grep dom-id | awk ' {print $NF} ')
port=$ (xenst Ore-read/local/domain/${dom}/console/vnc-port)
ip=$ (Xe pif-list management=true params=ip Host-uuid=${host} | awk ' {print $NF} ')

Echo run this on laptop and connect via VNC to Localhost:${port} "
echo"--> ssh-l ${port}:l Ocalhost:${port} Root@${ip} "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.