Skip to content

CBR find policy method doesn't work with policy name #595

@dsabelni

Description

@dsabelni

CBR method find_policy in located in otcextensions\sdk\cbr\v3_proxy.py doesn't work when the name of a policy is passed into the name_or_id parameter - ultimately it uses the find method of the Resource located in openstack\resource.py and there this parameter described this way:

:param name_or_id: This resource's identifier, if needed by the request. The default is ``None``.

so in my understanding, this parameter receives either Name or ID of a resource based on the type of the resource, but it can't receive either Name or ID for the same type of resource. In that case having the next parameter name and description in the CBR Proxy class is misleading:

:param name_or_id: The name or ID of a policy

If I'm correct in my assumption, I suggest updating the find_policy method from:

    def find_policy(self, name_or_id, ignore_missing=True):
        """Find a single CBR policy by name or ID

        :param name_or_id: The name or ID of a policy
        :param bool ignore_missing: When set to ``False``
            :class:`~openstack.exceptions.ResourceNotFound` will be raised
            when the policy does not exist.
            When set to ``True``, no exception will be set when attempting
            to delete a nonexistent policy.

        :returns: a :class:`~otcextensions.sdk.cbr.v3.policy.Policy` instance
        """
        return self._find(_policy.Policy, name_or_id,
                          ignore_missing=ignore_missing)

to:

    def find_policy(self, policy_id, ignore_missing=True):
        """Find a single CBR policy by name or ID

        :param policy_id: The ID of a policy
        :param bool ignore_missing: When set to ``False``
            :class:`~openstack.exceptions.ResourceNotFound` will be raised
            when the policy does not exist.
            When set to ``True``, no exception will be set when attempting
            to delete a nonexistent policy.

        :returns: a :class:`~otcextensions.sdk.cbr.v3.policy.Policy` instance
        """
        return self._find(_policy.Policy, name_or_id=policy_id,
                          ignore_missing=ignore_missing)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions