Search code examples
pythonopenstackopenstack-neutron

Openstack Neutron: How to update port vif-model using update_port() api


I wanted to update vif_model of already created port. I use following command in CLI

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

How to achieve the same using python apis of neutron. I'm trying to use update_port() api. But not sure about parameters.

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

gives below hint :

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

with_params(*args, **kwargs)


Solution

  • I looked at the Nova source for an example of how the update_port call is usually used, and it looks like you would call it something like this:

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