Search in sources :

Example 16 with VmNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilder method buildVmNetworkInterfacesFromDevices.

/**
 * Convert the devices map and make a list of {@linkplain VmNetworkInterface}
 * Mainly used to import the Hosted Engine Vm disks.
 *
 * @return A List of VM network interfaces {@linkplain VmNetworkInterface}
 */
public static ArrayList<VmNetworkInterface> buildVmNetworkInterfacesFromDevices(Map<String, Object> vmStruct) {
    ArrayList<VmNetworkInterface> nics = new ArrayList<>();
    Object[] devices = (Object[]) vmStruct.get(VdsProperties.Devices);
    if (devices != null) {
        for (Object device : devices) {
            Map<String, Object> deviceMap = (Map<String, Object>) device;
            if (VdsProperties.VM_INTERFACE_DEVICE_TYPE.equals(deviceMap.get(VdsProperties.Type))) {
                VmNetworkInterface nic = new VmNetworkInterface();
                nic.setId(Guid.createGuidFromString((String) deviceMap.get(VdsProperties.DeviceId)));
                nic.setMacAddress((String) deviceMap.get(VdsProperties.MAC_ADDR));
                nic.setName((String) deviceMap.get(VdsProperties.Name));
                // FIXME we can't deduce the network profile by the network name. its many to many.
                nic.setNetworkName((String) deviceMap.get(VdsProperties.NETWORK));
                String nicModel = (String) deviceMap.get(VdsProperties.NIC_TYPE);
                if ("virtio".equals(nicModel)) {
                    nicModel = "pv";
                }
                nic.setType(VmInterfaceType.valueOf(nicModel).getValue());
                if (deviceMap.containsKey(VdsProperties.Model)) {
                    String model = (String) deviceMap.get(VdsProperties.Model);
                    for (VmInterfaceType type : VmInterfaceType.values()) {
                        if (model.equals(type.getInternalName())) {
                            nic.setType(type.getValue());
                            break;
                        }
                    }
                }
                nics.add(nic);
            }
        }
    }
    return nics;
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) ArrayList(java.util.ArrayList) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType) Map(java.util.Map) HashMap(java.util.HashMap)

Example 17 with VmNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilder method buildNetworkInterfaceFromExternalProvider.

private static VmNetworkInterface buildNetworkInterfaceFromExternalProvider(Map<String, Object> map) {
    VmNetworkInterface nic = new VmNetworkInterface();
    nic.setMacAddress((String) map.get(VdsProperties.MAC_ADDR));
    nic.setRemoteNetworkName((String) map.get(VdsProperties.BRIDGE));
    nic.setType(VmInterfaceType.pv.getValue());
    if (map.containsKey(VdsProperties.Model)) {
        String model = (String) map.get(VdsProperties.Model);
        for (VmInterfaceType type : VmInterfaceType.values()) {
            if (model.equals(type.getInternalName())) {
                nic.setType(type.getValue());
                break;
            }
        }
    }
    return nic;
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType)

Example 18 with VmNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.

the class ProfileInstanceTypeEditor method syncSelectedItemWithNetworkInterface.

private void syncSelectedItemWithNetworkInterface(final VnicInstanceType model) {
    final VmNetworkInterface vnic = model.getNetworkInterface();
    VnicProfileView profile = model.getSelectedItem();
    vnic.setVnicProfileId(profile != null ? profile.getId() : null);
    vnic.setNetworkName(profile != null ? profile.getNetworkName() : null);
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView)

Example 19 with VmNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.

the class ProfilesInstanceTypeEditor method createGhostValue.

@Override
protected VnicInstanceType createGhostValue() {
    VmNetworkInterface vnic = new VmNetworkInterface();
    vnic.setName(AsyncDataProvider.getInstance().getNewNicName(vnics));
    vnics.add(vnic);
    VnicInstanceType vnicWithProfile = new VnicInstanceType(vnic);
    vnicWithProfile.setItems(vnicProfiles);
    return vnicWithProfile;
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VnicInstanceType(org.ovirt.engine.ui.uicommonweb.models.vms.VnicInstanceType)

Example 20 with VmNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.

the class TemplateInterfaceListModel method newEntity.

private void newEntity() {
    if (getWindow() != null) {
        return;
    }
    VmInterfaceModel model = NewTemplateInterfaceModel.createInstance(getEntity(), getEntity().getStoragePoolId(), getEntity().getCompatibilityVersion(), (ArrayList<VmNetworkInterface>) getItems(), this);
    setWindow(model);
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmInterfaceModel)

Aggregations

VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)115 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)25 Guid (org.ovirt.engine.core.compat.Guid)19 VM (org.ovirt.engine.core.common.businessentities.VM)16 HashMap (java.util.HashMap)11 List (java.util.List)9 Map (java.util.Map)9 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)6 MapVnicsContext (org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext)5 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)5 HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)5 VmNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics)5 Nic (org.ovirt.engine.api.model.Nic)4 VnicProfileHelper (org.ovirt.engine.core.bll.network.vm.VnicProfileHelper)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 Collection (java.util.Collection)3