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


Python portbindings.VNIC_TYPE属性代码示例

本文整理汇总了Python中neutron_lib.api.definitions.portbindings.VNIC_TYPE属性的典型用法代码示例。如果您正苦于以下问题:Python portbindings.VNIC_TYPE属性的具体用法?Python portbindings.VNIC_TYPE怎么用?Python portbindings.VNIC_TYPE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在neutron_lib.api.definitions.portbindings的用法示例。


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

示例1: logical_port_from_neutron_port

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def logical_port_from_neutron_port(port):
    return l2.LogicalPort(
        id=port['id'],
        lswitch=port['network_id'],
        topic=utils.get_obj_topic(port),
        macs=[port['mac_address']],
        ips=[ip['ip_address'] for ip in port.get('fixed_ips', [])],
        subnets=[ip['subnet_id'] for ip in port.get('fixed_ips', [])],
        name=port.get('name'),
        enabled=port.get('admin_state_up', False),
        version=port['revision_number'],
        device_owner=port.get('device_owner'),
        device_id=port.get('device_id'),
        security_groups=port.get('security_groups', []),
        port_security_enabled=port.get(psec.PORTSECURITY, False),
        allowed_address_pairs=_validate_ip_prefix_allowed_address_pairs(
            port.get(addr_apidef.ADDRESS_PAIRS, [])),
        binding_vnic_type=port.get(portbindings.VNIC_TYPE),
        qos_policy=port.get('qos_policy_id'),
        dhcp_params=_build_dhcp_params(port),
        binding=build_port_binding(port),
    ) 
开发者ID:openstack,项目名称:dragonflow,代码行数:24,代码来源:l2.py

示例2: test_bind_port_unsupported_vnic_type

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def test_bind_port_unsupported_vnic_type(self):
        network = mock.MagicMock(spec=api.NetworkContext)
        port_context = mock.MagicMock(
            spec=ctx.PortContext,
            current={'id': 'CURRENT_CONTEXT_ID',
                     portbindings.VNIC_TYPE: portbindings.VNIC_DIRECT},
            segments_to_bind=[self.valid_segment, self.invalid_segment],
            network=network)

        mgr = legacy_port_binding.LegacyPortBindingManager()
        mgr.bind_port(port_context)
        port_context.set_binding.assert_not_called() 
开发者ID:openstack,项目名称:networking-odl,代码行数:14,代码来源:test_legacy_port_binding.py

示例3: _fake_port_context

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def _fake_port_context(self, fake_segments, host_agents=None):
        network = mock.MagicMock(spec=api.NetworkContext)
        return mock.MagicMock(
            spec=ctx.PortContext,
            current={'id': 'PORTID',
                     portbindings.VNIC_TYPE: portbindings.VNIC_NORMAL},
            segments_to_bind=fake_segments, network=network,
            host_agents=lambda agent_type: host_agents,
            _plugin_context=mock.MagicMock()
        ) 
开发者ID:openstack,项目名称:networking-odl,代码行数:12,代码来源:test_pseudo_agentdb_binding.py

示例4: bind_port

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def bind_port(self, port_context):
        """Set binding for all valid segments

        """
        vnic_type = port_context.current.get(portbindings.VNIC_TYPE,
                                             portbindings.VNIC_NORMAL)
        if vnic_type not in self.supported_vnic_types:
            LOG.debug("Refusing to bind due to unsupported vnic_type: %s",
                      vnic_type)
            return

        valid_segment = None
        for segment in port_context.segments_to_bind:
            if self._check_segment(segment):
                valid_segment = segment
                break

        if valid_segment:
            vif_type = self._get_vif_type(port_context)
            LOG.debug("Bind port %(port)s on network %(network)s with valid "
                      "segment %(segment)s and VIF type %(vif_type)r.",
                      {'port': port_context.current['id'],
                       'network': port_context.network.current['id'],
                       'segment': valid_segment, 'vif_type': vif_type})

            port_context.set_binding(
                valid_segment[api.ID], vif_type,
                self.vif_details,
                status=n_const.PORT_STATUS_ACTIVE) 
开发者ID:openstack,项目名称:networking-odl,代码行数:31,代码来源:legacy_port_binding.py

示例5: _is_port_supported

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def _is_port_supported(port):
        """Return whether a port is supported by this driver.

        Ports supported by this driver have a VNIC type of 'baremetal'.

        :param port: The port to check
        :returns: Whether the port is supported by the NGS driver
        """
        vnic_type = port[portbindings.VNIC_TYPE]
        return vnic_type == portbindings.VNIC_BAREMETAL 
开发者ID:openstack,项目名称:networking-generic-switch,代码行数:12,代码来源:generic_switch_mech.py

示例6: _update_port_binding

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def _update_port_binding(self, port_res):
        port_res[portbindings.VNIC_TYPE] = portbindings.VNIC_NORMAL
        if cfg.CONF.df.vif_type == portbindings.VIF_TYPE_VHOST_USER:
            port_res[portbindings.VIF_DETAILS].update({
                portbindings.VHOST_USER_SOCKET: df_utils.get_vhu_sockpath(
                    cfg.CONF.df.vhost_sock_dir, port_res['id']
                )
            }) 
开发者ID:openstack,项目名称:dragonflow,代码行数:10,代码来源:mech_driver.py

示例7: _process_portbindings_create_and_update

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def _process_portbindings_create_and_update(self, context, port_data,
                                                port):
        binding_profile = port.get(portbindings.PROFILE)
        binding_profile_set = validators.is_attr_set(binding_profile)
        if not binding_profile_set and binding_profile is not None:
            del port[portbindings.PROFILE]

        binding_vnic = port.get(portbindings.VNIC_TYPE)
        binding_vnic_set = validators.is_attr_set(binding_vnic)
        if not binding_vnic_set and binding_vnic is not None:
            del port[portbindings.VNIC_TYPE]

        host = port_data.get(portbindings.HOST_ID)
        host_set = validators.is_attr_set(host)
        with context.session.begin(subtransactions=True):
            bind_port = context.session.query(
                models.PortBinding).filter_by(port_id=port['id']).first()
            if host_set:
                if not bind_port:
                    context.session.add(models.PortBinding(
                        port_id=port['id'],
                        host=host,
                        vif_type=self.vif_type))
                else:
                    bind_port.host = host
            else:
                host = bind_port.host if bind_port else None
        self._extend_port_dict_binding_host(port, host) 
开发者ID:openstack,项目名称:dragonflow,代码行数:30,代码来源:mech_driver.py

示例8: can_port_be_bound_to_virtual_bridge

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def can_port_be_bound_to_virtual_bridge(port):
    """Returns if port can be bound to a virtual bridge (e.g.: LB, OVS)

    :param port: (dict) A port dictionary.
    :returns: True if the port VNIC type is 'normal'; False in any other case.
    """
    return port[pb.VNIC_TYPE] == pb.VNIC_NORMAL 
开发者ID:openstack,项目名称:neutron-lib,代码行数:9,代码来源:utils.py

示例9: _hconfig_bind_port

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def _hconfig_bind_port(self, port_context, hconfig):
        """bind port after validating odl host configuration."""
        valid_segment = None

        for segment in port_context.segments_to_bind:
            if self._is_valid_segment(segment, hconfig['configurations']):
                valid_segment = segment
                break
        else:
            LOG.debug("No valid segments found!")
            return False

        confs = hconfig['configurations']['supported_vnic_types']

        # nova provides vnic_type in port_context to neutron.
        # neutron provides supported vif_type for binding based on vnic_type
        # in this case ODL hostconfigs has the vif_type to bind for vnic_type
        vnic_type = port_context.current.get(portbindings.VNIC_TYPE)

        vif_details = None
        for conf in confs:
            if conf["vnic_type"] == vnic_type:
                vif_type = conf.get('vif_type', portbindings.VIF_TYPE_OVS)
                LOG.debug("Binding vnic:'%s' to vif:'%s'", vnic_type, vif_type)
                vif_details = conf.get('vif_details', {})
                break
        else:
            LOG.error(
                "Binding failed: unsupported VNIC %(vnic_type)s on %(host)s",
                {'vnic_type': vnic_type, 'host': port_context.host})
            return False

        if not vif_details:  # empty vif_details could be trouble, warn.
            LOG.warning("hostconfig:vif_details was empty!")

        LOG.debug("Bind port %(port)s on network %(network)s with valid "
                  "segment %(segment)s and VIF type %(vif_type)r "
                  "VIF details %(vif_details)r.",
                  {'port': port_context.current['id'],
                   'network': port_context.network.current['id'],
                   'segment': valid_segment, 'vif_type': vif_type,
                   'vif_details': vif_details})

        port_status = self._prepare_initial_port_status(port_context)
        port_context.set_binding(valid_segment[api.ID], vif_type,
                                 vif_details, status=port_status)

        return True 
开发者ID:openstack,项目名称:networking-odl,代码行数:50,代码来源:pseudo_agentdb_binding.py

