/** * Synchronize the VM's {@link VmNetworkInterface}s with the ones from the snapshot.<br> * All existing NICs will be deleted, and the ones from the snapshot re-added.<br> * In case a MAC address is already in use, the user will be issued a warning in the audit log. * * @param nics The nics from snapshot. */ protected void synchronizeNics( Guid vmId, List<VmNetworkInterface> nics, CompensationContext compensationContext) { VmInterfaceManager vmInterfaceManager = new VmInterfaceManager(); vmInterfaceManager.removeAll(true, vmId); for (VmNetworkInterface vmInterface : nics) { // These fields are not saved in the OVF, so fill them with reasonable values. vmInterface.setId(Guid.NewGuid()); vmInterface.setVmId(vmId); vmInterfaceManager.add(vmInterface, compensationContext); } }