首页 > 系统服务 > 详细

VMware之群集数据获取

时间:2015-04-21 17:41:27      阅读:311      评论:0      收藏:0      [点我收藏+]

在昨天的文章中,介绍了存储器的概要信息显示。接下面,就写群集的概要信息吧

 1 ServiceInstance si;
 2 Statement s = conn.createStatement();
 3 System.out
 4                         .println("================1ServiceInstance(new URL(==========");
 5 //此处user,pwd。设置为true
 6                 si = new ServiceInstance(new URL(
 7         "https://vcenter5.dyxnet.com/sdk/"), usernameVal,
 8                         passwordVal, true);
 9                 // https://vcenter3.dyxnet.com/sdk
10                 System.out
11                         .println("================2ServiceInstance(new URL(==========");
12 //rootFolder
13                 Folder rootFolder = si.getRootFolder();
14 
15 // jimw
16                 InventoryNavigator inav = new InventoryNavigator(rootFolder);
17 //展示主机下的vm
18                 ManagedEntity[] esxs = inav.searchManagedEntities("HostSystem");
19 for (ManagedEntity me: esxs) {
20                    
21             Datacenter dc = (Datacenter) me;
22          String path = dc.getName();
23          System.out.println("数据中心:"+path);
24          int a=0;
25          for (Datastore ds :  dc.getDatastores()) {
26              DatastoreInfo info = ds.getInfo();
27              String dssUUID = null;
28              if(info instanceof VmfsDatastoreInfo) {
29                VmfsDatastoreInfo vdinfo = (VmfsDatastoreInfo) info;
30                dssUUID = vdinfo.getVmfs().getUuid();
31                System.out.println(  ds.getName());
32              
33                System.out.println("dssUUID:"+dssUUID
34                        +" MOR_type:"+ds.getMOR().getType()
35                        +" MOR_val :"+ds.getMOR().val
36                        +" MaxFileSize :"+info.getMaxFileSize()
37                        +" MaxVirtualDiskCapacity :"+info.getMaxVirtualDiskCapacity()///(1024 * 1024)
38                        +" FreeSpace :"+info.getFreeSpace()///(1024 * 1024)
39                        +" getTimeInMillis() :"+info.getTimestamp().getTimeInMillis()
40                        +" :");
41              }
42              System.out.println(info.getName());
43              
44              a+=1;
45             System.out.println(a+"ds:"+ds.getInfo().name);
46             System.out.println(a+"ds: "+ds.getInfo().getFreeSpace()/1024/1024/1024);
47         }
48          
49          for (ManagedEntity aa : dc.getHostFolder().getChildEntity()) {
50             System.out.println("群集:"+aa.getName());
51             if (aa.getAvailableField()!=null) {
52                 for (CustomFieldDef csf : aa.getAvailableField()) {
53                     System.out.println("Name:"+csf.getName());
54                 }
55                 
56             } else {
57                              System.out.println("csf null");
58             }
59             
60             if (aa.getCustomValue()!=null) {
61                 for (CustomFieldValue csfv : aa.getCustomValue()) {
62                     System.out.println("csfv:"+csfv.dynamicType);
63                     System.out.println("csfv:"+csfv.key);
64                      
65                     
66                     if ( csfv.getDynamicProperty()!=null) {
67                         for (DynamicProperty managedEntity : csfv.getDynamicProperty()) {
68                             System.out
69                                     .println(managedEntity.name);
70                             System.out
71                                     .println("1111111111");
72                         }
73                     } else {
74                              System.out
75                                     .println("csfv null");
76                     }
77                 }
78             } else {
79                 System.out.println(" again null");
80             }
81             
82             
83             
84             System.out.println("状态:"+aa.getOverallStatus().name());
85             System.out.println("状态ID:"+aa.getOverallStatus().ordinal());
86         }
87 
88                 }

 

VMware之群集数据获取

原文:http://www.cnblogs.com/jimw/p/4444877.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!