Skip to content

Export Policy and File operation changes NAS Storage pool creation - #11

Closed
piyush5netapp wants to merge 2 commits into
mainfrom
feature/CSTACKEX-33
Closed

Export Policy and File operation changes NAS Storage pool creation#11
piyush5netapp wants to merge 2 commits into
mainfrom
feature/CSTACKEX-33

Conversation

@piyush5netapp

Copy link
Copy Markdown

Description

This PR...

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?


public abstract String createExportPolicy(String svmName, String policyName);
public abstract boolean deleteExportPolicy(String svmName, String policyName);
public abstract boolean exportPolicyExists(String svmName, String policyName);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have getExportPolicy method

}

public abstract String createExportPolicy(String svmName, String policyName);
public abstract boolean deleteExportPolicy(String svmName, String policyName);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it void to pass back the exact error incase of failure

@@ -27,6 +27,8 @@ public NASStrategy(OntapStorage ontapStorage) {
}

public abstract String createExportPolicy(String svmName, String policyName);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return the policy object

public abstract boolean exportPolicyExists(String svmName, String policyName);
public abstract String addExportRule(String policyName, String clientMatch, String[] protocols, String[] roRule, String[] rwRule);
public abstract String assignExportPolicyToVolume(String volumeUuid, String policyName);
public abstract String enableNFS(String svmUuid);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this method, SVM should be pre-configured with NFS enabled.

@RequestMapping(method = RequestMethod.GET, value = "/{uuid}")
Svm getSvmByUUID(URI baseURL, @RequestHeader("Authorization") String header);

@RequestMapping(method = RequestMethod.PATCH)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this as not required now.

*/
@Override
public DataStore initialize(Map<String, Object> dsInfos) {
s_logger.info("initialize {}", dsInfos);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it debug and make it meaningful.

} else {
throw new CloudRuntimeException("ONTAP details validation failed, cannot create primary storage");
}
String storagePath = url + ":/" + storagePoolName;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the comment for assuming it is for NFS and URL value.

s_logger.info("initialize {}", dsInfos);
if (dsInfos == null) {
throw new CloudRuntimeException("Datastore info map is null, cannot create primary storage");
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the sample URL on which below code has been written.

exportPolicy.setSvm(svm);

// Create URI for export policy creation
URI url = URI.create(Constants.HTTPS + storage.getManagementLIF() + "/api/protocols/nfs/export-policies");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass this URL to constant


// Get policy ID first
URI getUrl = URI.create(Constants.HTTPS + storage.getManagementLIF() +
"/api/protocols/nfs/export-policies?name=" + policyName + "&svm.name=" + svmName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, put these in reusable constants

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

CopilotAI review requested due to automatic review settings November 4, 2025 04:47
@piyush5netapppiyush5netapp changed the title Export Policy and File operation changes NAS support Export Policy and File operation changes NAS Storage pool creationNov 4, 2025

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements comprehensive NAS support for the ONTAP storage plugin by adding export policy management and file operations. The changes migrate from Spring-based Feign clients to native Feign configuration and enhance the storage strategy pattern with complete NAS functionality.

  • Removes Spring Framework dependencies and migrates to native Feign client configuration
  • Implements complete NAS strategy with export policy management and file operations
  • Refactors storage classes to use immutable fields and proper dependency injection

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 7 comments.

Show a summary per file
FileDescription
Utility.javaRemoves Spring components and unused URI generation method
Constants.javaEnhances ProtocolType enum with string values
UnifiedNASStrategy.javaImplements comprehensive NAS operations including export policies and file management
UnifiedSANStrategy.javaAdds default constructor and dependency initialization
StorageStrategy.javaRefactors to use FeignClientFactory instead of Spring injection
NASStrategy.javaUpdates abstract methods for export policy operations
SANStrategy.javaAdds default constructor support
StorageProviderFactory.javaRemoves Spring annotations and refactors strategy creation
OntapPrimaryDatastoreProvider.javaUpdates logging imports and adds host listener
OntapHostListener.javaImplements HypervisorHostListener interface
OntapPrimaryDatastoreLifecycle.javaAdds URL parsing and hardcoded configuration for testing
Volume.javaAdds JSON ignore properties annotation
OntapStorage.javaConverts to immutable class with final fields
Job.javaFixes property mappings and variable naming
Multiple Feign clientsMigrates from Spring to native Feign annotations
FeignConfiguration.javaReplaces Spring configuration with native Feign setup
FeignClientFactory.javaNew factory class for creating Feign clients
OntapPrimaryDatastoreDriver.javaUpdates logging import
pom.xmlAdds feign-jackson dependency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +162 to +163
"10.196.38.171", extractedDetails.get(Constants.SVM_NAME), ProtocolType.NFS,
Boolean.parseBoolean(extractedDetails.get(Constants.IS_DISAGGREGATED))); // TODO hardcoded for testing

CopilotAINov 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded IP address should not be committed to production code. Consider using configuration or extractedDetails instead.

Suggested change
"10.196.38.171", extractedDetails.get(Constants.SVM_NAME), ProtocolType.NFS,
Boolean.parseBoolean(extractedDetails.get(Constants.IS_DISAGGREGATED)));// TODO hardcoded for testing
mLIF, extractedDetails.get(Constants.SVM_NAME), ProtocolType.NFS,
Boolean.parseBoolean(extractedDetails.get(Constants.IS_DISAGGREGATED)));

