• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python attributes.convert_to_int函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _convert_and_validate_segments

def _convert_and_validate_segments(segments, valid_values=None):
    for segment in segments:
        segment.setdefault(pnet.NETWORK_TYPE, attr.ATTR_NOT_SPECIFIED)
        segment.setdefault(pnet.PHYSICAL_NETWORK, attr.ATTR_NOT_SPECIFIED)
        segmentation_id = segment.get(pnet.SEGMENTATION_ID)
        if segmentation_id:
            segment[pnet.SEGMENTATION_ID] = attr.convert_to_int(
                segmentation_id)
        else:
            segment[pnet.SEGMENTATION_ID] = attr.ATTR_NOT_SPECIFIED
        if len(segment.keys()) != 3:
            msg = (_("Unrecognized attribute(s) '%s'") %
                   ', '.join(set(segment.keys()) -
                             set([pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
                                  pnet.SEGMENTATION_ID])))
            raise webob.exc.HTTPBadRequest(msg)
开发者ID:HoratiusTang,项目名称:neutron,代码行数:16,代码来源:multiprovidernet.py


示例2: _convert_and_validate_segments

def _convert_and_validate_segments(segments, valid_values=None):
    unique = set()
    for segment in segments:
        unique.add(tuple(segment.iteritems()))
        network_type = segment.get(pnet.NETWORK_TYPE, attr.ATTR_NOT_SPECIFIED)
        segment[pnet.NETWORK_TYPE] = network_type
        physical_network = segment.get(pnet.PHYSICAL_NETWORK, attr.ATTR_NOT_SPECIFIED)
        segment[pnet.PHYSICAL_NETWORK] = physical_network
        segmentation_id = segment.get(pnet.SEGMENTATION_ID)
        if segmentation_id:
            segment[pnet.SEGMENTATION_ID] = attr.convert_to_int(segmentation_id)
        else:
            segment[pnet.SEGMENTATION_ID] = attr.ATTR_NOT_SPECIFIED
        if len(segment.keys()) != 3:
            msg = _("Unrecognized attribute(s) '%s'") % ", ".join(
                set(segment.keys()) - set([pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK, pnet.SEGMENTATION_ID])
            )
            raise webob.exc.HTTPBadRequest(msg)
    if len(unique) != len(segments):
        raise SegmentsContainDuplicateEntry()
开发者ID:B-Rich,项目名称:neutron,代码行数:20,代码来源:multiprovidernet.py


示例3: convert_to_int_if_needed

def convert_to_int_if_needed(value):
    if not value or value is attr.ATTR_NOT_SPECIFIED:
        return value
    else:
        return attr.convert_to_int(value)
开发者ID:Vikash082,项目名称:group-based-policy,代码行数:5,代码来源:group_policy.py


示例4: test_convert_to_int_str

 def test_convert_to_int_str(self):
     self.assertEqual(4, attributes.convert_to_int('4'))
     self.assertEqual(6, attributes.convert_to_int('6'))
     self.assertRaises(n_exc.InvalidInput,
                       attributes.convert_to_int,
                       'garbage')
开发者ID:glove747,项目名称:liberty-neutron,代码行数:6,代码来源:test_attributes.py


示例5: test_convert_to_int_int

 def test_convert_to_int_int(self):
     self.assertEqual(-1, attributes.convert_to_int(-1))
     self.assertEqual(0, attributes.convert_to_int(0))
     self.assertEqual(1, attributes.convert_to_int(1))
开发者ID:glove747,项目名称:liberty-neutron,代码行数:4,代码来源:test_attributes.py


示例6: test_convert_to_int_int

 def test_convert_to_int_int(self):
     self.assertEqual(attributes.convert_to_int(-1), -1)
     self.assertEqual(attributes.convert_to_int(0), 0)
     self.assertEqual(attributes.convert_to_int(1), 1)
开发者ID:VeenaSL,项目名称:sriov,代码行数:4,代码来源:test_attributes.py


示例7: test_convert_to_int_str

 def test_convert_to_int_str(self):
     self.assertEqual(4, attributes.convert_to_int("4"))
     self.assertEqual(6, attributes.convert_to_int("6"))
     self.assertRaises(n_exc.InvalidInput, attributes.convert_to_int, "garbage")
开发者ID:manjeetbhatia,项目名称:test_l3,代码行数:4,代码来源:test_attributes.py


示例8: TODO

         'allow_post': False, 'allow_put': False,
         'validate': {'type:uuid_or_none': None}, 'is_visible': True,
         'enforce_policy': True},
     # TODO(ivar): The APIs should allow the creation of a group with a
     # custom subnet prefix length. It may be useful for both the proxy
     # groups and traditional ones.
 },
 gp.L3_POLICIES: {
     'proxy_ip_pool': {'allow_post': True, 'allow_put': False,
                       'validate': {'type:subnet': None},
                       'default': PROXY_CONF.default_proxy_ip_pool,
                       'is_visible': True},
     'proxy_subnet_prefix_length': {
         'allow_post': True, 'allow_put': True,
         'convert_to': attr.convert_to_int,
         'default': attr.convert_to_int(
             PROXY_CONF.default_proxy_subnet_prefix_length),
         'is_visible': True},
     # Proxy IP version is the same as the standard L3 pool ip version
 },
 gp.POLICY_TARGETS: {
     # This policy target will be used to reach the -proxied- PTG
     'proxy_gateway': {
         'allow_post': True, 'allow_put': False, 'default': False,
         'convert_to': attr.convert_to_boolean,
         'is_visible': True, 'required_by_policy': True,
         'enforce_policy': True},
     # This policy target is the default gateway for the -current- PTG
     # Only for internal use.
     'group_default_gateway': {
         'allow_post': True, 'allow_put': False, 'default': False,
         'convert_to': attr.convert_to_boolean,
开发者ID:anilgkurian,项目名称:group-based-policy,代码行数:32,代码来源:driver_proxy_group.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python attributes.convert_to_list函数代码示例发布时间:2022-05-27
下一篇:
Python attributes.convert_to_boolean函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap