Beispiel #1
0
def _extract_firmware_nodes_list(param_list):
    """
    Extract a firmware nodes list from param_list
    param_list is modified by the function call
    :param param_list: can have following formats
        * ['9', 'archi=wsn430:cc1101+site=grenoble', ...]  Alias type
        * ['grenoble', 'm3', '1-4+8-12+7', ...]  Physical type
    """

    # list in iotlab-experiment (alias or physical)
    if param_list[0].isdigit():  # alias selection
        # extract parameters
        nb_nodes, properties_str = param_list[0:2]
        param_list = param_list[2:]

        # parse parameters
        site, archi, _mobile = get_alias_properties(properties_str)
        mobile = mobile_from_mobile_str(_mobile)
        nodes = experiment.AliasNodes(int(nb_nodes), site, archi, mobile)
    else:  # physical selection
        # extract parameters
        site, archi, nodes_str = param_list[0:3]
        param_list = param_list[3:]

        # parse parameters
        nodes = common.nodes_list_from_info(site, archi, nodes_str)
    common.check_site_with_server(site)
    return nodes, param_list
Beispiel #2
0
def _extract_firmware_nodes_list(param_list):
    """
    Extract a firmware nodes list from param_list
    param_list is modified by the function call
    :param param_list: can have following formats
        * ['9', 'archi=wsn430:cc1101+site=grenoble', ...]  Alias type
        * ['grenoble', 'm3', '1-4+8-12+7', ...]  Physical type
    """

    # list in iotlab-experiment (alias or physical)
    if param_list[0].isdigit():  # alias selection
        # extract parameters
        nb_nodes, properties_str = param_list[0:2]
        param_list = param_list[2:]

        # parse parameters
        site, archi, _mobile = get_alias_properties(properties_str)
        mobile = mobile_from_mobile_str(_mobile)
        nodes = experiment.AliasNodes(int(nb_nodes), site, archi, mobile)
    else:  # physical selection
        # extract parameters
        site, archi, nodes_str = param_list[0:3]
        param_list = param_list[3:]

        # parse parameters
        nodes = common.nodes_list_from_info(site, archi, nodes_str)
    common.check_site_with_server(site)
    return nodes, param_list
Beispiel #3
0
def nodes_list_from_str(nodes_list_str):
    """ Convert the nodes_list_str to a list of nodes hostname
    Checks that given site exist
    :param nodes_list_str: short nodes format: site_name,archi,node_id_list
                           example: 'grenoble,m3,1-34+72'
    :returns: ['m3-1.grenoble.iot-lab.info', ...]
    """
    try:
        # 'grenoble,m3,1-34+72' -> ['grenoble', 'm3', '1-34+72']
        site, archi, nodes_str = nodes_list_str.split(',')
    except ValueError:
        raise ArgumentTypeError(
            'Invalid number of argument in nodes list: %r' % nodes_list_str)
    common.check_site_with_server(site)  # needs an external request
    return common.nodes_list_from_info(site, archi, nodes_str)
Beispiel #4
0
    def extract_nodes_and_message(line):
        """
        >>> WebsocketsSerialAggregator.extract_nodes_and_message('')
        (None, '')

        >>> WebsocketsSerialAggregator.extract_nodes_and_message(' ')
        (None, ' ')

        >>> WebsocketsSerialAggregator.extract_nodes_and_message('message')
        (None, 'message')

        >>> WebsocketsSerialAggregator.extract_nodes_and_message('-;message')
        (None, 'message')

        >>> WebsocketsSerialAggregator.extract_nodes_and_message(
        ...     'my_message_csv;msg')
        (None, 'my_message_csv;msg')

        >>> WebsocketsSerialAggregator.extract_nodes_and_message(
        ...      'saclay,M3,1;message')
        (['m3-1.saclay.iot-lab.info'], 'message')

        >>> WebsocketsSerialAggregator.extract_nodes_and_message(
        ...     'saclay,m3,1-3+5;message')
        ... # doctest: +NORMALIZE_WHITESPACE
        (['m3-1.saclay.iot-lab.info', 'm3-2.saclay.iot-lab.info', \
          'm3-3.saclay.iot-lab.info', 'm3-5.saclay.iot-lab.info'], 'message')
        """
        try:
            nodes_str, message = line.split(';')
            if nodes_str == '-':
                return None, message

            site, archi, list_str = nodes_str.split(',')

            # normalize archi
            archi = archi.lower()

            # get nodes list
            nodes = common_parser.nodes_list_from_info(site, archi, list_str)

            return nodes, message
        except (IndexError, ValueError):
            return None, line