From: Matus Fabian Date: Thu, 31 Mar 2016 07:46:39 +0000 (+0200) Subject: Add get_vhost_user_if_name_by_sock X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=commitdiff_plain;h=a2bb116ad0962a99c37faea9ba87a7bfc9367a5e;ds=sidebyside Add get_vhost_user_if_name_by_sock Change-Id: I1d7f2cdfcf29763ce94417c98d363021f1fb27a1 Signed-off-by: Matus Fabian --- 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