From: Barış Metin Date: Tue, 20 Oct 2009 12:58:19 +0000 (+0000) Subject: - don't hardcode the device name (depends on util-vserver-pl change rev. 15385) X-Git-Tag: NodeManager-1.8-16~1 X-Git-Url: http://git.onelab.eu/?p=nodemanager.git;a=commitdiff_plain;h=bb9618cf097e28949b5e50a7a7e1e489c07f56eb - don't hardcode the device name (depends on util-vserver-pl change rev. 15385) Setting tag NodeManager-1.8-16 --This line, and those below, will be ignored-- Please write a changelog for this new tag in the section above DIFF========= Index: tools.py =================================================================== --- tools.py (.../tags/NodeManager-1.8-15) (révision 15386) +++ tools.py (.../trunk) (révision 15386) @@ -8,12 +8,31 @@ import threading import fcntl import commands +import sioc import logger PID_FILE = '/var/run/nm.pid' +def get_default_if(): + interface = get_if_from_hwaddr(get_hwaddr_from_plnode()) + if not interface: interface = "eth0" + return interface + +def get_hwaddr_from_plnode(): + for line in open("/usr/boot/plnode.txt", 'r').readlines(): + if line.startswith("NET_DEVICE"): + return line.split("=")[1].strip().strip('"') + return None + +def get_if_from_hwaddr(hwaddr): + devs = sioc.gifconf() + for dev in devs: + dev_hwaddr = sioc.gifhwaddr(dev) + if dev_hwaddr == hwaddr: return dev + return None + def as_daemon_thread(run): """Call function with no arguments in its own thread.""" thr = threading.Thread(target=run) Index: bwmon.py =================================================================== --- bwmon.py (.../tags/NodeManager-1.8-15) (révision 15386) +++ bwmon.py (.../trunk) (révision 15386) @@ -52,8 +52,9 @@ seconds_per_day = 24 * 60 * 60 bits_per_byte = 8 +dev_default = tools.get_default_if() # Burst to line rate (or node cap). Set by NM. in KBit/s -default_MaxRate = int(bwlimit.get_bwcap() / 1000) +default_MaxRate = int(bwlimit.get_bwcap(dev_default) / 1000) default_Maxi2Rate = int(bwlimit.bwmax / 1000) # 5.4 Gbyte per day. 5.4 * 1024 k * 1024M * 1024G # 5.4 Gbyte per day max allowed transfered per recording period @@ -323,7 +324,7 @@ (self.name, bwlimit.format_tc_rate(maxrate), bwlimit.format_tc_rate(maxi2rate)), 1) - bwlimit.set(xid = self.xid, + bwlimit.set(xid = self.xid, dev = dev_default minrate = self.MinRate * 1000, maxrate = self.MaxRate * 1000, maxexemptrate = self.Maxi2Rate * 1000, @@ -704,7 +705,7 @@ nmdbcopy = copy.deepcopy(database.db) database.db_lock.release() try: - if getDefaults(nmdbcopy) and len(bwlimit.tc("class show dev eth0")) > 0: + if getDefaults(nmdbcopy) and len(bwlimit.tc("class show dev %s" % dev_default)) > 0: # class show to check if net:InitNodeLimit:bwlimit.init has run. sync(nmdbcopy) else: logger.log("bwmon: BW limits DISABLED.") Index: net.py =================================================================== --- net.py (.../tags/NodeManager-1.8-15) (révision 15386) +++ net.py (.../trunk) (révision 15386) @@ -11,8 +11,10 @@ import sioc, plnet # local modules -import bwlimit, logger, iptables +import bwlimit, logger, iptables, tools +dev_default = tools.get_default_if() + def start(options, conf): logger.log("net plugin starting up...") @@ -22,7 +24,7 @@ if 'OVERRIDES' in dir(config): if config.OVERRIDES.get('net_max_rate') == '-1': logger.log("net: Slice and node BW Limits disabled.") - if len(bwlimit.tc("class show dev eth0")): + if len(bwlimit.tc("class show dev %s" % dev_default)): logger.verbose("*** DISABLING NODE BW LIMITS ***") bwlimit.stop() else: Index: plugins/rawdisk.py =================================================================== --- plugins/rawdisk.py (.../tags/NodeManager-1.8-15) (révision 15386) +++ plugins/rawdisk.py (.../trunk) (révision 15386) @@ -39,7 +39,6 @@ break buf = buf.strip() fields = re.split(pat, buf) - print fields dev = fields[-1] if not dev.startswith("dm-") and dev.endswith("1") and dev not in in_vg: devices.append("/dev/%s" % dev) --- diff --git a/NodeManager.spec b/NodeManager.spec index 7ac21d2..9f72d9f 100644 --- a/NodeManager.spec +++ b/NodeManager.spec @@ -7,7 +7,7 @@ %define name NodeManager %define version 1.8 -%define taglevel 15 +%define taglevel 16 %define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}} @@ -108,6 +108,9 @@ rm -rf $RPM_BUILD_ROOT %{_sysconfdir}/logrotate.d/nm %changelog +* Tue Oct 20 2009 Baris Metin - NodeManager-1.8-16 +- - don't hardcode the device name (depends on util-vserver-pl change rev. 15385) + * Fri Oct 09 2009 Marc Fiuczynski - NodeManager-1.8-15 - The seed for random previously was the meaning of life (i.e., 42) but - that resulted in a not so random choice for the hmac. This