@@ -215,8 +215,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
215215 PlannerHostReservationDao _plannerHostReserveDao ;
216216 @ Inject
217217 protected DedicatedResourceDao _dedicatedDao ;
218- @ Inject
219- protected ConfigurationServer _configServer ;
220218
221219 protected List <? extends Discoverer > _discoverers ;
222220
@@ -462,7 +460,6 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws Illegal
462460
463461 List <ClusterVO > result = new ArrayList <ClusterVO >();
464462
465- long clusterId = 0 ;
466463 ClusterVO cluster = new ClusterVO (dcId , podId , clusterName );
467464 cluster .setHypervisorType (hypervisorType .toString ());
468465
@@ -479,14 +476,8 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws Illegal
479476 ex .addProxyObject (zone .getUuid (), "dcId" );
480477 throw ex ;
481478 }
482- clusterId = cluster .getId ();
483479 result .add (cluster );
484480
485- ClusterDetailsVO cluster_detail_cpu = new ClusterDetailsVO (clusterId , "cpuOvercommitRatio" , _configServer .getConfigValue (Config .CPUOverprovisioningFactor .key (), null , null ));
486- ClusterDetailsVO cluster_detail_ram = new ClusterDetailsVO (clusterId , "memoryOvercommitRatio" , _configServer .getConfigValue (Config .MemOverprovisioningFactor .key (), null , null ));
487- _clusterDetailsDao .persist (cluster_detail_cpu );
488- _clusterDetailsDao .persist (cluster_detail_ram );
489-
490481 if (clusterType == Cluster .ClusterType .CloudManaged ) {
491482 return result ;
492483 }
@@ -496,6 +487,8 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws Illegal
496487 details .put ("url" , url );
497488 details .put ("username" , username );
498489 details .put ("password" , password );
490+ details .put ("cpuOvercommitRatio" , _configDao .getValue (Config .CPUOverprovisioningFactor .key ()));
491+ details .put ("memoryOvercommitRatio" , _configDao .getValue (Config .MemOverprovisioningFactor .key ()));
499492 _clusterDetailsDao .persist (cluster .getId (), details );
500493
501494 boolean success = false ;
@@ -515,7 +508,7 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws Illegal
515508
516509 List <HostVO > hosts = new ArrayList <HostVO >();
517510 Map <? extends ServerResource , Map <String , String >> resources = null ;
518- resources = discoverer .find (dcId , podId , clusterId , uri , username , password , null );
511+ resources = discoverer .find (dcId , podId , cluster . getId () , uri , username , password , null );
519512
520513 if (resources != null ) {
521514 for (Map .Entry <? extends ServerResource , Map <String , String >> entry : resources .entrySet ()) {
@@ -536,8 +529,8 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws Illegal
536529 throw new DiscoveryException ("Unable to add the external cluster" );
537530 } finally {
538531 if (!success ) {
539- _clusterDetailsDao .deleteDetails (clusterId );
540- _clusterDao .remove (clusterId );
532+ _clusterDetailsDao .deleteDetails (cluster . getId () );
533+ _clusterDao .remove (cluster . getId () );
541534 }
542535 }
543536 }
0 commit comments