incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject git commit: Summary: Don't allow a vm to join a network if another VM of same name exists
Date Wed, 30 Jan 2013 00:58:59 GMT
Updated Branches:
  refs/heads/add_remove_nics aff919eab -> 89d8a478e


Summary: Don't allow a vm to join a network if another VM of same name exists

Submitted-by: Brian Angus <brian@betterservers.com>
Signed-off-by: Marcus Sorensen <marcus@betterservers.com> 1359507543 -0700


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/89d8a478
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/89d8a478
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/89d8a478

Branch: refs/heads/add_remove_nics
Commit: 89d8a478e0536b73d9028f262c1d3b4f4f34b0ff
Parents: aff919e
Author: Marcus Sorensen <marcus@betterservers.com>
Authored: Tue Jan 29 17:59:03 2013 -0700
Committer: Marcus Sorensen <marcus@betterservers.com>
Committed: Tue Jan 29 17:59:03 2013 -0700

----------------------------------------------------------------------
 server/src/com/cloud/vm/UserVmManagerImpl.java |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89d8a478/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index e00da92..d90b266 100644
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -967,14 +967,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
         if(_networkModel.getNicInNetwork(vmInstance.getId(),network.getId()) != null){
             s_logger.debug(vmInstance + " already in " + network + " going to add another
NIC");
         } else {
-            List<NicVO> nics = _nicDao.listByNetworkId(network.getId());
-            for (NicVO netnic : nics) {
-                VMInstanceVO vm = _vmDao.findById(netnic.getInstanceId());
-                if (vm != null) {
-                    if (vm.getHostName().equals(vmInstance.getHostName())) {
-                        throw new CloudRuntimeException(network + " already has a vm with
host name: '" + vmInstance.getHostName() + "' vmId:" + vm.getId() + " " + vm);
-                    }
-                }
+            //* get all vms hostNames in the network
+            List<String> hostNames = _vmInstanceDao.listDistinctHostNames(network.getId());
+            //* verify that there are no duplicates
+            if (hostNames.contains(vmInstance.getHostName())) {
+                throw new CloudRuntimeException(network + " already has a vm with host name:
'" + vmInstance.getHostName());
             }
         }
         


Mime
View raw message