Source:
public Pair<NicProfile, Integer> allocateNic(final NicProfile requested, final Network network, final Boolean isDefaultNic, int deviceId, final VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { final NetworkVO ntwkVO = _networksDao.findById(network.getId()); s_logger.debug("Allocating nic for vm " + vm.getVirtualMachine() + " in network " + network + " with requested profile " + requested); final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, ntwkVO.getGuruName()); if (requested != null && requested.getMode() == null) { requested.setMode(network.getMode()); } final NicProfile profile = guru.allocate(network, requested, vm); if (profile == null) { return null; } if (isDefaultNic != null) { profile.setDefaultNic(isDefaultNic); } if (requested != null && requested.getMode() == null) { profile.setMode(requested.getMode()); } else { profile.setMode(network.getMode()); } NicVO vo = new NicVO(guru.getName(), vm.getId(), network.getId(), vm.getType()); DataCenterVO dcVo = _dcDao.findById(network.getDataCenterId()); if (dcVo.getNetworkType() == NetworkType.Basic) { configureNicProfileBasedOnRequestedIp(requested, profile, network); } if(Objects.isNull(profile.getMtu())) { profile.setMtu(_kvmMtuSize); } deviceId = applyProfileToNic(vo, profile, deviceId); vo = _nicDao.persist(vo); final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId()); final NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vm.getHypervisorType(), network)); return new Pair<NicProfile, Integer>(vmNic, Integer.valueOf(deviceId)); }

Target:
public Pair<NicProfile, Integer> allocateNic(final NicProfile requested, final Network network, final Boolean isDefaultNic, int deviceId, final VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { final NetworkVO ntwkVO = _networksDao.findById(network.getId()); s_logger.debug("Allocating nic for vm " + vm.getVirtualMachine() + " in network " + network + " with requested profile " + requested); final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, ntwkVO.getGuruName()); if (requested != null && requested.getMode() == null) { requested.setMode(network.getMode()); } final NicProfile profile = guru.allocate(network, requested, vm); if (profile == null) { return null; } if (isDefaultNic != null) { profile.setDefaultNic(isDefaultNic); } if (requested != null && requested.getMode() == null) { profile.setMode(requested.getMode()); } else { profile.setMode(network.getMode()); } NicVO vo = new NicVO(guru.getName(), vm.getId(), network.getId(), vm.getType()); DataCenterVO dcVo = _dcDao.findById(network.getDataCenterId()); if (dcVo.getNetworkType() == NetworkType.Basic) { configureNicProfileBasedOnRequestedIp(requested, profile, network); } if (profile.getMtu() == null) { profile.setMtu(_kvmMtuSize); } deviceId = applyProfileToNic(vo, profile, deviceId); vo = _nicDao.persist(vo); final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId()); final NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vm.getHypervisorType(), network)); return new Pair<NicProfile, Integer>(vmNic, Integer.valueOf(deviceId)); }