博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vmware之VMware Remote Console (VMRC) SDK(一)
阅读量:6878 次
发布时间:2019-06-26

本文共 3211 字,大约阅读时间需要 10 分钟。

通过console可以实现类似远程桌面的功能,但它的实现方式和远程桌面不同,一般来说远程桌面必须要有网络支持,在机器关闭或者启动过程中无法连接。而console是通过esx的虚拟化组件实现远程桌面。在其sample代码中有一个用html+js编写ActiveX插件的示例。

下方是一个用winform写的console远程截图。

1

 

在vmware的developer center中,下载vmrc sdk,它会以com组件的形式安装,你可以在vs工具箱中找到。

下面上一段sample代码

1 using System; 2 using System.Linq; 3 using System.Windows.Forms; 4  5 using Vim25Api; 6 using AppUtil; 7  8 namespace WindowsFormsApplication1 9 {10     public partial class Form1 : Form11     {12         public AppUtil.AppUtil util = null;13 14         public Form1()15         {16             InitializeComponent();   17         }18 19         private void button1_Click(object sender, EventArgs e)20         {21             String[] arguments = new string[] {22                 "--url", "https://192.168.0.161/sdk", 23                 "--username","root",24                 "--password","P@ssw0rd", 25                 "--disablesso", "true",26                 "--ignorecert", "true"};27             try28             {29                 this.axVMwareEmbeddedRemoteConsole1.startup(2, VMwareRemoteConsoleTypeLib.VMRC_MessageMode.VMRC_DIALOG_MESSAGES, null);30 31                 util = AppUtil.AppUtil.initialize("Connect", constructOptions(), arguments.ToArray());32                 util.connect();33 34                 ManagedObjectReference mor = util.getConnection().ServiceRef;35                 ManagedObjectReference sessionMor = util._connection.Service.RetrieveServiceContent(mor).sessionManager;36                 string ticket = util._connection.Service.AcquireCloneTicket(sessionMor);37                 ManagedObjectReference vmMor = util.getServiceUtil().GetDecendentMoRef(null, "VirtualMachine", "test");38 39                 axVMwareEmbeddedRemoteConsole1.connect("192.168.0.161", null, true, ticket, null, null, vmMor.Value, null, null);40             }41             catch(Exception ex)42             {43                 MessageBox.Show(ex.ToString());44    45                 this.axVMwareEmbeddedRemoteConsole1.disconnect();46                 util.disConnect();47             }48         }49         private static OptionSpec[] constructOptions()50         {51             OptionSpec[] useroptions = new OptionSpec[5];52             useroptions[0] = new OptionSpec("url", "String", 1, "ser url", null);53             useroptions[1] = new OptionSpec("username", "String", 1, "user name", null);54             useroptions[2] = new OptionSpec("password", "String", 1, "password", null);55             useroptions[3] = new OptionSpec("disablesso", "bool", 0, "disablesso", null);56             useroptions[4] = new OptionSpec("ignorecert", "bool", 1, "ignorecert", null);57             return useroptions;58         }59 60         private void button2_Click(object sender, EventArgs e)61         {62             axVMwareEmbeddedRemoteConsole1.disconnect();63             util.disConnect();64         }65     }66 }

 

在建立connect连接时,有几个重要的参数

url为https://主机ip/sdk,登录帐号也是主机esx的帐号。

disablesso表示禁用sso单点登录验证,这个要加上,因为在我们远程登录验证不会使用sso。

ignorecert这个参数也要加上,不然会证书验证导致The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

这些参数如何运作可以到vsphere sdk中的apputil项目下找到。

转载于:https://www.cnblogs.com/yuefei/p/3615785.html

你可能感兴趣的文章
Ibatis实例程序
查看>>
Linux下Nagios的安装与配置
查看>>
esxi5手动打补丁升级
查看>>
spring core 笔记(一)
查看>>
一例mysql主从数据库,从库宕机后无法启动的解决方案
查看>>
WebView 设置软键盘弹出将屏幕上移
查看>>
通过xsl显示和输出XML数据2
查看>>
最简单的iOS网络请求
查看>>
Android软件开发之高斯模糊问题
查看>>
使用Idea14.1.4和maven3创建Javaweb项目
查看>>
golang实现文字云算法
查看>>
artTemplate 学习网址和书籍
查看>>
C++对象内存分配
查看>>
Cong!
查看>>
PHP语言拓展json模块
查看>>
spring 配置文件applicationContext.xml命名空间及标签解析
查看>>
我的友情链接
查看>>
回到顶部代码(兼容IE6)
查看>>
web.xml文件的作用
查看>>
iOS开发篇——OC延展类目协议介绍
查看>>