Skip to content

Commit 241d7f1

Browse files
Gupta, SuryaGupta, Surya
authored andcommitted
CSTACKEX-46 resolve check style issues
1 parent 63b484b commit 241d7f1

File tree

7 files changed

+25
-18
lines changed

7 files changed

+25
-18
lines changed

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ public boolean isValidName(String name) {
143143
return false;
144144
}
145145
// Regex: Starts with a letter, followed by letters, digits, or underscores
146-
String regex = "^[a-zA-Z][a-zA-Z0-9_]*$";
147-
return name.matches(regex);
146+
return name.matches(Constants.ONTAP_NAME_REGEX);
148147
}
149148

150149
private String createCloudStackVolumeForTypeVolume(StoragePoolVO storagePool, VolumeInfo volumeInfo) {

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/VolumeFeignClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,3 @@ public interface VolumeFeignClient {
4242
@Headers({"Accept: {acceptHeader}", "Authorization: {authHeader}"})
4343
JobResponse updateVolumeRebalancing(@Param("acceptHeader") String acceptHeader, @Param("uuid") String uuid, Volume volumeRequest);
4444
}
45-

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,4 @@ public int hashCode() {
143143

144144
@JsonInclude(JsonInclude.Include.NON_NULL)
145145
public static class Links { }
146-
147-
}
146+
}

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
285285
AccessGroup accessGroupRequest = createAccessGroupRequestByProtocol(storagePool, scope.getScopeId(), details, hostsIdentifier);
286286
strategy.createAccessGroup(accessGroupRequest);
287287
} catch (Exception e) {
288-
s_logger.error("attachCluster: Failed to create access group on storage system for cluster: " + primaryStore.getClusterId(), e);
289-
throw new CloudRuntimeException("attachCluster: Failed to create access group on storage system for cluster: " + primaryStore.getClusterId(), e);
288+
s_logger.error("attachCluster: Failed to create access group on storage system for cluster: " + primaryStore.getClusterId() + ". Exception: " + e.getMessage(), e);
289+
throw new CloudRuntimeException("attachCluster: Failed to create access group on storage system for cluster: " + primaryStore.getClusterId() + ". Exception: " + e.getMessage(), e);
290290
}
291291
}
292292
logger.debug("attachCluster: Attaching the pool to each of the host in the cluster: {}", primaryStore.getClusterId());
@@ -335,8 +335,13 @@ public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.Hyper
335335
throw new CloudRuntimeException(errMsg);
336336
}
337337
if (hostsIdentifier != null && !hostsIdentifier.isEmpty()) {
338-
AccessGroup accessGroupRequest = createAccessGroupRequestByProtocol(storagePool, scope.getScopeId(), details, hostsIdentifier);
339-
strategy.createAccessGroup(accessGroupRequest);
338+
try {
339+
AccessGroup accessGroupRequest = createAccessGroupRequestByProtocol(storagePool, scope.getScopeId(), details, hostsIdentifier);
340+
strategy.createAccessGroup(accessGroupRequest);
341+
} catch (Exception e) {
342+
s_logger.error("attachZone: Failed to create access group on storage system for zone with Exception: " + e.getMessage());
343+
throw new CloudRuntimeException("attachZone: Failed to create access group on storage system for zone with Exception: " + e.getMessage());
344+
}
340345
}
341346
for (HostVO host : hostsToConnect) {
342347
try {
@@ -461,4 +466,3 @@ public void changeStoragePoolScopeToCluster(DataStore store, ClusterScope cluste
461466

462467
}
463468
}
464-

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedSANStrategy.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222
import com.cloud.utils.exception.CloudRuntimeException;
2323
import org.apache.cloudstack.storage.feign.FeignClientFactory;
2424
import org.apache.cloudstack.storage.feign.client.SANFeignClient;
25-
import org.apache.cloudstack.storage.feign.model.Igroup;
26-
import org.apache.cloudstack.storage.feign.model.Lun;
27-
import org.apache.cloudstack.storage.feign.model.LunMap;
28-
import org.apache.cloudstack.storage.feign.model.OntapStorage;
25+
import org.apache.cloudstack.storage.feign.model.*;
2926
import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
3027
import org.apache.cloudstack.storage.service.model.AccessGroup;
3128
import org.apache.cloudstack.storage.service.model.CloudStackVolume;
@@ -224,9 +221,17 @@ public void enableLogicalAccess(Map<String, String> values) {
224221
String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
225222
// Create LunMap
226223
LunMap lunMapRequest = new LunMap();
227-
lunMapRequest.getSvm().setName(svmName);
228-
lunMapRequest.getLun().setName(lunName);
229-
lunMapRequest.getIgroup().setName(igroupName);
224+
Svm svm = new Svm();
225+
svm.setName(svmName);
226+
lunMapRequest.setSvm(svm);
227+
//Set Lun name
228+
Lun lun = new Lun();
229+
lun.setName(lunName);
230+
lunMapRequest.setLun(lun);
231+
//Set Igroup name
232+
Igroup igroup = new Igroup();
233+
igroup.setName(igroupName);
234+
lunMapRequest.setIgroup(igroup);
230235
OntapResponse<LunMap> createdLunMap = sanFeignClient.createLunMap(authHeader, true, lunMapRequest);
231236
if (createdLunMap == null || createdLunMap.getRecords() == null || createdLunMap.getRecords().size() == 0) {
232237
s_logger.error("enableLogicalAccess: LunMap failed for Lun: {} and igroup: {}", lunName, igroupName);

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class Constants {
5656

5757
public static final String VOLUME_PATH_PREFIX = "/vol/";
5858

59+
public static final String ONTAP_NAME_REGEX = "^[a-zA-Z][a-zA-Z0-9_]*$";
5960
public static final String KVM = "KVM";
6061

6162
public static final String HTTPS = "https://";

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/Utility.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static StorageStrategy getStrategyByStoragePoolDetails(Map<String, String
8383
}
8484

8585
public static String getLunName(String volName, String lunName) {
86-
//LUN name in ONTAP unified : "/vol/VolumeName/LunName"
86+
//LUN name in ONTAP unified format: "/vol/VolumeName/LunName"
8787
return Constants.VOLUME_PATH_PREFIX + volName + Constants.SLASH + lunName;
8888
}
8989

0 commit comments

Comments
 (0)