Skip to content

Commit 973f5e2

Browse files
CSTACKEX-34: Upgrade to framework classes design
1 parent 25353c2 commit 973f5e2

File tree

9 files changed

+264
-54
lines changed

9 files changed

+264
-54
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: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,67 +22,67 @@
2222
import org.apache.cloudstack.storage.utils.Constants.ProtocolType;
2323

2424
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;
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;
3131

3232
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;
33+
username = username;
34+
password = password;
35+
managementLIF = managementLIF;
36+
svmName = svmName;
37+
protocolType = protocolType;
38+
isDisaggregated = isDisaggregated;
3939
}
4040

4141
public String getUsername() {
42-
return _username;
42+
return username;
4343
}
4444

4545
public void setUsername(String username) {
46-
_username = username;
46+
username = username;
4747
}
4848

4949
public String getPassword() {
50-
return _password;
50+
return password;
5151
}
5252

5353
public void setPassword(String password) {
54-
_password = password;
54+
password = password;
5555
}
5656

5757
public String getManagementLIF() {
58-
return _managementLIF;
58+
return managementLIF;
5959
}
6060

6161
public void setManagementLIF(String managementLIF) {
62-
_managementLIF = managementLIF;
62+
managementLIF = managementLIF;
6363
}
6464

6565
public String getSvmName() {
66-
return _svmName;
66+
return svmName;
6767
}
6868

6969
public void setSvmName(String svmName) {
70-
_svmName = svmName;
70+
svmName = svmName;
7171
}
7272

7373
public ProtocolType getProtocol() {
74-
return _protocolType;
74+
return protocolType;
7575
}
7676

7777
public void setProtocol(ProtocolType protocolType) {
78-
_protocolType = protocolType;
78+
protocolType = protocolType;
7979
}
8080

8181
public Boolean getIsDisaggregated() {
82-
return _isDisaggregated;
82+
return isDisaggregated;
8383
}
8484

8585
public void setIsDisaggregated(Boolean isDisaggregated) {
86-
_isDisaggregated = isDisaggregated;
86+
isDisaggregated = isDisaggregated;
8787
}
8888
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
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;
2827
import org.apache.cloudstack.storage.utils.Constants.ProtocolType;
2928
import org.apache.logging.log4j.LogManager;
3029
import org.apache.logging.log4j.Logger;

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,5 @@ 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
}
3430

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: 157 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
import java.util.List;
4343
import java.util.Objects;
4444

45+
/**
46+
* Storage Strategy represents the communication path for all the ONTAP storage options
47+
*
48+
* ONTAP storage operation would vary based on
49+
* Supported protocols: NFS3.0, NFS4.1, FC, iSCSI, Nvme/TCP and Nvme/FC
50+
* Supported platform: Unified and Disaggregated
51+
*/
4552
public abstract class StorageStrategy {
4653
@Inject
4754
private Utility utils;
@@ -57,10 +64,21 @@ public abstract class StorageStrategy {
5764

5865
private final OntapStorage storage;
5966

67+
/**
68+
* Presents aggregate object for the unified storage, not eligible for disaggregated
69+
*/
6070
private List<Aggregate> aggregates;
6171

6272
private static final Logger s_logger = (Logger) LogManager.getLogger(StorageStrategy.class);
6373

74+
protected enum PROTOCOLS
75+
{ NFS30,
76+
NFS41,
77+
FC,
78+
iSCSI,
79+
NvmeTCP,
80+
NvmeFC };
81+
6482
public StorageStrategy(OntapStorage ontapStorage) {
6583
storage = ontapStorage;
6684
}
@@ -108,7 +126,16 @@ public boolean connect() {
108126
}
109127

110128
// Common methods like create/delete etc., should be here
111-
public void createVolume(String volumeName, Long size) {
129+
130+
/**
131+
* Creates ONTAP Flex-Volume
132+
* Eligible only for Unified ONTAP storage
133+
* throw exception in case of disaggregated ONTAP storage
134+
*
135+
* @param volumeName
136+
* @param size
137+
*/
138+
public void createStorageVolume(String volumeName, Long size) {
112139
s_logger.info("Creating volume: " + volumeName + " of size: " + size + " bytes");
113140

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

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

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,61 @@
2121

2222
import org.apache.cloudstack.storage.feign.model.OntapStorage;
2323

24+
import java.util.Map;
25+
2426
public class UnifiedNASStrategy extends NASStrategy{
2527
public UnifiedNASStrategy(OntapStorage ontapStorage) {
2628
super(ontapStorage);
2729
}
2830

2931
@Override
30-
public String createExportPolicy(String svmName, String policyName) {
31-
return "";
32+
public void createCloudStackVolume(Map<String, String> values) {
33+
34+
}
35+
36+
@Override
37+
void updateCloudStackVolume(Map<String, String> values) {
38+
39+
}
40+
41+
@Override
42+
void deleteCloudStackVolume(Map<String, String> values) {
43+
44+
}
45+
46+
@Override
47+
void getCloudStackVolume(Map<String, String> values) {
48+
49+
}
50+
51+
@Override
52+
void enableAccess(Map<String, String> values) {
53+
3254
}
3355

3456
@Override
35-
public String addExportRule(String policyName, String clientMatch, String[] protocols, String[] roRule, String[] rwRule) {
36-
return "";
57+
void disableAccess(Map<String, String> values) {
58+
3759
}
3860

3961
@Override
40-
public String assignExportPolicyToVolume(String volumeUuid, String policyName) {
41-
return "";
62+
void updateAccess(Map<String, String> values) {
63+
4264
}
4365

4466
@Override
45-
public String enableNFS(String svmUuid) {
46-
return "";
67+
void getAccess(Map<String, String> values) {
68+
4769
}
70+
71+
@Override
72+
void enableLogicalAccess(Map<String, String> values) {
73+
74+
}
75+
76+
@Override
77+
void disableLogicalAccess(Map<String, String> values) {
78+
79+
}
80+
4881
}

0 commit comments

Comments
 (0)