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

Working Branch Authentication #414

Closed
rizumu opened this issue Jun 28, 2014 · 8 comments
Closed

Working Branch Authentication #414

rizumu opened this issue Jun 28, 2014 · 8 comments

Comments

@rizumu
Copy link

rizumu commented Jun 28, 2014

I'm testing out django-cumulus with the lastest pyrax commit on the working branch, which resolves other bugfixes I'm looking forward to landing, however something has changed because authentication is no longer working (the latest release authenticates just fine). Do you have any suggestions as to what it could be? Are there backwards incompatible changes coming that I should fix upstream in the django cumulus library?

I hit this traceback with any manage.py command:

Traceback (most recent call last):
  File "./manage.py", line 19, in <module>
    execute_from_command_line(sys.argv)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 427, in execute_from_command_line
    utility.execute()
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 391, in execute
    django.setup()
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/django/apps/registry.py", line 105, in populate
    app_config.import_models(all_models)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/django/apps/base.py", line 160, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/avatar/models.py", line 23, in <module>
    avatar_storage = get_storage_class(settings.AVATAR_STORAGE)()
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/cumulus/storage.py", line 88, in __init__
    pyrax.set_credentials(self.username, self.api_key)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/__init__.py", line 431, in _wrapped
    return fnc(*args, **kwargs)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/__init__.py", line 494, in set_credentials
    tenant_id=tenant_id, region=region, authenticate=authenticate)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/identity/rax_identity.py", line 69, in set_credentials
    region=region, tenant_id=tenant_id, authenticate=authenticate)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/base_identity.py", line 425, in set_credentials
    self.authenticate()
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/identity/rax_identity.py", line 88, in authenticate
    password=password, api_key=api_key, tenant_id=tenant_id)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/base_identity.py", line 626, in authenticate
    raise exc.AuthenticationFailed(err)
pyrax.exceptions.AuthenticationFailed: Not Found - Resource Not Found.
@EdLeafe
Copy link
Contributor

EdLeafe commented Jun 30, 2014

I'm not able to see what's going on. Can you turn on the HTTP debugging so I can see what the request looks like? In the traceback above is the line:

  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/cumulus/storage.py", line 88, in __init__
    pyrax.set_credentials(self.username, self.api_key)

Just before the call to set_credentials(), can you add the line:

pyrax.set_http_debug(True)

...and then paste the output here? Be sure to obscure your actual credentials.

@rizumu
Copy link
Author

rizumu commented Jun 30, 2014

Sure, I wanted to provide more debug info but wasn't sure exactly what that would be. Thanks for the explanation.

$ ./manage.py shell

REQ: curl -i -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' https://auth.api.rackspacecloud.com/v1.0/tokens

[22:06:32][DEBUG] pyrax http.py:http_log_req:91 |
REQ: curl -i -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' https://auth.api.rackspacecloud.com/v1.0/tokens

REQ BODY: {'auth': {'RAX-KSKEY:apiKeyCredentials': {'username': 'xxx', 'apiKey': 'xxx'}}}

[22:06:32][DEBUG] pyrax http.py:http_log_req:93 | REQ BODY: {'auth': {'RAX-KSKEY:apiKeyCredentials': {'username': 'xxx', 'apiKey': 'xxx'}}}

RESP: <Response [404]> {u'itemNotFound': {u'message': u'Resource Not Found', u'code': 404}}

[22:06:33][DEBUG] pyrax http.py:http_log_resp:104 | RESP: <Response [404]> {u'itemNotFound': {u'message': u'Resource Not Found', u'code': 404}}


REQ: curl -i -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' https://auth.api.rackspacecloud.com/v1.0/tokens

[22:06:33][DEBUG] pyrax http.py:http_log_req:91 |
REQ: curl -i -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' https://auth.api.rackspacecloud.com/v1.0/tokens

REQ BODY: {'auth': {'passwordCredentials': {'username': 'xxx', 'password': 'xxx'}, 'tenantId': 'xxx'}}

[22:06:33][DEBUG] pyrax http.py:http_log_req:93 | REQ BODY: {'auth': {'passwordCredentials': {'username': 'xxx', 'password': 'xxx'}, 'tenantId': 'xxx'}}

