当前位置: 首页>>代码示例>>Python>>正文


Python pyos.set_credential_file函数代码示例

本文整理汇总了Python中pyos.set_credential_file函数的典型用法代码示例。如果您正苦于以下问题:Python set_credential_file函数的具体用法?Python set_credential_file怎么用?Python set_credential_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了set_credential_file函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_set_credential_file

 def test_set_credential_file(self):
     with utils.SelfDeletingTempfile() as tmpname:
         with open(tmpname, "wb") as tmp:
             tmp.write("[keystone]\n")
             tmp.write("username = %s\n" % self.username)
             tmp.write("password = %s\n" % self.password)
             tmp.write("tenant_id = %s\n" % self.tenant_id)
         pyos.set_credential_file(tmpname)
         self.assertEqual(pyos.identity.username, self.username)
         self.assertEqual(pyos.identity.password, self.password)
         self.assertTrue(pyos.identity.authenticated)
开发者ID:emonty,项目名称:pyos,代码行数:11,代码来源:test_module.py

示例2: in

#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from __future__ import print_function

import os
import pyos

pyos.set_setting("identity_type", "rackspace")
creds_file = os.path.expanduser("~/.rackspace_cloud_credentials")
pyos.set_credential_file(creds_file)
cbs = pyos.cloud_blockstorage

# This assumes that you have are deleting the volumes named 'my_fast_volume'
# and 'my_standard_volume' that were created in create_volume.py.
for nm in ("my_fast_volume", "my_standard_volume"):
    try:
        vol = cbs.findall(name=nm)[0]
    except IndexError:
        print("There is no volume named '%s'. Skipping..." % nm)
        vol = None
    if vol:
        print("Deleting", vol)
        vol.delete()
print()
print("Done.")
开发者ID:emonty,项目名称:pyos,代码行数:31,代码来源:delete_volume.py

示例3: setUp

 def setUp(self):
     pyos.set_credential_file(creds_file)
开发者ID:emonty,项目名称:pyos,代码行数:2,代码来源:test_module.py


注:本文中的pyos.set_credential_file函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。