|
18 | 18 | */ |
19 | 19 | package org.apache.cloudstack.storage.driver; |
20 | 20 |
|
21 | | -import com.cloud.agent.api.Answer; |
22 | | -import com.cloud.agent.api.to.DataObjectType; |
23 | 21 | import com.cloud.agent.api.to.DataStoreTO; |
24 | 22 | import com.cloud.agent.api.to.DataTO; |
25 | | -import com.cloud.exception.InvalidParameterValueException; |
26 | 23 | import com.cloud.host.Host; |
27 | 24 | import com.cloud.storage.Storage; |
28 | 25 | import com.cloud.storage.StoragePool; |
|
43 | 40 | import org.apache.cloudstack.storage.command.CommandResult; |
44 | 41 | import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; |
45 | 42 | import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao; |
46 | | -import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; |
47 | 43 | import org.apache.cloudstack.storage.feign.model.OntapStorage; |
48 | 44 | import org.apache.cloudstack.storage.provider.StorageProviderFactory; |
49 | 45 | import org.apache.cloudstack.storage.service.StorageStrategy; |
50 | | -import org.apache.cloudstack.storage.service.model.CloudStackVolume; |
51 | 46 | import org.apache.cloudstack.storage.service.model.ProtocolType; |
52 | 47 | import org.apache.cloudstack.storage.utils.Constants; |
53 | | -import org.apache.cloudstack.storage.utils.Utility; |
54 | 48 | import org.apache.logging.log4j.LogManager; |
55 | 49 | import org.apache.logging.log4j.Logger; |
56 | 50 |
|
@@ -87,57 +81,7 @@ public DataStoreTO getStoreTO(DataStore store) { |
87 | 81 |
|
88 | 82 | @Override |
89 | 83 | public void createAsync(DataStore dataStore, DataObject dataObject, AsyncCompletionCallback<CreateCmdResult> callback) { |
90 | | - CreateCmdResult createCmdResult = null; |
91 | | - String path = null; |
92 | | - String errMsg = null; |
93 | | - if (dataStore == null) { |
94 | | - throw new InvalidParameterValueException("createAsync: dataStore should not be null"); |
95 | | - } |
96 | | - if (dataObject == null) { |
97 | | - throw new InvalidParameterValueException("createAsync: dataObject should not be null"); |
98 | | - } |
99 | | - if (callback == null) { |
100 | | - throw new InvalidParameterValueException("createAsync: callback should not be null"); |
101 | | - } |
102 | | - try { |
103 | | - s_logger.info("createAsync: Started for data store [{}] and data object [{}] of type [{}]", |
104 | | - dataStore, dataObject, dataObject.getType()); |
105 | | - if (dataObject.getType() == DataObjectType.VOLUME) { |
106 | | - path = createCloudStackVolumeForTypeVolume(dataStore, dataObject); |
107 | | - createCmdResult = new CreateCmdResult(path, new Answer(null, true, null)); |
108 | | - } else { |
109 | | - errMsg = "Invalid DataObjectType (" + dataObject.getType() + ") passed to createAsync"; |
110 | | - s_logger.error(errMsg); |
111 | | - throw new CloudRuntimeException(errMsg); |
112 | | - } |
113 | | - } catch (Exception e) { |
114 | | - errMsg = e.getMessage(); |
115 | | - s_logger.error("createAsync: Failed for dataObject [{}]: {}", dataObject, errMsg); |
116 | | - createCmdResult = new CreateCmdResult(null, new Answer(null, false, errMsg)); |
117 | | - createCmdResult.setResult(e.toString()); |
118 | | - } finally { |
119 | | - callback.complete(createCmdResult); |
120 | | - } |
121 | | - } |
122 | 84 |
|
123 | | - private String createCloudStackVolumeForTypeVolume(DataStore dataStore, DataObject dataObject) { |
124 | | - StoragePoolVO storagePool = storagePoolDao.findById(dataStore.getId()); |
125 | | - if(storagePool == null) { |
126 | | - s_logger.error("createCloudStackVolume : Storage Pool not found for id: " + dataStore.getId()); |
127 | | - throw new CloudRuntimeException("createCloudStackVolume : Storage Pool not found for id: " + dataStore.getId()); |
128 | | - } |
129 | | - Map<String, String> details = storagePoolDetailsDao.listDetailsKeyPairs(dataStore.getId()); |
130 | | - StorageStrategy storageStrategy = getStrategyByStoragePoolDetails(details); |
131 | | - s_logger.info("createCloudStackVolumeForTypeVolume: Connection to Ontap SVM [{}] successful, preparing CloudStackVolumeRequest", details.get(Constants.SVM_NAME)); |
132 | | - CloudStackVolume cloudStackVolumeRequest = Utility.createCloudStackVolumeRequestByProtocol(storagePool, details, dataObject); |
133 | | - CloudStackVolume cloudStackVolume = storageStrategy.createCloudStackVolume(cloudStackVolumeRequest); |
134 | | - if (ProtocolType.ISCSI.name().equalsIgnoreCase(details.get(Constants.PROTOCOL)) && cloudStackVolume.getLun() != null && cloudStackVolume.getLun().getName() != null) { |
135 | | - return cloudStackVolume.getLun().getName(); |
136 | | - } else { |
137 | | - String errMsg = "createCloudStackVolumeForTypeVolume: Volume creation failed. Lun or Lun Path is null for dataObject: " + dataObject; |
138 | | - s_logger.error(errMsg); |
139 | | - throw new CloudRuntimeException(errMsg); |
140 | | - } |
141 | 85 | } |
142 | 86 |
|
143 | 87 | @Override |
|
0 commit comments