Skip to content

Commit 7368be6

Browse files
Gupta, SuryaGupta, Surya
authored andcommitted
CSTACKEX-35 Fix OStype
1 parent 043c0fd commit 7368be6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.cloud.agent.api.to.DataTO;
2525
import com.cloud.exception.InvalidParameterValueException;
2626
import com.cloud.host.Host;
27+
import com.cloud.hypervisor.Hypervisor;
2728
import com.cloud.storage.Storage;
2829
import com.cloud.storage.StoragePool;
2930
import com.cloud.storage.Volume;
@@ -59,6 +60,9 @@
5960
import java.util.List;
6061
import java.util.Map;
6162

63+
import static com.cloud.hypervisor.Hypervisor.HypervisorType.KVM;
64+
import static com.cloud.hypervisor.Hypervisor.HypervisorType.VMware;
65+
6266
public class OntapPrimaryDatastoreDriver implements PrimaryDataStoreDriver {
6367

6468
private static final Logger logger = (Logger)LogManager.getLogger(OntapPrimaryDatastoreDriver.class);
@@ -145,11 +149,22 @@ private String createCloudStackVolume(long storagePoolId, DataObject dataObject)
145149
String lunOrFileName = dataObject.getName();
146150
Long size = dataObject.getSize();
147151
String volName = storagePool.getName();
152+
String hypervisorType = storagePool.getHypervisor().name();
153+
String osType = null;
154+
switch (hypervisorType) {
155+
case Constants.KVM:
156+
osType = Lun.OsTypeEnum.LINUX.getValue();
157+
break;
158+
default:
159+
String errMsg = "createCloudStackVolume : Unsupported hypervisor type " + hypervisorType + " for ONTAP storage";
160+
logger.error(errMsg);
161+
throw new CloudRuntimeException(errMsg);
162+
}
148163

149164
// Create LUN based on protocol
150165
if (ontapStorage.getProtocol().equals(Constants.ISCSI)) {
151166
SANStrategy sanStrategy = StorageProviderFactory.getSANStrategy(ontapStorage);
152-
Lun lun = sanStrategy.createLUN(svmName, volName, lunOrFileName, size , Lun.OsTypeEnum.LINUX.getValue());
167+
Lun lun = sanStrategy.createLUN(svmName, volName, lunOrFileName, size , osType);
153168
if(lun.getName() == null || lun.getName().isEmpty()) {
154169
throw new CloudRuntimeException("createCloudStackVolume : LUN Name is invalid");
155170
}

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
@@ -52,5 +52,6 @@ public enum ProtocolType {
5252

5353
public static final String VOLUME_PATH_PREFIX = "/vol/";
5454
public static final String PATH_SEPARATOR = "/";
55+
public static final String KVM = "KVM";
5556
public static final String GET_JOB_BY_UUID = "/api/cluster/jobs";
5657
}

0 commit comments

Comments
 (0)