How to attach an interface to an instance with the openstack client?

According to the OpenStack docs the individual clients are deprecated in favor for the openstack client.

The following individual clients are deprecated in favor of a common client. (source)

So I started using the openstack client. With the nova client, I could attach interfaces to instances after their creation with nova interface-attach --port-id $PID <Nova instance name>. I wonder how this is possible with the openstack client?

There is port set --device-owner and port set --device, but they doesn't seem to work properly.


Solution 1:

I also wanted to do this and eventually found openstack server add port $SERVERNAME $PORTUUID works with latest python-openstack. See here for documentation.

But I really just wanted to do this during instance creation and discovered you can also add multiple interfaces with specified IP addresses using the --nic option to server create, like: openstack server create --network Net1 --nic net-id=$NET2_UUID,v4-fixed-ip=$IPADDRESS ....

Hope this helps someone else from doing the same research.