Exemplo n.º 1
0
def parse_options():
    """ Handle node-cli command-line options with argparse """

    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(
        parents=[parent_parser],
        formatter_class=RawTextHelpFormatter,
        epilog=(help_msgs.PARSER_EPILOG.format(cli="robot", option="--status"))
        # + # help_msgs.COMMAND_EPILOG),  # TODO
    )

    parser.add_argument("-i", "--id", dest="experiment_id", type=int, help="experiment id submission")

    # command
    cmd_group = parser.add_mutually_exclusive_group(required=True)

    cmd_group.add_argument(
        "-s", "--status", help="Get robot status", const="status", dest="command", action="store_const"
    )

    # nodes list or exclude list
    common.add_nodes_selection_list(parser)

    return parser
Exemplo n.º 2
0
def parse_options():
    """ Handle iotlab-auth command-line options with argparse """
    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(parents=[parent_parser],
                                     formatter_class=RawTextHelpFormatter,
                                     description=AUTH_PARSER)

    parser.add_argument('-k',
                        '--add-ssh-key',
                        dest='add_key',
                        action='store_true',
                        help="add user's ssh public key to iot-lab account")
    parser.add_argument('-i',
                        '--identity-file',
                        dest='identity_file',
                        default=auth.IDENTITY_FILE,
                        help="specify ssh identity file to use")
    parser.add_argument('-l',
                        '--list-ssh-keys',
                        dest='list_keys',
                        action='store_true',
                        help="list ssh keys configured on IoT-LAB account")

    return parser
Exemplo n.º 3
0
def parse_options():
    """ Handle profile-cli command-line options with argparse """
    parent_parser = common.base_parser(user_required=True)
    # We create top level parser
    parser = argparse.ArgumentParser(
        parents=[parent_parser], formatter_class=RawTextHelpFormatter, description=AUTH_PARSER
    )

    return parser
Exemplo n.º 4
0
def parse_options():
    """ Handle iotlab-auth command-line options with argparse """
    parent_parser = common.base_parser(user_required=True)
    # We create top level parser
    parser = argparse.ArgumentParser(parents=[parent_parser],
                                     formatter_class=RawTextHelpFormatter,
                                     description=AUTH_PARSER)

    return parser
Exemplo n.º 5
0
def parse_options():
    """ Handle node-cli command-line options with argparse """

    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(
        description=NODE_PARSER,
        parents=[parent_parser], formatter_class=RawTextHelpFormatter,
        epilog=(help_msgs.PARSER_EPILOG.format(cli='node', option='--update') +
                NODE_EPILOG),
    )

    parser.add_argument(
        '-i', '--id', dest='experiment_id', type=int,
        help='experiment id submission')

    # command
    # argument with parameter can't both set 'command' and set argument value
    # so save argument, and command will be left to 'with_arguments'
    parser.set_defaults(command='with_argument')
    cmd_group = parser.add_mutually_exclusive_group(required=True)

    cmd_group.add_argument(
        '-sta', '--start', help='start command', const='start',
        dest='command', action='store_const')

    cmd_group.add_argument(
        '-sto', '--stop', help='stop command', const='stop',
        dest='command', action='store_const')

    cmd_group.add_argument(
        '-r', '--reset', help='reset command', const='reset',
        dest='command', action='store_const')

    cmd_group.add_argument(
        '--debug-start', help='start debugger', const='debug-start',
        dest='command', action='store_const')

    cmd_group.add_argument(
        '--debug-stop', help='stop debugger', const='debug-stop',
        dest='command', action='store_const')

    cmd_group.add_argument('-up', '--update',
                           dest='firmware_path', default=None,
                           help='flash firmware command with path file')

    cmd_group.add_argument('--profile', '--update-profile',
                           dest='profile_name', default=None,
                           help='change nodes current monitoring profile')

    # nodes list or exclude list
    common.add_nodes_selection_list(parser)

    return parser
Exemplo n.º 6
0
    def test_main_cli_jmespath_fmt():
        """ Run main_cli with --jmespath and --format options

        Test getting deployed nodes from 'experiment-cli get -p'"""
        function = Mock(
            return_value={
                "deploymentresults": {
                    "0": [
                        "a8-5.grenoble.iot-lab.info",
                        "a8-6.grenoble.iot-lab.info",
                        "a8-7.grenoble.iot-lab.info",
                        "a8-8.grenoble.iot-lab.info",
                        "a8-9.grenoble.iot-lab.info"
                    ]
                },
                "duration":
                60,
                "firmwareassociations":
                None,
                "name":
                None,
                "nodes": [
                    "a8-5.grenoble.iot-lab.info", "a8-6.grenoble.iot-lab.info",
                    "a8-7.grenoble.iot-lab.info", "a8-8.grenoble.iot-lab.info",
                    "a8-9.grenoble.iot-lab.info"
                ],
                "profileassociations":
                None,
                "profiles":
                None,
                "reservation":
                None,
                "state":
                "Running",
                "type":
                "physical"
            })

        nodes_list_ret = ('a8-5.grenoble.iot-lab.info'
                          ' a8-6.grenoble.iot-lab.info'
                          ' a8-7.grenoble.iot-lab.info'
                          ' a8-8.grenoble.iot-lab.info'
                          ' a8-9.grenoble.iot-lab.info')

        # like experiment-cli get --print
        parser = common.base_parser()
        args = ['--jmespath', 'deploymentresults."0"', '--format', '" ".join']
        # No need to add 'exp-cli get -p' function is mocked

        with patch('%s.print' % BUILTIN) as mock_print:
            common.main_cli(function, parser, args)
            mock_print.assert_called_with(nodes_list_ret)
Exemplo n.º 7
0
def parse_options():
    """ Handle iotlab-robot command-line options with argparse """

    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(parents=[parent_parser])

    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # not required by default in Python3

    # Robot Commands

    # 'status' command
    status_parser = subparsers.add_parser('status', help='Get robot status')
    common.add_nodes_selection_list(status_parser)
    common.add_expid_arg(status_parser)

    # 'update' command
    up_parser = subparsers.add_parser('update', help='Update robot mobility')
    up_parser.add_argument('-n',
                           '--name',
                           dest='up_name',
                           required=True,
                           help='Update robot mobility')
    common.add_nodes_selection_list(up_parser)
    common.add_expid_arg(up_parser)

    # Mobility commands

    # 'get' command
    get_parser = subparsers.add_parser('get', help='Get robot mobilities')
    get_group = get_parser.add_mutually_exclusive_group(required=True)
    get_group.add_argument('-l',
                           '--list',
                           dest='list',
                           action='store_true',
                           help='Get circuits list')
    get_group.add_argument('-n', '--name', dest='get_name', help='Get circuit')
    get_parser.add_argument('--site',
                            action='append',
                            dest='get_selection',
                            type=lambda x: ('site', x),
                            help='filter list by site')
    get_parser.add_argument('--type',
                            action='append',
                            dest='get_selection',
                            type=lambda x: ('type', x),
                            help='filter list by circuit type')

    return parser
Exemplo n.º 8
0
def parse_options():
    """ Handle node-cli command-line options with argparse """

    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(
        parents=[parent_parser], formatter_class=RawTextHelpFormatter,
        epilog=(help_msgs.PARSER_EPILOG
                % {'cli': 'node', 'option': '--update'}
                + help_msgs.COMMAND_EPILOG),
    )

    parser.add_argument(
        '-i', '--id', dest='experiment_id', type=int,
        help='experiment id submission')

    # command
    # 'update' sets firmware name to firmware_path, so cannot set command
    parser.set_defaults(command='update')
    cmd_group = parser.add_mutually_exclusive_group(required=True)

    cmd_group.add_argument(
        '-sta', '--start', help='start command', const='start',
        dest='command', action='store_const')

    cmd_group.add_argument(
        '-sto', '--stop', help='stop command', const='stop',
        dest='command', action='store_const')

    cmd_group.add_argument(
        '-r', '--reset', help='reset command', const='reset',
        dest='command', action='store_const')

    cmd_group.add_argument('-up', '--update',
                           dest='firmware_path', default=None,
                           help='flash firmware command with path file')

    # nodes list or exclude list
    list_group = parser.add_mutually_exclusive_group()

    list_group.add_argument(
        '-e', '--exclude', action='append',
        type=nodes_list_from_str,
        dest='exclude_nodes_list', help='exclude nodes list')
    list_group.add_argument(
        '-l', '--list', action='append',
        type=nodes_list_from_str,
        dest='nodes_list', help='nodes list')

    return parser
Exemplo n.º 9
0
    def test_main_cli_jmespath_fmt():
        """ Run main_cli with --jmespath and --format options

        Test getting deployed nodes from 'experiment-cli get -p'"""
        function = Mock(
            return_value={
                "deploymentresults": {
                    "0": [
                        "a8-5.grenoble.iot-lab.info",
                        "a8-6.grenoble.iot-lab.info",
                        "a8-7.grenoble.iot-lab.info",
                        "a8-8.grenoble.iot-lab.info",
                        "a8-9.grenoble.iot-lab.info",
                    ]
                },
                "duration": 60,
                "firmwareassociations": None,
                "name": None,
                "nodes": [
                    "a8-5.grenoble.iot-lab.info",
                    "a8-6.grenoble.iot-lab.info",
                    "a8-7.grenoble.iot-lab.info",
                    "a8-8.grenoble.iot-lab.info",
                    "a8-9.grenoble.iot-lab.info",
                ],
                "profileassociations": None,
                "profiles": None,
                "reservation": None,
                "state": "Running",
                "type": "physical",
            }
        )

        nodes_list_ret = (
            "a8-5.grenoble.iot-lab.info"
            " a8-6.grenoble.iot-lab.info"
            " a8-7.grenoble.iot-lab.info"
            " a8-8.grenoble.iot-lab.info"
            " a8-9.grenoble.iot-lab.info"
        )

        # like experiment-cli get --print
        parser = common.base_parser()
        args = ["--jmespath", 'deploymentresults."0"', "--format", '" ".join']
        # No need to add 'exp-cli get -p' function is mocked

        with patch("%s.print" % BUILTIN) as mock_print:
            common.main_cli(function, parser, args)
            mock_print.assert_called_with(nodes_list_ret)
Exemplo n.º 10
0
def parse_options():
    """ Handle iotlab-admin command-line options with argparse """
    parent_parser = common.base_parser()

    # We create top level parser
    parser = ArgumentParser(parents=[parent_parser])
    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # not required by default in Python3

    # ####### WAIT PARSER ###############
    wait_parser = experiment.parser_add_wait_subparser(subparsers,
                                                       expid_required=True)
    wait_parser.add_argument('--exp-user', required=True)

    return parser
Exemplo n.º 11
0
def parse_options():
    """ Handle experiment-cli command-line options with argparse """
    parent_parser = common.base_parser()

    # We create top level parser
    parser = ArgumentParser(parents=[parent_parser])
    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # not required by default in Python3

    # ####### WAIT PARSER ###############
    wait_parser = experiment.parser_add_wait_subparser(subparsers,
                                                       expid_required=True)
    wait_parser.add_argument('--exp-user', required=True)

    return parser
Exemplo n.º 12
0
def parse_options():
    """ Handle node-cli command-line options with argparse """

    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(parents=[parent_parser])

    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # not required by default in Python3

    # Robot Commands

    # 'status' command
    status_parser = subparsers.add_parser('status', help='Get robot status')
    common.add_nodes_selection_list(status_parser)
    common.add_expid_arg(status_parser)

    # 'update' command
    up_parser = subparsers.add_parser('update', help='Update robot mobility')
    up_parser.add_argument('update_name_site',
                           help='Update robot mobility',
                           metavar='NAME,SITE',
                           type=name_site)
    common.add_nodes_selection_list(up_parser)
    common.add_expid_arg(up_parser)

    # Mobility commands

    # 'get' command
    get_parser = subparsers.add_parser('get', help='Get robot mobilities')
    get_group = get_parser.add_mutually_exclusive_group(required=True)
    get_group.add_argument('-l',
                           '--list',
                           dest='get_list',
                           action='store_true',
                           help='Get mobilities list')
    get_group.add_argument('-n',
                           '--name',
                           dest='get_name_site',
                           type=name_site,
                           metavar='NAME,SITE',
                           help='Get given mobility')

    return parser
Exemplo n.º 13
0
def parse_options():
    """Parse command line option."""
    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(parents=[parent_parser], )

    common.add_expid_arg(parser)

    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # needed for python 3.

    # update-m3 parser
    update_parser = subparsers.add_parser('flash-m3',
                                          help='Flash the M3 firmware of A8 '
                                          'node')
    update_parser.add_argument('firmware', help='firmware elf path.')
    # nodes list or exclude list
    common.add_nodes_selection_list(update_parser)

    # reset-m3 parser
    reset_parser = subparsers.add_parser('reset-m3',
                                         help='reset the M3 of A8 node')
    # nodes list or exclude list
    common.add_nodes_selection_list(reset_parser)

    # wait-for-boot parser
    boot_parser = subparsers.add_parser('wait-for-boot',
                                        help='Waits until A8 node have boot')

    boot_parser.add_argument('--max-wait',
                             type=int,
                             default=120,
                             help='Maximum waiting delay for A8 nodes boot '
                             '(in seconds)')

    # nodes list or exclude list
    common.add_nodes_selection_list(boot_parser)

    parser.add_argument('--verbose',
                        action='store_true',
                        help='Set verbose output')

    return parser
