ging / fiware-idm-deprecated

DEPRECATED - Identity Manager - Keyrock
Apache License 2.0
18 stars 25 forks source link

FIWARE_CLOUD_APP / ROLE_ID #34

Closed DerJayDee closed 8 years ago

DerJayDee commented 8 years ago

The settings defined in https://github.com/ging/horizon/blob/master/openstack_dashboard/local/local_settings.py.example#L569 seem to cause trouble in my installation of keystone / horizon: I signed up in the frontend to create a new user, logged in as admin and tried to change the new user role to a community role. Upon sending the request I get the following error:

Environment:

Request Method: POST
Request URL: http://<horizon root url>/idm_admin/user_accounts/jde/update/

Django Version: 1.6.11
Python Version: 2.7.9
Installed Applications:
['openstack_dashboard.dashboards.settings',
 'openstack_dashboard.dashboards.idm',
 'openstack_dashboard.dashboards.idm_admin',
 'openstack_dashboard',
 'django.contrib.contenttypes',
 'django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'django_pyscss',
 'openstack_dashboard.django_pyscss_fix',
 'compressor',
 'horizon',
 'openstack_auth',
 'nocaptcha_recaptcha',
 'django_summernote',
 'corsheaders']
Installed Middleware:
('corsheaders.middleware.CorsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'openstack_dashboard.fiware_middleware.middleware.UserInfoMiddleware',
 'openstack_dashboard.fiware_middleware.middleware.OrganizationInfoMiddleware',
 'openstack_dashboard.fiware_middleware.middleware.SwitchMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'horizon.middleware.HorizonMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:
File "/opt/idm/.venv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/decorators.py" in dec
  36.         return view_func(request, *args, **kwargs)
File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/decorators.py" in dec
  52.             return view_func(request, *args, **kwargs)
File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/decorators.py" in dec
  36.         return view_func(request, *args, **kwargs)
File "/opt/idm/.venv/lib/python2.7/site-packages/django/views/generic/base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)
File "/opt/idm/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/idm_admin/user_accounts/views.py" in dispatch
  89.             return super(UpdateAccountView, self).dispatch(request, *args, **kwargs)
File "/opt/idm/.venv/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
  87.         return handler(request, *args, **kwargs)
File "/opt/idm/.venv/lib/python2.7/site-packages/django/views/generic/edit.py" in post
  171.             return self.form_valid(form)
File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/forms/views.py" in form_valid
  118.             exceptions.handle(self.request)
File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/exceptions.py" in handle
  334.     six.reraise(exc_type, exc_value, exc_traceback)
File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/forms/views.py" in form_valid
  115.             handled = form.handle(self.request, form.cleaned_data)
File "/opt/idm/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/idm_admin/user_accounts/forms.py" in handle
  288.             self.update_account(request, user, role_id, regions, duration)
File "/opt/idm/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/idm_admin/user_accounts/forms.py" in update_account
  72.             self._activate_cloud(request, user.id, user.cloud_project_id)
File "/opt/idm/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/idm_admin/user_accounts/forms.py" in _activate_cloud
  129.             application=cloud_app.id,

Exception Type: AttributeError at /idm_admin/user_accounts/jde/update/
Exception Value: 'NoneType' object has no attribute 'id'

I believe that the FIWARE_DEFAULT_CLOUD_ROLE_ID causes this error since my log from the virtual server shows the following:

[Mon Jan 18 07:53:23.025074 2016] [wsgi:error] [pid 1400:tid 140235133982464] Not Found: No Role found with id: 8605715701e44bf5be1e2fbe49cab080 (HTTP 404)
[Mon Jan 18 07:53:23.025097 2016] [wsgi:error] [pid 1400:tid 140235133982464] Traceback (most recent call last):
[Mon Jan 18 07:53:23.025100 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/fiware_api/keystone.py", line 749, in _get_element_and_cache
[Mon Jan 18 07:53:23.025103 2016] [wsgi:error] [pid 1400:tid 140235133982464]     role = function(request, role)
[Mon Jan 18 07:53:23.025114 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/fiware_api/keystone.py", line 800, in <lambda>
[Mon Jan 18 07:53:23.025117 2016] [wsgi:error] [pid 1400:tid 140235133982464]     request, default_cloud, lambda req, role_id: internal_keystoneclient(req).fiware_roles.roles.get(role_id))
[Mon Jan 18 07:53:23.025120 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/v3/contrib/fiware_roles/roles.py", line 41, in get
[Mon Jan 18 07:53:23.025122 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return super(RoleManager, self).get(role_id=base.getid(role))
[Mon Jan 18 07:53:23.025124 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/base.py", line 73, in func
[Mon Jan 18 07:53:23.025127 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return f(*args, **new_kwargs)
[Mon Jan 18 07:53:23.025129 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/base.py", line 334, in get
[Mon Jan 18 07:53:23.025131 2016] [wsgi:error] [pid 1400:tid 140235133982464]     self.key)
[Mon Jan 18 07:53:23.025133 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/base.py", line 136, in _get
[Mon Jan 18 07:53:23.025136 2016] [wsgi:error] [pid 1400:tid 140235133982464]     resp, body = self.client.get(url, **kwargs)
[Mon Jan 18 07:53:23.025138 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/httpclient.py", line 687, in get
[Mon Jan 18 07:53:23.025140 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return self._cs_request(url, 'GET', **kwargs)
[Mon Jan 18 07:53:23.025142 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/httpclient.py", line 674, in _cs_request
[Mon Jan 18 07:53:23.025145 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return self.request(url, method, **kwargs)
[Mon Jan 18 07:53:23.025147 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/httpclient.py", line 660, in request
[Mon Jan 18 07:53:23.025149 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return self._adapter.request(*args, **kwargs)
[Mon Jan 18 07:53:23.025152 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/adapter.py", line 200, in request
[Mon Jan 18 07:53:23.025154 2016] [wsgi:error] [pid 1400:tid 140235133982464]     resp = super(LegacyJsonAdapter, self).request(*args, **kwargs)
[Mon Jan 18 07:53:23.025156 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/adapter.py", line 89, in request
[Mon Jan 18 07:53:23.025158 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return self.session.request(url, method, **kwargs)
[Mon Jan 18 07:53:23.025161 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/utils.py", line 318, in inner
[Mon Jan 18 07:53:23.025163 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return func(*args, **kwargs)
[Mon Jan 18 07:53:23.025165 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/src/fiwareclient/keystoneclient/session.py", line 389, in request
[Mon Jan 18 07:53:23.025167 2016] [wsgi:error] [pid 1400:tid 140235133982464]     raise exceptions.from_response(resp, method, url)
[Mon Jan 18 07:53:23.025170 2016] [wsgi:error] [pid 1400:tid 140235133982464] NotFound: No Role found with id: 8605715701e44bf5be1e2fbe49cab080 (HTTP 404)
[Mon Jan 18 07:53:23.071054 2016] [wsgi:error] [pid 1400:tid 140235133982464] Internal Server Error: /idm_admin/user_accounts/jde/update/
[Mon Jan 18 07:53:23.071064 2016] [wsgi:error] [pid 1400:tid 140235133982464] Traceback (most recent call last):
[Mon Jan 18 07:53:23.071073 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 112, in get_response
[Mon Jan 18 07:53:23.071076 2016] [wsgi:error] [pid 1400:tid 140235133982464]     response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Mon Jan 18 07:53:23.071078 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/decorators.py", line 36, in dec
[Mon Jan 18 07:53:23.071081 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return view_func(request, *args, **kwargs)
[Mon Jan 18 07:53:23.071083 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/decorators.py", line 52, in dec
[Mon Jan 18 07:53:23.071085 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return view_func(request, *args, **kwargs)
[Mon Jan 18 07:53:23.071088 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/decorators.py", line 36, in dec
[Mon Jan 18 07:53:23.071090 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return view_func(request, *args, **kwargs)
[Mon Jan 18 07:53:23.071092 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
[Mon Jan 18 07:53:23.071094 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return self.dispatch(request, *args, **kwargs)
[Mon Jan 18 07:53:23.071097 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/idm_admin/user_accounts/views.py", line 89, in dispatch
[Mon Jan 18 07:53:23.071099 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return super(UpdateAccountView, self).dispatch(request, *args, **kwargs)
[Mon Jan 18 07:53:23.071102 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/lib/python2.7/site-packages/django/views/generic/base.py", line 87, in dispatch
[Mon Jan 18 07:53:23.071104 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return handler(request, *args, **kwargs)
[Mon Jan 18 07:53:23.071106 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/.venv/lib/python2.7/site-packages/django/views/generic/edit.py", line 171, in post
[Mon Jan 18 07:53:23.071109 2016] [wsgi:error] [pid 1400:tid 140235133982464]     return self.form_valid(form)
[Mon Jan 18 07:53:23.071111 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/forms/views.py", line 118, in form_valid
[Mon Jan 18 07:53:23.071113 2016] [wsgi:error] [pid 1400:tid 140235133982464]     exceptions.handle(self.request)
[Mon Jan 18 07:53:23.071115 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/exceptions.py", line 334, in handle
[Mon Jan 18 07:53:23.071118 2016] [wsgi:error] [pid 1400:tid 140235133982464]     six.reraise(exc_type, exc_value, exc_traceback)
[Mon Jan 18 07:53:23.071120 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../horizon/forms/views.py", line 115, in form_valid
[Mon Jan 18 07:53:23.071122 2016] [wsgi:error] [pid 1400:tid 140235133982464]     handled = form.handle(self.request, form.cleaned_data)
[Mon Jan 18 07:53:23.071125 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/idm_admin/user_accounts/forms.py", line 288, in handle
[Mon Jan 18 07:53:23.071127 2016] [wsgi:error] [pid 1400:tid 140235133982464]     self.update_account(request, user, role_id, regions, duration)
[Mon Jan 18 07:53:23.071129 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/idm_admin/user_accounts/forms.py", line 72, in update_account
[Mon Jan 18 07:53:23.071132 2016] [wsgi:error] [pid 1400:tid 140235133982464]     self._activate_cloud(request, user.id, user.cloud_project_id)
[Mon Jan 18 07:53:23.071137 2016] [wsgi:error] [pid 1400:tid 140235133982464]   File "/opt/idm/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/idm_admin/user_accounts/forms.py", line 129, in _activate_cloud
[Mon Jan 18 07:53:23.071140 2016] [wsgi:error] [pid 1400:tid 140235133982464]     application=cloud_app.id,
[Mon Jan 18 07:53:23.071142 2016] [wsgi:error] [pid 1400:tid 140235133982464] AttributeError: 'NoneType' object has no attribute 'id'

In what table from keystone should I find the app name and / or the ID?

Help on this one would be much apprechiated.

garcianavalon commented 8 years ago

That setting is very specific to the FIWARE Lab use case, where the Cloud Portal is stored as an application so it can use the OAuth protocol to log in users. What makes this app more important is the fact that certain types of users (community and trial) are required to be authorized in the app (in other words, have roles assigned). Therefore, when you try to update the user's status to community or trial, the IdM tries to find this app and its default role to assign it to the user.

You have two options here:

Hope this helps!

DerJayDee commented 8 years ago

Thanks for the reply. I thought the user types would activate the signed up account.

So if I don't want to use the FIWARE Lab, all FIWARE parameters in local_settings.py can be ignored?

garcianavalon commented 8 years ago

I would like to say yes, ignore all FIWARE_ settings, but some of them are required :( In general, sensible defaults are provided. If you have a doubt of any in particular, just ask.

DerJayDee commented 8 years ago

Okay I'm going on just ignoring these settings, thanks.