use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class OvfManagerTest method initInterfaces.
private static void initInterfaces(VM vm) {
List<VmNetworkInterface> ifaces = new ArrayList<>();
RandomUtils rnd = RandomUtils.instance();
for (int i = 0; i < rnd.nextInt(2, 10); i++) {
VmNetworkInterface vmInterface = new VmNetworkInterface();
vmInterface.setStatistics(new VmNetworkStatistics());
vmInterface.setId(Guid.newGuid());
vmInterface.setVmId(vm.getId());
vmInterface.setName(generateRandomName());
vmInterface.setVnicProfileName(generateRandomName());
vmInterface.setNetworkName(generateRandomName());
vmInterface.setLinked(rnd.nextBoolean());
vmInterface.setSpeed(rnd.nextInt(1000));
vmInterface.setType(rnd.nextInt(10));
vmInterface.setMacAddress(rnd.nextMacAddress());
ifaces.add(vmInterface);
}
vm.setInterfaces(ifaces);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class VmValidatorTest method mockVnic.
private VmNetworkInterface mockVnic(boolean passthrough, boolean migratable, boolean plugged) {
VmNetworkInterface vnic = mock(VmNetworkInterface.class);
when(vnic.isPassthrough()).thenReturn(passthrough);
when(vnic.isPlugged()).thenReturn(plugged);
Guid vnicProfileId = Guid.newGuid();
when(vnic.getVnicProfileId()).thenReturn(vnicProfileId);
VnicProfile profile = mock(VnicProfile.class);
when(vnicProfileDao.get(vnicProfileId)).thenReturn(profile);
when(profile.isMigratable()).thenReturn(migratable);
return vnic;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class BackendTemplateNicResourceTest method setUpNicExpectations.
private VmNetworkInterface setUpNicExpectations() {
VmNetworkInterface nic = mock(VmNetworkInterface.class);
when(nic.getId()).thenReturn(NIC_ID);
when(nic.getType()).thenReturn(0);
return nic;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildInterfaceStatisticsData.
public static List<VmNetworkInterface> buildInterfaceStatisticsData(Map<String, Object> struct) {
// ------------- vm network statistics -----------------------
if (!struct.containsKey(VdsProperties.VM_NETWORK)) {
return null;
}
Map networkStruct = (Map) struct.get(VdsProperties.VM_NETWORK);
List<VmNetworkInterface> interfaceStatistics = new ArrayList<>();
for (Object tempNic : networkStruct.values()) {
Map nic = (Map) tempNic;
VmNetworkInterface stats = new VmNetworkInterface();
if (nic.containsKey(VdsProperties.VM_INTERFACE_NAME)) {
stats.setName((String) ((nic.get(VdsProperties.VM_INTERFACE_NAME) instanceof String) ? nic.get(VdsProperties.VM_INTERFACE_NAME) : null));
}
extractInterfaceStatistics(nic, stats);
stats.setMacAddress((String) ((nic.get(VdsProperties.MAC_ADDR) instanceof String) ? nic.get(VdsProperties.MAC_ADDR) : null));
interfaceStatistics.add(stats);
}
return interfaceStatistics;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildVmStaticDataFromExternalProvider.
private static VmStatic buildVmStaticDataFromExternalProvider(Map<String, Object> struct) {
if (!struct.containsKey(VdsProperties.vm_guid) || !struct.containsKey(VdsProperties.vm_name) || !struct.containsKey(VdsProperties.mem_size_mb) || !struct.containsKey(VdsProperties.num_of_cpus)) {
return null;
}
VmStatic vmStatic = new VmStatic();
vmStatic.setId(Guid.createGuidFromString((String) struct.get(VdsProperties.vm_guid)));
vmStatic.setName((String) struct.get(VdsProperties.vm_name));
vmStatic.setMemSizeMb(parseIntVdsProperty(struct.get(VdsProperties.mem_size_mb)));
vmStatic.setNumOfSockets(parseIntVdsProperty(struct.get(VdsProperties.num_of_cpus)));
vmStatic.setCustomCpuName((String) struct.get(VdsProperties.cpu_model));
vmStatic.setCustomEmulatedMachine((String) struct.get(VdsProperties.emulatedMachine));
addGraphicsDeviceFromExternalProvider(vmStatic, struct);
if (struct.containsKey(VdsProperties.vm_disks)) {
for (Object disk : (Object[]) struct.get(VdsProperties.vm_disks)) {
Map<String, Object> diskMap = (Map<String, Object>) disk;
if (VdsProperties.Disk.equals(diskMap.get(VdsProperties.type))) {
DiskImage image = buildDiskImageFromExternalProvider(diskMap, vmStatic.getId());
vmStatic.getImages().add(image);
}
}
}
if (struct.containsKey(VdsProperties.NETWORKS)) {
int idx = 0;
for (Object networkMap : (Object[]) struct.get(VdsProperties.NETWORKS)) {
VmNetworkInterface nic = buildNetworkInterfaceFromExternalProvider((Map<String, Object>) networkMap);
nic.setName(String.format("nic%d", ++idx));
nic.setVmName(vmStatic.getName());
nic.setVmId(vmStatic.getId());
vmStatic.getInterfaces().add(nic);
}
}
return vmStatic;
}
Aggregations