Exemplo n.º 14
0
def parse_options():
    """ Handle iotlab-robot command-line options with argparse """

    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(parents=[parent_parser])

    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # not required by default in Python3

    # Robot Commands

    # 'status' command
    status_parser = subparsers.add_parser('status', help='Get robot status')
    common.add_nodes_selection_list(status_parser)
    common.add_expid_arg(status_parser)

    # 'update' command
    up_parser = subparsers.add_parser('update', help='Update robot mobility')
    up_parser.add_argument('update_name_site', help='Update robot mobility',
                           metavar='NAME,SITE', type=name_site)
    common.add_nodes_selection_list(up_parser)
    common.add_expid_arg(up_parser)

    # Mobility commands

    # 'get' command
    get_parser = subparsers.add_parser('get', help='Get robot mobilities')
    get_group = get_parser.add_mutually_exclusive_group(required=True)
    get_group.add_argument('-l', '--list', dest='get_list',
                           action='store_true', help='Get mobilities list')
    get_group.add_argument('-n', '--name', dest='get_name_site',
                           type=name_site, metavar='NAME,SITE',
                           help='Get given mobility')

    return parser
Exemplo n.º 15
0
def parse_options():
    """ Handle experiment-cli command-line options with argparse """
    parent_parser = common.base_parser()

    # We create top level parser
    parser = ArgumentParser(description=help_msgs.EXPERIMENT_PARSER,
                            parents=[parent_parser],
                            epilog=help_msgs.PARSER_EPILOG % {
                                'cli': 'experiment',
                                'option': 'submit'
                            },
                            formatter_class=RawTextHelpFormatter)

    subparsers = parser.add_subparsers(dest='command')

    submit_parser = subparsers.add_parser('submit',
                                          help='submit user experiment',
                                          epilog=help_msgs.SUBMIT_EPILOG,
                                          formatter_class=RawTextHelpFormatter)

    submit_parser.add_argument('-l',
                               '--list',
                               action='append',
                               dest='nodes_list',
                               required=True,
                               type=exp_resources_from_str,
                               help="experiment list")

    submit_parser.add_argument('-n', '--name', help='experiment name')

    submit_parser.add_argument('-d',
                               '--duration',
                               required=True,
                               type=int,
                               help='experiment duration in minutes')

    submit_parser.add_argument('-r',
                               '--reservation',
                               type=int,
                               help=('experiment schedule starting : seconds '
                                     'since 1970-01-01 00:00:00 UTC'))

    submit_parser.add_argument('-p',
                               '--print',
                               dest='print_json',
                               action='store_true',
                               help='print experiment submission')

    # ####### STOP PARSER ###############
    stop_parser = subparsers.add_parser('stop', help='stop user experiment')
    stop_parser.add_argument('-i',
                             '--id',
                             dest='experiment_id',
                             type=int,
                             help='experiment id submission')

    # ####### GET PARSER ###############
    get_parser = subparsers.add_parser('get',
                                       epilog=help_msgs.GET_EPILOG,
                                       help='get user\'s experiment',
                                       formatter_class=RawTextHelpFormatter)

    get_parser.add_argument('-i',
                            '--id',
                            dest='experiment_id',
                            type=int,
                            help='experiment id')

    get_group = get_parser.add_mutually_exclusive_group(required=True)
    get_group.add_argument('-r',
                           '--resources',
                           dest='get_cmd',
                           action='store_const',
                           const='resources',
                           help='get an experiment resources list')
    get_group.add_argument('-ri',
                           '--resources-id',
                           dest='get_cmd',
                           action='store_const',
                           const='id',
                           help=('get an experiment resources id list '
                                 '(EXP_LIST format : 1-34+72)'))

    get_group.add_argument('-s',
                           '--exp-state',
                           dest='get_cmd',
                           action='store_const',
                           const='state',
                           help='get an experiment state')
    get_group.add_argument('-p',
                           '--print',
                           dest='get_cmd',
                           action='store_const',
                           const='',
                           help='get an experiment submission')
    get_group.add_argument('-a',
                           '--archive',
                           dest='get_cmd',
                           action='store_const',
                           const='data',
                           help='get an experiment archive (tar.gz)')

    # --list with its options
    get_group.add_argument('-l',
                           '--list',
                           dest='get_cmd',
                           action='store_const',
                           const='experiment_list',
                           help='get user\'s experiment list')

    get_parser.add_argument('--offset',
                            default=0,
                            type=int,
                            help='experiment list start index')

    get_parser.add_argument('--limit',
                            default=0,
                            type=int,
                            help='experiment list lenght')

    get_parser.add_argument('--state', help='experiment list state filter')

    # ####### LOAD PARSER ###############
    load_parser = subparsers.add_parser('load',
                                        epilog=help_msgs.LOAD_EPILOG,
                                        help='load and submit user experiment',
                                        formatter_class=RawTextHelpFormatter)

    load_parser.add_argument('-f',
                             '--file',
                             dest='path_file',
                             required=True,
                             help='experiment path file')

    load_parser.add_argument('-l',
                             '--list',
                             dest='firmware_list',
                             default=[],
                             type=(lambda s: s.split(',')),
                             help='comma separated firmware(s) path list')

    # ####### INFO PARSER ###############
    info_parser = subparsers.add_parser('info',
                                        epilog=help_msgs.INFO_EPILOG,
                                        help='resources description list',
                                        formatter_class=RawTextHelpFormatter)

    info_parser.add_argument('--site', help='resources list filter by site')
    # subcommand
    info_group = info_parser.add_mutually_exclusive_group(required=True)
    info_group.add_argument('-l',
                            '--list',
                            dest='list_id',
                            action='store_false',
                            help='list resources')
    info_group.add_argument('-li',
                            '--list-id',
                            dest='list_id',
                            action='store_true',
                            help=('resources id list by archi and state '
                                  '(EXP_LIST format : 1-34+72)'))

    # ####### WAIT PARSER ###############
    wait_parser = subparsers.add_parser('wait',
                                        help='wait user experiment started',
                                        epilog=help_msgs.WAIT_EPILOG,
                                        formatter_class=RawTextHelpFormatter)

    wait_parser.add_argument('-i',
                             '--id',
                             dest='experiment_id',
                             type=int,
                             help='experiment id submission')

    wait_parser.add_argument(
        '--state',
        default='Running',
        help="wait states `State1,State2` or Finished, default 'Running'")
    wait_parser.add_argument('--step',
                             default=5,
                             type=int,
                             help="Wait time in seconds between each check")
    wait_parser.add_argument('--timeout',
                             default=float('+inf'),
                             type=float,
                             help="Max time to wait in seconds")

    return parser
