Skip to main content
 首页 » 编程设计

python之Openstack 中子 : How to update port vif-model using update_port() api

2025年05月04日14wayfarer

我想更新已创建端口的 vif_model。我在 CLI 中使用以下命令

neutron port-update --binding:vif_model=avp <port_id> 

如何使用 neutron 的 python api 实现相同的目的。 我正在尝试使用 update_port() api。但不确定参数。

>>> from neutronclient.neutron import client 
>>> neutron = client.Client('2.0', endpoint_url=neutron_endpoint, token=tok) 
>>> help(neutron.update_port) 

给出以下提示:

Help on function with_params in module neutronclient.v2_0.client:

with_params(*args, **kwargs)

请您参考如下方法:

我查看了 Nova source 中通常如何使用 update_port 调用的示例,看起来您会这样调用它:

client.update_port('1fe691a6-f3a0-4586-b126-9fabb11e962a', 
                   {'port':  
                     {'binding:vif_type': 'avp'}})