Skip to content

Commit

Permalink
Avoid importing modules in codepaths (hb)
Browse files Browse the repository at this point in the history
  • Loading branch information
cvaroqui committed Dec 2, 2018
1 parent 6a78557 commit 2012586
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/hb.py
Expand Up @@ -13,6 +13,8 @@
from rcGlobalEnv import rcEnv
from storage import Storage

rcifconfig = __import__("rcIfconfig"+rcEnv.sysname)

class Hb(shared.OsvcThread):
"""
Heartbeat parent class
Expand Down Expand Up @@ -128,8 +130,7 @@ def set_beating(self, nodename="*"):

@staticmethod
def get_ip_address(ifname):
mod = __import__("rcIfconfig"+rcEnv.sysname)
ifconfig = mod.ifconfig()
ifconfig = rcifconfig.ifconfig()
intf = ifconfig.interface(ifname)
if isinstance(intf.ipaddr, list):
addr = intf.ipaddr[0]
Expand Down

0 comments on commit 2012586

Please sign in to comment.