Copilot uses AI. Check for mistakes.
parameters.setName(storagePoolName);
parameters.setProviderName(providerName);
parameters.setManaged(true);
parameters.setHost("10.196.38.171");

CopilotAINov 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another hardcoded IP address that should be replaced with proper configuration or variable.

Copilot uses AI. Check for mistakes.
// .logger(feignConfiguration.createLogger())
.retryer(feignConfiguration.createRetryer())
.requestInterceptor(feignConfiguration.createRequestInterceptor())
.target(clientClass, "https://10.196.38.171/");

CopilotAINov 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded base URL in FeignClientFactory should be configurable to support different environments.

Copilot uses AI. Check for mistakes.
URI updateVolumeUrl = URI.create(Constants.HTTPS + storage.getManagementLIF() +
"/api/storage/volumes/" + volumeUuid);

//volumeFeignClient.updateVolumeRebalancing(updateVolumeUrl, authHeader, volumeUuid, volumeUpdate);

CopilotAINov 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out code should be removed or properly implemented before production deployment.

Suggested change
//volumeFeignClient.updateVolumeRebalancing(updateVolumeUrl, authHeader, volumeUuid, volumeUpdate);
volumeFeignClient.updateVolumeRebalancing(updateVolumeUrl, authHeader, volumeUuid, volumeUpdate);

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +70
s_logger.info(" storage object is {} ", storage.getPassword());
s_logger.info(" storage object is {} ", storage.getUsername());

CopilotAINov 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging sensitive information like passwords should be avoided as it can expose credentials in log files.

Suggested change
s_logger.info(" storage object is {} ", storage.getPassword());
s_logger.info(" storage object is {} ", storage.getUsername());
// Do not log sensitive information such as password or username

Copilot uses AI. Check for mistakes.
utils = ComponentContext.inject(Utility.class);
// Initialize FeignClientFactory and create NAS client
feignClientFactory = new FeignClientFactory();
sanFeignClient = feignClientFactory.createClient(SANFeignClient.class);// TODO needs to be changed

CopilotAINov 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO comment indicates incomplete implementation that should be addressed before production.

Copilot uses AI. Check for mistakes.
public class UnifiedNASStrategy extends NASStrategy{

private Utility utils;
// // Add missing Feign client setup for NAS operations

CopilotAINov 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out code should be removed to improve code clarity.

Suggested change
// // Add missing Feign client setup for NAS operations

Copilot uses AI. Check for mistakes.
// .logger(feignConfiguration.createLogger())
.retryer(feignConfiguration.createRetryer())
.requestInterceptor(feignConfiguration.createRequestInterceptor())
.target(clientClass, "https://10.196.38.171/");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not merge such changes, you can do this for internal testing.


@RequestMapping(method=RequestMethod.GET, value="/{uuid}")
Aggregate getAggregateByUUID(URI baseURL,@RequestHeader("Authorization") String header, @PathVariable(name = "uuid", required = true) String uuid);
@RequestLine("GET /")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add url

details.put(Constants.IS_DISAGGREGATED, "false");

OntapStorage ontapStorage = new OntapStorage(extractedDetails.get(Constants.USERNAME), extractedDetails.get(Constants.PASSWORD),
"10.196.38.171", extractedDetails.get(Constants.SVM_NAME), ProtocolType.NFS,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no hard code values

piyush5netapp pushed a commit that referenced this pull request Dec 4, 2025
# This is the 1st commit message:
NFS Cloudstack volume and export policy utils
# This is the commit message #2:
Licencse add in files
# This is the commit message #3:
accessgroup create recode
# This is the commit message #4:
creatacessgroup for NFS impl
# This is the commit message #5:
storage pool mounting on host
# This is the commit message #6:
storage pool mounting on host 1
# This is the commit message #7:
vm restart issue
# This is the commit message #8:
vm restart issue 1
# This is the commit message #9:
vm restart issue 2
# This is the commit message #10:
vm instance creation test1
# This is the commit message #11:
vm instance creation test4
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@piyush5netapp@rajiv-jain-netapp@suryag1201