[Openstack] how to decide orders of multiple nic

Vishvananda Ishaya vishvananda at gmail.com
Fri Nov 9 21:02:12 UTC 2012


The api doesn't support any way to order these, so they are being returned in db order. In essex we retrieved each network individually, but now they are retrieved together. I believe the following will fix your issue:

diff --git a/nova/network/manager.py b/nova/network/manager.py
index d032fe1..4866803 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -1797,8 +1797,10 @@ class NetworkManager(manager.SchedulerDependentManager):
                                    project_only="allow_none")
 
     def _get_networks_by_uuids(self, context, network_uuids):
-        return self.db.network_get_all_by_uuids(context, network_uuids,
-                                                project_only="allow_none")
+        networks = self.db.network_get_all_by_uuids(context, network_uuids,
+                                                    project_only="allow_none")
+        networks.sort(key=lambda x: network_uuids.index(x['uuid']))
+        return networks
 
     @wrap_check_policy
     def get_vifs_by_instance(self, context, instance_id):
@@ -2114,8 +2116,10 @@ class VlanManager(RPCAllocateFixedIP, FloatingIP, NetworkManager):
         # NOTE(vish): Don't allow access to networks with project_id=None as
         #             these are networksa that haven't been allocated to a
         #             project yet.
-        return self.db.network_get_all_by_uuids(context, network_uuids,
-                                                project_only=True)
+        networks = self.db.network_get_all_by_uuids(context, network_uuids,
+                                                    project_only=True)
+        networks.sort(key=lambda x: network_uuids.index(x['uuid']))
+        return networks
 
     def _get_networks_for_instance(self, context, instance_id, project_id,
                                    requested_networks=None):

If you could verify that it helps and report a bug, I would be happy to propose it into essex and backport it.

Vish

On Nov 9, 2012, at 11:57 AM, Yi Sun <beyounn at gmail.com> wrote:

> I have two nic cards, I want eth0 to always be connected to network1
> and eth1 to always be connected to network2.
> In the essex, I can do this by arrange the order of --nic options in
> the "nova boot" command. But in the folsom,it does not seem to work
> anymore, the following commands connect eth0 to the same network
> nova --no-cache boot --image db64c7ed-3496-499e-a097-73362cb5f447
> --flavor 2 --nic net-id=ff899ad7-a0c2-4e46-a0a4-bf086eda9164 --nic
> net-id=12e964db-14e3-4e85-98c8-45987c89e1d1 user-host-2
> nova --no-cache boot --image db64c7ed-3496-499e-a097-73362cb5f447
> --flavor 2  --nic net-id=12e964db-14e3-4e85-98c8-45987c89e1d1 --nic
> net-id=ff899ad7-a0c2-4e46-a0a4-bf086eda9164 user-host-2
> 
> Could someone tell me how to solve this problem?
> Thanks
> Yi
> -- 
> Android-x86
> http://www.android-x86.org
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~openstack
> Post to     : openstack at lists.launchpad.net
> Unsubscribe : https://launchpad.net/~openstack
> More help   : https://help.launchpad.net/ListHelp





More information about the Openstack mailing list