From 6ebdafd4c3508cbaaa157da614d46af61f7791cc Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Tue, 4 Jan 2011 03:56:15 -0800 Subject: [PATCH] Add vmware cluster will automatically bring in all hosts under the cluster --- .../cloud/agent/manager/AgentManagerImpl.java | 17 ++++++++++++----- .../configuration/DefaultComponentLibrary.java | 2 ++ ui/scripts/cloud.core.host.js | 6 +----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index e40dc90c62b..b69b200f06b 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -85,6 +85,7 @@ import com.cloud.api.commands.UpdateHostCmd; import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; import com.cloud.configuration.dao.ConfigurationDao; +import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterIpAddressVO; @@ -226,7 +227,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS @Inject protected StoragePoolHostDao _storagePoolHostDao = null; @Inject protected GuestOSCategoryDao _guestOSCategoryDao = null; @Inject protected DetailsDao _hostDetailsDao = null; - @Inject protected ClusterDao _clusterDao; + @Inject protected ClusterDao _clusterDao = null; + @Inject protected ClusterDetailsDao _clusterDetailsDao = null; @Inject(adapter=DeploymentPlanner.class) private Adapters _planners; @@ -579,10 +581,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS try { cluster = _clusterDao.persist(cluster); } catch (Exception e) { - cluster = _clusterDao.findBy(clusterName, podId); - if (cluster == null) { - throw new CloudRuntimeException("Unable to create cluster " + clusterName + " in pod " + podId + " and data center " + dcId, e); - } + // no longer tolerate exception during the cluster creation phase + throw new CloudRuntimeException("Unable to create cluster " + clusterName + " in pod " + podId + " and data center " + dcId, e); } clusterId = cluster.getId(); result.add(cluster); @@ -591,6 +591,13 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS return result; } + // save cluster details for later cluster/host cross-checking + Map details = new HashMap(); + details.put("url", url); + details.put("username", username); + details.put("password", password); + _clusterDetailsDao.persist(cluster.getId(), details); + boolean success = false; try { try { diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java index b8b96d2c727..04a13bfb1ee 100644 --- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java +++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java @@ -43,6 +43,7 @@ import com.cloud.configuration.dao.ResourceLimitDaoImpl; import com.cloud.consoleproxy.AgentBasedStandaloneConsoleProxyManager; import com.cloud.dao.EntityManager; import com.cloud.dao.EntityManagerImpl; +import com.cloud.dc.ClusterDetailsDaoImpl; import com.cloud.dc.dao.AccountVlanMapDaoImpl; import com.cloud.dc.dao.ClusterDaoImpl; import com.cloud.dc.dao.DataCenterDaoImpl; @@ -234,6 +235,7 @@ public class DefaultComponentLibrary implements ComponentLibrary { addDao("FirewallRulesDao", FirewallRulesDaoImpl.class); addDao("PortForwardingRulesDao", PortForwardingRulesDaoImpl.class); addDao("UsageEventDao", UsageEventDaoImpl.class); + addDao("ClusterDetailsDao", ClusterDetailsDaoImpl.class); } Map> _managers = new HashMap>(); diff --git a/ui/scripts/cloud.core.host.js b/ui/scripts/cloud.core.host.js index 4f26be1eb8e..3534166dd29 100644 --- a/ui/scripts/cloud.core.host.js +++ b/ui/scripts/cloud.core.host.js @@ -58,11 +58,7 @@ function hostToMidmenu(jsonObj, $midmenuItem1) { $iconContainer.find("#icon").attr("src", "images/midmenuicon_host.png"); $midmenuItem1.find("#first_row").text(fromdb(jsonObj.name).substring(0,25)); - - if(!!jsonObj.clustertype && jsonObj.clustertype == "ExternalManaged") - $midmenuItem1.find("#second_row").text("Externally managed cluster"); - else - $midmenuItem1.find("#second_row").text(jsonObj.ipaddress.substring(0,25)); + $midmenuItem1.find("#second_row").text(jsonObj.ipaddress.substring(0,25)); updateHostStateInMidMenu(jsonObj, $midmenuItem1); }