コード例 #1
0
def init_pipe(counter='1',
              source='',
              dest='',
              rate='',
              delay='',
              rtt='',
              loss='',
              queue_size='',
              queue_size_mult='1.0',
              queue_disc='',
              queue_disc_params='',
              bidir='0',
              attach_to_queue=''):
    "Configure pipe on router, including rate shaping, AQM, loss/delay emulation"

    # get internal addresses
    dummy, source_internal = get_address_pair(source)
    dummy, dest_internal = get_address_pair(dest)

    # get type of current host
    htype = get_type_cached(env.host_string)

    if htype == 'FreeBSD':
        execute(init_dummynet_pipe, counter, source_internal, dest_internal,
                rate, delay, rtt, loss, queue_size, queue_size_mult,
                queue_disc, queue_disc_params, bidir)
    elif htype == 'Linux':
        execute(init_tc_pipe, counter, source_internal, dest_internal, rate,
                delay, rtt, loss, queue_size, queue_size_mult, queue_disc,
                queue_disc_params, bidir, attach_to_queue)
    else:
        abort("Router must be running FreeBSD or Linux")
コード例 #2
0
ファイル: routersetup.py プロジェクト: knneth/teacup
def init_pipe(counter='1', source='', dest='', rate='', delay='', rtt='', loss='',
              queue_size='', queue_size_mult='1.0', queue_disc='', 
              queue_disc_params='', bidir='0', attach_to_queue=''):
    "Configure pipe on router, including rate shaping, AQM, loss/delay emulation"

    # get internal addresses
    dummy, source_internal = get_address_pair(source)
    dummy, dest_internal = get_address_pair(dest)

    # get type of current host
    htype = get_type_cached(env.host_string)

    if htype == 'FreeBSD':
        execute(
            init_dummynet_pipe,
            counter,
            source_internal,
            dest_internal,
            rate,
            delay,
            rtt,
            loss,
            queue_size,
            queue_size_mult,
            queue_disc,
            queue_disc_params,
            bidir)
    elif htype == 'Linux':
        execute(
            init_tc_pipe,
            counter,
            source_internal,
            dest_internal,
            rate,
            delay,
            rtt,
            loss,
            queue_size,
            queue_size_mult,
            queue_disc,
            queue_disc_params,
            bidir,
            attach_to_queue)
    else:
        abort("Router must be running FreeBSD or Linux")
コード例 #3
0
ファイル: loggers.py プロジェクト: fredhau/neat-test-suite
def start_custom_logger(file_prefix='', remote_dir='', local_dir='', name='', logname='UNKNOWN', directory='', copy_file='0', add_prefix='0', hostname='', parameters=''):
     hostn, host_internal = get_address_pair(hostname)
 
     execute(start_custom_logger_local, file_prefix, remote_dir, local_dir,
             name, logname, directory, copy_file, add_prefix, parameters,
             hosts=[hostn])
コード例 #4
0
def get_address_pair_analysis(test_id, host, do_abort='1'):
    global host_internal_ip_cache
    global host_list_cache
    internal = ''
    external = ''
    TMP_CONF_FILE = '___oldconfig.py'

    # XXX the whole old config access should be moved into separate module as 
    # similar code is also in clockoffset

    # prior to TEACUP version 0.9 it was required to run the analysis with a config
    # file that had config.TPCONF_host_internal_ip as it was used to run the experiment
    # (or a superset of it). Since version 0.9 we use config.TPCONF_host_internal_ip
    # (as well as config.TPCONF_hosts and config.TPCONF_router) from the file 
    # <test_id_prefix>_tpconf_vars.log.gz in the test experiment directory.

    if test_id not in host_internal_ip_cache:
        # first find the directory but looking for mandatory uname file
        uname_file = get_testid_file_list('', test_id,
                                          'uname.log.gz', '')
        dir_name = os.path.dirname(uname_file[0])

        if dir_name in host_internal_ip_cache:
            # create test id cache entry from directory entry 
            host_internal_ip_cache[test_id] = host_internal_ip_cache[dir_name]
            if host_internal_ip_cache[test_id] != None:
                host_list_cache[test_id] = host_list_cache[dir_name]
        else:
            # try to find old config information

            # look for tpconf_vars.log.gz file in that directory 
            var_file = local('find -L %s -name "*tpconf_vars.log.gz"' % dir_name,
                             capture=True)

            if len(var_file) > 0:
                # new approach without using config.py

                # unzip archived file
                local('gzip -cd %s > %s' % (var_file, TMP_CONF_FILE))

                # load the TPCONF_variables into oldconfig
                oldconfig = imp.load_source('oldconfig', TMP_CONF_FILE)

                # remove temporary unzipped file 
                try:
                    os.remove(TMP_CONF_FILE)
                    os.remove(TMP_CONF_FILE + 'c') # remove the compiled file as well
                except OSError:
                    pass

                # store data in cache (both under test id and directory name)
                host_internal_ip_cache[test_id] = oldconfig.TPCONF_host_internal_ip
                host_list_cache[test_id] = oldconfig.TPCONF_hosts + oldconfig.TPCONF_router
                host_internal_ip_cache[dir_name] = oldconfig.TPCONF_host_internal_ip
                host_list_cache[dir_name] = oldconfig.TPCONF_hosts + oldconfig.TPCONF_router
            else:
                # old approach using the functions in hostint.py that access config.py
                # store empty value in cache (both under test id and directory name)
                host_internal_ip_cache[test_id] = None
                host_internal_ip_cache[dir_name] = None

    if host_internal_ip_cache[test_id] != None:
        # new approach

        # pretend it is an external name and perform lookup
        internal = host_internal_ip_cache[test_id].get(host, [])
        if len(internal) == 0:
            # host is internal name, so need to find external name
            internal = host
            for e, i in host_internal_ip_cache[test_id].items():
                if i[0] == host:
                    external = e
        else:
            # host is external name
            internal = internal[0]
            external = host

        hosts = host_list_cache[test_id]

    else:
        # old approach

        (external, internal) = get_address_pair(host, do_abort)

        hosts = get_part_hosts(test_id)

    if external not in hosts:
        return ('', '')
    else:
        return (external, internal)