Esempio n. 1
0
    def __configure_edge_reliability(self, a, b, relistr, edict):
        relidict = fsutil.mkdict(relistr)
        ttf = ttr = None
        for k, v in relidict.iteritems():
            if k == 'failureafter':
                ttf = eval(v)
                if isinstance(ttf, (int, float)):
                    ttf = modulation_generator([ttf])

            elif k == 'downfor':
                ttr = eval(v)
                if isinstance(ttr, (int, float)):
                    ttr = modulation_generator([ttr])

            elif k == 'mttf':
                ttf = eval(v)

            elif k == 'mttr':
                ttr = eval(v)

        if ttf or ttr:
            assert (ttf and ttr)
            xttf = next(ttf)
            self.after(xttf, 'link-failure-' + a + '-' + b, self.__linkdown, a,
                       b, edict, ttf, ttr)
Esempio n. 2
0
    def __configure_edge_reliability(self, a, b, relistr, edict):
        relidict = fsutil.mkdict(relistr)
        ttf = ttr = None
        for k,v in relidict.iteritems():
            if k == 'failureafter':
                ttf = eval(v)
                if isinstance(ttf, (int, float)):
                    ttf = modulation_generator([ttf])

            elif k == 'downfor':
                ttr = eval(v)
                if isinstance(ttr, (int, float)):
                    ttr = modulation_generator([ttr])

            elif k == 'mttf':
                ttf = eval(v)

            elif k == 'mttr':
                ttr = eval(v)

        if ttf or ttr:
            assert(ttf and ttr)
            xttf = next(ttf)
            fscore().after(xttf, 'link-failure-'+a+'-'+b, self.__linkdown, a, b, edict, ttf, ttr)
Esempio n. 3
0
        fm = FlowEventGenModulator(tgen, stime=st, emerge_profile=emerge, sustain_profile=profile, withdraw_profile=withdraw)
        return fm

     
    def __configure_traf_spec(self, trafname, trafspec, srcnode):
        '''Configure a traffic generator based on specification elements'''
        trafspeclist = trafspec.split()

        # first item in the trafspec list should be the traffic generator name.
        # also need to traverse the remainder of the and do substitutions for common configuration elements
        specname = trafspeclist[0].strip()
        tclass = specname.capitalize()
        fulltrafspec = trafspeclist[1:]
        trafgenname = "{}TrafficGenerator".format(tclass)

        try:
            importname = "traffic_generators.{}".format(specname)
            m = import_module(importname)
        except ImportError,e:
            raise InvalidTrafficSpecification(trafspec)

        classobj = getattr(m, trafgenname)
        if not classobj:
            self.logger.warn("Bad config: can't find TrafficGenerator class named {0}.  Add the class '{0}' to traffic.py, or fix the config.".format(trafgenname))
            raise InvalidTrafficSpecification(trafspec)
        else:
            trafdict = fsutil.mkdict(fulltrafspec)
            self.logger.debug("Creating {} with specification {}".format(str(classobj),trafdict))
            gen = lambda: classobj(srcnode, **trafdict)
            return gen