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} " |