RESP: <Response [404]> {u'itemNotFound': {u'message': u'Resource Not Found', u'code': 404}}

[22:06:33][DEBUG] pyrax http.py:http_log_resp:104 | RESP: <Response [404]> {u'itemNotFound': {u'message': u'Resource Not Found', u'code': 404}}

Traceback (most recent call last):
  File "./manage.py", line 19, in <module>
    execute_from_command_line(sys.argv)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/django/apps/registry.py", line 106, in populate
    app_config.import_models(all_models)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/django/apps/config.py", line 190, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/Cellar/python/2.7.7_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/avatar/models.py", line 28, in <module>
    avatar_storage = get_storage_class(settings.AVATAR_STORAGE)()
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/cumulus/storage.py", line 120, in __init__
    pyrax.set_credentials(self.username, self.api_key)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/__init__.py", line 434, in _wrapped
    return fnc(*args, **kwargs)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/__init__.py", line 497, in set_credentials
    tenant_id=tenant_id, region=region, authenticate=authenticate)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/identity/rax_identity.py", line 69, in set_credentials
    region=region, tenant_id=tenant_id, authenticate=authenticate)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/base_identity.py", line 425, in set_credentials
    self.authenticate()
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/identity/rax_identity.py", line 88, in authenticate
    password=password, api_key=api_key, tenant_id=tenant_id)
  File "/home/rizumu/.virtualenvs/myenv/lib/python2.7/site-packages/pyrax/base_identity.py", line 626, in authenticate
    raise exc.AuthenticationFailed(err)
pyrax.exceptions.AuthenticationFailed: Not Found - Resource Not Found.

@EdLeafe
Copy link
Contributor

EdLeafe commented Jul 16, 2014

Sorry for the delay in responding - been swamped!!

I see that your authentication request is the wrong URI:

REQ: curl -i -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' https://auth.api.rackspacecloud.com/v1.0/tokens

This should have v2.0, not v1.0, in the URI. How are you setting up authentication?

rizumu added a commit to rizumu/django-cumulus that referenced this issue Jul 18, 2014
rizumu added a commit to rizumu/django-cumulus that referenced this issue Jul 18, 2014
@rizumu
Copy link
Author

rizumu commented Jul 18, 2014

@EdLeafe That was it, thank you!

@rizumu rizumu closed this as completed Jul 18, 2014
@rizumu
Copy link
Author

rizumu commented Jul 18, 2014

@EdLeafe I can now connect, but unfortnately, with v2 I can not use the Rackspace Files CDN. For a container that has CDN enabled, container.cdn_enabled mistakenly returns false and any attempt to use a CDN feature replies with *** NotCDNEnabled: CDN is not enabled for this service.

Is there a way to get both the auth and CDN working with either v1 or v2 on pyrax 1.9.0?

@EdLeafe
Copy link
Contributor

EdLeafe commented Jul 18, 2014

That should have been fixed in #423, and my tests show it working. Are you sure you have upgraded completely to 1.9.0? Or could it be using an older pyrax? What do you get if you run:

import pyrax
print pyrax.version.version

@rizumu
Copy link
Author

rizumu commented Jul 18, 2014

1.9.0 I've just proven CDN works in the shell, but when I'm using django-cumulus it isn't. I'm trying to narrow it down now but it seems it must be a problem in our cumulus connections. I'm going to dig in there now. Thanks again.

@rizumu
Copy link
Author

rizumu commented Jul 18, 2014

I think what happened is we were using a combination of swiftclient and pyrax for compatibility and feature requirements and that is where things get hairy because in that in one of our management commands we are always using swiftclient but in our storage class we have a conditional for swiftclient/pyrax. Now that CDN is fixed, we should be able to clean this up on our side. Hopefully this is the case and I can push a fix today.

rizumu added a commit to django-cumulus/django-cumulus that referenced this issue Jul 18, 2014
rizumu added a commit to rizumu/django-cumulus that referenced this issue Jul 18, 2014
rizumu added a commit to rizumu/django-cumulus that referenced this issue Aug 4, 2014
rizumu added a commit to rizumu/django-cumulus that referenced this issue Aug 4, 2014
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