如果可能,pyrax是否使用servicenet,还是应该手动设置?

时间:2014-01-17 20:00:49

标签: python rackspace-cloud cloudfiles pyrax

我正在使用pyrax来操作Rackspace云文件。 我可以强制pyrax使用servicenet而不是publicnet,还是自动选择?

在django-cumulus设置中我们有settings.CUMULUS['SERVICENET']参数来处理它,但我没有找到,如何将这个参数设置为pyrax本身。

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>)

我在哪里可以告诉pyrax使用servicenet?

1 个答案:

答案 0 :(得分:4)

在创建连接时将public设置为False

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

connect_to_cloudfiles上的文档:

  

创建用于处理云文件的客户端。默认是   连接到公共URL;如果您需要使用ServiceNet   连接,将False传递给'public'参数。

来源:pyrax/init.py, connect_to_files method