- private byte[] getHardwareMAC() {
- Enumeration<NetworkInterface> nis;
- byte[] macAddress = null;
-
- try {
- nis = NetworkInterface.getNetworkInterfaces();
- } catch (SocketException e) {
- log.error("Failed to acquire controller MAC: ", e);
- return macAddress;
- }
-
- while (nis.hasMoreElements()) {
- NetworkInterface ni = nis.nextElement();
- try {
- macAddress = ni.getHardwareAddress();
- } catch (SocketException e) {
- log.error("Failed to acquire controller MAC: ", e);
- }
- if (macAddress != null) {
- break;
- }
- }
- if (macAddress == null) {
- log.warn("Failed to acquire controller MAC: No physical interface found");
- // This happens when running controller on windows VM, for example
- // Try parsing the OS command output
- }
- return macAddress;
- }
-