Vijava 学习笔记之 HostSystem 连接
无情
阅读:626
2021-03-31 22:38:31
评论:0
package com.vmware.client;
import com.vmware.util.ClientSesion;
import com.vmware.vim25.*;
import com.vmware.vim25.mo.*;
import java.net.URL;
/**
* Created by vixuan-008 on 2015/4/14.
*/
public class HostSystemClient {
public static void main(String[] args){
try{
ClientSesion session=new ClientSesion("IP地址","用户名","密码");
URL url = new URL("https", session.getHost(), "/sdk");
ServiceInstance si = new ServiceInstance(url, session.getUsername(), session.getPassword(), true);
Folder rootFolder = si.getRootFolder();
ManagedEntity[] mes =new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem");
if(mes==null || mes.length==0){
si.getServerConnection().logout();
}
//遍历Vcenter 下的服务器资源
for(int i=0;i<mes.length;i++){
HostSystem systems=(HostSystem)mes[i];
//服务器配置信息
HostConfigInfo hostConfigInfo=systems.getConfig();
//服务器容量信息
HostCapability hostCapability=systems.getCapability();
//vm 最多运行数量
System.out.println("max running vm is:"+hostCapability.maxHostRunningVms);
}
System.out.println("HostSystem numbers:"+mes.length);
}catch(Exception e){
e.printStackTrace();
}
}
}
相关截图:
<img src="https://img-blog.csdn.net/20150414192807066?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhvdXpoaXdlbmdhbmc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。