Source:
protected void addVmInterfaces() { VmInterfaceManager vmInterfaceManager = new VmInterfaceManager(); List<VmNetworkInterface> interfaces = getVmTemplate().getInterfaces(); List<String> invalidNetworkNames = new ArrayList<String>(); List<String> invalidIfaceNames = new ArrayList<String>(); Map<String, Network> networksInVdsByName = Entities.entitiesByName(getNetworkDAO().getAllForCluster(getVmTemplate().getVdsGroupId())); List<VnicProfileView> vnicProfilesInDc = getDbFacade().getVnicProfileViewDao().getAllForDataCenter(getStoragePoolId()); for (VmNetworkInterface iface : interfaces) { 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()); if (!vmInterfaceManager.updateNicWithVnicProfile(iface, iface.getNetworkName(), iface.getVnicProfileName(), getVdsGroup().getcompatibility_version(), networksInVdsByName, vnicProfilesInDc, getCurrentUser().getUserId())) { invalidNetworkNames.add(iface.getNetworkName()); invalidIfaceNames.add(iface.getName()); iface.setVnicProfileId(null); } getVmNicDao().save(nic); getCompensationContext().snapshotNewEntity(nic); VmNetworkStatistics iStat = new VmNetworkStatistics(); nic.setStatistics(iStat); iStat.setId(iface.getId()); iStat.setVmId(getVmTemplateId()); getDbFacade().getVmNetworkStatisticsDao().save(iStat); getCompensationContext().snapshotNewEntity(iStat); } auditInvalidInterfaces(invalidNetworkNames, invalidIfaceNames); }

Target:
protected void addVmInterfaces() { VmInterfaceManager vmInterfaceManager = new VmInterfaceManager(); List<VmNetworkInterface> interfaces = getVmTemplate().getInterfaces(); List<String> invalidNetworkNames = new ArrayList<String>(); List<String> invalidIfaceNames = new ArrayList<String>(); Map<String, Network> networksInVdsByName = Entities.entitiesByName(getNetworkDAO().getAllForCluster(getVmTemplate().getVdsGroupId())); List<VnicProfileView> vnicProfilesInDc = getDbFacade().getVnicProfileViewDao().getAllForDataCenter(getStoragePoolId()); for (VmNetworkInterface iface : interfaces) { 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()); if (!vmInterfaceManager.updateNicWithVnicProfile(iface, getVdsGroup().getcompatibility_version(), networksInVdsByName, vnicProfilesInDc, getCurrentUser().getUserId())) { invalidNetworkNames.add(iface.getNetworkName()); invalidIfaceNames.add(iface.getName()); } nic.setVnicProfileId(iface.getVnicProfileId()); getVmNicDao().save(nic); getCompensationContext().snapshotNewEntity(nic); VmNetworkStatistics iStat = new VmNetworkStatistics(); nic.setStatistics(iStat); iStat.setId(iface.getId()); iStat.setVmId(getVmTemplateId()); getDbFacade().getVmNetworkStatisticsDao().save(iStat); getCompensationContext().snapshotNewEntity(iStat); } auditInvalidInterfaces(invalidNetworkNames, invalidIfaceNames); }