-
Couldn't load subscription status.
- Fork 0
CSTACKEX-7: ONTAP Primary storage pool #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| //this method to get all svms and also filtered svms based on query params as a part of URL | ||
| @RequestMapping(method = RequestMethod.GET) | ||
| OntapResponse<Svm> getSvmResponse(URI baseURL, @RequestHeader("Authorization") String header); | ||
| OntapResponse<Svm> getSvms(URI baseURL, @RequestHeader("Authorization") String header); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we kept this naming convention for other feign client and this can return only one record also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted it back
| public static String Username; | ||
| public static String Password; | ||
| public static String ManagementLIF; | ||
| public static String Svm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
svm is an object which can not be string use svmName instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, will rename it
| public static String Password; | ||
| public static String ManagementLIF; | ||
| public static String Svm; | ||
| public static String Protocol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have type as enum with supported protocols?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| @SuppressWarnings("unchecked") | ||
| Map<String, String> details = (Map<String, String>)dsInfos.get("details"); | ||
| // Validations | ||
| if (podId != null && clusterId == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can combine this check into one check bcz both are required, also clusterId can be empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in my previous review to this change i nanother PR, I gave comment to use trim command and then empty check. Please add them for each mandatory parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of it, done
| } | ||
|
|
||
| PrimaryDataStoreParameters parameters = new PrimaryDataStoreParameters(); | ||
| if (clusterId != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this check is required again? it is already checked above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Customer has an option to not send both cluster and pod ids, in case of creating a zone level primary storage pool.
| details.put(Constants.MANAGEMENTLIF, url); | ||
|
|
||
| // Validate the ONTAP details | ||
| if(details.get(Constants.ISDISAGGREGATED) == null || details.get(Constants.ISDISAGGREGATED).isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add _ for ISDISAGGREGATED constant like IS_DISAGGREGATED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| // Call the SVM API to check if the SVM exists | ||
| Svm svm = null; | ||
| URI url = URI.create(Constants.HTTPS + storage.getManagementLIF() + Constants.GETSVMs); | ||
| OntapResponse<Svm> svms = svmFeignClient.getSvms(url, authHeader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a check for svms null check object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| public class Constants { | ||
| public static final String NFS = "nfs"; | ||
| public static final String ISCSI = "iscsi"; | ||
| public static final String PROTOCOL = "protocol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add _ where ever possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| // Create URI for POST CreateVolume API | ||
| URI url = utils.generateURI(Constants.CREATEVOLUME); | ||
| // Call the VolumeFeignClient to create the volume | ||
| JobResponse jobResponse = volumeFeignClient.createVolumeWithJob(url, authHeader, volumeRequest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add null checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks
| url = utils.generateURI(Constants.GETJOBBYUUID); | ||
| int jobRetryCount = 0, maxJobRetries = Constants.JOBMAXRETRIES; | ||
| Job createVolumeJob = null; | ||
| while(createVolumeJob == null || createVolumeJob.getState().equals(Constants.JOBRUNNING) || createVolumeJob.getState().equals(Constants.JOBQUEUE) || createVolumeJob.getState().equals(Constants.JOBPAUSED)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of checking for all state of job, check for not success
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be lost during rebase, thanks, done
| Svm svm = null; | ||
| URI url = URI.create(Constants.HTTPS + storage.getManagementLIF() + Constants.GETSVMs); | ||
| OntapResponse<Svm> svms = svmFeignClient.getSvms(url, authHeader); | ||
| for (Svm storageVM : svms.getRecords()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of getting all svm and picking based on name, better to call getSVMByName. We may need to add this method in svmFeignClient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this approach is not optimized. fetch the SVM using name as query parameter instead fetch all then find for desired name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the necessary changes
|
|
||
| @RequestMapping(method = RequestMethod.DELETE, value="/{uuid}") | ||
| void deleteVolume(@RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid); | ||
| void deleteVolume(URI baseURL, @RequestHeader("Authorization") String authHeader, @PathVariable("uuid") String uuid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with this change, why do we need to add url parameter at class level annotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't pass it explicitly, we need to set a property statically in application.properties or somewhere like that, which in our case is not feasible. Also, user might ask us to deal with multiple filers, so, the IP wouldn't be static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not seeing any significant changes here, better remove this class from the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This came in as part of rebase. It just has some space changes. Sure, will try to revert it
| @SuppressWarnings("unchecked") | ||
| Map<String, String> details = (Map<String, String>)dsInfos.get("details"); | ||
| // Validations | ||
| if (podId != null && clusterId == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in my previous review to this change i nanother PR, I gave comment to use trim command and then empty check. Please add them for each mandatory parameter
| Svm svm = null; | ||
| URI url = URI.create(Constants.HTTPS + storage.getManagementLIF() + Constants.GETSVMs); | ||
| OntapResponse<Svm> svms = svmFeignClient.getSvms(url, authHeader); | ||
| for (Svm storageVM : svms.getRecords()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this approach is not optimized. fetch the SVM using name as query parameter instead fetch all then find for desired name.
1573d0c to
a9c7f65
Compare
| ClusterVO clusterVO = _clusterDao.findById(clusterId); | ||
| Preconditions.checkNotNull(clusterVO, "Unable to locate the specified cluster"); | ||
| if (clusterVO.getHypervisorType() != Hypervisor.HypervisorType.KVM) { | ||
| throw new CloudRuntimeException("ONTAP primary storage is not supported for KVM hypervisor"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| import org.apache.cloudstack.storage.utils.Constants.ProtocolType; | ||
|
|
||
| public class OntapStorage { | ||
| public static String Username; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow naming convention for all fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you added only inports in this class ?
| public class OntapStorage { | ||
| public static String _username; | ||
| public static String _password; | ||
| public static String _managementLIF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use camel casing for the variable name
| } | ||
| } | ||
|
|
||
| if (storagePoolName == null || storagePoolName.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty check on the sting parameters must use trim method as well
| throw new CloudRuntimeException("iSCSI protocol is not enabled on SVM " + svmName); | ||
| } | ||
| List<Aggregate> aggrs = svm.getAggregates(); | ||
| if (aggrs == null || aggrs.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One use case to validate here is that if the passed credentials belong to the cluster, then by default, all the aggregates are mapped to the underlying SVMs. However, if credentials belong to an SVM user, then aggregates must be assigned to the SVM to access them.
@suryag1201 can you help @sandeeplocharla to close on this use case implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are dependencies on these changes for other engineers, approving this PR for now. Ensure you are picking up the given comments in subsequent PR
Description
This PR...
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?