From: Jiri Pirko <jiri(a)mellanox.com>
python task might need to get host object by interface object.
I actually have usecase for this. So just add the method.
Signed-off-by: Jiri Pirko <jiri(a)mellanox.com>
---
lnst/Controller/Task.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index 7f9dc8e..673048d 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -175,7 +175,7 @@ class HostAPI(object):
for i in self._m.get_interfaces():
if i.get_id() is None:
continue
- self._interfaces[i.get_id()] = InterfaceAPI(i)
+ self._interfaces[i.get_id()] = InterfaceAPI(i, self)
self._bg_id_seq = 0
@@ -364,8 +364,9 @@ class HostAPI(object):
self._m.sync_resources(sync_table)
class InterfaceAPI(object):
- def __init__(self, interface):
+ def __init__(self, interface, host):
self._if = interface
+ self._host = host
def get_id(self):
return self._if.get_id()
@@ -418,6 +419,9 @@ class InterfaceAPI(object):
def set_link_down(self):
return self._if.set_link_down()
+ def get_host(self):
+ return self._host
+
class ModuleAPI(object):
""" An API class representing a module. """
--
2.4.3
Show replies by date