Exemplo n.º 16
0
def parse_options():
    """ Handle profile-cli command-line opts with argparse """
    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(
        description=PROFILE_PARSER,
        parents=[parent_parser], epilog=help_msgs.PARSER_EPILOG.format(
            cli='profile', option='add'),
        formatter_class=RawTextHelpFormatter)

    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # not required by default in Python3

    add_wsn430_parser = subparsers.add_parser(
        'addwsn430', help='add wsn430 user profile',
        epilog=help_msgs.ADD_EPILOG_WSN430,
        formatter_class=RawTextHelpFormatter)

    #
    # m3 profile
    #
    add_m3_parser = subparsers.add_parser(
        'addm3', help='add m3 user profile',
        epilog=help_msgs.ADD_EPILOG_M3_A8.format(cmd='addm3', archi='m3'),
        formatter_class=RawTextHelpFormatter)
    add_m3_a8_parser('M3', add_m3_parser)

    #
    # a8 profile
    #
    add_a8_parser = subparsers.add_parser(
        'adda8', help='add a8 user profile',
        epilog=help_msgs.ADD_EPILOG_M3_A8.format(cmd='adda8', archi='a8'),
        formatter_class=RawTextHelpFormatter)
    add_m3_a8_parser('A8', add_a8_parser)

    add_custom_parser = subparsers.add_parser(
        'addcustom', help='add custom user profile',
        epilog=help_msgs.ADD_EPILOG_M3_A8.format(cmd='addcustom',
                                                 archi='custom'),
        formatter_class=RawTextHelpFormatter)
    add_m3_a8_parser('CUSTOM', add_custom_parser)

    del_parser = subparsers.add_parser('del', help='delete user profile')
    get_parser = subparsers.add_parser('get', help='get user\'s profile')
    load_parser = subparsers.add_parser('load', help='load user profile')

    #
    # WSN430 profile
    #
    add_wsn430_parser.add_argument('-n', '--name', required=True,
                                   help='profile name')
    add_wsn430_parser.add_argument(
        '-j', '--json', action='store_true',
        help='print profile JSON representation without add it')

    add_wsn430_parser.add_argument(
        '-p', '--power',
        dest='power_mode', default='dc',
        help='power mode (dc by default)',
        choices=ProfileWSN430.choices['power_mode'])

    # WSN430 Consumption
    group_wsn430_consumption = add_wsn430_parser.add_argument_group(
        'Consumption measure')

    group_wsn430_consumption.add_argument(
        '-cfreq', dest='cfreq', type=int,
        choices=ProfileWSN430.choices['consumption']['frequency'],
        help='frequency measure (ms)')

    group_wsn430_consumption.add_argument(
        '-power', action='store_true',
        help='power measure')
    group_wsn430_consumption.add_argument(
        '-voltage', action='store_true',
        help='voltage measure')
    group_wsn430_consumption.add_argument(
        '-current', action='store_true',
        help='current measure')

    # WSN430 Radio
    group_wsn430_radio = add_wsn430_parser.add_argument_group(
        'Radio measure')
    group_wsn430_radio.add_argument(
        '-rfreq', dest='rfreq', type=int,
        choices=ProfileWSN430.choices['radio']['frequency'],
        help='frequency measure (ms)')

    # WSN430 Sensor
    group_wsn430_sensor = add_wsn430_parser.add_argument_group(
        'Sensor measure')
    group_wsn430_sensor.add_argument(
        '-sfreq', dest='sfreq', type=int,
        choices=ProfileWSN430.choices['sensor']['frequency'],
        help='frequency measure (ms)')

    group_wsn430_sensor.add_argument(
        '-temperature', action='store_true',
        help='temperature measure')
    group_wsn430_sensor.add_argument(
        '-luminosity', action='store_true',
        help='luminosity measure')

    # Delete Profile
    del_parser.add_argument('-n', '--name', required=True, help='profile name')

    # Get Profile
    get_group = get_parser.add_mutually_exclusive_group(required=True)

    get_group.add_argument('-n', '--name', help='profile name')

    get_group.add_argument(
        '-l', '--list', action='store_true',
        help='print profile\'s list JSON representation')

    # Load Profile
    load_parser.add_argument(
        '-f', '--file', dest='path_file', required=True,
        help='profile JSON representation path file')

    return parser
Exemplo n.º 17
0
def parse_options():
    """ Handle iotlab-experiment command-line options with argparse """
    parent_parser = common.base_parser()

    # We create top level parser
    parser = ArgumentParser(
        description=EXPERIMENT_PARSER,
        parents=[parent_parser],
        epilog=help_msgs.PARSER_EPILOG.format(
            cli='experiment', option='submit'),
        formatter_class=RawTextHelpFormatter)

    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # not required by default in Python3

    # ####### SUBMIT PARSER ###############
    parser_add_submit_subparser(subparsers)

    # ####### SCRIPT PARSER ###############
    parser_add_script_subparser(subparsers)

    # ####### STOP PARSER ###############
    stop_parser = subparsers.add_parser('stop', help='stop user experiment')
    common.add_expid_arg(stop_parser)

    # ####### GET PARSER ###############
    get_parser = subparsers.add_parser(
        'get',
        epilog=help_msgs.GET_EPILOG,
        help='get user\'s experiment',
        formatter_class=RawTextHelpFormatter)

    common.add_expid_arg(get_parser)

    get_group = get_parser.add_mutually_exclusive_group(required=True)
    get_group.add_argument(
        '-r', '--resources', dest='get_cmd', action='store_const',
        const='resources', help='get an experiment resources list')
    get_group.add_argument(
        '-ri', '--resources-id', dest='get_cmd', action='store_const',
        const='id', help=('get an experiment resources id list '
                          '(EXP_LIST format : 1-34+72)'))

    get_group.add_argument(
        '-s', '--exp-state', dest='get_cmd', action='store_const',
        const='state', help='get an experiment state')
    get_group.add_argument(
        '-st', '--start-time', dest='get_cmd', action='store_const',
        const='start', help='get expected experiment start time')
    get_group.add_argument(
        '-p', '--print', dest='get_cmd', action='store_const',
        const='', help='get an experiment submission')
    get_group.add_argument(
        '-a', '--archive', dest='get_cmd', action='store_const',
        const='data', help='get an experiment archive (tar.gz)')

    # --list with its options
    get_group.add_argument(
        '-l', '--list', dest='get_cmd', action='store_const',
        const='experiment_list', help='get user\'s experiment list')

    get_parser.add_argument('--offset', default=0, type=int,
                            help='experiment list start index')

    get_parser.add_argument('--limit', default=0, type=int,
                            help='experiment list maximum length')

    get_parser.add_argument('--state', help='experiment list state filter')

    get_group.add_argument('-e', '--experiments', dest='get_cmd',
                           action='store_const',
                           const='experiments',
                           help='get running experiments ids')
    get_parser.add_argument(
        '--active', action='store_true', default=False,
        help='experiments: include waiting/starting experiments')

    # ####### LOAD PARSER ###############
    load_parser = subparsers.add_parser('load', epilog=help_msgs.LOAD_EPILOG,
                                        help='load and submit user experiment',
                                        formatter_class=RawTextHelpFormatter)

    load_parser.add_argument('-f', '--file', dest='path_file',
                             metavar='EXP_JSON', required=True,
                             help='experiment path file')

    _load_list_help = ('file path for firmware/script/... if not in'
                       ' current directory.')

    load_parser.add_argument('-l', '--list', metavar='FILEPATH',
                             dest='files', default=[],
                             type=(lambda s: s.split(',')), action='append',
                             help=_load_list_help)

    # ####### RELOAD PARSER ###############
    reload_parser = subparsers.add_parser('reload',
                                          epilog=help_msgs.RELOAD_EPILOG,
                                          help='reload user experiment',
                                          formatter_class=RawTextHelpFormatter)
    common.add_expid_arg(reload_parser, required=True)

    _parser_add_duration_and_reservation(reload_parser,
                                         duration_required=False)

    # ####### INFO PARSER ###############
    info_parser = subparsers.add_parser('info', epilog=help_msgs.INFO_EPILOG,
                                        help='resources description list',
                                        formatter_class=RawTextHelpFormatter)

    info_parser.add_argument('--site',
                             action='append', dest='info_selection',
                             type=lambda x: ('site', x),
                             help='resources list filter by site')
    info_parser.add_argument('--archi',
                             action='append', dest='info_selection',
                             type=lambda x: ('archi', x),
                             help='resources list filter by architecture')
    info_parser.add_argument('--state', action='append', dest='info_selection',
                             type=lambda x: ('state', x),
                             help='resources list filter by state')

    # subcommand
    info_group = info_parser.add_mutually_exclusive_group(required=True)
    info_group.add_argument('-l', '--list', dest='list_id',
                            action='store_false', help='list resources')
    info_group.add_argument('-li', '--list-id', dest='list_id',
                            action='store_true',
                            help=('resources id list by archi and state '
                                  '(EXP_LIST format : 1-34+72)'))

    # ####### WAIT PARSER ###############
    parser_add_wait_subparser(subparsers, expid_required=False)

    return parser
Exemplo n.º 18
0
def parse_options():
    """ Handle iotlab-node command-line options with argparse """

    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(
        description=NODE_PARSER,
        parents=[parent_parser], formatter_class=RawTextHelpFormatter,
        epilog=(help_msgs.PARSER_EPILOG.format(cli='node', option='--update') +
                NODE_EPILOG),
    )

    common.add_expid_arg(parser)

    # command
    # argument with parameter can't both set 'command' and set argument value
    # so save argument, and command will be left to 'with_arguments'
    parser.set_defaults(command='with_argument')
    cmd_group = parser.add_mutually_exclusive_group(required=True)

    cmd_group.add_argument(
        '-sta', '--start', help='start command', const='start',
        dest='command', action='store_const')

    cmd_group.add_argument(
        '-sto', '--stop', help='stop command', const='stop',
        dest='command', action='store_const')

    cmd_group.add_argument(
        '-r', '--reset', help='reset command', const='reset',
        dest='command', action='store_const')
    cmd_group.add_argument(
        '--update-idle', help='flash idle firmware', const='update-idle',
        dest='command', action='store_const')

    cmd_group.add_argument(
        '--debug-start', help='start debugger', const='debug-start',
        dest='command', action='store_const')

    cmd_group.add_argument(
        '--debug-stop', help='stop debugger', const='debug-stop',
        dest='command', action='store_const')

    cmd_group.add_argument('-up', '--update',
                           dest='firmware_path', default=None,
                           help='flash firmware command with path file')

    cmd_group.add_argument('--profile', '--update-profile',
                           dest='profile_name', default=None,
                           help='change nodes current monitoring profile')
    cmd_group.add_argument('--profile-load',
                           dest='profile_path', default=None,
                           help=('change nodes current monitoring profile'
                                 ' with provided JSON'))
    cmd_group.add_argument('--profile-reset',
                           dest='command', const='profile-reset',
                           action='store_const',
                           help='reset to default no monitoring profile')

    # nodes list or exclude list
    common.add_nodes_selection_list(parser)

    return parser
