Seeking help for Keystone Error while assign_role_to_user for a Project in Openstack SDK

Ayush Jaiswal jaiswalaj716 at gmail.com
Fri Oct 21 09:55:34 UTC 2022


Hi Team,

I am using the Openstack SDK in my django rest api project where I have to
create a new project and assign various users with different roles to that
project in openstack. However, while adding a user to a project I am
getting the following error.

[image: image.png]

Complete details of the steps I followed that resulted in this error are in
the text file attached with this email.

Kindly help me resolve this issue. Your support is highly appreciated.

-- 
Thanks and Regards,
Ayush Jaiswal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.openstack.org/pipermail/openstack-discuss/attachments/20221021/0c2335d7/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 47351 bytes
Desc: not available
URL: <https://lists.openstack.org/pipermail/openstack-discuss/attachments/20221021/0c2335d7/attachment-0001.png>
-------------- next part --------------
# clouds.yml file content START. Replace the credentials accordingly.

# This is a clouds.yaml file, which can be used by OpenStack tools as a source
# of configuration on how to connect to a cloud. If this is your only cloud,
# just put this file in ~/.config/openstack/clouds.yaml and tools like
# python-openstackclient will just work with no further config. (You will need
# to add your password to the auth section)
# If you have more than one cloud account, add the cloud entry to the clouds
# section of your existing file and you can refer to them by name with
# OS_CLOUD=openstack or --os-cloud=openstack
clouds:
  openstack:
    auth:
      auth_url: http://192.168.36.129:5000
      username: "admin"
      password: "admin"
      project_id: d525a3ec045045d3b430420458e9a990
      project_name: "admin"
      user_domain_name: "Default"
    region_name: "RegionOne"
    interface: "public"
    identity_api_version: 3


# clouds.yml file content END.




# Following are python shell commands to assign a user to the project

# For importing connection object of openstack sdk to access openstack
>>> from cloud_resources.connect import conn

# To check if object "conn" is working properly
>>> servers = conn.compute.servers()
# If following shell command prints a list of server then connection is established successfully and object "conn" is working properly.
# I performed the same check and it was working fine.
>>> print(servers)

# To fetch an existing Project with Project ID = 37ac4f1be68e4c95b666f0750f5efc8d. Replace with your Project ID.
>>> project = conn.identity.get_project("37ac4f1be68e4c95b666f0750f5efc8d")
# Following shell command prints the project's detail
# I performed the same check and it was working fine.
>>> print(project)

# To fetch an existing User with User ID = e5b8d04148ea41c48028728cdc484497. Replace with your User ID.
>>> user = conn.identity.get_user("e5b8d04148ea41c48028728cdc484497")
# Following shell command prints the user's detail
# I performed the same check and it was working fine.
>>> print(user)

# To fetch an existing Role (with which the project will be accessed by the user) with Role ID = 3e875c2689de4b9aa4bc38739578e7f5. Replace with your Role ID. 
# This is ID is of role Admin
>>> role = conn.identity.get_role("3e875c2689de4b9aa4bc38739578e7f5")
# Following shell command prints the role's detail
# I performed the same check and it was working fine.
>>> print(role)

# Calling the openstack sdk built-in function to assign user to the project with the Admin role.
>>> project.assign_role_to_user(conn.session, user, role)

# Output of the above shell command

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/opt/original/OpenYmir/venv/lib/python3.10/site-packages/openstack/identity/v3/project.py", line 69, in assign_role_to_user
    resp = session.put(url,)
  File "/opt/original/OpenYmir/venv/lib/python3.10/site-packages/keystoneauth1/session.py", line 1157, in put
    return self.request(url, 'PUT', **kwargs)
  File "/opt/original/OpenYmir/venv/lib/python3.10/site-packages/keystoneauth1/session.py", line 815, in request
    raise exceptions.EndpointNotFound()
keystoneauth1.exceptions.catalog.EndpointNotFound: Could not find requested endpoint in Service Catalog.


# Observation: With Google search it has been observed that this was an actual bug in the openstack sdk for keystoneauth1 (version < 3.2), but it was resolved afterwards. However, in our scenario this issue is still there even when keystoneauth1 is updated to version 5.0.0.


# Pip Freeze output of current venv
appdirs==1.4.4
asgiref==3.5.2
certifi==2022.9.24
cffi==1.15.1
charset-normalizer==2.1.1
cryptography==38.0.1
decorator==5.1.1
Django==4.1.2
django-cors-headers==3.13.0
djangorestframework==3.14.0
dogpile.cache==1.1.8
idna==3.4
iso8601==1.1.0
jmespath==1.0.1
jsonpatch==1.32
jsonpointer==2.3
keystoneauth1==5.0.0
munch==2.5.0
netifaces==0.11.0
openstacksdk==0.102.0
os-service-types==1.7.0
pbr==5.10.0
pycparser==2.21
pytz==2022.4
PyYAML==6.0
requests==2.28.1
requestsexceptions==1.4.0
six==1.16.0
sqlparse==0.4.3
stevedore==4.0.1
urllib3==1.26.12


More information about the openstack-discuss mailing list