def __init__(self, *args, **kwargs): super(BandwidthMonitor, self).__init__(*args, **kwargs) self.datapaths = {} self.dpset = kwargs['dpset'] self.topo = Topology(cfgfile) self.bwstats = BandwidthStats(self.topo) self.monitor_thread = hub.spawn(self.monitor)
def topology(): if 'file' not in request.files: flash('Потрібно вибрати файл', category='error') return redirect(url_for('index')) file = request.files['file'] filename = file.filename if filename == '': flash('Файл не вибрано', category='error') return redirect(url_for('index')) ext = os.path.splitext(filename)[1][1:] if not allowed_file(filename): flash('Формат {} не підтримується'.format(ext), category='error') return redirect(url_for('index')) topology = Topology(file=file.stream, type=ext) return render_template('topology.html', t=topology.make_report())
def __init__(self, *args, **kwargs): super(Multijet2, self).__init__(*args, **kwargs) wsgi = kwargs['wsgi'] wsgi.register(MultijetServer, {'app': self}) self._dp = None # self._verifiers = {} self._qs = {} self._cps = [100] self._node_id = platform.node() topo = Topology() topo.load('/common/topo.json') self._topo = topo self._pkt_trans = None with open('/common/spanningtree.json') as f: _spanning_tree = json.load(f) self._flood_ports = _spanning_tree[self._node_id]
pass def exception(self, msg, *args, **kwargs): pass class MockBandwidthStats(object): def __init__(self, topo): self.topo = topo self.hostBw = {} def addHostBwStat(self, host, txbytes, rxbytes): pass cfgfile = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "config.txt")) if not os.path.isfile(cfgfile): print "Cannot run test without file", cfgfile print "To create file, run mdc (eg, sudo ./mdc --vid)" sys.exit(1) topo = Topology(cfgfile) policy = AdaptivePolicy(topo, MockBandwidthStats(topo), MockLogger()) policy.utilization['s101'] = 100 policy.utilization['s102'] = 50 policy.utilization['s103'] = 200 print "Testing with values:", str(policy.utilization) print "Expected min: s102" print "Your code returns min:", str(policy.minUtilization())