aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2016-03-31 09:46:39 +0200
committerGerrit Code Review <gerrit@fd.io>2016-04-01 14:19:54 +0000
commita2bb116ad0962a99c37faea9ba87a7bfc9367a5e (patch)
treec571ffe5c495c04558d86abd8d124d090783246a /resources
parent4b2b04f21eee90ee3c9b4ebed2d8546dbc7be8e1 (diff)
Add get_vhost_user_if_name_by_sock
Change-Id: I1d7f2cdfcf29763ce94417c98d363021f1fb27a1 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/VhostUser.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/resources/libraries/python/VhostUser.py b/resources/libraries/python/VhostUser.py
index cf4ca0b278..1a311e03fc 100644
--- a/resources/libraries/python/VhostUser.py
+++ b/resources/libraries/python/VhostUser.py
@@ -37,3 +37,19 @@ class VhostUser(object):
else:
raise RuntimeError('Create Vhost-user interface failed on node '
'"{}"'.format(node['host']))
+
+ @staticmethod
+ def get_vhost_user_if_name_by_sock(node, socket):
+ """Get Vhost-user interface name by socket.
+
+ :param node: Node to get Vhost-user interface name on.
+ :param socket: Vhost-user interface socket path.
+ :type node: dict
+ :type socket: str
+ :return: Interface name or None if not found.
+ :rtype: str
+ """
+ for interface in node['interfaces'].values():
+ if interface.get('socket') == socket:
+ return interface.get('name')
+ return None