Exemplo n.º 19
0
def parse_options():
    """ Handle experiment-cli command-line options with argparse """
    parent_parser = common.base_parser()

    # We create top level parser
    parser = ArgumentParser(
        description=EXPERIMENT_PARSER,
        parents=[parent_parser],
        epilog=help_msgs.PARSER_EPILOG.format(
            cli='experiment', option='submit'),
        formatter_class=RawTextHelpFormatter)

    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # not required by default in Python3

    submit_parser = subparsers.add_parser(
        'submit', help='submit user experiment',
        epilog=help_msgs.SUBMIT_EPILOG, formatter_class=RawTextHelpFormatter)

    submit_parser.add_argument('-l', '--list', action='append',
                               dest='nodes_list', required=True,
                               type=exp_resources_from_str,
                               help="experiment list")

    submit_parser.add_argument('-n', '--name', help='experiment name')

    submit_parser.add_argument('-d', '--duration', required=True, type=int,
                               help='experiment duration in minutes')

    submit_parser.add_argument('-r', '--reservation', type=int,
                               help=('experiment schedule starting : seconds '
                                     'since 1970-01-01 00:00:00 UTC'))

    submit_parser.add_argument('-p', '--print',
                               dest='print_json', action='store_true',
                               help='print experiment submission')

    # ####### STOP PARSER ###############
    stop_parser = subparsers.add_parser('stop', help='stop user experiment')
    stop_parser.add_argument('-i', '--id', dest='experiment_id', type=int,
                             help='experiment id submission')

    # ####### GET PARSER ###############
    get_parser = subparsers.add_parser(
        'get',
        epilog=help_msgs.GET_EPILOG,
        help='get user\'s experiment',
        formatter_class=RawTextHelpFormatter)

    get_parser.add_argument('-i', '--id', dest='experiment_id', type=int,
                            help='experiment id')

    get_group = get_parser.add_mutually_exclusive_group(required=True)
    get_group.add_argument(
        '-r', '--resources', dest='get_cmd', action='store_const',
        const='resources', help='get an experiment resources list')
    get_group.add_argument(
        '-ri', '--resources-id', dest='get_cmd', action='store_const',
        const='id', help=('get an experiment resources id list '
                          '(EXP_LIST format : 1-34+72)'))

    get_group.add_argument(
        '-s', '--exp-state', dest='get_cmd', action='store_const',
        const='state', help='get an experiment state')
    get_group.add_argument(
        '-st', '--start-time', dest='get_cmd', action='store_const',
        const='start', help='get expected experiment start time')
    get_group.add_argument(
        '-p', '--print', dest='get_cmd', action='store_const',
        const='', help='get an experiment submission')
    get_group.add_argument(
        '-a', '--archive', dest='get_cmd', action='store_const',
        const='data', help='get an experiment archive (tar.gz)')

    # --list with its options
    get_group.add_argument(
        '-l', '--list', dest='get_cmd', action='store_const',
        const='experiment_list', help='get user\'s experiment list')

    get_parser.add_argument('--offset', default=0, type=int,
                            help='experiment list start index')

    get_parser.add_argument('--limit', default=0, type=int,
                            help='experiment list lenght')

    get_parser.add_argument('--state', help='experiment list state filter')

    # ####### LOAD PARSER ###############
    load_parser = subparsers.add_parser('load', epilog=help_msgs.LOAD_EPILOG,
                                        help='load and submit user experiment',
                                        formatter_class=RawTextHelpFormatter)

    load_parser.add_argument('-f', '--file', dest='path_file',
                             required=True, help='experiment path file')

    load_parser.add_argument('-l', '--list', dest='firmware_list', default=[],
                             type=(lambda s: s.split(',')),
                             help='comma separated firmware(s) path list')

    # ####### INFO PARSER ###############
    info_parser = subparsers.add_parser('info', epilog=help_msgs.INFO_EPILOG,
                                        help='resources description list',
                                        formatter_class=RawTextHelpFormatter)

    info_parser.add_argument('--site', help='resources list filter by site')
    # subcommand
    info_group = info_parser.add_mutually_exclusive_group(required=True)
    info_group.add_argument('-l', '--list', dest='list_id',
                            action='store_false', help='list resources')
    info_group.add_argument('-li', '--list-id', dest='list_id',
                            action='store_true',
                            help=('resources id list by archi and state '
                                  '(EXP_LIST format : 1-34+72)'))

    # ####### WAIT PARSER ###############
    wait_parser = subparsers.add_parser(
        'wait', help='wait user experiment started',
        epilog=help_msgs.WAIT_EPILOG, formatter_class=RawTextHelpFormatter)

    wait_parser.add_argument('-i', '--id', dest='experiment_id', type=int,
                             help='experiment id submission')

    wait_parser.add_argument(
        '--state', default='Running',
        help="wait states `State1,State2` or Finished, default 'Running'")
    wait_parser.add_argument(
        '--step', default=5, type=int,
        help="Wait time in seconds between each check")
    wait_parser.add_argument(
        '--timeout', default=float('+inf'), type=float,
        help="Max time to wait in seconds")

    return parser
Exemplo n.º 20
0
def parse_options():
    """ Handle iotlab-status command-line options with argparse """

    parent_parser = common.base_parser()
    # We create top level parser
    epilog_msg = help_msgs.PARSER_EPILOG.format(cli='status', option='--sites')
    epilog_msg += STATUS_EPILOG
    parser = argparse.ArgumentParser(
        description=STATUS_PARSER,
        parents=[parent_parser],
        formatter_class=RawTextHelpFormatter,
        epilog=epilog_msg,
    )

    parser.set_defaults(command='with_argument')
    status_group = parser.add_mutually_exclusive_group(required=True)
    status_group.add_argument('-s',
                              '--sites',
                              help='get testbed sites list',
                              const='sites',
                              dest='command',
                              action='store_const')

    status_group.add_argument('-n',
                              '--nodes',
                              help='get testbed nodes list',
                              const='nodes',
                              dest='command',
                              action='store_const')

    status_group.add_argument('-ni',
                              '--nodes-ids',
                              help='get testbed nodes ids list (1-3+5)',
                              const='nodes-ids',
                              dest='command',
                              action='store_const')

    status_group.add_argument('-er',
                              '--experiments-running',
                              help='get testbed running experiments list',
                              const='experiments',
                              dest='command',
                              action='store_const')

    parser.add_argument('--site',
                        action='append',
                        dest='nodes_selection',
                        type=lambda x: ('site', x),
                        help='testbed nodes list filter by site')
    parser.add_argument('--archi',
                        action='append',
                        dest='nodes_selection',
                        type=lambda x: ('archi', x),
                        help='testbed nodes list filter by architecture')
    parser.add_argument('--state',
                        action='append',
                        dest='nodes_selection',
                        type=lambda x: ('state', x),
                        help='testbed nodes list filter by state')

    return parser
