Open stgaver opened 1 month ago
@stgaver, thank you for identifying these issues and even providing a fix for these 👍. I would highly encourage you to submit a PR too.
@anupamaloke , I was going to but I don't seem to have proper permissions to create a new branch.
@stgaver, you should be able to fork the repo into your account, clone the forked repo, create a new branch and make the proposed code changes, commit and then submit a PR to this upstream repo.
There are several issues with the get_sdss method in storage_pool.py
Issue 1 - Getting the SDS associated with a storage pool and only requesting certain fields is failing. Root cause: In get_sdss when we do a .get on the Sds objects we are passing filter_fields and fields as positional arguments. This causes fields to be put into filter_fields. As a result we get the AttributeError since a list doesn’t have a .items.
return Sds(self.token, self.configuration).get(filter_fields, fields)
Fix: The fix here is to pass them as named args as in get(filter_fields=filter_fields, fields=fields) After this change, SDS IDs are returned, albeit incorrectly. See Issue 2.Test script
This fails with error:
Issue 2: ALL SDSs are returned for get_sdss for a storage_pool. get_sdss should only return the SDS associated with the defined storage pool. Root cause: If filter_fields isn’t passed to the get_sdss method filter_fields is never updated with the SDS IDs associated with the storage pool from the get_related call. Also the format of the filter_fields is incorrect. Fix: Add the following code
With these two fixes the results are as expected from the test script:
Issue 3: If passing filter_fields to get_sdss so that we only get one of the sds in this storage_pool we get zero sds. Root cause: The get_related call filters based on the field ‘sdsId’ so that is what you have to pass in filter_fields to get_sdss like:
client.storage_pool.get_sdss("1f5e866000000003", filter_fields={'sdsId': ['0bb1eb5000000009']})
The filter_fields is then updated with {‘id’: ..} so filter_fields will have both sdsId and id in it. But both aren’t present so the filter fails and no SDS ids are returned. Fix: pop off sdsId from the filter_fields before trying to return the SDSsIn summary, all the changes: