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

Python utils.is_valid_vlan_tag函数代码示例

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

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



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

示例1: _validate_network_mapping_info

 def _validate_network_mapping_info(self, network_mapping_info):
     self._set_mapping_info_defaults(network_mapping_info)
     network_id = network_mapping_info.get(NETWORK_ID)
     if not network_id:
         raise exceptions.InvalidInput(
             error_message=_("A network identifier must be specified "
                             "when connecting a network to a network "
                             "gateway. Unable to complete operation"))
     connection_attrs = set(network_mapping_info.keys())
     if not connection_attrs.issubset(ALLOWED_CONNECTION_ATTRIBUTES):
         raise exceptions.InvalidInput(
             error_message=(_("Invalid keys found among the ones provided "
                              "in request body: %(connection_attrs)s."),
                            connection_attrs))
     seg_type = network_mapping_info.get(SEGMENTATION_TYPE)
     seg_id = network_mapping_info.get(SEGMENTATION_ID)
     # The NSX plugin accepts 0 as a valid vlan tag
     seg_id_valid = seg_id == 0 or utils.is_valid_vlan_tag(seg_id)
     if seg_type.lower() == 'flat' and seg_id:
         msg = _("Cannot specify a segmentation id when "
                 "the segmentation type is flat")
         raise exceptions.InvalidInput(error_message=msg)
     elif (seg_type.lower() == 'vlan' and not seg_id_valid):
         msg = _("Invalid segmentation id (%d) for "
                 "vlan segmentation type") % seg_id
         raise exceptions.InvalidInput(error_message=msg)
     return network_id
开发者ID:gkotton,项目名称:vmware-nsx-1,代码行数:27,代码来源:networkgw_db.py


示例2: validate_provider_segment

    def validate_provider_segment(self, segment):
        physical_network = segment.get(api.PHYSICAL_NETWORK)
        if not physical_network:
            msg = _("physical_network required for VLAN provider network")
            raise exc.InvalidInput(error_message=msg)
        if physical_network not in self.network_vlan_ranges:
            msg = (_("physical_network '%s' unknown for VLAN provider network")
                   % physical_network)
            raise exc.InvalidInput(error_message=msg)

        segmentation_id = segment.get(api.SEGMENTATION_ID)
        if segmentation_id is None:
            msg = _("segmentation_id required for VLAN provider network")
            raise exc.InvalidInput(error_message=msg)
        if not utils.is_valid_vlan_tag(segmentation_id):
            msg = (_("segmentation_id out of range (%(min)s through "
                     "%(max)s)") %
                   {'min': q_const.MIN_VLAN_TAG,
                    'max': q_const.MAX_VLAN_TAG})
            raise exc.InvalidInput(error_message=msg)

        for key, value in segment.items():
            if value and key not in [api.NETWORK_TYPE,
                                     api.PHYSICAL_NETWORK,
                                     api.SEGMENTATION_ID]:
                msg = _("%s prohibited for VLAN provider network") % key
                raise exc.InvalidInput(error_message=msg)
开发者ID:50infivedays,项目名称:neutron,代码行数:27,代码来源:type_vlan.py


示例3: _process_provider_create

    def _process_provider_create(self, context, attrs):
        network_type = attrs.get(provider.NETWORK_TYPE)
        physical_network = attrs.get(provider.PHYSICAL_NETWORK)
        segmentation_id = attrs.get(provider.SEGMENTATION_ID)

        network_type_set = attributes.is_attr_set(network_type)
        physical_network_set = attributes.is_attr_set(physical_network)
        segmentation_id_set = attributes.is_attr_set(segmentation_id)

        if not (network_type_set or physical_network_set or segmentation_id_set):
            return (None, None, None)

        if not network_type_set:
            msg = _("provider:network_type required")
            raise q_exc.InvalidInput(error_message=msg)
        elif network_type == constants.TYPE_FLAT:
            if segmentation_id_set:
                msg = _("provider:segmentation_id specified for flat network")
                raise q_exc.InvalidInput(error_message=msg)
            else:
                segmentation_id = constants.FLAT_VLAN_ID
        elif network_type == constants.TYPE_VLAN:
            if not segmentation_id_set:
                msg = _("provider:segmentation_id required")
                raise q_exc.InvalidInput(error_message=msg)
            if not utils.is_valid_vlan_tag(segmentation_id):
                msg = _("provider:segmentation_id out of range " "(%(min_id)s through %(max_id)s)") % {
                    "min_id": q_const.MIN_VLAN_TAG,
                    "max_id": q_const.MAX_VLAN_TAG,
                }
                raise q_exc.InvalidInput(error_message=msg)
        elif network_type == constants.TYPE_LOCAL:
            if physical_network_set:
                msg = _("provider:physical_network specified for local " "network")
                raise q_exc.InvalidInput(error_message=msg)
            else:
                physical_network = None
            if segmentation_id_set:
                msg = _("provider:segmentation_id specified for local " "network")
                raise q_exc.InvalidInput(error_message=msg)
            else:
                segmentation_id = constants.LOCAL_VLAN_ID
        else:
            msg = _("provider:network_type %s not supported") % network_type
            raise q_exc.InvalidInput(error_message=msg)

        if network_type in [constants.TYPE_VLAN, constants.TYPE_FLAT]:
            if physical_network_set:
                if physical_network not in self.network_vlan_ranges:
                    msg = _("Unknown provider:physical_network %s") % physical_network
                    raise q_exc.InvalidInput(error_message=msg)
            elif "default" in self.network_vlan_ranges:
                physical_network = "default"
            else:
                msg = _("provider:physical_network required")
                raise q_exc.InvalidInput(error_message=msg)

        return (network_type, physical_network, segmentation_id)
