1
2
3
4
5 package oshi.driver.windows.wmi;
6
7 import com.sun.jna.platform.win32.COM.WbemcliUtil.WmiQuery;
8 import com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult;
9
10 import oshi.annotation.concurrent.ThreadSafe;
11 import oshi.util.platform.windows.WmiQueryHandler;
12
13
14
15
16 @ThreadSafe
17 public final class MSFTStorage {
18
19 private static final String STORAGE_NAMESPACE = "ROOT\\Microsoft\\Windows\\Storage";
20 private static final String MSFT_STORAGE_POOL_WHERE_IS_PRIMORDIAL_FALSE = "MSFT_StoragePool WHERE IsPrimordial=FALSE";
21 private static final String MSFT_STORAGE_POOL_TO_PHYSICAL_DISK = "MSFT_StoragePoolToPhysicalDisk";
22 private static final String MSFT_PHYSICAL_DISK = "MSFT_PhysicalDisk";
23 private static final String MSFT_VIRTUAL_DISK = "MSFT_VirtualDisk";
24
25
26
27
28 public enum StoragePoolProperty {
29 FRIENDLYNAME, OBJECTID;
30 }
31
32
33
34
35
36 public enum StoragePoolToPhysicalDiskProperty {
37 STORAGEPOOL, PHYSICALDISK;
38 }
39
40
41
42
43 public enum PhysicalDiskProperty {
44 FRIENDLYNAME, PHYSICALLOCATION, OBJECTID;
45 }
46
47
48
49
50 public enum VirtualDiskProperty {
51 FRIENDLYNAME, OBJECTID;
52 }
53
54 private MSFTStorage() {
55 }
56
57
58
59
60
61
62
63 public static WmiResult<StoragePoolProperty> queryStoragePools(WmiQueryHandler h) {
64 WmiQuery<StoragePoolProperty> storagePoolQuery = new WmiQuery<>(STORAGE_NAMESPACE,
65 MSFT_STORAGE_POOL_WHERE_IS_PRIMORDIAL_FALSE, StoragePoolProperty.class);
66 return h.queryWMI(storagePoolQuery, false);
67 }
68
69
70
71
72
73
74
75
76 public static WmiResult<StoragePoolToPhysicalDiskProperty> queryStoragePoolPhysicalDisks(WmiQueryHandler h) {
77 WmiQuery<StoragePoolToPhysicalDiskProperty> storagePoolToPhysicalDiskQuery = new WmiQuery<>(STORAGE_NAMESPACE,
78 MSFT_STORAGE_POOL_TO_PHYSICAL_DISK, StoragePoolToPhysicalDiskProperty.class);
79 return h.queryWMI(storagePoolToPhysicalDiskQuery, false);
80 }
81
82
83
84
85
86
87
88 public static WmiResult<PhysicalDiskProperty> queryPhysicalDisks(WmiQueryHandler h) {
89 WmiQuery<PhysicalDiskProperty> physicalDiskQuery = new WmiQuery<>(STORAGE_NAMESPACE, MSFT_PHYSICAL_DISK,
90 PhysicalDiskProperty.class);
91 return h.queryWMI(physicalDiskQuery, false);
92 }
93
94
95
96
97
98
99
100 public static WmiResult<VirtualDiskProperty> queryVirtualDisks(WmiQueryHandler h) {
101 WmiQuery<VirtualDiskProperty> virtualDiskQuery = new WmiQuery<>(STORAGE_NAMESPACE, MSFT_VIRTUAL_DISK,
102 VirtualDiskProperty.class);
103 return h.queryWMI(virtualDiskQuery, false);
104 }
105
106 }