1717 * under the License.
1818 */
1919
20- package org .apache .cloudstack .storage .service ;
20+ package org .apache .cloudstack .storage .service ;
2121
2222import com .cloud .utils .exception .CloudRuntimeException ;
2323import feign .FeignException ;
4141import org .apache .cloudstack .storage .service .model .AccessGroup ;
4242import org .apache .cloudstack .storage .service .model .CloudStackVolume ;
4343import org .apache .cloudstack .storage .service .model .ProtocolType ;
44- import org .apache .cloudstack .storage .utils .Constants ;
45- import org .apache .cloudstack .storage .utils .Utility ;
44+ import org .apache .cloudstack .storage .utils .OntapStorageConstants ;
45+ import org .apache .cloudstack .storage .utils .OntapStorageUtils ;
4646import org .apache .logging .log4j .LogManager ;
4747import org .apache .logging .log4j .Logger ;
4848
@@ -68,7 +68,7 @@ public abstract class StorageStrategy {
6868
6969 public StorageStrategy (OntapStorage ontapStorage ) {
7070 storage = ontapStorage ;
71- String baseURL = Constants .HTTPS + storage .getManagementLIF ();
71+ String baseURL = OntapStorageConstants .HTTPS + storage .getManagementLIF ();
7272 s_logger .info ("Initializing StorageStrategy with base URL: " + baseURL );
7373 this .feignClientFactory = new FeignClientFactory ();
7474 this .aggregateFeignClient = feignClientFactory .createClient (AggregateFeignClient .class , baseURL );
@@ -82,13 +82,13 @@ public StorageStrategy(OntapStorage ontapStorage) {
8282 public boolean connect () {
8383 s_logger .info ("Attempting to connect to ONTAP cluster at " + storage .getManagementLIF () + " and validate SVM " +
8484 storage .getSvmName () + ", protocol " + storage .getProtocol ());
85- String authHeader = Utility .generateAuthHeader (storage .getUsername (), storage .getPassword ());
85+ String authHeader = OntapStorageUtils .generateAuthHeader (storage .getUsername (), storage .getPassword ());
8686 String svmName = storage .getSvmName ();
8787 try {
8888 Svm svm = new Svm ();
8989 s_logger .info ("Fetching the SVM details..." );
90- Map <String , Object > queryParams = Map .of (Constants .NAME , svmName , Constants .FIELDS , Constants .AGGREGATES +
91- Constants .COMMA + Constants .STATE );
90+ Map <String , Object > queryParams = Map .of (OntapStorageConstants .NAME , svmName , OntapStorageConstants .FIELDS , OntapStorageConstants .AGGREGATES +
91+ OntapStorageConstants .COMMA + OntapStorageConstants .STATE );
9292 OntapResponse <Svm > svms = svmFeignClient .getSvmResponse (queryParams , authHeader );
9393 if (svms != null && svms .getRecords () != null && !svms .getRecords ().isEmpty ()) {
9494 svm = svms .getRecords ().get (0 );
@@ -98,14 +98,14 @@ public boolean connect() {
9898 }
9999
100100 s_logger .info ("Validating SVM state and protocol settings..." );
101- if (!Objects .equals (svm .getState (), Constants .RUNNING )) {
101+ if (!Objects .equals (svm .getState (), OntapStorageConstants .RUNNING )) {
102102 s_logger .error ("SVM " + svmName + " is not in running state." );
103103 return false ;
104104 }
105- if (Objects .equals (storage .getProtocol (), Constants .NFS ) && !svm .getNfsEnabled ()) {
105+ if (Objects .equals (storage .getProtocol (), OntapStorageConstants .NFS ) && !svm .getNfsEnabled ()) {
106106 s_logger .error ("NFS protocol is not enabled on SVM " + svmName );
107107 return false ;
108- } else if (Objects .equals (storage .getProtocol (), Constants .ISCSI ) && !svm .getIscsiEnabled ()) {
108+ } else if (Objects .equals (storage .getProtocol (), OntapStorageConstants .ISCSI ) && !svm .getIscsiEnabled ()) {
109109 s_logger .error ("iSCSI protocol is not enabled on SVM " + svmName );
110110 return false ;
111111 }
@@ -155,13 +155,13 @@ public Volume createStorageVolume(String volumeName, Long size) {
155155 throw new CloudRuntimeException ("Invalid volume size provided: " + size );
156156 }
157157
158- String authHeader = Utility .generateAuthHeader (storage .getUsername (), storage .getPassword ());
158+ String authHeader = OntapStorageUtils .generateAuthHeader (storage .getUsername (), storage .getPassword ());
159159
160160 Volume volumeRequest = new Volume ();
161161 Svm svm = new Svm ();
162162 svm .setName (svmName );
163163 Nas nas = new Nas ();
164- nas .setPath (Constants .SLASH + volumeName );
164+ nas .setPath (OntapStorageConstants .SLASH + volumeName );
165165
166166 volumeRequest .setName (volumeName );
167167 volumeRequest .setSvm (svm );
@@ -231,7 +231,7 @@ public Volume createStorageVolume(String volumeName, Long size) {
231231 s_logger .error ("Exception while creating volume: " , e );
232232 throw new CloudRuntimeException ("Failed to create volume: " + e .getMessage ());
233233 }
234- OntapResponse <Volume > volumesResponse = volumeFeignClient .getAllVolumes (authHeader , Map .of (Constants .NAME , volumeName ));
234+ OntapResponse <Volume > volumesResponse = volumeFeignClient .getAllVolumes (authHeader , Map .of (OntapStorageConstants .NAME , volumeName ));
235235 if (volumesResponse == null || volumesResponse .getRecords () == null || volumesResponse .getRecords ().isEmpty ()) {
236236 s_logger .error ("Volume " + volumeName + " not found after creation." );
237237 throw new CloudRuntimeException ("Volume " + volumeName + " not found after creation." );
@@ -246,7 +246,7 @@ public Volume createStorageVolume(String volumeName, Long size) {
246246 }
247247 s_logger .info ("Volume created successfully: " + volumeName );
248248 try {
249- Map <String , Object > queryParams = Map .of (Constants .NAME , volumeName );
249+ Map <String , Object > queryParams = Map .of (OntapStorageConstants .NAME , volumeName );
250250 s_logger .debug ("Fetching volume details for: " + volumeName );
251251
252252 OntapResponse <Volume > ontapVolume = volumeFeignClient .getVolume (authHeader , queryParams );
@@ -284,7 +284,7 @@ public Volume updateStorageVolume(Volume volume) {
284284
285285 public void deleteStorageVolume (Volume volume ) {
286286 s_logger .info ("Deleting ONTAP volume by name: " + volume .getName () + " and uuid: " + volume .getUuid ());
287- String authHeader = Utility .generateAuthHeader (storage .getUsername (), storage .getPassword ());
287+ String authHeader = OntapStorageUtils .generateAuthHeader (storage .getUsername (), storage .getPassword ());
288288 try {
289289 JobResponse jobResponse = volumeFeignClient .deleteVolume (authHeader , volume .getUuid ());
290290 Boolean jobSucceeded = jobPollForSuccess (jobResponse .getJob ().getUuid ());
@@ -305,14 +305,14 @@ public Volume getStorageVolume(Volume volume) {
305305 }
306306
307307 public String getStoragePath () {
308- String authHeader = Utility .generateAuthHeader (storage .getUsername (), storage .getPassword ());
308+ String authHeader = OntapStorageUtils .generateAuthHeader (storage .getUsername (), storage .getPassword ());
309309 String targetIqn = null ;
310310 try {
311311 if (storage .getProtocol () == ProtocolType .ISCSI ) {
312312 s_logger .info ("Fetching iSCSI target IQN for SVM: {}" , storage .getSvmName ());
313313
314314 Map <String , Object > queryParams = new HashMap <>();
315- queryParams .put (Constants .SVM_DOT_NAME , storage .getSvmName ());
315+ queryParams .put (OntapStorageConstants .SVM_DOT_NAME , storage .getSvmName ());
316316 queryParams .put ("fields" , "enabled,target" );
317317 queryParams .put ("max_records" , "1" );
318318
@@ -345,25 +345,25 @@ public String getStoragePath() {
345345 }
346346
347347 public String getNetworkInterface () {
348- String authHeader = Utility .generateAuthHeader (storage .getUsername (), storage .getPassword ());
348+ String authHeader = OntapStorageUtils .generateAuthHeader (storage .getUsername (), storage .getPassword ());
349349 try {
350350 Map <String , Object > queryParams = new HashMap <>();
351- queryParams .put (Constants .SVM_DOT_NAME , storage .getSvmName ());
351+ queryParams .put (OntapStorageConstants .SVM_DOT_NAME , storage .getSvmName ());
352352 if (storage .getProtocol () != null ) {
353353 switch (storage .getProtocol ()) {
354354 case NFS3 :
355- queryParams .put (Constants .SERVICES , Constants .DATA_NFS );
355+ queryParams .put (OntapStorageConstants .SERVICES , OntapStorageConstants .DATA_NFS );
356356 break ;
357357 case ISCSI :
358- queryParams .put (Constants .SERVICES , Constants .DATA_ISCSI );
358+ queryParams .put (OntapStorageConstants .SERVICES , OntapStorageConstants .DATA_ISCSI );
359359 break ;
360360 default :
361361 s_logger .error ("Unsupported protocol: " + storage .getProtocol ());
362362 throw new CloudRuntimeException ("Unsupported protocol: " + storage .getProtocol ());
363363 }
364364 }
365- queryParams .put (Constants .FIELDS , Constants .IP_ADDRESS );
366- queryParams .put (Constants .RETURN_RECORDS , Constants .TRUE );
365+ queryParams .put (OntapStorageConstants .FIELDS , OntapStorageConstants .IP_ADDRESS );
366+ queryParams .put (OntapStorageConstants .RETURN_RECORDS , OntapStorageConstants .TRUE );
367367 OntapResponse <IpInterface > response =
368368 networkFeignClient .getNetworkIpInterfaces (authHeader , queryParams );
369369 if (response != null && response .getRecords () != null && !response .getRecords ().isEmpty ()) {
@@ -419,9 +419,9 @@ private Boolean jobPollForSuccess(String jobUUID) {
419419 int jobRetryCount = 0 ;
420420 Job jobResp = null ;
421421 try {
422- String authHeader = Utility .generateAuthHeader (storage .getUsername (), storage .getPassword ());
423- while (jobResp == null || !jobResp .getState ().equals (Constants .JOB_SUCCESS )) {
424- if (jobRetryCount >= Constants .JOB_MAX_RETRIES ) {
422+ String authHeader = OntapStorageUtils .generateAuthHeader (storage .getUsername (), storage .getPassword ());
423+ while (jobResp == null || !jobResp .getState ().equals (OntapStorageConstants .JOB_SUCCESS )) {
424+ if (jobRetryCount >= OntapStorageConstants .JOB_MAX_RETRIES ) {
425425 s_logger .error ("Job did not complete within expected time." );
426426 throw new CloudRuntimeException ("Job did not complete within expected time." );
427427 }
@@ -430,17 +430,17 @@ private Boolean jobPollForSuccess(String jobUUID) {
430430 jobResp = jobFeignClient .getJobByUUID (authHeader , jobUUID );
431431 if (jobResp == null ) {
432432 s_logger .warn ("Job with UUID " + jobUUID + " not found. Retrying..." );
433- } else if (jobResp .getState ().equals (Constants .JOB_FAILURE )) {
433+ } else if (jobResp .getState ().equals (OntapStorageConstants .JOB_FAILURE )) {
434434 throw new CloudRuntimeException ("Job failed with error: " + jobResp .getMessage ());
435435 }
436436 } catch (FeignException .FeignClientException e ) {
437437 throw new CloudRuntimeException ("Failed to fetch job status: " + e .getMessage ());
438438 }
439439
440440 jobRetryCount ++;
441- Thread .sleep (Constants .CREATE_VOLUME_CHECK_SLEEP_TIME );
441+ Thread .sleep (OntapStorageConstants .CREATE_VOLUME_CHECK_SLEEP_TIME );
442442 }
443- if (jobResp == null || !jobResp .getState ().equals (Constants .JOB_SUCCESS )) {
443+ if (jobResp == null || !jobResp .getState ().equals (OntapStorageConstants .JOB_SUCCESS )) {
444444 return false ;
445445 }
446446 } catch (FeignException .FeignClientException e ) {
0 commit comments