@@ -131,6 +131,8 @@ public boolean connect() {
131131 throw new CloudRuntimeException ("No aggregates are assigned to SVM " + svmName );
132132 }
133133 // Set the aggregates which are according to the storage requirements
134+ int maxAvailableAggregateSpace = storage .getSize ().intValue ();
135+ Aggregate aggrChosen = null ;
134136 for (Aggregate aggr : aggrs ) {
135137 s_logger .debug ("Found aggregate: " + aggr .getName () + " with UUID: " + aggr .getUuid ());
136138 Aggregate aggrResp = aggregateFeignClient .getAggregateByUUID (authHeader , aggr .getUuid ());
@@ -142,13 +144,18 @@ public boolean connect() {
142144 s_logger .warn ("Aggregate " + aggr .getName () + " does not have sufficient available space. Skipping this aggregate." );
143145 continue ;
144146 }
145- s_logger .info ("Selected aggregate: " + aggr .getName () + " for volume operations." );
146- this .aggregates = List .of (aggr );
147+ if (aggrResp .getAvailableBlockStorageSpace () >= maxAvailableAggregateSpace ) {
148+ maxAvailableAggregateSpace = aggrResp .getAvailableBlockStorageSpace ().intValue ();
149+ aggrChosen = aggr ;
150+ }
147151 }
152+
153+ this .aggregates = List .of (aggrChosen );
148154 if (this .aggregates == null || this .aggregates .isEmpty ()) {
149155 s_logger .error ("No suitable aggregates found on SVM " + svmName + " for volume creation." );
150156 throw new CloudRuntimeException ("No suitable aggregates found on SVM " + svmName + " for volume creation." );
151157 }
158+ s_logger .info ("Selected aggregate: " + aggrChosen .getName () + " for volume operations." );
152159 s_logger .info ("Successfully connected to ONTAP cluster and validated ONTAP details provided" );
153160 } catch (Exception e ) {
154161 throw new CloudRuntimeException ("Failed to connect to ONTAP cluster: " + e .getMessage (), e );
0 commit comments