F5Networks / f5-icontrol-rest-python

Generic python library used by the F5 SDK and other F5 projects to communicate with BIG-IP® via the REST API
http://icontrol.readthedocs.org/en/latest/
Apache License 2.0
36 stars 32 forks source link

subPath should allow for "/" and translate it appropriately to "~" #163

Closed jasonrahm closed 5 years ago

jasonrahm commented 5 years ago

This issue discovered and reported on the sdk repo: https://github.com/F5Networks/f5-common-python/issues/1522.

For gtm members reference, unable to properly use subPath to check exists. If I have a subPath of ltm3.test.local:/part1 on my member object and submit the query:

gp.members_s.member.exists(name='v1', subPath='ltm3.test.local:/part1', partition='Common')

I get this error:

  File "/Users/rahm/Documents/PycharmProjects/f5-common-python/f5py3/lib/python3.7/site-packages/icontrol/session.py", line 212, in generate_bigip_uri
    **kwargs)
  File "/Users/rahm/Documents/PycharmProjects/f5-common-python/f5py3/lib/python3.7/site-packages/icontrol/session.py", line 181, in _validate_uri_parts
    _validate_name_partition_subpath(sub_path)
  File "/Users/rahm/Documents/PycharmProjects/f5-common-python/f5py3/lib/python3.7/site-packages/icontrol/session.py", line 150, in _validate_name_partition_subpath
    raise InvalidInstanceNameOrFolder(error_message)
icontrol.exceptions.InvalidInstanceNameOrFolder: instance names and partitions cannot contain '/', but it's: ltm3.test.local:/part1

If I comment out the validation, I still get a 400 error from the rest interface because it does not like the "/" supplied in the subPath.

But if I change my subPath from ltm3.test.local:/part1 to ltm3.test.local:~part1, I get a successful response.

So I think what we need to do is twofold:

jasonrahm commented 5 years ago

for reference, previous commit on subPath support.