vcenter用到java吗_Vijava 学习笔记之 VCenter连接
package com.vmware.util;
/**
* Created by vixuan-008 on 2015/4/8.
* ClientSesion 類:連接VCent服務(wù)器(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;
}
//默認(rèn)構(gòu)造函數(shù)
public ClientSesion(){
super();
}
//構(gòu)造函數(shù)
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();
}
}
}
相關(guān)結(jié)果截圖:
總結(jié)
以上是生活随笔為你收集整理的vcenter用到java吗_Vijava 学习笔记之 VCenter连接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python皮同_Python Open
- 下一篇: java string对象创建_Stri