def _instance_update_dynamic(self, instance, device):
        load = [
            int(value)
            for value in instance._load_monitor.get_device_load(device)
        ]
        if load is None:
            return

        if not device in instance._stats:
            self._init_stats_and_idle(instance, device)
        self._update_stats(instance, device, load)
        self._update_idle(instance, device)

        stats = instance._stats[device]
        idle = instance._idle[device]

        if idle["level"] == 0 and idle["read"] >= self._level_steps and idle[
                "write"] >= self._level_steps:
            idle["level"] = 1
            log.info("%s: setting 100Mbps" % device)
            ethcard(device).set_speed(100)
        elif idle["level"] == 1 and (idle["read"] == 0 or idle["write"] == 0):
            idle["level"] = 0
            log.info("%s: setting max speed" % device)
            ethcard(device).set_max_speed()

        log.debug("%s load: read %0.2f, write %0.2f" %
                  (device, stats["read"], stats["write"]))
        log.debug("%s idle: read %d, write %d, level %d" %
                  (device, idle["read"], idle["write"], idle["level"]))
예제 #2
0
	def _instance_update_dynamic(self, instance, device):
		load = map(lambda value: int(value), instance._load_monitor.get_device_load(device))
		if load is None:
			return

		if not device in instance._stats:
			self._init_stats_and_idle(instance, device)
		self._update_stats(instance, device, load)
		self._update_idle(instance, device)

		stats = instance._stats[device]
		idle = instance._idle[device]

		if idle["level"] == 0 and idle["read"] >= self._level_steps and idle["write"] >= self._level_steps:
			idle["level"] = 1
			log.info("%s: setting 100Mbps" % device)
			ethcard(device).set_speed(100)
		elif idle["level"] == 1 and (idle["read"] == 0 or idle["write"] == 0):
			idle["level"] = 0
			log.info("%s: setting max speed" % device)
			ethcard(device).set_max_speed()

		log.debug("%s load: read %0.2f, write %0.2f" % (device, stats["read"], stats["write"]))
		log.debug("%s idle: read %d, write %d, level %d" % (device, idle["read"], idle["write"], idle["level"]))
 def _instance_unapply_dynamic(self, instance, device):
     if device in instance._idle and instance._idle[device]["level"] > 0:
         instance._idle[device]["level"] = 0
         log.info("%s: setting max speed" % device)
         ethcard(device).set_max_speed()
 def _init_stats_and_idle(self, instance, device):
     max_speed = self._calc_speed(ethcard(device).get_max_speed())
     instance._stats[device] = {"new": 4 * [0], "max": 2 * [max_speed, 1]}
     instance._idle[device] = {"level": 0, "read": 0, "write": 0}
예제 #5
0
	def _init_stats_and_idle(self, instance, device):
		max_speed = self._calc_speed(ethcard(device).get_max_speed())
		instance._stats[device] = { "new": 4 * [0], "max": 2 * [max_speed, 1] }
		instance._idle[device] = { "level": 0, "read": 0, "write": 0 }
예제 #6
0
	def _instance_unapply_dynamic(self, instance, device):
		if device in instance._idle and instance._idle[device]["level"] > 0:
			instance._idle[device]["level"] = 0
			log.info("%s: setting max speed" % device)
			ethcard(device).set_max_speed()