日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

noVNC

發布時間:2024/6/30 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 noVNC 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

noNVC基礎用法:

1、下載noVNC

git clone?https://github.com/novnc/noVNC.git

?

2、編輯qemu.conf配置文件

  Vim /etc/libvirt/qemu.conf

  將配置文件中的vnc_listen = "0.0.0.0" 啟用

?

3、查看虛擬機vnc端口

  Virsh vncdisplay vm001

  :0????? // 表示5900

  也可以在創建虛擬機xml文件是指定vm的vnc端口

<graphics type='vnc' port='5910' autoport='no' listen='0.0.0.0'><listen type='address' address='0.0.0.0'/> </graphics>

?

4、啟動noVNC

  .noVNC/utils/launch.sh --vnc host_ip:5910

?

noVNC高級用法:

在基礎用法用需要為每啟用一個代理,在實際應用中不可能為每臺虛擬機都架一個代理,這種方式對端口號的消耗也是巨大的。

因此我們需要做的是使用一個端口來使用多個代理,因此需要引入Token的概念。

這里需要用的是websockify,在 Github 上 noVNC 和 websockify 本來就是獨立的兩個項目。

在我們第一次運行./noVNC/utils/launch.sh時會自動下載websockify

?

目錄結構:

?

1、創建token文件

  在websockify目錄中創建目錄token,并在該目錄下創建token文件,寫入以下內容:

token: host_ip:port

  這里需要注意的坑是token:后面是有一個空格的(少了這個空格讓我調試了一個夜晚)。

?

2、啟動websockify

  進入websockify目錄 --web ../ 是為了使用noVNC的vnc.html和vnc_lite.html文件

./run --web ../ --target-config ./token/token localhost:8888

?

3、瀏覽器測試

 http://localhost:8888/vnc_lite.html?path=?token=vm004  (這里我直接使用的是虛擬機vm004的名稱來作為Token,只需要修改Token就能夠訪問相應的虛擬機)?

?

擴展Token類型

?

Custom plugins should match the format of the BasePlugin class found in websockify/token_plugins.py. Namely, they should implement an __init__(self, src) method (where src is the value of --token-source), and a lookup(self, token) method which either returns a (host, port) tuple, or None.

?

The plugin can be placed in any module that's importable by websockify, and then be used as such:

$ ./run ... --token-plugin some.module.TokenClass --token-source 'some information here'

?

Example:

import memcache import simplejsonclass TokenMemc(object):def __init__(self, src):self._server = srcdef lookup(self, token):client = memcache.Client([self._server], debug=0)stuff = client.get(token)combo = simplejson.loads(stuff)pair = combo["host"]return pair.split(':')

?

轉載于:https://www.cnblogs.com/vincenshen/p/7923402.html

總結

以上是生活随笔為你收集整理的noVNC的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。