示例10: create

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def create(self, context, loadbalancer):
        """Create a loadbalancer."""
        driver = self.driver
        self.loadbalancer = loadbalancer
        try:
            agent, service = self._schedule_agent_create_service(context)
            agent_host = agent['host']
            agent_config = agent.get('configurations', {})
            LOG.debug("agent configurations: %s" % agent_config)

            scheduler = self.driver.scheduler
            agent_config_dict = \
                scheduler.deserialize_agent_configurations(agent_config)

            if not agent_config_dict.get('nova_managed', False):
                # Update the port for the VIP to show ownership by this driver
                port_data = {
                    'admin_state_up': True,
                    'device_owner': 'network:f5lbaasv2',
                    'status': q_const.PORT_STATUS_ACTIVE
                }
                port_data[portbindings.HOST_ID] = agent_host
                if driver.unlegacy_setting_placeholder_driver_side:
                    LOG.debug('setting to normal')
                    port_data[portbindings.VNIC_TYPE] = "normal"
                else:
                    LOG.debug('setting to baremetal')
                    port_data[portbindings.VNIC_TYPE] = "baremetal"
                port_data[portbindings.PROFILE] = {}
                driver.plugin.db._core_plugin.update_port(
                    context,
                    loadbalancer.vip_port_id,
                    {'port': port_data}
                )
                # agent, service = self._schedule_agent_create_service(context)
                if driver.unlegacy_setting_placeholder_driver_side:
                    LOG.debug('calling extra build():')
                    service = self.driver.service_builder.build(
                        context, self.loadbalancer, agent)
            else:
                LOG.debug("Agent devices are nova managed")

            driver.agent_rpc.create_loadbalancer(
                context, loadbalancer.to_api_dict(), service, agent_host)

        except (lbaas_agentschedulerv2.NoEligibleLbaasAgent,
                lbaas_agentschedulerv2.NoActiveLbaasAgent) as e:
            LOG.error("Exception: loadbalancer create: %s" % e)
            driver.plugin.db.update_status(
                context,
                models.LoadBalancer,
                loadbalancer.id,
                plugin_constants.ERROR)
        except Exception as e:
            LOG.error("Exception: loadbalancer create: %s" % e.message)
            raise e 
开发者ID:F5Networks,项目名称:f5-openstack-lbaasv2-driver,代码行数:58,代码来源:driver_v2.py

示例11: create_port_on_network

# 需要导入模块: from neutron_lib.api.definitions import portbindings [as 别名]
# 或者: from neutron_lib.api.definitions.portbindings import VNIC_TYPE [as 别名]
def create_port_on_network(self, context, network_id=None,
                               mac_address=None, name=None, host=None,
                               device_id=None,
                               vnic_type=portbindings.VNIC_NORMAL,
                               binding_profile={}):
        """Create a port on a network."""
        ports = []
        if network_id and name:
            filters = {'name': [name]}
            ports = self.driver.plugin.db._core_plugin.get_ports(
                context,
                filters=filters
            )

        if not ports:
            network = self.driver.plugin.db._core_plugin.get_network(
                context,
                network_id
            )

            if not mac_address:
                mac_address = neutron_const.ATTR_NOT_SPECIFIED
            if not host:
                host = ''
            if not name:
                name = ''

            port_data = {
                'tenant_id': network['tenant_id'],
                'name': name,
                'network_id': network_id,
                'mac_address': mac_address,
                'admin_state_up': True,
                'device_owner': 'network:f5lbaasv2',
                'status': neutron_const.PORT_STATUS_ACTIVE,
                'fixed_ips': neutron_const.ATTR_NOT_SPECIFIED
            }
            if device_id:
                port_data['device_id'] = device_id
            port_data[portbindings.HOST_ID] = host
            port_data[portbindings.VNIC_TYPE] = vnic_type
            port_data[portbindings.PROFILE] = binding_profile

            port = self.driver.plugin.db._core_plugin.create_port(
                context, {'port': port_data})
            # Because ML2 marks ports DOWN by default on creation
            update_data = {
                'status': neutron_const.PORT_STATUS_ACTIVE
            }
            self.driver.plugin.db._core_plugin.update_port(
                context, port['id'], {'port': update_data})
            return port

        else:
            return ports[0]

    # return a single active agent to implement cluster wide changes
    # which can not efficiently mapped back to a particulare agent 
开发者ID:F5Networks,项目名称:f5-openstack-lbaasv2-driver,代码行数:60,代码来源:plugin_rpc.py


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