Example #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
Example #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
Example #3
0
    def test_check_site_with_server(self):
        """Test check_site_with_server."""
        common.check_site_with_server('grenoble')

        # Invalid site
        self.assertRaises(argparse.ArgumentTypeError,
                          common.check_site_with_server, 'unknown')

        # sites list can be provided
        common.check_site_with_server('strasourg', ['gre', 'strasourg', 'lil'])
Example #4
0
    def test_check_site_with_server(self):
        """Test check_site_with_server."""
        common.check_site_with_server('grenoble')

        # Invalid site
        self.assertRaises(argparse.ArgumentTypeError,
                          common.check_site_with_server, 'unknown')

        # sites list can be provided
        common.check_site_with_server('strasourg', ['gre', 'strasourg', 'lil'])
Example #5
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)