From 7de4583d8ee352d1868cca6aa4921b4e518a3242 Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Thu, 24 Jan 2013 16:28:41 -0700 Subject: [PATCH] Summary: Fixed a bug when trying to change the default NIC when the default nic was already on the same network as the nic you were trying to make the default. Reported-by: Brian Angus Submitted-by: Brian Angus Signed-off-by: Marcus Sorensen 1359070121 -0700 --- .../storage/resource/NfsSecondaryStorageResource.java | 3 ++- server/src/com/cloud/vm/UserVmManagerImpl.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java index a4bea9df2b4..a634c68bcd2 100755 --- a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java +++ b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java @@ -398,7 +398,8 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements @Override public boolean accept(final File directory, final String fileName) { - return !fileName.startsWith("."); + File fileToUpload = new File(directory.getAbsolutePath() + "/" + fileName); + return !fileName.startsWith(".") && !fileToUpload.isDirectory(); } }, new ObjectNamingStrategy() { @Override diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index d2e85a0e05f..e8382588399 100644 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1072,8 +1072,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager throw new CloudRuntimeException("refusing to set default nic because chosen nic is already the default"); } - NicProfile existing = _networkModel.getNicProfile(vmInstance, existingdefaultnet.getId(), null); - + NicProfile existing = null; + List nicProfiles = _networkMgr.getNicProfiles(vmInstance); + for (NicProfile nicProfile : nicProfiles) { + if(nicProfile.isDefaultNic() && nicProfile.getNetworkId() == existingdefaultnet.getId()){ + existing = nicProfile; + continue; + } + } + if (existing == null){ s_logger.warn("Failed to update default nic, no nic profile found for existing default network"); throw new CloudRuntimeException("Failed to find a nic profile for the existing default network. This is bad and probably means some sort of configuration corruption");