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

Python utils.is_port_trusted函数代码示例

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

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



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

示例1: _get_security_groups_on_port

    def _get_security_groups_on_port(self, context, port):
        """Check that all security groups on port belong to tenant.

        :returns: all security groups IDs on port belonging to tenant.
        """
        port = port['port']
        if not validators.is_attr_set(port.get(ext_sg.SECURITYGROUPS)):
            return
        if port.get('device_owner') and utils.is_port_trusted(port):
            return

        port_sg = port.get(ext_sg.SECURITYGROUPS, [])
        filters = {'id': port_sg}
        tenant_id = port.get('tenant_id')
        if tenant_id:
            filters['tenant_id'] = [tenant_id]
        valid_groups = set(g['id'] for g in
                           self.get_security_groups(context, fields=['id'],
                                                    filters=filters))

        requested_groups = set(port_sg)
        port_sg_missing = requested_groups - valid_groups
        if port_sg_missing:
            raise ext_sg.SecurityGroupNotFound(id=', '.join(port_sg_missing))

        return requested_groups
开发者ID:Lily913,项目名称:neutron,代码行数:26,代码来源:securitygroups_db.py


示例2: setup_arp_spoofing_protection

def setup_arp_spoofing_protection(vif, port_details):
    current_rules = ebtables(['-L']).splitlines()
    if not port_details.get('port_security_enabled', True):
        # clear any previous entries related to this port
        delete_arp_spoofing_protection([vif], current_rules)
        LOG.info(_LI("Skipping ARP spoofing rules for port '%s' because "
                     "it has port security disabled"), vif)
        return
    if utils.is_port_trusted(port_details):
        # clear any previous entries related to this port
        delete_arp_spoofing_protection([vif], current_rules)
        LOG.debug("Skipping ARP spoofing rules for network owned port "
                  "'%s'.", vif)
        return
    # collect all of the addresses and cidrs that belong to the port
    addresses = {f['ip_address'] for f in port_details['fixed_ips']}
    if port_details.get('allowed_address_pairs'):
        addresses |= {p['ip_address']
                      for p in port_details['allowed_address_pairs']}

    addresses = {ip for ip in addresses
                 if netaddr.IPNetwork(ip).version == 4}
    if any(netaddr.IPNetwork(ip).prefixlen == 0 for ip in addresses):
        # don't try to install protection because a /0 prefix allows any
        # address anyway and the ARP_SPA can only match on /1 or more.
        return

    install_arp_spoofing_protection(vif, addresses, current_rules)
开发者ID:Blahhhhh,项目名称:neutron,代码行数:28,代码来源:arp_protect.py


示例3: _validate_max_ips_per_port

    def _validate_max_ips_per_port(self, fixed_ip_list, device_owner):
        if common_utils.is_port_trusted({'device_owner': device_owner}):
            return

        if len(fixed_ip_list) > cfg.CONF.max_fixed_ips_per_port:
            msg = _('Exceeded maximum amount of fixed ips per port.')
            raise exc.InvalidInput(error_message=msg)
开发者ID:annp,项目名称:neutron,代码行数:7,代码来源:ipam_backend_mixin.py


示例4: _determine_port_security_and_has_ip

    def _determine_port_security_and_has_ip(self, context, port):
        """Returns a tuple of booleans (port_security_enabled, has_ip).

        Port_security is the value associated with the port if one is present
        otherwise the value associated with the network is returned. has_ip is
        if the port is associated with an ip or not.
        """
        has_ip = self._ip_on_port(port)
        # we don't apply security groups for dhcp, router
        if port.get('device_owner') and utils.is_port_trusted(port):
            return (False, has_ip)

        if validators.is_attr_set(port.get(psec.PORTSECURITY)):
            port_security_enabled = port[psec.PORTSECURITY]

        # If port has an ip and security_groups are passed in
        # conveniently set port_security_enabled to true this way
        # user doesn't also have to pass in port_security_enabled=True
        # when creating ports.
        elif has_ip and validators.is_attr_set(port.get('security_groups')):
            port_security_enabled = True
        else:
            port_security_enabled = self._get_network_security_binding(
                context, port['network_id'])

        return (port_security_enabled, has_ip)
开发者ID:21atlas,项目名称:neutron,代码行数:26,代码来源:portsecurity_db.py


示例5: _ensure_default_security_group_on_port

 def _ensure_default_security_group_on_port(self, context, port):
     # we don't apply security groups for dhcp, router
     port = port["port"]
     if port.get("device_owner") and utils.is_port_trusted(port):
         return
     default_sg = self._ensure_default_security_group(context, port["tenant_id"])
     if not validators.is_attr_set(port.get(ext_sg.SECURITYGROUPS)):
         port[ext_sg.SECURITYGROUPS] = [default_sg]
开发者ID:sebrandon1,项目名称:neutron,代码行数:8,代码来源:securitygroups_db.py


示例6: _ensure_default_security_group_on_port

 def _ensure_default_security_group_on_port(self, context, port):
     # we don't apply security groups for dhcp, router
     port = port['port']
     if port.get('device_owner') and utils.is_port_trusted(port):
         return
     tenant_id = self._get_tenant_id_for_create(context, port)
     default_sg = self._ensure_default_security_group(context, tenant_id)
     if not attributes.is_attr_set(port.get(ext_sg.SECURITYGROUPS)):
         port[ext_sg.SECURITYGROUPS] = [default_sg]
开发者ID:rajamony,项目名称:neutron,代码行数:9,代码来源:securitygroups_db.py


示例7: _determine_port_security

    def _determine_port_security(self, context, port):
        """Returns a boolean (port_security_enabled).

        Port_security is the value associated with the port if one is present
        otherwise the value associated with the network is returned.
        """
        if port.get('device_owner') and utils.is_port_trusted(port):
            return False

        if attr.is_attr_set(port.get(psec.PORTSECURITY)):
            port_security_enabled = port[psec.PORTSECURITY]
        else:
            port_security_enabled = self._get_network_security_binding(
                context, port['network_id'])

        return port_security_enabled
开发者ID:paperandsoap,项目名称:dragonflow,代码行数:16,代码来源:plugin.py


示例8: _get_devices_info

 def _get_devices_info(self, context, devices):
     return dict(
         (port['id'], port)
         for port in self.plugin.get_ports_from_devices(context, devices)
         if port and not utils.is_port_trusted(port)
     )
开发者ID:asgard-lab,项目名称:neutron,代码行数:6,代码来源:securitygroups_rpc.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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