Skip to content
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

_validate_suffix_collections needs rework #119

Closed
wojtek0806 opened this issue Nov 19, 2016 · 4 comments
Closed

_validate_suffix_collections needs rework #119

wojtek0806 opened this issue Nov 19, 2016 · 4 comments

Comments

@wojtek0806
Copy link
Contributor

I have recently hit an edge case where the name of my resource had to contain '/' this has led to problems with our validation method:


C:\Users\wypior\Documents\PythonProjects\f5-common-python\f5\bigip\tm\gtm\test\functional\test_topology.py:57: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Users\wypior\Documents\PythonProjects\f5-common-python\f5\bigip\tm\gtm\test\functional\test_topology.py:47: in delete_topology
    name=name)
C:\Users\wypior\Documents\PythonProjects\f5-common-python\f5\bigip\tm\gtm\topology.py:145: in load
    return self._load(**kwargs)
C:\Users\wypior\Documents\PythonProjects\f5-common-python\f5\bigip\resource.py:919: in _load
    response = refresh_session.get(base_uri, **kwargs)
C:\Python27\Lib\site-packages\icontrol\session.py:221: in wrapper
    sub_path, suffix, **kwargs)
C:\Python27\Lib\site-packages\icontrol\session.py:177: in generate_bigip_uri
    _validate_uri_parts(base_uri, partition, name, sub_path, suffix)
C:\Python27\Lib\site-packages\icontrol\session.py:151: in _validate_uri_parts
    _validate_name_partition_subpath(name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

element = 'ldns: subnet 192.168.100.0/24 server: subnet 192.168.200.0/24'

    def _validate_name_partition_subpath(element):
        # '/' and '~' are illegal characters
        if element == '':
            return True
        if '~' in element:
            error_message =\
                "instance names and partitions cannot contain '~', but it's: %s"\
                % element
            raise InvalidInstanceNameOrFolder(error_message)
        elif '/' in element:
            error_message =\
                "instance names and partitions cannot contain '/', but it's: %s"\
                % element
>           raise InvalidInstanceNameOrFolder(error_message)
E           InvalidInstanceNameOrFolder: instance names and partitions cannot contain '/', but it's: ldns: subnet 192.168.100.0/24 server: subnet 192.168.200.0/24

C:\Python27\Lib\site-packages\icontrol\session.py:123: InvalidInstanceNameOrFolder

This issue is blocking the implementation of GTM endpoints in our SDK

@wojtek0806
Copy link
Contributor Author

@swormke

@wojtek0806
Copy link
Contributor Author

the self link for this resource looks like this:

u'https://localhost/mgmt/tm/gtm/topology/ldns:%20subnet%20192.168.100.0~24%20server:%20subnet%20192.168.200.0~24?ver=12.1.0'

@caphrim007
Copy link
Contributor

@wojtek0806 slashes arent the problem as the selfLink shows that slashes are converted, or interpreted, as tilde's (~).

What happens if you provide your same value with ~ instead of / ?

@wojtek0806
Copy link
Contributor Author

if you check function it will also raise exception..

wojtek0806 added a commit to wojtek0806/f5-icontrol-rest-python that referenced this issue Nov 29, 2016
Problem:

_validate_suffix_collections method assumes that '~' and '/' in elements are incorrect. This leads to issues where 'name' contains '~' or '/' on purpose.

Analysis:
This patch introduces name_transform bool (with default being False), with it set to True, the 'name' element will not be validated for the presence of '~' and '/' characters. It will also convert all '/' in the name into '~'. To use this ability BIGIP needs to pass the argument 'name_transform' in the **kwargs when calling the iControl.

Tests:
unit
functional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants