use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class VmInterfaceManager method removeFromExternalNetworks.
protected void removeFromExternalNetworks(List<? extends VmNic> interfaces) {
Transaction transaction = TransactionSupport.suspend();
for (VmNic iface : interfaces) {
getExternalNetworkManagerFactory().create(iface).deallocateIfExternal();
}
TransactionSupport.resume(transaction);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class VmNicDaoTest method testGetAllForTemplate.
/**
* Ensures that interfaces are returned.
*/
@Test
public void testGetAllForTemplate() {
List<VmNic> result = dao.getAllForTemplate(TEMPLATE_ID);
assertNotNull(result);
assertFalse(result.isEmpty());
for (VmNic iface : result) {
assertEquals(TEMPLATE_ID, iface.getVmTemplateId());
}
}
use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class VmNicDaoTest method testGetAllInterfacesForVm.
/**
* Ensures that a collection of interfaces related the specified VM are returned.
*/
@Test
public void testGetAllInterfacesForVm() {
List<VmNic> result = dao.getAllForVm(VM_ID);
assertNotNull(result);
assertFalse(result.isEmpty());
for (VmNic iface : result) {
assertEquals(VM_ID, iface.getVmId());
}
}
use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class ImportVmTemplateCommand method addVmInterfaces.
protected void addVmInterfaces() {
VnicProfileHelper vnicProfileHelper = new VnicProfileHelper(getVmTemplate().getClusterId(), getStoragePoolId(), AuditLogType.IMPORTEXPORT_IMPORT_TEMPLATE_INVALID_INTERFACES);
for (VmNetworkInterface iface : getVmTemplate().getInterfaces()) {
if (iface.getId() == null) {
iface.setId(Guid.newGuid());
}
iface.setVmId(getVmTemplateId());
VmNic nic = new VmNic();
nic.setId(iface.getId());
nic.setVmTemplateId(getVmTemplateId());
nic.setName(iface.getName());
nic.setLinked(iface.isLinked());
nic.setSpeed(iface.getSpeed());
nic.setType(iface.getType());
vnicProfileHelper.updateNicWithVnicProfileForUser(iface, getCurrentUser());
nic.setVnicProfileId(iface.getVnicProfileId());
vmNicDao.save(nic);
getCompensationContext().snapshotNewEntity(nic);
VmNetworkStatistics iStat = new VmNetworkStatistics();
nic.setStatistics(iStat);
iStat.setId(iface.getId());
iStat.setVmId(getVmTemplateId());
vmNetworkStatisticsDao.save(iStat);
getCompensationContext().snapshotNewEntity(iStat);
}
vnicProfileHelper.auditInvalidInterfaces(getVmTemplateName());
}
use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class VmTemplateManagementCommand method removeNetwork.
protected void removeNetwork() {
List<VmNic> list = vmNicDao.getAllForTemplate(getVmTemplateId());
for (VmNic iface : list) {
vmDeviceDao.remove(new VmDeviceId(iface.getId(), getVmTemplateId()));
vmNicDao.remove(iface.getId());
}
}
Aggregations