30 5月 2013

[VMware] 使用JAVA撰寫vim --建立與Esx Server的連線


這段時間對於VIM有點興趣,稍微研究了一下,就順手作個筆記囉~
在連線的部分,需要有ESX IP,User 帳號,User Password
import com.vmware.vim25.mo.ServiceInstance;
public void connectEsxServer(String Esxip, String EsxUserId, String EsxPWD) throws Exception {
   String EsxUrl;
   ServiceInstance si;
   EsxUrl = "https://" + Esxip+ "/sdk"
   si = new ServiceInstance(new URL(EsxUrl), EsxUserId, EsxPWD,true);
   if (si == null) {
       System.out.println("Host not found");
   return;
  }
 }

利用這個方式,便可以透過ServiceInstance 來與Esx Server建立連線

沒有留言:

張貼留言