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


Python pyos.set_setting函数代码示例

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


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

示例1: test_set_region_setting

 def test_set_region_setting(self):
     ident = pyos.identity
     ident.region = "DFW"
     pyos.set_setting("region", "ORD")
     self.assertEqual(ident.region, "DFW")
     pyos.set_setting("region", "LON")
     self.assertEqual(ident.region, "LON")
开发者ID:emonty,项目名称:pyos,代码行数:7,代码来源:test_module.py

示例2: test_connect_to_cloudfiles_ServiceNet

 def test_connect_to_cloudfiles_ServiceNet(self):
     orig = pyos.get_setting("use_servicenet")
     pyos.set_setting("use_servicenet", True)
     pyos.cloudfiles = None
     pyos.connect_to_cloudfiles = self.orig_connect_to_cloudfiles
     sav = pyos._create_client
     pyos._create_client = Mock()
     cf = pyos.connect_to_cloudfiles(public=False)
     pyos._create_client.assert_called_once_with(ep_name="object_store",
             region=None, public=False)
     pyos.set_setting("use_servicenet", orig)
     pyos._create_client = sav
开发者ID:emonty,项目名称:pyos,代码行数:12,代码来源:test_module.py

示例3: test_safe_region

 def test_safe_region(self):
     # Pass direct
     reg = utils.random_unicode()
     ret = pyos._safe_region(reg)
     self.assertEqual(reg, ret)
     # From config setting
     orig_reg = pyos.get_setting("region")
     reg = utils.random_unicode()
     pyos.set_setting("region", reg)
     ret = pyos._safe_region()
     self.assertEqual(reg, ret)
     # Identity default
     pyos.set_setting("region", None)
     orig_defreg = pyos.identity.get_default_region
     reg = utils.random_unicode()
     pyos.identity.get_default_region = Mock(return_value=reg)
     ret = pyos._safe_region()
     self.assertEqual(reg, ret)
     pyos.identity.get_default_region = orig_defreg
     pyos.set_setting("region", orig_reg)
开发者ID:emonty,项目名称:pyos,代码行数:20,代码来源:test_module.py

示例4: in

#    a copy of the License at
#
#         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()
开发者ID:emonty,项目名称:pyos,代码行数:31,代码来源:delete_volume.py


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