开发者ID:sukhdevkapur,项目名称:neutron,代码行数:58,代码来源:lb_neutron_plugin.py


示例4: verify_vlan_range

def verify_vlan_range(vlan_range):
    """Raise an exception for invalid tags or malformed range."""
    for vlan_tag in vlan_range:
        if not utils.is_valid_vlan_tag(vlan_tag):
            raise n_exc.NetworkVlanRangeError(vlan_range=vlan_range, error=_("%s is not a valid VLAN tag") % vlan_tag)
    if vlan_range[1] < vlan_range[0]:
        raise n_exc.NetworkVlanRangeError(
            vlan_range=vlan_range, error=_("End of VLAN range is less than start of VLAN range")
        )
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:9,代码来源:utils.py


示例5: _process_provider_create

    def _process_provider_create(self, context, attrs):
        network_type = attrs.get(provider.NETWORK_TYPE)
        physical_network = attrs.get(provider.PHYSICAL_NETWORK)
        segmentation_id = attrs.get(provider.SEGMENTATION_ID)

        network_type_set = attributes.is_attr_set(network_type)
        physical_network_set = attributes.is_attr_set(physical_network)
        segmentation_id_set = attributes.is_attr_set(segmentation_id)

        if not (network_type_set or physical_network_set or
                segmentation_id_set):
            return (None, None, None)

        if not network_type_set:
            msg = _("provider:network_type required")
            raise n_exc.InvalidInput(error_message=msg)
        elif network_type == svc_constants.TYPE_FLAT:
            if segmentation_id_set:
                msg = _("provider:segmentation_id specified for flat network")
                raise n_exc.InvalidInput(error_message=msg)
            else:
                segmentation_id = None
        elif network_type == svc_constants.TYPE_VLAN:
            if not segmentation_id_set:
                msg = _("provider:segmentation_id required")
                raise n_exc.InvalidInput(error_message=msg)
            if not utils.is_valid_vlan_tag(segmentation_id):
                msg = (_("provider:segmentation_id out of range "
                         "(%(min_id)s through %(max_id)s)") %
                       {'min_id': constants.MIN_VLAN_TAG,
                        'max_id': constants.MAX_VLAN_TAG})
                raise n_exc.InvalidInput(error_message=msg)
        elif network_type == svc_constants.TYPE_LOCAL:
            if physical_network_set:
                msg = _("provider:physical_network specified for local "
                        "network")
                raise n_exc.InvalidInput(error_message=msg)
            else:
                physical_network = None
            if segmentation_id_set:
                msg = _("provider:segmentation_id specified for local "
                        "network")
                raise n_exc.InvalidInput(error_message=msg)
            else:
                segmentation_id = None
        else:
            if not segmentation_id_set:
                segmentation_id = None
            if not physical_network_set:
                physical_network = None

        return network_type, physical_network, segmentation_id
开发者ID:msagheer,项目名称:networking-plumgrid,代码行数:52,代码来源:plugin.py


示例6: _validate_network_mapping_info

 def _validate_network_mapping_info(self, network_mapping_info):
     self._set_mapping_info_defaults(network_mapping_info)
     network_id = network_mapping_info.get(NETWORK_ID)
     if not network_id:
         raise exceptions.InvalidInput(
             error_message=_(
                 "A network identifier must be specified "
                 "when connecting a network to a network "
                 "gateway. Unable to complete operation"
             )
         )
     connection_attrs = set(network_mapping_info.keys())
     if not connection_attrs.issubset(ALLOWED_CONNECTION_ATTRIBUTES):
         raise exceptions.InvalidInput(
             error_message=(
                 _("Invalid keys found among the ones provided " "in request body: %(connection_attrs)s."),
                 connection_attrs,
             )
         )
     seg_type = network_mapping_info.get(SEGMENTATION_TYPE)
     seg_id = network_mapping_info.get(SEGMENTATION_ID)
     # It is important to validate that the segmentation ID is actually an
     # integer value
     try:
         seg_id = int(seg_id)
     except ValueError:
         msg = _(
             "An invalid segmentation ID was specified. The " "segmentation ID must be a positive integer number"
         )
         raise exceptions.InvalidInput(error_message=msg)
     # The NSX plugin accepts 0 as a valid vlan tag
     seg_id_valid = seg_id == 0 or utils.is_valid_vlan_tag(seg_id)
     if seg_type.lower() == "flat" and seg_id:
         msg = _("Cannot specify a segmentation id when " "the segmentation type is flat")
         raise exceptions.InvalidInput(error_message=msg)
     elif seg_type.lower() == "vlan" and not seg_id_valid:
         msg = _("Invalid segmentation id (%s) for " "vlan segmentation type") % seg_id
         raise exceptions.InvalidInput(error_message=msg)
     return network_id
开发者ID:kongseokhwan,项目名称:kulcloud-neutron,代码行数:39,代码来源:networkgw_db.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.log_opt_values函数代码示例发布时间:2022-05-27
下一篇:
Python utils.is_port_trusted函数代码示例发布时间: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