rubrik-sdk-for-python icon indicating copy to clipboard operation
rubrik-sdk-for-python copied to clipboard

get_sla_objects skips objects with same name

Open nvmdd opened this issue 4 years ago • 3 comments

Expected Behavior .get_sla_objects to return all objects from sla

Current Behavior

returns dictionary of {name:id}. objects with the same name are skipped.

Failure Information (for bugs)

When we have a lot of objects with the same name for example "master" database in mssql_db objects .get_sla_objects appends the results in the dictionary and repeating keys will be overwritten and only objects with unique names get returned.

Steps to Reproduce have 2 objects with same name, (in my case to containers of an mssql database "master"= within the same SLA. query .get_sla_objects , only one "master" object will be returned.

nvmdd avatar Sep 08 '21 10:09 nvmdd

This is happening because it's a dictionary. The keys will be unique. If you're adding new key-value pair to a dictionary which already has the key, it will just update the existing value for that particular key. That's the nature of dictionary.

kambleakash0 avatar Sep 08 '22 13:09 kambleakash0

Well yeah the keys will be unique but you wont be able get them all with this function when you have matching names due to, as you said, nature of dictionary. I rewrote the function for myself using the ID as key so I could get ALL the objects in the SLA not just the ones with a unique name as key.

nvmdd avatar Sep 09 '22 09:09 nvmdd

Yes, every time we need to use the custom function as inverting the kay-values mapping will also result in loss of data.

kambleakash0 avatar Sep 09 '22 16:09 kambleakash0