scope oshi_detectVM.
static SS #vmMap = litmap(
"00:50:56", "VMware ESX 3",
"00:0C:29", "VMware ESX 3",
"00:05:69", "VMware ESX 3",
"00:03:FF", "Microsoft Hyper-V",
"00:1C:42", "Parallels Desktop",
"00:0F:4B", "Virtual Iron 4",
"00:16:3E", "Xen or Oracle VM",
"08:00:27", "Sun xVM VirtualBox");
static S[] #vmArray = { "Linux KVM", "Linux lguest", "OpenVZ", "Qemu", "Microsoft Virtual PC",
"VMWare", "linux-vserver", "Xen", "FreeBSD Jail", "OpenVZ Host", "VirtualBox", "Parallels",
"Linux Containers", "LXC" };
static Pair<Bool, S> oshi_detectVM() {
HardwareAbstractionLayer hw = oshi_hardware();
// Try well known MAC addresses
NetworkIF[] nifs = hw.getNetworkIFs();
for (NetworkIF nif : nifs) {
S mac = nif.getMacaddr().substring(0, 8).toUpperCase();
if (vmMap.containsKey(mac))
ret pair(true, vmMap.get(mac));
}
// Try well known models
S model = hw.getComputerSystem().getModel();
for (String vm : vmArray)
if (model.contains(vm))
ret pair(true, vm);
ret pair(false, "Could not detect a VM");
}
end scopedownload show line numbers debug dex old transpilations
Travelled to 11 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1019745 |
| Snippet name: | oshi_detectVM - are we on a virtual machine? |
| Eternal ID of this version: | #1019745/2 |
| Text MD5: | 68fbcc3e93776d63252bb580af152984 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-11-24 16:58:11 |
| Source code size: | 1117 bytes / 37 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 864 / 1033 |
| Version history: | 1 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |