Ido Barkan has uploaded a new change for review.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
net: add simple network namespace functions to ipwrapper
Adding simple wrappers for adding, deleting, and executing ip commands in other namespaces.
Change-Id: I6b83c9635fba4feb4946ceba460f3ab8c09ad656 Signed-off-by: Ido Barkan ibarkan@redhat.com --- M lib/vdsm/ipwrapper.py M tests/nettestlib.py 2 files changed, 26 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/46447/1
diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py index 3ded776..e8aa6cd 100644 --- a/lib/vdsm/ipwrapper.py +++ b/lib/vdsm/ipwrapper.py @@ -585,3 +585,20 @@ def linkDel(dev): command = [_IP_BINARY.cmd, 'link', 'del', 'dev', dev] _execCmd(command) + + +def netns_add(name): + _execCmd([_IP_BINARY.cmd, 'netns', 'add', name]) + + +def netns_delete(name): + _execCmd([_IP_BINARY.cmd, 'netns', 'delete', name]) + + +def netns_exec(netns_name, command): + netns_command = [_IP_BINARY.cmd, 'netns', 'exec', netns_name] + _execCmd(netns_command + command) + + +def netns_assign(device, netns_name): + _execCmd([_IP_BINARY.cmd, 'link', 'set', device, 'netns', netns_name]) diff --git a/tests/nettestlib.py b/tests/nettestlib.py index 2ffb11a..c923f44 100644 --- a/tests/nettestlib.py +++ b/tests/nettestlib.py @@ -132,6 +132,15 @@ pass
+@contextmanager +def network_namespace(name): + netns_add(name) + try: + yield name + finally: + netns_delete(name) + + def _listenOnDevice(fd, icmp): while True: packet = os.read(fd, 2048)
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Petr Horáček has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 2: Code-Review+1
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Ido Barkan has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 3: Verified+1
Ondřej Svoboda has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 3: Code-Review+1
Dan Kenigsberg has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 3: Code-Review-1
(1 comment)
https://gerrit.ovirt.org/#/c/46447/3/lib/vdsm/ipwrapper.py File lib/vdsm/ipwrapper.py:
Line 587: _execCmd(command) Line 588: Line 589: Line 590: def netns_add(name): Line 591: _execCmd([_IP_BINARY.cmd, 'netns', 'add', name]) please keep the original hierarchy. this function is link_set_netnsnetnsnetnsnetnsnetnsnetnsnetnsnetns Line 592: Line 593: Line 594: def netns_delete(name): Line 595: _execCmd([_IP_BINARY.cmd, 'netns', 'delete', name])
Ido Barkan has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 3:
(1 comment)
https://gerrit.ovirt.org/#/c/46447/3/lib/vdsm/ipwrapper.py File lib/vdsm/ipwrapper.py:
Line 587: _execCmd(command) Line 588: Line 589: Line 590: def netns_add(name): Line 591: _execCmd([_IP_BINARY.cmd, 'netns', 'add', name])
please keep the original hierarchy. this function is link_set_netnsnetnsnet
I do not understand Line 592: Line 593: Line 594: def netns_delete(name): Line 595: _execCmd([_IP_BINARY.cmd, 'netns', 'delete', name])
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 6:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 7:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 8:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Ido Barkan has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 8: -Verified
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 9:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 9: Code-Review-1
(1 comment)
https://gerrit.ovirt.org/#/c/46447/9/lib/vdsm/ipwrapper.py File lib/vdsm/ipwrapper.py:
Line 599: netns_command = [_IP_BINARY.cmd, 'netns', 'exec', netns_name] Line 600: _execCmd(netns_command + command) Line 601: Line 602: Line 603: def netns_assign(device, netns_name): sorry for the failed former attempt to review this function.
It is a wrapper of `ip link set device netns`, and as such it should have a similar name to that of linkSet.
How about
def link_set_netns(dev, netns): return linkSet(dev, ['netns', netns]
Ido Barkan has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 9:
(1 comment)
https://gerrit.ovirt.org/#/c/46447/9/lib/vdsm/ipwrapper.py File lib/vdsm/ipwrapper.py:
Line 599: netns_command = [_IP_BINARY.cmd, 'netns', 'exec', netns_name] Line 600: _execCmd(netns_command + command) Line 601: Line 602: Line 603: def netns_assign(device, netns_name):
sorry for the failed former attempt to review this function.
done
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 10:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 10: Code-Review+2
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 11:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Ido Barkan has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 11: Verified+1
Dan Kenigsberg has submitted this change and it was merged.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
net: add simple network namespace functions to ipwrapper
Adding simple wrappers for adding, deleting, and executing ip commands in other namespaces.
Change-Id: I6b83c9635fba4feb4946ceba460f3ab8c09ad656 Signed-off-by: Ido Barkan ibarkan@redhat.com Reviewed-on: https://gerrit.ovirt.org/46447 Reviewed-by: Dan Kenigsberg danken@redhat.com Continuous-Integration: Jenkins CI --- M lib/vdsm/ipwrapper.py M tests/nettestlib.py 2 files changed, 28 insertions(+), 1 deletion(-)
Approvals: Ido Barkan: Verified Jenkins CI: Passed CI tests Dan Kenigsberg: Looks good to me, approved
automation@ovirt.org has posted comments on this change.
Change subject: net: add simple network namespace functions to ipwrapper ......................................................................
Patch Set 12:
* Update tracker::IGNORE, no Bug-Url found * Set MODIFIED::IGNORE, no Bug-Url found.
vdsm-patches@lists.fedorahosted.org