Fixed ip assignment using --nic parameter doesn't work

Bug #1046358 reported by Nevon Brake
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
In Progress
High
Akihiro Motoki

Bug Description

Using the latest devstack on master, I tried to assign a fixed ip using the v4-fixed-ip option in the --nic parameter of the nova boot command, but the address is assigned using the automatic allocation instead.

Looking at the code it seems the Quantum api call in Nova doesn't pass the parameter correctly.

nova/nova/network/quantumv2/api.py (line 127):
port_req_body['port']['fixed_ip'] = fixed_ip

Based on the way Quantum uses the port request body, I think this should be:

port_req_body['port']['fixed_ips'] = [{'ip_address':fixed_ip}]

Works as expected after I made this change.

Nevon Brake (nevonb)
description: updated
Nevon Brake (nevonb)
summary: - Fixed ip assigned using --nic parameter doesn't work
+ Fixed ip assignment using --nic parameter doesn't work
Revision history for this message
Vish Ishaya (vishvananda) wrote :

seems reasonable. Assigned to dan to verify if the fix is correct.

Changed in nova:
assignee: nobody → dan wendlandt (danwent)
importance: Undecided → High
status: New → Triaged
Revision history for this message
dan wendlandt (danwent) wrote :

Yes, this should work.

We actually intentionally did not implement this in the code, as we have another model for doing the same thing: rather than telling nova all of the network config you want, you create a quantum port with a particular config (e.g., IP address, etc.), and then pass that port in when booting a VM using --nic port=id=XYZ. The goal here is that we didn't want the set of options that you pass to --nic to explode to include everything that quantum will support in the future. That would be a mess for the nova folks.

Given that nova already supported to the v4-fixed-ip flag pre-quantum, there's a reasonable argument that we should try and support that flag just for backward compat.

Revision history for this message
dan wendlandt (danwent) wrote :

Note: one other thing you should do to make this patch "correct" was that you should update the def validate_networks() method to make sure that this IP address is valid for the network, and has not already been allocated. the validate_networks() method is called by the API layer to confirm that the params passed into the network are valid. This lets us return a 400 if the network data is invalid. If you don't do this, the VM boot API call will "succeed", but the VM will end up in error state when the compute layer later calls allocate_for_instance and reaches out to Quantum.

Revision history for this message
Nevon Brake (nevonb) wrote :

There's also some unit test code to be fixed. Did you want me to put together a patch with the fix, validation and test changes?

Revision history for this message
dan wendlandt (danwent) wrote :

I'd be happy to review and test. It sounds like Vish is up for accepting it.

Revision history for this message
Nevon Brake (nevonb) wrote :

I have a patch for this, but waiting on internal CCLA approval before I can submit for review.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/13881

Changed in nova:
assignee: dan wendlandt (danwent) → Nevon Brake (nevonb)
status: Triaged → In Progress
Changed in nova:
assignee: Nevon Brake (nevonb) → Akihiro Motoki (amotoki)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.