use of com.vmware.vim25.ArrayOfGuestNicInfo in project photon-model by vmware.
the class VmOverlayTest method setup.
@Before
public void setup() {
ObjectContent cont = new ObjectContent();
ManagedObjectReference ref = new ManagedObjectReference();
ref.setType(VimNames.TYPE_VM);
ref.setValue("vm-123");
cont.setObj(ref);
Map<String, Object> props = new HashMap<>();
ArrayOfGuestNicInfo arrayOfGuestNicInfo = new ArrayOfGuestNicInfo();
List<GuestNicInfo> listGuestNicInfo = arrayOfGuestNicInfo.getGuestNicInfo();
GuestNicInfo nic1 = new GuestNicInfo();
List<String> ipsNic1 = nic1.getIpAddress();
String mac1Address = "00:50:56:8b:54:bd";
String mac2Address = "98:87:fd:9e:ed:6d";
nic1.setMacAddress(mac1Address);
ipsNic1.add("192.168.1.10");
ipsNic1.add("192.168.1.11");
GuestNicInfo nic2 = new GuestNicInfo();
List<String> ipsNic2 = nic2.getIpAddress();
nic2.setMacAddress(mac2Address);
ipsNic2.add("10.10.10.20");
listGuestNicInfo.add(nic1);
listGuestNicInfo.add(nic2);
props.put(vm_guest_net, arrayOfGuestNicInfo);
this.overlay = new VmOverlay(ref, props);
}
use of com.vmware.vim25.ArrayOfGuestNicInfo in project photon-model by vmware.
the class VmOverlay method getMapNic2IpV4Addresses.
/**
* Builds a map of external device index and ips or mac addresses and ips
* @return Map
*/
public Map<String, List<String>> getMapNic2IpV4Addresses() {
ArrayOfGuestNicInfo arr = (ArrayOfGuestNicInfo) getOrDefault(VimPath.vm_guest_net, null);
if (arr == null) {
return Collections.emptyMap();
}
HashMap<String, List<String>> mapNicIpAddresses = new HashMap<>();
if (arr.getGuestNicInfo() != null) {
for (int index = 0; index < arr.getGuestNicInfo().size(); index++) {
List<String> ips = arr.getGuestNicInfo().get(index).getIpAddress().stream().filter(s -> !s.contains(":")).collect(Collectors.toList());
mapNicIpAddresses.put(Integer.toString(index), ips);
String macAddress = arr.getGuestNicInfo().get(index).getMacAddress();
if (macAddress != null) {
mapNicIpAddresses.put(macAddress, ips);
}
}
}
return mapNicIpAddresses;
}
Aggregations