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


Python attributes.convert_to_int函数代码示例

本文整理汇总了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;未经允许,请勿转载。