Exemplo n.º 21
0
def parse_options():
    """ Handle profile-cli command-line opts with argparse """
    parent_parser = common.base_parser()
    # We create top level parser
    parser = argparse.ArgumentParser(description=PROFILE_PARSER,
                                     parents=[parent_parser],
                                     epilog=help_msgs.PARSER_EPILOG.format(
                                         cli='profile', option='add'),
                                     formatter_class=RawTextHelpFormatter)

    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # not required by default in Python3

    add_wsn430_parser = subparsers.add_parser(
        'addwsn430',
        help='add wsn430 user profile',
        epilog=help_msgs.ADD_EPILOG_WSN430,
        formatter_class=RawTextHelpFormatter)

    #
    # m3 profile
    #
    add_m3_parser = subparsers.add_parser(
        'addm3',
        help='add m3 user profile',
        epilog=help_msgs.ADD_EPILOG_M3_A8.format(cmd='addm3', archi='m3'),
        formatter_class=RawTextHelpFormatter)
    add_m3_a8_parser('M3', add_m3_parser)

    #
    # a8 profile
    #
    add_a8_parser = subparsers.add_parser(
        'adda8',
        help='add a8 user profile',
        epilog=help_msgs.ADD_EPILOG_M3_A8.format(cmd='adda8', archi='a8'),
        formatter_class=RawTextHelpFormatter)
    add_m3_a8_parser('A8', add_a8_parser)

    add_custom_parser = subparsers.add_parser(
        'addcustom',
        help='add custom user profile',
        epilog=help_msgs.ADD_EPILOG_M3_A8.format(cmd='addcustom',
                                                 archi='custom'),
        formatter_class=RawTextHelpFormatter)
    add_m3_a8_parser('CUSTOM', add_custom_parser)

    del_parser = subparsers.add_parser('del', help='delete user profile')
    get_parser = subparsers.add_parser('get', help='get user\'s profile')
    load_parser = subparsers.add_parser('load', help='load user profile')

    #
    # WSN430 profile
    #
    add_wsn430_parser.add_argument('-n',
                                   '--name',
                                   required=True,
                                   help='profile name')
    add_wsn430_parser.add_argument(
        '-j',
        '--json',
        action='store_true',
        help='print profile JSON representation without add it')

    add_wsn430_parser.add_argument('-p',
                                   '--power',
                                   dest='power_mode',
                                   default='dc',
                                   help='power mode (dc by default)',
                                   choices=ProfileWSN430.choices['power_mode'])

    # WSN430 Consumption
    group_wsn430_consumption = add_wsn430_parser.add_argument_group(
        'Consumption measure')

    group_wsn430_consumption.add_argument(
        '-cfreq',
        dest='cfreq',
        type=int,
        choices=ProfileWSN430.choices['consumption']['frequency'],
        help='frequency measure (ms)')

    group_wsn430_consumption.add_argument('-power',
                                          action='store_true',
                                          help='power measure')
    group_wsn430_consumption.add_argument('-voltage',
                                          action='store_true',
                                          help='voltage measure')
    group_wsn430_consumption.add_argument('-current',
                                          action='store_true',
                                          help='current measure')

    # WSN430 Radio
    group_wsn430_radio = add_wsn430_parser.add_argument_group('Radio measure')
    group_wsn430_radio.add_argument(
        '-rfreq',
        dest='rfreq',
        type=int,
        choices=ProfileWSN430.choices['radio']['frequency'],
        help='frequency measure (ms)')

    # WSN430 Sensor
    group_wsn430_sensor = add_wsn430_parser.add_argument_group(
        'Sensor measure')
    group_wsn430_sensor.add_argument(
        '-sfreq',
        dest='sfreq',
        type=int,
        choices=ProfileWSN430.choices['sensor']['frequency'],
        help='frequency measure (ms)')

    group_wsn430_sensor.add_argument('-temperature',
                                     action='store_true',
                                     help='temperature measure')
    group_wsn430_sensor.add_argument('-luminosity',
                                     action='store_true',
                                     help='luminosity measure')

    # Delete Profile
    del_parser.add_argument('-n', '--name', required=True, help='profile name')

    # Get Profile
    get_group = get_parser.add_mutually_exclusive_group(required=True)

    get_group.add_argument('-n', '--name', help='profile name')

    get_group.add_argument('-l',
                           '--list',
                           action='store_true',
                           help='print profile\'s list JSON representation')

    # Load Profile
    load_parser.add_argument('-f',
                             '--file',
                             dest='path_file',
                             required=True,
                             help='profile JSON representation path file')

    return parser
Exemplo n.º 22
0
def parse_options():
    """ Handle iotlab-experiment command-line options with argparse """
    parent_parser = common.base_parser()

    # We create top level parser
    parser = ArgumentParser(description=EXPERIMENT_PARSER,
                            parents=[parent_parser],
                            epilog=help_msgs.PARSER_EPILOG.format(
                                cli='experiment', option='submit'),
                            formatter_class=RawTextHelpFormatter)

    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True  # not required by default in Python3

    # ####### SUBMIT PARSER ###############
    parser_add_submit_subparser(subparsers)

    # ####### SCRIPT PARSER ###############
    parser_add_script_subparser(subparsers)

    # ####### STOP PARSER ###############
    stop_parser = subparsers.add_parser('stop', help='stop user experiment')
    common.add_expid_arg(stop_parser)

    # ####### GET PARSER ###############
    get_parser = subparsers.add_parser('get',
                                       epilog=help_msgs.GET_EPILOG,
                                       help='get user\'s experiment',
                                       formatter_class=RawTextHelpFormatter)

    common.add_expid_arg(get_parser)

    get_group = get_parser.add_mutually_exclusive_group(required=True)
    get_group.add_argument('-r',
                           '--resources',
                           dest='get_cmd',
                           action='store_const',
                           const='resources',
                           help='get an experiment resources list')
    get_group.add_argument('-ri',
                           '--resources-id',
                           dest='get_cmd',
                           action='store_const',
                           const='id',
                           help=('get an experiment resources id list '
                                 '(EXP_LIST format : 1-34+72)'))

    get_group.add_argument('-s',
                           '--exp-state',
                           dest='get_cmd',
                           action='store_const',
                           const='state',
                           help='get an experiment state')
    get_group.add_argument('-st',
                           '--start-time',
                           dest='get_cmd',
                           action='store_const',
                           const='start',
                           help='get expected experiment start time')
    get_group.add_argument('-p',
                           '--print',
                           dest='get_cmd',
                           action='store_const',
                           const='',
                           help='get an experiment submission')
    get_group.add_argument('-a',
                           '--archive',
                           dest='get_cmd',
                           action='store_const',
                           const='data',
                           help='get an experiment archive (tar.gz)')

    # --list with its options
    get_group.add_argument('-l',
                           '--list',
                           dest='get_cmd',
                           action='store_const',
                           const='experiment_list',
                           help='get user\'s experiment list')

    get_parser.add_argument('--offset',
                            default=0,
                            type=int,
                            help='experiment list start index')

    get_parser.add_argument('--limit',
                            default=0,
                            type=int,
                            help='experiment list maximum length')

    get_parser.add_argument('--state', help='experiment list state filter')

    get_group.add_argument('-e',
                           '--experiments',
                           dest='get_cmd',
                           action='store_const',
                           const='experiments',
                           help='get running experiments ids')
    get_parser.add_argument(
        '--active',
        action='store_true',
        default=False,
        help='experiments: include waiting/starting experiments')

    # ####### LOAD PARSER ###############
    load_parser = subparsers.add_parser('load',
                                        epilog=help_msgs.LOAD_EPILOG,
                                        help='load and submit user experiment',
                                        formatter_class=RawTextHelpFormatter)

    load_parser.add_argument('-f',
                             '--file',
                             dest='path_file',
                             metavar='EXP_JSON',
                             required=True,
                             help='experiment path file')

    _load_list_help = ('file path for firmware/script/... if not in'
                       ' current directory.')

    load_parser.add_argument('-l',
                             '--list',
                             metavar='FILEPATH',
                             dest='files',
                             default=[],
                             type=(lambda s: s.split(',')),
                             action='append',
                             help=_load_list_help)

    # ####### RELOAD PARSER ###############
    reload_parser = subparsers.add_parser('reload',
                                          epilog=help_msgs.RELOAD_EPILOG,
                                          help='reload user experiment',
                                          formatter_class=RawTextHelpFormatter)
    common.add_expid_arg(reload_parser, required=True)

    _parser_add_duration_and_reservation(reload_parser,
                                         duration_required=False)

    # ####### INFO PARSER ###############
    info_parser = subparsers.add_parser('info',
                                        epilog=help_msgs.INFO_EPILOG,
                                        help='resources description list',
                                        formatter_class=RawTextHelpFormatter)

    info_parser.add_argument('--site',
                             action='append',
                             dest='info_selection',
                             type=lambda x: ('site', x),
                             help='resources list filter by site')
    info_parser.add_argument('--archi',
                             action='append',
                             dest='info_selection',
                             type=lambda x: ('archi', x),
                             help='resources list filter by architecture')
    info_parser.add_argument('--state',
                             action='append',
                             dest='info_selection',
                             type=lambda x: ('state', x),
                             help='resources list filter by state')

    # subcommand
    info_group = info_parser.add_mutually_exclusive_group(required=True)
    info_group.add_argument('-l',
                            '--list',
                            dest='list_id',
                            action='store_false',
                            help='list resources')
    info_group.add_argument('-li',
                            '--list-id',
                            dest='list_id',
                            action='store_true',
                            help=('resources id list by archi and state '
                                  '(EXP_LIST format : 1-34+72)'))

    # ####### WAIT PARSER ###############
    parser_add_wait_subparser(subparsers, expid_required=False)

    return parser
