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;
}
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;
}
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);
}
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;
}
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);
}
Aggregations