Skip to content

Getting a single LUN mapping #40

Description

@tacerus

Hi,

I am trying to retrieve a a LUN mapping resource for a single specific LUN.

get() on a LunMap with a filter which should only match a single entry results in an error:

mapresource = LunMap({'igroup.name': 'myig', 'lun.uuid': '8f27a86c-8c79-4d94-ab22-e86868954d5c'})
mrs = mapresource.get()
NetAppRestError: Received more than one record in the response LunMap.

And get_collection() results in a large amount of unrelated mappings:

mapresource = LunMap({'igroup.name': my'ig', 'lun.uuid': '8f27a86c-8c79-4d94-ab22-e86868954d5c'})
mrs = mapresource.get_collection()
print(len(list(mrs)))
41

Same results if using lun.name or even logical_unit_number:

mapresource = LunMap({'igroup.name': 'myig', 'lun.name': '/vol/lun_kvm_system/lun901'})
mrs = mapresource.get_collection()
print(len(list(mrs)))
41

mapresource = LunMap({'igroup.name': 'myig', 'logical_unit_number': '901'})
mrs = mapresource.get_collection()
print(len(list(mrs)))
41

I would expect to retrieve only one mapping result if a distinct filter is specified. Am I missing something?

Edit: this is against ONTAP 9.9 with the libraries netapp-lib 2021.6.25 and netapp-ontap 9.13.1.0.

Activity

  1. github-actions commented on Jun 25, 2023

    @github-actions

    Thank you for reporting an issue! If you haven't already joined our Discord community,
    then we invite you to do so. This is a great place to get help and ask questions from our community.

  2. noorbuchi commented on Sep 25, 2023

    @noorbuchi
    Contributor

    Hello,

    It would be very helpful to know what the requests and responses from your example look like. Can you please enabled debug logging and share the output. You can do that by including this in your script:

    import logging
    from netapp_ontap import config, utils
    utils.LOG_ALL_API_CALLS = 1
    utils.DEBUG = 1
    logging.basicConfig(level=logging.DEBUG)

    Just by looking at your code, I can think of couple possible issues.

    mapresource = LunMap({'igroup.name': 'myig', 'lun.uuid': '8f27a86c-8c79-4d94-ab22-e86868954d5c'})
    mrs = mapresource.get()

    The above code is incorrect. The library expects path keys (lun.uuid and igroup.uuid as shown in the screenshot) to be positional arguments in the object constructor. Instead you're passing a dictionary which gets ignored by the library. Then, the get requests essentially just becomes a collection get and returns multiple records.

    image

    To fix this, you should restructure the code to this:

    mapresource = LunMap(myig, 8f27a86c-8c79-4d94-ab22-e86868954d5c)
    mapresource.get()

    As for the second example, you're making an incorrect request because get_collection is a static method for the object. You can set query parameters on the collection get using keyword arguments. So the correct code can look something like this:

    records = LunMap.get_collection()
    

    Please let me know if this helps.

    -Noor

  3. tacerus commented on Sep 29, 2023

    @tacerus
    Author

    Interesting, thank you for elaborating on this! I'll try to test your suggestions and report back soon, if needed with the debug output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions