简体   繁体   中英

Does pyrax use servicenet if it's possible, or should I set it manually?

I'm using pyrax to manipulate Rackspace Cloud Files. Can I force pyrax to use servicenet instead of publicnet, or is it choosen automatically?

In django-cumulus settings we have settings.CUMULUS['SERVICENET'] parameter to handle it, but I didn't found, how to set this param to pyrax itself.

import pyrax

cls = pyrax.utils.import_class('pyrax.identity.rax_identity.RaxIdentity')
pyrax.identity = cls()
pyrax.set_setting('region', <REGION>)
pyrax.set_credentials(<USERNAME>, <API_KEY>)
cf = pyrax.cloudfiles
rackspace_media_container = cf.get_container(<CONTAINER>)

Where can I tell pyrax to use servicenet?

Set public to False when creating the connection, explicitly:

cf = pyrax.connect_to_cloudfiles(region=<REGION>, public=False)

Documentation on connect_to_cloudfiles :

Creates a client for working with cloud files. The default is to connect to the public URL; if you need to work with the ServiceNet connection, pass False to the 'public' parameter.

Source: pyrax/ init .py, connect_to_files method .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM