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

Can't set identity_class based in the identity_type through OS environment variables #82

Closed
michelts opened this issue Jun 1, 2013 · 9 comments
Labels

Comments

@michelts
Copy link

michelts commented Jun 1, 2013

Hi,

I'm trying to use django-cumulus with pyrax and novaclient without success.

The error raised is:

IdentityClassNotDefined at ...
No identity class has been defined for the current environment.

In the issue #79, @mlew comments he need to set the identity_type in code. I did it and it worked, but I don't want to change cumulus or my code to include it.

In fact, I read the pyrax code and note that the set method for settings changes the identity_class when the identity_type is changed (pyrax/init.py:166) but for the default environment, this settings param would never be set and I will never fall in the default rackspace identity_type, consequently, the rax_identity.RaxIdentity.

I try to set it through config files without success but I must admit, I didn't try enough. I want to use OS env variables as they are easier to set in my uWSGI deployment.

I can't set the identity_class through OS env variables and if I set identity_type, it will work as a default, it will never pass through the set method and this way, will never update the identity_class.

In fact, there is a default_identity_type/region/encoding but they aren't used until read_config is called, IF I set a config file (something I want to avoid).

Well, this is what I could dig up first time :)

I don't feel secure to fix it myself until work a little more with the lib, this is the first time with pyrax. Anyway, anything I could help just tell me!

@EdLeafe
Copy link
Contributor

EdLeafe commented Jun 1, 2013

Based on the line number you quoted, it looks like you're not on the latest release. The current version is 1.4.2, which fixed several issues relating to the handling of the default environment when no configuration file is defined. Can you upgrade to the latest and see if that corrects your issues?

@toloco
Copy link

toloco commented Jun 4, 2013

Having similar problem, and I double checked my version it's 1.4.3

File "/home/tolo/Projects/yosilo.se/yosilose/core/storage.py", line 17, in connect
pyrax.set_credentials(self.option["user"], self.option["key"])
File "/home/tolo/.virtualenvs/yosilo/local/lib/python2.7/site-packages/pyrax/init.py", line 332, in _wrapped
_create_identity()
File "/home/tolo/.virtualenvs/yosilo/local/lib/python2.7/site-packages/pyrax/init.py", line 323, in _create_identity
raise exc.IdentityClassNotDefined("No identity class has "
pyrax.exceptions.IdentityClassNotDefined: No identity class has been defined for the current environment.

Any clues? It was working till last update, if it helps

@sivel
Copy link
Contributor

sivel commented Jun 4, 2013

@toloco: Please be sure to check https://github.com/rackspace/pyrax/blob/master/docs/pyrax_doc.md#set-up-authentication

Basically, you have a few options such as placing pyrax.set_setting("identity_type", "rackspace") in your script after your import pyrax and before you start interacting with the pyrax module such as calling set_credentials.

@EdLeafe
Copy link
Contributor

EdLeafe commented Jun 4, 2013

How are you defining the identity class? Are you using a configuration file, an environment variable, or setting it manually, as described in the docs?

Versions prior to 1.4 only supported Rackspace identity, so this was not required. Now that pyrax supports any identity service, it is necessary to at least define which type you are using.

@toloco
Copy link

toloco commented Jun 4, 2013

I already set identity_type and its working, how should I proceed? It looks like a patch

@EdLeafe
Copy link
Contributor

EdLeafe commented Jun 4, 2013

If this is just a temporary script, then setting the identity_type in code is the easiest thing. But if you're going to be doing development, or running an app that uses pyrax, it's best to create a configuration file to hold that setting.

@michelts
Copy link
Author

michelts commented Jun 4, 2013

@EdLeafe I'm using 1.4.3 now and I had the same problem: you don't set the identity_class when identity_type comes from os.environ (and I checked the environ, the var is here).

This way, the option 2 in the docs (as suggested by @sivel) cannot be applied.

You also aren't using the default values unless a config file is defined with a default section.

@EdLeafe
Copy link
Contributor

EdLeafe commented Jun 4, 2013

@michelts Ah! Thanks - I see the issue now. I'll get out a fix for reading the identity_class setting when os.environ["CLOUD_ID_TYPE"] is defined.

EdLeafe added a commit that referenced this issue Jun 4, 2013
@EdLeafe
Copy link
Contributor

EdLeafe commented Jun 4, 2013

OK, this should be fixed in 1.4.4. Please update and let me know if you have any further issues.

@EdLeafe EdLeafe closed this as completed Jun 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants