Skip to content

Commit 618f957

Browse files
Merge pull request #13 from NetApp/feature/CSTACKEX-34
CSTACKEX-34: Upgrade to framework classes design
2 parents 25353c2 + 5815ebd commit 618f957

File tree

14 files changed

+400
-64
lines changed

14 files changed

+400
-64
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
import org.springframework.web.bind.annotation.RequestHeader;
2727
import org.springframework.web.bind.annotation.RequestMapping;
2828
import org.springframework.web.bind.annotation.RequestMethod;
29-
import org.springframework.web.bind.annotation.RequestParam;
30-
3129
import java.net.URI;
32-
import java.util.Map;
3330

3431
@FeignClient(name = "SvmClient", url = "https://{clusterIP}/api/svm/svms", configuration = FeignConfiguration.class)
3532
public interface SvmFeignClient {

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

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,70 +19,71 @@
1919

2020
package org.apache.cloudstack.storage.feign.model;
2121

22-
import org.apache.cloudstack.storage.utils.Constants.ProtocolType;
22+
23+
import org.apache.cloudstack.storage.service.model.ProtocolType;
2324

2425
public class OntapStorage {
25-
public static String _username;
26-
public static String _password;
27-
public static String _managementLIF;
28-
public static String _svmName;
29-
public static ProtocolType _protocolType;
30-
public static Boolean _isDisaggregated;
26+
private String username;
27+
private String password;
28+
private String managementLIF;
29+
private String svmName;
30+
private ProtocolType protocolType;
31+
private Boolean isDisaggregated;
3132

3233
public OntapStorage(String username, String password, String managementLIF, String svmName, ProtocolType protocolType, Boolean isDisaggregated) {
33-
_username = username;
34-
_password = password;
35-
_managementLIF = managementLIF;
36-
_svmName = svmName;
37-
_protocolType = protocolType;
38-
_isDisaggregated = isDisaggregated;
34+
this.username = username;
35+
this.password = password;
36+
this.managementLIF = managementLIF;
37+
this.svmName = svmName;
38+
this.protocolType = protocolType;
39+
this.isDisaggregated = isDisaggregated;
3940
}
4041

4142
public String getUsername() {
42-
return _username;
43+
return username;
4344
}
4445

4546
public void setUsername(String username) {
46-
_username = username;
47+
username = username;
4748
}
4849

4950
public String getPassword() {
50-
return _password;
51+
return password;
5152
}
5253

5354
public void setPassword(String password) {
54-
_password = password;
55+
password = password;
5556
}
5657

5758
public String getManagementLIF() {
58-
return _managementLIF;
59+
return managementLIF;
5960
}
6061

6162
public void setManagementLIF(String managementLIF) {
62-
_managementLIF = managementLIF;
63+
managementLIF = managementLIF;
6364
}
6465

6566
public String getSvmName() {
66-
return _svmName;
67+
return svmName;
6768
}
6869

6970
public void setSvmName(String svmName) {
70-
_svmName = svmName;
71+
svmName = svmName;
7172
}
7273

7374
public ProtocolType getProtocol() {
74-
return _protocolType;
75+
return protocolType;
7576
}
7677

7778
public void setProtocol(ProtocolType protocolType) {
78-
_protocolType = protocolType;
79+
protocolType = protocolType;
7980
}
8081

8182
public Boolean getIsDisaggregated() {
82-
return _isDisaggregated;
83+
return isDisaggregated;
8384
}
8485

8586
public void setIsDisaggregated(Boolean isDisaggregated) {
86-
_isDisaggregated = isDisaggregated;
87+
isDisaggregated = isDisaggregated;
8788
}
8889
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ public void setRecords(List<T> records) {
5959
this.records = records;
6060
this.numRecords = (records != null) ? records.size() : 0;
6161
}
62-
}
62+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
import org.apache.cloudstack.storage.feign.model.OntapStorage;
4343
import org.apache.cloudstack.storage.provider.StorageProviderFactory;
4444
import org.apache.cloudstack.storage.service.StorageStrategy;
45+
import org.apache.cloudstack.storage.service.model.ProtocolType;
4546
import org.apache.cloudstack.storage.utils.Constants;
46-
import org.apache.cloudstack.storage.utils.Constants.ProtocolType;
4747
import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
4848
import org.apache.logging.log4j.LogManager;
4949
import org.apache.logging.log4j.Logger;
@@ -145,7 +145,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
145145
boolean isValid = storageStrategy.connect();
146146
if (isValid) {
147147
// String volumeName = storagePoolName + "_vol"; //TODO: Figure out a better naming convention
148-
storageStrategy.createVolume(storagePoolName, Long.parseLong((details.get("size")))); // TODO: size should be in bytes, so see if conversion is needed
148+
storageStrategy.createStorageVolume(storagePoolName, Long.parseLong((details.get("size")))); // TODO: size should be in bytes, so see if conversion is needed
149149
} else {
150150
throw new CloudRuntimeException("ONTAP details validation failed, cannot create primary storage");
151151
}

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/provider/StorageProviderFactory.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@
2424
import org.apache.cloudstack.storage.service.StorageStrategy;
2525
import org.apache.cloudstack.storage.service.UnifiedNASStrategy;
2626
import org.apache.cloudstack.storage.service.UnifiedSANStrategy;
27-
import org.apache.cloudstack.storage.utils.Constants;
28-
import org.apache.cloudstack.storage.utils.Constants.ProtocolType;
27+
import org.apache.cloudstack.storage.service.model.ProtocolType;
2928
import org.apache.logging.log4j.LogManager;
3029
import org.apache.logging.log4j.Logger;
3130
import org.springframework.stereotype.Component;
3231

3332
@Component
3433
public class StorageProviderFactory {
3534
private final StorageStrategy storageStrategy;
36-
private static final Logger s_logger = (Logger) LogManager.getLogger(StorageProviderFactory.class);
35+
private static final Logger s_logger = LogManager.getLogger(StorageProviderFactory.class);
3736

3837
private StorageProviderFactory(OntapStorage ontapStorage) {
3938
ProtocolType protocol = ontapStorage.getProtocol();

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,4 @@ public NASStrategy(OntapStorage ontapStorage) {
2626
super(ontapStorage);
2727
}
2828

29-
public abstract String createExportPolicy(String svmName, String policyName);
30-
public abstract String addExportRule(String policyName, String clientMatch, String[] protocols, String[] roRule, String[] rwRule);
31-
public abstract String assignExportPolicyToVolume(String volumeUuid, String policyName);
32-
public abstract String enableNFS(String svmUuid);
3329
}
34-

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,4 @@ public SANStrategy(OntapStorage ontapStorage) {
2626
super(ontapStorage);
2727
}
2828

29-
public abstract String createLUN(String svmName, String volumeName, String lunName, long sizeBytes, String osType);
30-
public abstract String createIgroup(String svmName, String igroupName, String[] initiators);
31-
public abstract String mapLUNToIgroup(String lunName, String igroupName);
32-
public abstract String enableISCSI(String svmUuid);
3329
}

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

Lines changed: 156 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import org.apache.cloudstack.storage.feign.model.Volume;
3232
import org.apache.cloudstack.storage.feign.model.response.JobResponse;
3333
import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
34+
import org.apache.cloudstack.storage.service.model.AccessGroup;
35+
import org.apache.cloudstack.storage.service.model.CloudStackVolume;
3436
import org.apache.cloudstack.storage.utils.Constants;
3537
import org.apache.cloudstack.storage.utils.Utility;
3638
import org.apache.logging.log4j.LogManager;
@@ -42,6 +44,13 @@
4244
import java.util.List;
4345
import java.util.Objects;
4446

47+
/**
48+
* Storage Strategy represents the communication path for all the ONTAP storage options
49+
*
50+
* ONTAP storage operation would vary based on
51+
* Supported protocols: NFS3.0, NFS4.1, FC, iSCSI, Nvme/TCP and Nvme/FC
52+
* Supported platform: Unified and Disaggregated
53+
*/
4554
public abstract class StorageStrategy {
4655
@Inject
4756
private Utility utils;
@@ -57,12 +66,16 @@ public abstract class StorageStrategy {
5766

5867
private final OntapStorage storage;
5968

69+
/**
70+
* Presents aggregate object for the unified storage, not eligible for disaggregated
71+
*/
6072
private List<Aggregate> aggregates;
6173

6274
private static final Logger s_logger = (Logger) LogManager.getLogger(StorageStrategy.class);
6375

6476
public StorageStrategy(OntapStorage ontapStorage) {
6577
storage = ontapStorage;
78+
6679
}
6780

6881
// Connect method to validate ONTAP cluster, credentials, protocol, and SVM
@@ -108,7 +121,16 @@ public boolean connect() {
108121
}
109122

110123
// Common methods like create/delete etc., should be here
111-
public void createVolume(String volumeName, Long size) {
124+
125+
/**
126+
* Creates ONTAP Flex-Volume
127+
* Eligible only for Unified ONTAP storage
128+
* throw exception in case of disaggregated ONTAP storage
129+
*
130+
* @param volumeName
131+
* @param size
132+
*/
133+
public Volume createStorageVolume(String volumeName, Long size) {
112134
s_logger.info("Creating volume: " + volumeName + " of size: " + size + " bytes");
113135

114136
String svmName = storage.getSvmName();
@@ -168,5 +190,138 @@ public void createVolume(String volumeName, Long size) {
168190
throw new CloudRuntimeException("Failed to create volume: " + e.getMessage());
169191
}
170192
s_logger.info("Volume created successfully: " + volumeName);
193+
//TODO
194+
return null;
195+
}
196+
197+
/**
198+
* Updates ONTAP Flex-Volume
199+
* Eligible only for Unified ONTAP storage
200+
* throw exception in case of disaggregated ONTAP storage
201+
*
202+
* @param values
203+
*/
204+
public Volume updateStorageVolume(Volume volume)
205+
{
206+
//TODO
207+
return null;
171208
}
209+
210+
/**
211+
* Delete ONTAP Flex-Volume
212+
* Eligible only for Unified ONTAP storage
213+
* throw exception in case of disaggregated ONTAP storage
214+
*
215+
* @param values
216+
*/
217+
public void deleteStorageVolume(Volume volume)
218+
{
219+
//TODO
220+
}
221+
222+
/**
223+
* Updates ONTAP Flex-Volume
224+
* Eligible only for Unified ONTAP storage
225+
* throw exception in case of disaggregated ONTAP storage
226+
*
227+
* @param values
228+
*/
229+
public Volume getStorageVolume(Volume volume)
230+
{
231+
//TODO
232+
return null;
233+
}
234+
235+
/**
236+
* Method encapsulates the behavior based on the opted protocol in subclasses.
237+
* it is going to mimic
238+
* createLun for iSCSI, FC protocols
239+
* createFile for NFS3.0 and NFS4.1 protocols
240+
* createNameSpace for Nvme/TCP and Nvme/FC protocol
241+
* @param values
242+
*/
243+
abstract public CloudStackVolume createCloudStackVolume(CloudStackVolume cloudstackVolume);
244+
245+
/**
246+
* Method encapsulates the behavior based on the opted protocol in subclasses.
247+
* it is going to mimic
248+
* updateLun for iSCSI, FC protocols
249+
* updateFile for NFS3.0 and NFS4.1 protocols
250+
* updateNameSpace for Nvme/TCP and Nvme/FC protocol
251+
* @param values
252+
*/
253+
abstract CloudStackVolume updateCloudStackVolume(CloudStackVolume cloudstackVolume);
254+
255+
/**
256+
* Method encapsulates the behavior based on the opted protocol in subclasses.
257+
* it is going to mimic
258+
* deleteLun for iSCSI, FC protocols
259+
* deleteFile for NFS3.0 and NFS4.1 protocols
260+
* deleteNameSpace for Nvme/TCP and Nvme/FC protocol
261+
* @param values
262+
*/
263+
abstract void deleteCloudStackVolume(CloudStackVolume cloudstackVolume);
264+
265+
/**
266+
* Method encapsulates the behavior based on the opted protocol in subclasses.
267+
* it is going to mimic
268+
* getLun for iSCSI, FC protocols
269+
* getFile for NFS3.0 and NFS4.1 protocols
270+
* getNameSpace for Nvme/TCP and Nvme/FC protocol
271+
* @param values
272+
*/
273+
abstract CloudStackVolume getCloudStackVolume(CloudStackVolume cloudstackVolume);
274+
275+
/**
276+
* Method encapsulates the behavior based on the opted protocol in subclasses
277+
* createiGroup for iSCSI and FC protocols
278+
* createExportPolicy for NFS 3.0 and NFS 4.1 protocols
279+
* createSubsystem for Nvme/TCP and Nvme/FC protocols
280+
* @param values
281+
*/
282+
abstract AccessGroup createAccessGroup(AccessGroup accessGroup);
283+
284+
/**
285+
* Method encapsulates the behavior based on the opted protocol in subclasses
286+
* deleteiGroup for iSCSI and FC protocols
287+
* deleteExportPolicy for NFS 3.0 and NFS 4.1 protocols
288+
* deleteSubsystem for Nvme/TCP and Nvme/FC protocols
289+
* @param values
290+
*/
291+
abstract void deleteAccessGroup(AccessGroup accessGroup);
292+
293+
/**
294+
* Method encapsulates the behavior based on the opted protocol in subclasses
295+
* updateiGroup example add/remove-Iqn for iSCSI and FC protocols
296+
* updateExportPolicy example add/remove-Rule for NFS 3.0 and NFS 4.1 protocols
297+
* //TODO for Nvme/TCP and Nvme/FC protocols
298+
* @param values
299+
*/
300+
abstract AccessGroup updateAccessGroup(AccessGroup accessGroup);
301+
302+
/**
303+
* Method encapsulates the behavior based on the opted protocol in subclasses
304+
* getiGroup for iSCSI and FC protocols
305+
* getExportPolicy for NFS 3.0 and NFS 4.1 protocols
306+
* getNameSpace for Nvme/TCP and Nvme/FC protocols
307+
* @param values
308+
*/
309+
abstract AccessGroup getAccessGroup(AccessGroup accessGroup);
310+
311+
/**
312+
* Method encapsulates the behavior based on the opted protocol in subclasses
313+
* lunMap for iSCSI and FC protocols
314+
* //TODO for Nvme/TCP and Nvme/FC protocols
315+
* @param values
316+
*/
317+
abstract void enableLogicalAccess(Map<String,String> values);
318+
319+
/**
320+
* Method encapsulates the behavior based on the opted protocol in subclasses
321+
* lunUnmap for iSCSI and FC protocols
322+
* //TODO for Nvme/TCP and Nvme/FC protocols
323+
* @param values
324+
*/
325+
abstract void disableLogicalAccess(Map<String,String> values);
326+
172327
}

0 commit comments

Comments
 (0)