Skip to content

Commit 2e8f8ee

Browse files
sandeeplocharlaLocharla, Sandeep
authored andcommitted
CSTACKEX-50: Disable, Re-Enable, Delete Storage pool and Enter, Exit Maintenance mode (#20)
* CSTACKEX-50: Disable, Re-Enable, Delete Storage pool and Enter, Exit Storage pool workflows * CSTACKEX-50: Changes for selecting aggregate, retrieving ip interface and setting host and path * CSTACKEX-50: Fixed some issues seen while testing * CSTACKEX-50: Fixed few EOF lint issues * CSTACKEX-50: Fixed few lint issues * CSTACKEX-50: Included changes for Delete storage pool and modified some methods according to the latest design * CSTACKEX-050: Rebased the code with the latest in master * CSTACKEX-050: Fixed lint issues * CSTACKEX-050: Added some missing changes --------- Co-authored-by: Locharla, Sandeep <Sandeep.Locharla@netapp.com>
1 parent 8568831 commit 2e8f8ee

4 files changed

Lines changed: 315 additions & 163 deletions

File tree

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

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
* under the License.
2020
*/
2121

22-
import com.cloud.agent.api.Answer;
23-
import com.cloud.agent.api.to.DataObjectType;
2422
import com.cloud.agent.api.to.DataStoreTO;
2523
import com.cloud.agent.api.to.DataTO;
26-
import com.cloud.exception.InvalidParameterValueException;
2724
import com.cloud.host.Host;
2825
import com.cloud.storage.Storage;
2926
import com.cloud.storage.StoragePool;
@@ -44,14 +41,11 @@
4441
import org.apache.cloudstack.storage.command.CommandResult;
4542
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
4643
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
47-
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
4844
import org.apache.cloudstack.storage.feign.model.OntapStorage;
4945
import org.apache.cloudstack.storage.provider.StorageProviderFactory;
5046
import org.apache.cloudstack.storage.service.StorageStrategy;
51-
import org.apache.cloudstack.storage.service.model.CloudStackVolume;
5247
import org.apache.cloudstack.storage.service.model.ProtocolType;
5348
import org.apache.cloudstack.storage.utils.Constants;
54-
import org.apache.cloudstack.storage.utils.Utility;
5549
import org.apache.logging.log4j.LogManager;
5650
import org.apache.logging.log4j.Logger;
5751

@@ -88,57 +82,7 @@ public DataStoreTO getStoreTO(DataStore store) {
8882

8983
@Override
9084
public void createAsync(DataStore dataStore, DataObject dataObject, AsyncCompletionCallback<CreateCmdResult> callback) {
91-
CreateCmdResult createCmdResult = null;
92-
String path = null;
93-
String errMsg = null;
94-
if (dataStore == null) {
95-
throw new InvalidParameterValueException("createAsync: dataStore should not be null");
96-
}
97-
if (dataObject == null) {
98-
throw new InvalidParameterValueException("createAsync: dataObject should not be null");
99-
}
100-
if (callback == null) {
101-
throw new InvalidParameterValueException("createAsync: callback should not be null");
102-
}
103-
try {
104-
s_logger.info("createAsync: Started for data store [{}] and data object [{}] of type [{}]",
105-
dataStore, dataObject, dataObject.getType());
106-
if (dataObject.getType() == DataObjectType.VOLUME) {
107-
path = createCloudStackVolumeForTypeVolume(dataStore, dataObject);
108-
createCmdResult = new CreateCmdResult(path, new Answer(null, true, null));
109-
} else {
110-
errMsg = "Invalid DataObjectType (" + dataObject.getType() + ") passed to createAsync";
111-
s_logger.error(errMsg);
112-
throw new CloudRuntimeException(errMsg);
113-
}
114-
} catch (Exception e) {
115-
errMsg = e.getMessage();
116-
s_logger.error("createAsync: Failed for dataObject [{}]: {}", dataObject, errMsg);
117-
createCmdResult = new CreateCmdResult(null, new Answer(null, false, errMsg));
118-
createCmdResult.setResult(e.toString());
119-
} finally {
120-
callback.complete(createCmdResult);
121-
}
122-
}
12385

124-
private String createCloudStackVolumeForTypeVolume(DataStore dataStore, DataObject dataObject) {
125-
StoragePoolVO storagePool = storagePoolDao.findById(dataStore.getId());
126-
if(storagePool == null) {
127-
s_logger.error("createCloudStackVolume : Storage Pool not found for id: " + dataStore.getId());
128-
throw new CloudRuntimeException("createCloudStackVolume : Storage Pool not found for id: " + dataStore.getId());
129-
}
130-
Map<String, String> details = storagePoolDetailsDao.listDetailsKeyPairs(dataStore.getId());
131-
StorageStrategy storageStrategy = getStrategyByStoragePoolDetails(details);
132-
s_logger.info("createCloudStackVolumeForTypeVolume: Connection to Ontap SVM [{}] successful, preparing CloudStackVolumeRequest", details.get(Constants.SVM_NAME));
133-
CloudStackVolume cloudStackVolumeRequest = Utility.createCloudStackVolumeRequestByProtocol(storagePool, details, dataObject);
134-
CloudStackVolume cloudStackVolume = storageStrategy.createCloudStackVolume(cloudStackVolumeRequest);
135-
if (ProtocolType.ISCSI.name().equalsIgnoreCase(details.get(Constants.PROTOCOL)) && cloudStackVolume.getLun() != null && cloudStackVolume.getLun().getName() != null) {
136-
return cloudStackVolume.getLun().getName();
137-
} else {
138-
String errMsg = "createCloudStackVolumeForTypeVolume: Volume creation failed. Lun or Lun Path is null for dataObject: " + dataObject;
139-
s_logger.error(errMsg);
140-
throw new CloudRuntimeException(errMsg);
141-
}
14286
}
14387

14488
@Override
@@ -278,7 +222,7 @@ private StorageStrategy getStrategyByStoragePoolDetails(Map<String, String> deta
278222
}
279223
String protocol = details.get(Constants.PROTOCOL);
280224
OntapStorage ontapStorage = new OntapStorage(details.get(Constants.USERNAME), details.get(Constants.PASSWORD),
281-
details.get(Constants.MANAGEMENT_LIF), details.get(Constants.SVM_NAME), ProtocolType.valueOf(protocol),
225+
details.get(Constants.MANAGEMENT_LIF), details.get(Constants.SVM_NAME), Long.parseLong(details.get(Constants.SIZE)), ProtocolType.valueOf(protocol),
282226
Boolean.parseBoolean(details.get(Constants.IS_DISAGGREGATED)));
283227
StorageStrategy storageStrategy = StorageProviderFactory.getStrategy(ontapStorage);
284228
boolean isValid = storageStrategy.connect();

0 commit comments

Comments
 (0)