예제 #1
0
def opts_parser():
    """ Argument parser object """
    import argparse
    parser = argparse.ArgumentParser()
    common_parser.add_auth_arguments(parser)

    nodes_group = parser.add_argument_group(
        description="By default, select currently running experiment nodes",
        title="Nodes selection")

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

    nodes_group.add_argument(
        '-l', '--list', type=common_parser.nodes_list_from_str,
        dest='nodes_list', help='nodes list, may be given multiple times')

    nodes_group.add_argument('-a', '--algo', default='syncronous',
                             choices=ALGOS.keys(), help='Algorithm to run')

    nodes_group.add_argument(
        '-n', '--num-loop', type=int, required=True,
        dest='num_loop', help='number_of_loops_to_run')

    nodes_group.add_argument(
        '-o', '--out-file', required=True,
        dest='outfile', help='Files where to output traces')

    return parser
예제 #2
0
def base_parser():
    """ Basic parser for all scripts """
    import argparse
    parser = argparse.ArgumentParser()
    common_parser.add_auth_arguments(parser)

    nodes_group = parser.add_argument_group(
        description="By default, select currently running experiment nodes",
        title="Nodes selection")

    nodes_group.add_argument('-i',
                             '--id',
                             dest='experiment_id',
                             type=int,
                             help='experiment id submission')
    nodes_group.add_argument('-l',
                             '--list',
                             dest='nodes_list',
                             type=common_parser.nodes_list_from_str,
                             help='nodes list, may be given multiple times')

    output = parser.add_argument_group(title="Output selection")
    output.add_argument('-o',
                        '--outdir',
                        required=True,
                        dest='outdir',
                        help='Output directory')
    return parser
예제 #3
0
def opts_parser():
    """ Argument parser object """
    parser = argparse.ArgumentParser()
    common_parser.add_auth_arguments(parser)

    parser.add_argument('uids_json_files', nargs='+', help='uids json files')
    parser.add_argument('--outdir', default='.',
                        help='out directory for result files')
    return parser
예제 #4
0
def opts_parser():
    """ Argument parser object """
    parser = argparse.ArgumentParser()
    common_parser.add_auth_arguments(parser)

    parser.add_argument('uids_json_files', nargs='+', help='uids json files')
    parser.add_argument('--outdir',
                        default='.',
                        help='out directory for result files')
    return parser
예제 #5
0
def parse_options():
    """Parse command line option."""
    parser = argparse.ArgumentParser()
    common.add_auth_arguments(parser, False)
    common.add_output_formatter(parser)
    # nodes list or exclude list
    common.add_nodes_selection_list(parser)
    parser.add_argument('-v',
                        '--version',
                        action='version',
                        version=iotlabwscli.__version__)
    common.add_expid_arg(parser)
    parser.add_argument('--verbose',
                        action='store_true',
                        help='Set verbose output')
    return parser
예제 #6
0
def opts_parser():
    """ Argument parser object """
    import argparse
    parser = argparse.ArgumentParser()
    common_parser.add_auth_arguments(parser)

    nodes_group = parser.add_argument_group(
        description="By default, select currently running experiment nodes",
        title="Nodes selection")

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

    nodes_group.add_argument('-l',
                             '--list',
                             type=node_parser.nodes_list_from_str,
                             dest='nodes_list',
                             help='nodes list, may be given multiple times')

    nodes_group.add_argument('-a',
                             '--algo',
                             default='syncronous',
                             choices=ALGOS.keys(),
                             help='Algorithm to run')

    nodes_group.add_argument('-n',
                             '--num-loop',
                             type=int,
                             required=True,
                             dest='num_loop',
                             help='number_of_loops_to_run')

    nodes_group.add_argument('-o',
                             '--out-file',
                             required=True,
                             dest='outfile',
                             help='Files where to output traces')

    return parser
예제 #7
0
파일: manager.py 프로젝트: dbohn/openlab
def opts_parser():
    """ Argument parser object """
    import argparse
    parser = argparse.ArgumentParser()
    common_parser.add_auth_arguments(parser)

    nodes_group = parser.add_argument_group(
        description="By default, select currently running experiment nodes",
        title="Nodes selection")

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

    nodes_group.add_argument(
        '-l', '--list', type=common_parser.nodes_list_from_str,
        dest='nodes_list', help='nodes list, may be given multiple times')

    nodes_group.add_argument(
        '-o', '--output-graph', help='Save the network graph', action='store_true')

    return parser
