package com.vmware.util;
/**
* Created by vixuan-008 on 2015/4/8.
* ClientSesion 类:连接VCent服务器(URL、用户名和密码)
*/
public class ClientSesion implements java.io.Serializable {
private String host;//vcent url
private String username;//vcent 用户名
private String password;//vcent 密码
// set 和 get
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
//默认构造函数
public ClientSesion(){
super();
}
//构造函数
public ClientSesion(String host, String username, String password) {
super();
this.host = host;
this.username = username;
this.password = password;
}
}
package com.vmware.client;
import com.vmware.util.ClientSesion;
import com.vmware.vim25.AboutInfo;
import com.vmware.vim25.mo.*;
import java.net.URL;
/**
* Created by vixuan-008 on 2015/4/8.
* 测试类
*/
public class Client {
public static void main(String[] args){
try{
ClientSesion session=new ClientSesion("172.16.1.20","root","vmware");
URL url = new URL("https", session.getHost(), "/sdk");
ServiceInstance si = new ServiceInstance(url, session.getUsername(), session.getPassword(), true);
Folder rootFolder = si.getRootFolder();
//VCenter vc = new VCenter();
AboutInfo ai = si.getAboutInfo();
System.out.println("名称"+ai.getFullName());
System.out.println("版本:"+ai.getVersion());
// System.out.println(ai.apiType);
// si.currentTime();
}catch(Exception e){
e.printStackTrace();
}
}
}
---------------------
作者:在奋斗的大道
来源:CSDN
原文:https://blog.csdn.net/zhouzhiwengang/article/details/45044817
版权声明:本文为博主原创文章,转载请附上博文链接!