Search in sources :

Example 1 with ArrayOfGuestNicInfo

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);
}
Also used : ObjectContent(com.vmware.vim25.ObjectContent) HashMap(java.util.HashMap) GuestNicInfo(com.vmware.vim25.GuestNicInfo) ArrayOfGuestNicInfo(com.vmware.vim25.ArrayOfGuestNicInfo) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) ArrayOfGuestNicInfo(com.vmware.vim25.ArrayOfGuestNicInfo) Before(org.junit.Before)

Example 2 with ArrayOfGuestNicInfo

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;
}
Also used : VimPath(com.vmware.photon.controller.model.adapters.vsphere.util.VimPath) PowerState(com.vmware.photon.controller.model.resources.ComputeService.PowerState) ZonedDateTime(java.time.ZonedDateTime) HashMap(java.util.HashMap) ArrayOfVirtualDevice(com.vmware.vim25.ArrayOfVirtualDevice) VirtualCdrom(com.vmware.vim25.VirtualCdrom) Map(java.util.Map) VirtualMachineSnapshotTree(com.vmware.vim25.VirtualMachineSnapshotTree) VirtualDevice(com.vmware.vim25.VirtualDevice) ArrayOfManagedObjectReference(com.vmware.vim25.ArrayOfManagedObjectReference) VirtualMachinePowerState(com.vmware.vim25.VirtualMachinePowerState) ArrayOfVirtualMachineSnapshotTree(com.vmware.vim25.ArrayOfVirtualMachineSnapshotTree) ObjectContent(com.vmware.vim25.ObjectContent) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) VimNames(com.vmware.photon.controller.model.adapters.vsphere.util.VimNames) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) NetworkInterfaceStateWithDetails(com.vmware.photon.controller.model.adapters.vsphere.ProvisionContext.NetworkInterfaceStateWithDetails) DateTimeParseException(java.time.format.DateTimeParseException) List(java.util.List) VirtualDisk(com.vmware.vim25.VirtualDisk) DateTimeFormatter(java.time.format.DateTimeFormatter) ObjectUpdate(com.vmware.vim25.ObjectUpdate) VirtualEthernetCard(com.vmware.vim25.VirtualEthernetCard) Optional(java.util.Optional) Comparator(java.util.Comparator) VirtualFloppy(com.vmware.vim25.VirtualFloppy) Collections(java.util.Collections) ArrayOfGuestNicInfo(com.vmware.vim25.ArrayOfGuestNicInfo) HashMap(java.util.HashMap) List(java.util.List) ArrayOfGuestNicInfo(com.vmware.vim25.ArrayOfGuestNicInfo)

Aggregations

ArrayOfGuestNicInfo (com.vmware.vim25.ArrayOfGuestNicInfo)2 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)2 ObjectContent (com.vmware.vim25.ObjectContent)2 HashMap (java.util.HashMap)2 NetworkInterfaceStateWithDetails (com.vmware.photon.controller.model.adapters.vsphere.ProvisionContext.NetworkInterfaceStateWithDetails)1 VimNames (com.vmware.photon.controller.model.adapters.vsphere.util.VimNames)1 VimPath (com.vmware.photon.controller.model.adapters.vsphere.util.VimPath)1 PowerState (com.vmware.photon.controller.model.resources.ComputeService.PowerState)1 ArrayOfManagedObjectReference (com.vmware.vim25.ArrayOfManagedObjectReference)1 ArrayOfVirtualDevice (com.vmware.vim25.ArrayOfVirtualDevice)1 ArrayOfVirtualMachineSnapshotTree (com.vmware.vim25.ArrayOfVirtualMachineSnapshotTree)1 GuestNicInfo (com.vmware.vim25.GuestNicInfo)1 ObjectUpdate (com.vmware.vim25.ObjectUpdate)1 VirtualCdrom (com.vmware.vim25.VirtualCdrom)1 VirtualDevice (com.vmware.vim25.VirtualDevice)1 VirtualDisk (com.vmware.vim25.VirtualDisk)1 VirtualEthernetCard (com.vmware.vim25.VirtualEthernetCard)1 VirtualFloppy (com.vmware.vim25.VirtualFloppy)1 VirtualMachinePowerState (com.vmware.vim25.VirtualMachinePowerState)1 VirtualMachineSnapshotTree (com.vmware.vim25.VirtualMachineSnapshotTree)1