예제 #8
0
def parse_options():
    """Parse command line option."""
    parent_parser = argparse.ArgumentParser(add_help=False)
    common.add_auth_arguments(parent_parser, False)
    parent_parser.add_argument('-v', '--version',
                               action='version',
                               version=iotlabsshcli.__version__)

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

    common.add_expid_arg(parser)
    common.add_output_formatter(parser)

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

    # update-m3 parser
    update_parser = subparsers.add_parser('flash-m3',
                                          parents=[parent_parser],
                                          help='Flash the M3 firmware of A8 '
                                               'nodes')
    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',
                                         parents=[parent_parser],
                                         help='Reset the M3 of A8 nodes')
    # nodes list or exclude list
    common.add_nodes_selection_list(reset_parser)

    # wait-for-boot parser
    boot_parser = subparsers.add_parser('wait-for-boot',
                                        parents=[parent_parser],
                                        help='Waits until A8 nodes 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)

    # run-script parser
    run_script_parser = subparsers.add_parser('run-script',
                                              parents=[parent_parser],
                                              help='Run a script in background'
                                                   ' on A8 nodes')
    run_script_parser.add_argument('script', help='script path.')
    run_script_parser.add_argument('--frontend', action='store_true',
                                   help='Execution on SSH frontend')
    # nodes list or exclude list
    common.add_nodes_selection_list(run_script_parser)

    # run-cmd parser
    run_cmd_parser = subparsers.add_parser('run-cmd',
                                           parents=[parent_parser],
                                           help='Run a command on A8 nodes')
    run_cmd_parser.add_argument('cmd', help='Command')
    run_cmd_parser.add_argument('--frontend', action='store_true',
                                help='Execution on SSH frontend')
    # nodes list or exclude list
    common.add_nodes_selection_list(run_cmd_parser)

    # copy-file parser
    copy_file_parser = subparsers.add_parser('copy-file',
                                             parents=[parent_parser],
                                             help='Copy file on'
                                                  ' SSH frontend directory'
                                                  ' (~/A8/.iotlabsshcli/)')
    copy_file_parser.add_argument('file_path', help='File path')
    # nodes list or exclude list
    common.add_nodes_selection_list(copy_file_parser)

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

    return parser
예제 #9
0
def parse_options():
    """Parse command line option."""
    parent_parser = argparse.ArgumentParser(add_help=False)
    common.add_auth_arguments(parent_parser, False)
    parent_parser.add_argument('-v',
                               '--version',
                               action='version',
                               version=iotlabsshcli.__version__)

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

    common.add_expid_arg(parser)
    common.add_output_formatter(parser)

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

    # pylint: disable=super-with-arguments
    class DeprecateHelpFormatter(argparse.HelpFormatter):
        """ Add drepecated help formatter """
        def add_usage(self, usage, actions, groups, prefix=None):
            # self._prog = iotlab-ssh flash-m3 | reset-m3
            old_cmd = self._prog.split()[-1]
            new_cmd = old_cmd.split('-')[0]
            deprecate_warn_cmd(old_cmd, new_cmd, 20)
            return super(DeprecateHelpFormatter,
                         self).add_usage(usage, actions, groups, prefix)

    update_parser = subparsers.add_parser('flash',
                                          parents=[parent_parser],
                                          help='Flash node\'s '
                                          'co-microcontroller')
    update_parser.add_argument('firmware', help='firmware path.')
    # nodes list or exclude list
    common.add_nodes_selection_list(update_parser)

    # reset parser
    reset_parser = subparsers.add_parser('reset',
                                         parents=[parent_parser],
                                         help='Reset node\'s '
                                         'co-microcontroller')
    # nodes list or exclude list
    common.add_nodes_selection_list(reset_parser)

    # wait-for-boot parser
    boot_parser = subparsers.add_parser('wait-for-boot',
                                        parents=[parent_parser],
                                        help='Waits until Linux nodes '
                                        'have boot')
    boot_parser.add_argument('--max-wait',
                             type=int,
                             default=120,
                             help='Maximum waiting delay for nodes boot '
                             '(in seconds)')
    # nodes list or exclude list
    common.add_nodes_selection_list(boot_parser)

    # run-script parser
    run_script_parser = subparsers.add_parser('run-script',
                                              parents=[parent_parser],
                                              help='Run a script in '
                                              'background on Linux '
                                              'nodes')
    run_script_parser.add_argument('script', help='script path.')
    run_script_parser.add_argument('--frontend',
                                   action='store_true',
                                   help='Execution on SSH frontend')
    # nodes list or exclude list
    common.add_nodes_selection_list(run_script_parser)

    # run-cmd parser
    run_cmd_parser = subparsers.add_parser('run-cmd',
                                           parents=[parent_parser],
                                           help='Run a command on Linux nodes')
    run_cmd_parser.add_argument('cmd', help='Command')
    run_cmd_parser.add_argument('--frontend',
                                action='store_true',
                                help='Execution on SSH frontend')
    # nodes list or exclude list
    common.add_nodes_selection_list(run_cmd_parser)

    # copy-file parser
    copy_file_parser = subparsers.add_parser('copy-file',
                                             parents=[parent_parser],
                                             help='Copy file on'
                                             ' SSH frontend directory'
                                             ' (~/shared/.iotlabsshcli)')
    copy_file_parser.add_argument('file_path', help='File path')
    # nodes list or exclude list
    common.add_nodes_selection_list(copy_file_parser)

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

    # update-m3 parser
    help_msg = 'DEPRECATED: use flash subcommand instead'
    update_m3_parser = \
        subparsers.add_parser('flash-m3', help=help_msg,
                              parents=[parent_parser],
                              formatter_class=DeprecateHelpFormatter)
    update_m3_parser.add_argument('firmware', help='firmware path.')
    # nodes list or exclude list
    common.add_nodes_selection_list(update_m3_parser)

    # reset-m3 parser
    help_msg = 'DEPRECATED: use reset subcommand instead'
    reset_m3_parser = \
        subparsers.add_parser('reset-m3', help=help_msg,
                              parents=[parent_parser],
                              formatter_class=DeprecateHelpFormatter)
    # nodes list or exclude list
    common.add_nodes_selection_list(reset_m3_parser)

    return parser