-
Notifications
You must be signed in to change notification settings - Fork 209
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
pyrax.set_credentials() throws pyrax.exceptions.IdentityClassNotDefined exception #79
Comments
Duplicate of #77. Fixed in v1.4.1 |
I tried running the same code that works with pyrax 1.3.9 using 1.4.0 and 1.4.1. With each of these distributions I'm still getting the following exception: pyrax.exceptions.IdentityClassNotDefined: No identity class has been defined for the current environment My code looks like this: import pyrax
pyrax.set_settings(username, key, region=region) |
Ed, I am not sure this is the same thing. This is caused when there is no ~/.pyrax.cfg file or if the file exists but is empty, as pyrax.Settings.read_config either doesn't get called or doesn't actually do anything. If there is no such file, pyrax.identity is not set up. Seeing as though there is a default_identity_type, I'd imagine, that regardless of having a config file, this should still work. As it stands now, I cannot see any easy way of authenticating without a ~/.pyrax.cfg. Unless I am just missing something obvious here. The only way I see that it can work without having a .pyrax.cfg is to do something like: import pyrax
cls = pyrax.utils.import_class('pyrax.identity.rax_identity.RaxIdentity')
pyrax.identity = cls()
pyrax.set_credentials('username', 'apikey') |
OK, I think the report just looked the same as the one from yesterday. This is not a bug; rather, it is exactly what the exception was designed to do. You have to define the identity class somehow: in either the config file, in the environment variable, or by calling |
Using pyrax.set_setting with an empty or non-existent file seems to fail as well
You may have some other changes coming that will help, but I imagine more than just that would be required to make set_setting on it's own handle this case. Just trying to figure out what the best practice way of doing this will be without a .pyrax.cfg file. Since this is a somewhat non-backwards compatible change, it would be good to have a standard "resolution" to getting people back up and running, that may not involve a .pyrax.cfg file. Of course creating a .pyrax.cfg file and giving at least a heading will resolve things. However, a pure code based approach may make it easier for deploying applications utilizing pyrax. So far, it looks like my code snippet above is the easiest I have found, but again, I haven't had much time to dig through the new code, so you may know of something I am missing. |
Yes, I've handled that. And no, it should be backwards-compatible - that's why these things are bugs. I added the environment variable support as well as the manual settings so that the config file wouldn't be required. I guess the only thing that isn't backwards-compatible is that you can no longer assume that the can only be run on Rackspace. |
OK, 1.4.2 has been pushed. Let me know if any problems remain. |
Ok, looks like this is fixed, but I had to add the following line before I called set_credentials(), as sivel pointed out: pyrax.settings.set('identity_type', 'rackspace') The docs should be updated here to reflect this additional requirement. |
I added that information in the section below ("Pyrax Configuration"). But you're correct - it's probably good to mention it in the auth section as well. |
This seems like a bug, I have only been using the pyrax for about an hour, so I might have overlooked something, but it seems odd that set_credentials authorises and then list_containers fails for being Unauthorised:
|
Hmmm... I'm not able to reproduce this. Can you tell me what version of python-swiftclient is installed? If it's 1.3.0 or later, could you run this and let me know what it outputs?
|
Here you go:
Issues in the past (python-cloudfiles) have stemmed from the fact I am trying to connect to the UK cloud files, could this be the cause? |
Yes, that is definitely the case here. pyrax still defaults to the 'DFW' region, as seen in the output you provided:
before the call to |
Hold on - I just tested this, and found another bug. I've opened up a new issue: #86. |
feedmagnet/deployment#1482 The version bump to 1.4.4 of pyrax was backwards in compatible as described in pycontribs/pyrax#79
OK, @amg84 - this has been fixed in 1.4.5. You can now set the region using |
Reference discussion over here: pycontribs#79
Reference discussion over here: pycontribs#79 Trying from the working branch this time. =)
pycontribs/pyrax#79 Pyrax now requires you to set the identity type - if this hasn't been done in a config file you have to do it in code. Patch forces rackspace identity type. Example error message without this patch - Traceback (most recent call last): File "./dns-updater.py", line 56, in <module> argh.dispatch_command(main) File "/usr/local/lib/python2.7/dist-packages/argh/dispatching.py", line 231, in dispatch_command dispatch(parser, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/argh/dispatching.py", line 125, in dispatch for line in lines: File "/usr/local/lib/python2.7/dist-packages/argh/dispatching.py", line 202, in _execute_command for line in result: File "/usr/local/lib/python2.7/dist-packages/argh/dispatching.py", line 185, in _call result = args.function(*positional, **keywords) File "./dns-updater.py", line 21, in main pyrax.set_credential_file(os.path.expanduser(creds_file)) File "/usr/local/lib/python2.7/dist-packages/pyrax/__init__.py", line 430, in _wrapped _create_identity() File "/usr/local/lib/python2.7/dist-packages/pyrax/__init__.py", line 413, in _create_identity raise exc.IdentityClassNotDefined("No identity class has " pyrax.exceptions.IdentityClassNotDefined: No identity class has been defined for the current environment.
Authenticating with pyrax.set_credentials() seems to have broken in pyrax >=1.4.0. When I try to run code that worked with 1.3.9 I get the following exception:
pyrax.exceptions.IdentityClassNotDefined: No identity class has been defined for the current environment.
The text was updated successfully, but these errors were encountered: