@@ -653,10 +653,24 @@ public Ternary<Boolean, Map<String, String>, String> prepareStorageClient(String
653653 if (!ScaleIOUtil .startSDCService ()) {
654654 return new Ternary <>(false , null , "Couldn't start SDC service on host" );
655655 }
656- } else {
657- logger .debug ("SDC service is active on host, re-starting it" );
658- if (!ScaleIOUtil .restartSDCService ()) {
659- return new Ternary <>(false , null , "Couldn't restart SDC service on host" );
656+ }
657+
658+ if (MapUtils .isNotEmpty (details ) && details .containsKey (ScaleIOGatewayClient .STORAGE_POOL_MDMS )) {
659+ // Assuming SDC service is started, add mdms
660+ String mdms = details .get (ScaleIOGatewayClient .STORAGE_POOL_MDMS );
661+ String [] mdmAddresses = mdms .split ("," );
662+ if (mdmAddresses .length > 0 ) {
663+ if (ScaleIOUtil .isMdmPresent (mdmAddresses [0 ])) {
664+ return new Ternary <>(true , getSDCDetails (details ), "MDM added, no need to prepare the SDC client" );
665+ }
666+
667+ ScaleIOUtil .addMdms (mdmAddresses );
668+ if (!ScaleIOUtil .isMdmPresent (mdmAddresses [0 ])) {
669+ return new Ternary <>(false , null , "Failed to add MDMs" );
670+ } else {
671+ logger .debug (String .format ("MDMs %s added to storage pool %s" , mdms , uuid ));
672+ applyMdmsChangeWaitTime (details );
673+ }
660674 }
661675 }
662676
@@ -784,12 +798,12 @@ private Map<String, String> getSDCDetails(Map<String, String> details) {
784798 if (sdcId != null ) {
785799 sdcDetails .put (ScaleIOGatewayClient .SDC_ID , sdcId );
786800 return sdcDetails ;
787- } else {
788- String sdcGuId = ScaleIOUtil . getSdcGuid ();
789- if ( sdcGuId != null ) {
790- sdcDetails . put ( ScaleIOGatewayClient . SDC_GUID , sdcGuId );
791- return sdcDetails ;
792- }
801+ }
802+
803+ String sdcGuId = ScaleIOUtil . getSdcGuid ();
804+ if ( sdcGuId != null ) {
805+ sdcDetails . put ( ScaleIOGatewayClient . SDC_GUID , sdcGuId ) ;
806+ return sdcDetails ;
793807 }
794808
795809 try {
0 commit comments