Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions ansible/roles/vm_set/library/vm_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
PTF_FP_IFACE_TEMPLATE = 'eth%d'
BACK_ROOT_END_IF_TEMPLATE = 'veth-bb-%s'
BACK_VM_END_IF_TEMPLATE = 'veth-bv-%s'
RETRIES = 3


class VMTopology(object):
Expand Down Expand Up @@ -405,8 +406,20 @@ def bind_phys_vlan(self, br_name, vlan_iface, injected_iface, vm_iface, disconne
if vlan_iface not in ports:
VMTopology.cmd('ovs-vsctl add-port %s %s' % (br_name, vlan_iface))

bindings = VMTopology.get_ovs_port_bindings(br_name)
vlan_iface_id = bindings[vlan_iface]
# Vlan interface addition may take few secs to reflect in OVS Command,
# Let`s retry few times.
retries = 0
vlan_iface_id = None
while retries < RETRIES:
bindings = VMTopology.get_ovs_port_bindings(br_name)
vlan_iface_id = bindings[vlan_iface]
if vlan_iface_id is not None:
break
time.sleep(1)
retries += 1
if vlan_iface_id is None:
raise Exception("Can't find vlan_iface_id")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please raise an Exception inside of the get_ovs_port_bindings method? I don't see any reason you want to have it here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I will change that part.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure will raise in function get_ovs_port_bindings.


injected_iface_id = bindings[injected_iface]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please hide retry logic inside of get_ovs_port_bindings()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.) I can do that, but I will need to add an extra argument [=vlan_iface] to function get_ovs_port_bindings().
i.e get_ovs_port_bindings(br_name) ==> get_ovs_port_bindings(br_name, vlan_iface).

2.) Or I can write an wrapper on top on get_ovs_port_bindings(br_name) to check vlan_iface.

Kindly let me know which sounds better. Thanks a lot for review.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gentle Reminder for review.

vm_iface_id = bindings[vm_iface]

Expand Down