Exemplo n.º 23
0
def parse_options():
    """ Handle experiment-cli command-line options with argparse """
    parent_parser = common.base_parser()

    # We create top level parser
    parser = ArgumentParser(
        description=EXPERIMENT_PARSER,
        parents=[parent_parser],
        epilog=help_msgs.PARSER_EPILOG.format(cli="experiment", option="submit"),
        formatter_class=RawTextHelpFormatter,
    )

    subparsers = parser.add_subparsers(dest="command")
    subparsers.required = True  # not required by default in Python3

    submit_parser = subparsers.add_parser(
        "submit", help="submit user experiment", epilog=help_msgs.SUBMIT_EPILOG, formatter_class=RawTextHelpFormatter
    )

    submit_parser.add_argument(
        "-l",
        "--list",
        action="append",
        dest="nodes_list",
        required=True,
        type=exp_resources_from_str,
        help="experiment list",
    )

    submit_parser.add_argument("-n", "--name", help="experiment name")

    submit_parser.add_argument("-d", "--duration", required=True, type=int, help="experiment duration in minutes")

    submit_parser.add_argument(
        "-r",
        "--reservation",
        type=int,
        help=("experiment schedule starting : seconds " "since 1970-01-01 00:00:00 UTC"),
    )

    submit_parser.add_argument(
        "-p", "--print", dest="print_json", action="store_true", help="print experiment submission"
    )

    # ####### STOP PARSER ###############
    stop_parser = subparsers.add_parser("stop", help="stop user experiment")
    common.add_expid_arg(stop_parser)

    # ####### GET PARSER ###############
    get_parser = subparsers.add_parser(
        "get", epilog=help_msgs.GET_EPILOG, help="get user's experiment", formatter_class=RawTextHelpFormatter
    )

    common.add_expid_arg(get_parser)

    get_group = get_parser.add_mutually_exclusive_group(required=True)
    get_group.add_argument(
        "-r",
        "--resources",
        dest="get_cmd",
        action="store_const",
        const="resources",
        help="get an experiment resources list",
    )
    get_group.add_argument(
        "-ri",
        "--resources-id",
        dest="get_cmd",
        action="store_const",
        const="id",
        help=("get an experiment resources id list " "(EXP_LIST format : 1-34+72)"),
    )

    get_group.add_argument(
        "-s", "--exp-state", dest="get_cmd", action="store_const", const="state", help="get an experiment state"
    )
    get_group.add_argument(
        "-st",
        "--start-time",
        dest="get_cmd",
        action="store_const",
        const="start",
        help="get expected experiment start time",
    )
    get_group.add_argument(
        "-p", "--print", dest="get_cmd", action="store_const", const="", help="get an experiment submission"
    )
    get_group.add_argument(
        "-a", "--archive", dest="get_cmd", action="store_const", const="data", help="get an experiment archive (tar.gz)"
    )

    # --list with its options
    get_group.add_argument(
        "-l", "--list", dest="get_cmd", action="store_const", const="experiment_list", help="get user's experiment list"
    )

    get_parser.add_argument("--offset", default=0, type=int, help="experiment list start index")

    get_parser.add_argument("--limit", default=0, type=int, help="experiment list lenght")

    get_parser.add_argument("--state", help="experiment list state filter")

    # ####### LOAD PARSER ###############
    load_parser = subparsers.add_parser(
        "load",
        epilog=help_msgs.LOAD_EPILOG,
        help="load and submit user experiment",
        formatter_class=RawTextHelpFormatter,
    )

    load_parser.add_argument("-f", "--file", dest="path_file", required=True, help="experiment path file")

    load_parser.add_argument(
        "-l",
        "--list",
        dest="firmware_list",
        default=[],
        type=(lambda s: s.split(",")),
        help="comma separated firmware(s) path list",
    )

    # ####### INFO PARSER ###############
    info_parser = subparsers.add_parser(
        "info", epilog=help_msgs.INFO_EPILOG, help="resources description list", formatter_class=RawTextHelpFormatter
    )

    info_parser.add_argument("--site", help="resources list filter by site")
    # subcommand
    info_group = info_parser.add_mutually_exclusive_group(required=True)
    info_group.add_argument("-l", "--list", dest="list_id", action="store_false", help="list resources")
    info_group.add_argument(
        "-li",
        "--list-id",
        dest="list_id",
        action="store_true",
        help=("resources id list by archi and state " "(EXP_LIST format : 1-34+72)"),
    )

    # ####### WAIT PARSER ###############
    wait_parser = subparsers.add_parser(
        "wait", help="wait user experiment started", epilog=help_msgs.WAIT_EPILOG, formatter_class=RawTextHelpFormatter
    )

    common.add_expid_arg(wait_parser)

    wait_parser.add_argument(
        "--state", default="Running", help="wait states `State1,State2` or Finished, default 'Running'"
    )
    wait_parser.add_argument("--step", default=5, type=int, help="Wait time in seconds between each check")
    wait_parser.add_argument("--timeout", default=float("+inf"), type=float, help="Max time to wait in seconds")

    return parser