|
19 | 19 | * under the License. |
20 | 20 | */ |
21 | 21 |
|
22 | | -import com.cloud.agent.api.Answer; |
23 | | -import com.cloud.agent.api.to.DataObjectType; |
24 | 22 | import com.cloud.agent.api.to.DataStoreTO; |
25 | 23 | import com.cloud.agent.api.to.DataTO; |
26 | | -import com.cloud.exception.InvalidParameterValueException; |
27 | 24 | import com.cloud.host.Host; |
28 | 25 | import com.cloud.storage.Storage; |
29 | 26 | import com.cloud.storage.StoragePool; |
|
44 | 41 | import org.apache.cloudstack.storage.command.CommandResult; |
45 | 42 | import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; |
46 | 43 | import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao; |
47 | | -import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; |
48 | 44 | import org.apache.cloudstack.storage.feign.model.OntapStorage; |
49 | 45 | import org.apache.cloudstack.storage.provider.StorageProviderFactory; |
50 | 46 | import org.apache.cloudstack.storage.service.StorageStrategy; |
51 | | -import org.apache.cloudstack.storage.service.model.CloudStackVolume; |
52 | 47 | import org.apache.cloudstack.storage.service.model.ProtocolType; |
53 | 48 | import org.apache.cloudstack.storage.utils.Constants; |
54 | | -import org.apache.cloudstack.storage.utils.Utility; |
55 | 49 | import org.apache.logging.log4j.LogManager; |
56 | 50 | import org.apache.logging.log4j.Logger; |
57 | 51 |
|
@@ -88,57 +82,7 @@ public DataStoreTO getStoreTO(DataStore store) { |
88 | 82 |
|
89 | 83 | @Override |
90 | 84 | 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 | | - } |
123 | 85 |
|
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 | | - } |
142 | 86 | } |
143 | 87 |
|
144 | 88 | @Override |
@@ -278,7 +222,7 @@ private StorageStrategy getStrategyByStoragePoolDetails(Map<String, String> deta |
278 | 222 | } |
279 | 223 | String protocol = details.get(Constants.PROTOCOL); |
280 | 224 | 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), |
282 | 226 | Boolean.parseBoolean(details.get(Constants.IS_DISAGGREGATED))); |
283 | 227 | StorageStrategy storageStrategy = StorageProviderFactory.getStrategy(ontapStorage); |
284 | 228 | boolean isValid = storageStrategy.connect(); |
|
0 commit comments