예제 #1
0
            def load_command_table(self, args):
                super(DeprecationTestCommandLoader,
                      self).load_command_table(args)
                with CommandGroup(self, '', '{}#{{}}'.format(__name__)) as g:
                    g.command('cmd1',
                              'example_handler',
                              deprecate_info=g.deprecate(redirect='alt-cmd1'))
                    g.command('cmd2',
                              'example_handler',
                              deprecate_info=g.deprecate(redirect='alt-cmd2',
                                                         hide='1.0.0'))
                    g.command('cmd3',
                              'example_handler',
                              deprecate_info=g.deprecate(redirect='alt-cmd3',
                                                         hide='0.1.0'))
                    g.command('cmd4',
                              'example_handler',
                              deprecate_info=g.deprecate(redirect='alt-cmd4',
                                                         expiration='1.0.0'))
                    g.command('cmd5',
                              'example_handler',
                              deprecate_info=g.deprecate(redirect='alt-cmd5',
                                                         expiration='0.1.0'))

                with CommandGroup(self,
                                  'grp1',
                                  '{}#{{}}'.format(__name__),
                                  deprecate_info=self.deprecate(
                                      redirect='alt-grp1')) as g:
                    g.command('cmd1', 'example_handler')

                return self.command_table
예제 #2
0
    def load_command_table(self, args):
        """Load commands into the command table.

        Args:
            args (list): List of arguments from the command line.

        Returns:
            collections.OrderedDict: Load commands into the command table.
        """
        with CommandGroup(self, '', 'superbench.cli._handler#{}') as g:
            g.command('version', 'version_command_handler')
            g.command('deploy', 'deploy_command_handler')
            g.command('exec', 'exec_command_handler')
            g.command('run', 'run_command_handler')
        with CommandGroup(self, 'benchmark',
                          'superbench.cli._benchmark_handler#{}') as g:
            g.command('list', 'benchmark_list_command_handler')
            g.command('list-parameters',
                      'benchmark_list_params_command_handler')
        with CommandGroup(self, 'node',
                          'superbench.cli._node_handler#{}') as g:
            g.command('info', 'info_command_handler')
        with CommandGroup(self, 'result',
                          'superbench.cli._result_handler#{}') as g:
            g.command('diagnosis', 'diagnosis_command_handler')
            g.command('summary', 'summary_command_handler')
        return super().load_command_table(args)
예제 #3
0
def load_command_table(self, args):
    """
    Loads the command table
    """
    def operation_group(name):
        return '{cli_name}.commands.{name}#{name}'.format(
            cli_name=__CLI_NAME__, name=name)

    with CommandGroup(self, _COMMAND_GROUP,
                      operation_group(_LOGIN)) as command_group:
        command_group.command(_LOGIN, _LOGIN)

    with CommandGroup(self, _COMMAND_GROUP,
                      operation_group(_DOWNLOAD)) as command_group:
        command_group.command(_DOWNLOAD, _DOWNLOAD)

    with CommandGroup(self, _COMMAND_GROUP,
                      operation_group(_CREATE)) as command_group:
        command_group.command(_CREATE, _CREATE)

    with CommandGroup(self, _COMMAND_GROUP,
                      operation_group(_UPDATE)) as command_group:
        command_group.command(_UPDATE, _UPDATE)

    with CommandGroup(self, _COMMAND_GROUP,
                      operation_group(_VALIDATE)) as command_group:
        command_group.command(_VALIDATE, _VALIDATE)
예제 #4
0
 def load_command_table(self, args):
     with CommandGroup(self, 'router', '__main__#{}') as g:
         g.command('list', 'router_list')
     with CommandGroup(self, 'port', '__main__#{}') as g:
         g.command('add', 'port_add')
         g.command('delete', 'port_delete')
         g.command('list', 'port_list')
     return OrderedDict(self.command_table)
예제 #5
0
            def load_command_table(self, args):
                super(PreviewTestCommandLoader, self).load_command_table(args)
                with CommandGroup(self, '', '{}#{{}}'.format(__name__)) as g:
                    g.command('cmd1', 'example_handler', is_preview=True)

                with CommandGroup(self,
                                  'grp1',
                                  '{}#{{}}'.format(__name__),
                                  is_preview=True) as g:
                    g.command('cmd1', 'example_handler')

                return self.command_table
예제 #6
0
def load_build_commands(cli_command_loader):
    with CommandGroup(cli_command_loader, 'build',
                      'vsts.cli.build.common.{}') as g:
        # basic vsts_cli_build commands
        g.command('list',
                  'build#build_list',
                  table_transformer=transform_builds_table_output)
        g.command('queue',
                  'build#build_queue',
                  table_transformer=transform_build_table_output)
        g.command('show',
                  'build#build_show',
                  table_transformer=transform_build_table_output)

        # basic vsts_cli_build definition commands
        g.command('definition list',
                  'build_definition#build_definition_list',
                  table_transformer=transform_definitions_table_output)
        g.command('definition show',
                  'build_definition#build_definition_show',
                  table_transformer=transform_definition_table_output)

        # basic vsts_cli_build task commands
        g.command('task list',
                  'task#task_list',
                  table_transformer=transform_tasks_table_output)
        g.command('task show',
                  'task#task_show',
                  table_transformer=transform_task_table_output)
예제 #7
0
    def test_register_command(self):
        cl = CLICommandsLoader(self.mock_ctx)
        command_name = 'test register sample-command'
        with CommandGroup(cl, 'test register', '{}#{{}}'.format(__name__)) as g:
            g.command('sample-command', '{}.{}'.format(TestCommandRegistration.__name__,
                                                       TestCommandRegistration.sample_command_handler.__name__))

        self.assertEqual(len(cl.command_table), 1, 'We expect exactly one command in the command table')
        cl.load_arguments(command_name)
        command_metadata = cl.command_table[command_name]
        self.assertEqual(len(command_metadata.arguments), 4, 'We expected exactly 4 arguments')
        some_expected_arguments = {
            'group_name': CLIArgumentType(dest='group_name',
                                          required=True,
                                          help='The name of the group.'),
            'resource_name': CLIArgumentType(dest='resource_name',
                                             required=True,
                                             help='The name of the resource.'),
            'opt_param': CLIArgumentType(required=False,
                                         help='Used to verify reflection correctly identifies optional params.'),
            'expand': CLIArgumentType(required=False,
                                      help='The expand expression to apply on the operation.')
        }

        for probe in some_expected_arguments:
            existing = next(arg for arg in command_metadata.arguments if arg == probe)
            contains_subset = _dictContainsSubset(some_expected_arguments[existing].settings,
                                                  command_metadata.arguments[existing].options)
            self.assertTrue(contains_subset)
        self.assertEqual(command_metadata.arguments['resource_name'].options_list, ['--resource-name'])
예제 #8
0
 def test_register_cli_argument(self):
     cl = CLICommandsLoader(self.mock_ctx)
     command_name = 'test register sample-command'
     with CommandGroup(cl, 'test register', '{}#{{}}'.format(__name__)) as g:
         g.command('sample-command', '{}.{}'.format(TestCommandRegistration.__name__,
                                                    TestCommandRegistration.sample_command_handler.__name__))
     with ArgumentsContext(cl, command_name) as ac:
         ac.argument('resource_name', CLIArgumentType(
         options_list=('--wonky-name', '-n'), metavar='RNAME', help='Completely WONKY name...',
         required=False
     ))
     cl.load_arguments(command_name)
     self.assertEqual(len(cl.command_table), 1, 'We expect exactly one command in the command table')
     command_metadata = cl.command_table[command_name]
     self.assertEqual(len(command_metadata.arguments), 4, 'We expected exactly 4 arguments')
     some_expected_arguments = {
         'group_name': CLIArgumentType(dest='group_name', required=True),
         'resource_name': CLIArgumentType(dest='resource_name', required=False),
     }
     for probe in some_expected_arguments:
         existing = next(arg for arg in command_metadata.arguments if arg == probe)
         contains_subset = _dictContainsSubset(some_expected_arguments[existing].settings,
                                               command_metadata.arguments[existing].options)
         self.assertTrue(contains_subset)
     self.assertEqual(command_metadata.arguments['resource_name'].options_list, ('--wonky-name', '-n'))
    def test_register_extra_cli_argument(self):
        cl = CLICommandsLoader(self.mock_ctx)
        command_name = self._set_command_name('test register sample-command')
        with CommandGroup(cl, 'test register',
                          '{}#{{}}'.format(__name__)) as g:
            g.command(
                'sample-command', '{}.{}'.format(
                    TestCommandRegistration.__name__,
                    TestCommandRegistration.sample_command_handler.__name__))
        with ArgumentsContext(cl, command_name) as ac:
            ac.extra('added_param',
                     options_list=('--added-param', ),
                     metavar='ADDED',
                     help='Just added this right now!',
                     required=True)
        cl.load_arguments(command_name)
        self.assertEqual(len(cl.command_table), 1,
                         'We expect exactly one command in the command table')
        command_metadata = cl.command_table[command_name]
        self.assertEqual(len(command_metadata.arguments), 5,
                         'We expected exactly 5 arguments')

        some_expected_arguments = {
            'added_param': CLIArgumentType(dest='added_param', required=True)
        }

        for probe in some_expected_arguments:
            existing = next(arg for arg in command_metadata.arguments
                            if arg == probe)
            contains_subset = _dictContainsSubset(
                some_expected_arguments[existing].settings,
                command_metadata.arguments[existing].options)
            self.assertTrue(contains_subset)
예제 #10
0
 def test_register_cli_argument_with_overrides(self):
     cl = CLICommandsLoader(self.mock_ctx)
     global_vm_name_type = CLIArgumentType(
         options_list=('--foo', '-f'), metavar='FOO', help='foo help'
     )
     derived_vm_name_type = CLIArgumentType(base_type=global_vm_name_type,
                                            help='first modification')
     with CommandGroup(cl, 'test', '{}#{{}}'.format(__name__)) as g:
         g.command('sample-get', '{}.{}'.format(TestCommandRegistration.__name__,
                                                TestCommandRegistration.sample_command_handler.__name__))
         g.command('command sample-get-1', '{}.{}'.format(TestCommandRegistration.__name__,
                                                          TestCommandRegistration.sample_command_handler.__name__))
         g.command('command sample-get-2', '{}.{}'.format(TestCommandRegistration.__name__,
                                                          TestCommandRegistration.sample_command_handler.__name__))
     with ArgumentsContext(cl, 'test') as ac:
         ac.argument('resource_name', global_vm_name_type)
     with ArgumentsContext(cl, 'test command') as ac:
         ac.argument('resource_name', derived_vm_name_type)
     with ArgumentsContext(cl, 'test command sample-get-2') as ac:
         ac.argument('resource_name', derived_vm_name_type, help='second modification')
     cl.load_arguments('test sample-get')
     cl.load_arguments('test command sample-get-1')
     cl.load_arguments('test command sample-get-2')
     self.assertEqual(len(cl.command_table), 3, 'We expect exactly three commands in the command table')
     command1 = cl.command_table['test sample-get'].arguments['resource_name']
     command2 = cl.command_table['test command sample-get-1'].arguments['resource_name']
     command3 = cl.command_table['test command sample-get-2'].arguments['resource_name']
     self.assertTrue(command1.options['help'] == 'foo help')
     self.assertTrue(command2.options['help'] == 'first modification')
     self.assertTrue(command3.options['help'] == 'second modification')
    def test_override_using_register_cli_argument(self):
        def sample_sdk_method(param_a):  # pylint: disable=unused-argument
            pass

        def test_validator_completer():
            pass

        cl = CLICommandsLoader(self.mock_ctx)
        command_name = self._set_command_name(
            'override_using_register_cli_argument foo')
        setattr(sys.modules[__name__], sample_sdk_method.__name__,
                sample_sdk_method)
        with CommandGroup(cl, 'override_using_register_cli_argument',
                          '{}#{{}}'.format(__name__)) as g:
            g.command('foo', sample_sdk_method.__name__)
        with ArgumentsContext(cl,
                              'override_using_register_cli_argument') as ac:
            ac.argument('param_a',
                        options_list=('--overridden', '-r'),
                        validator=test_validator_completer,
                        completer=test_validator_completer,
                        required=False)
        cl.load_arguments(command_name)

        command_metadata = cl.command_table[command_name]
        self.assertEqual(len(command_metadata.arguments), 1,
                         'We expected exactly 1 arguments')

        actual_arg = command_metadata.arguments['param_a']
        self.assertEqual(actual_arg.options_list, ('--overridden', '-r'))
        self.assertEqual(actual_arg.validator, test_validator_completer)
        self.assertEqual(actual_arg.completer, test_validator_completer)
        self.assertFalse(actual_arg.options['required'])
예제 #12
0
            def load_command_table(self, args):
                super(HelpTestCommandLoader, self).load_command_table(args)
                with CommandGroup(self, '', '{}#{{}}'.format(__name__)) as g:
                    g.command('n1', 'example_handler')
                    g.command('n2', 'example_handler')
                    g.command('n3', 'example_handler')
                    g.command('n4', 'example_handler')
                    g.command('n5', 'example_handler')

                with CommandGroup(self, 'group alpha', '{}#{{}}'.format(__name__)) as g:
                    g.command('n1', 'example_handler')

                with CommandGroup(self, 'group beta', '{}#{{}}'.format(__name__)) as g:
                    g.command('n1', 'example_handler')

                return self.command_table
예제 #13
0
 def load_command_table(self, args):
     with CommandGroup(self, 'task', 'egor.task#{}') as g:
         g.command('parse', 'parse_task')
         g.command('test', 'test_task')
         g.command('remove', 'remove_task')
         g.command('copy', 'copy_task')
         g.command('testcase', 'new_test_case')
     return OrderedDict(self.command_table)
예제 #14
0
def load_command_table(self, _):

    def operation_group(name):
        return 'azdev.operations.{}#{{}}'.format(name)

    with CommandGroup(self, '', operation_group('setup')) as g:
        g.command('setup', 'setup')

    # TODO: enhance with tox support
    with CommandGroup(self, '', operation_group('tests')) as g:
        g.command('test', 'run_tests')

    with CommandGroup(self, '', operation_group('style')) as g:
        g.command('style', 'check_style')

    with CommandGroup(self, '', operation_group('linter')) as g:
        g.command('linter', 'run_linter')

    with CommandGroup(self, 'verify', operation_group('pypi')) as g:
        g.command('history', 'check_history')
        g.command('version', 'verify_versions')

    with CommandGroup(self, 'verify', operation_group('help')) as g:
        g.command('document-map', 'check_document_map')

    with CommandGroup(self, 'verify', operation_group('legal')) as g:
        g.command('license', 'check_license_headers')

    with CommandGroup(self, 'perf', operation_group('performance')) as g:
        g.command('load-times', 'check_load_time')

    # with CommandGroup(self, 'sdk', operation_group('python_sdk')) as g:
    #     g.command('draft', 'install_draft_sdk')

    with CommandGroup(self, 'extension', operation_group('extensions')) as g:
        g.command('add', 'add_extension')
        g.command('remove', 'remove_extension')
        g.command('list', 'list_extensions')
        # g.command('build', 'build_extension')
        # g.command('publish', 'publish_extension')
        g.command('update-index', 'update_extension_index')

    with CommandGroup(self, 'extension repo', operation_group('extensions')) as g:
        g.command('add', 'add_extension_repo')
        g.command('remove', 'remove_extension_repo')
        g.command('list', 'list_extension_repos')
예제 #15
0
    def test_register_command_group_with_no_group_name(self):
        cl = CLICommandsLoader(self.mock_ctx)
        command_name = 'sample-command'
        with CommandGroup(cl, None, '{}#{{}}'.format(__name__)) as g:
            g.command('sample-command', '{}.{}'.format(TestCommandRegistration.__name__,
                                                       TestCommandRegistration.sample_command_handler.__name__))

        self.assertEqual(len(cl.command_table), 1, 'We expect exactly one command in the command table')
        self.assertIn(command_name, cl.command_table)
예제 #16
0
            def load_command_table(self, args):
                super(ExperimentalTestCommandLoader,
                      self).load_command_table(args)

                with CommandGroup(self,
                                  'group1',
                                  '{}#{{}}'.format(__name__),
                                  is_experimental=True) as g:
                    g.command('cmd1', 'example_handler')

                return self.command_table
예제 #17
0
def load_transfer_commands(cli_command_loader):
    with CommandGroup(cli_command_loader, 'artifact',
                      'mvnfeed.cli.transfer.{}') as g:
        g.command('transfer', 'transfer#transfer_artifact')
        g.command('bulk-transfer', 'transfer#transfer_bulk')

    with CommandGroup(cli_command_loader, 'config stage_dir',
                      'mvnfeed.cli.transfer.{}') as g:
        g.command('set', 'configuration#set_stagedir')
        g.command('view', 'configuration#view_stagedir')

    with CommandGroup(cli_command_loader, 'config repo',
                      'mvnfeed.cli.transfer.{}') as g:
        g.command('add', 'configuration#add_repository')
        g.command('delete', 'configuration#delete_repository')
        g.command('list', 'configuration#list_repositories')

    with CommandGroup(cli_command_loader, 'input',
                      'mvnfeed.cli.transfer.{}') as g:
        g.command('cleanup', 'cleanup#cleanup_file')
예제 #18
0
 def test_register_command_custom_excluded_params(self):
     command_name = 'test sample-command'
     ep = ['self', 'raw', 'custom_headers', 'operation_config', 'content_version', 'kwargs', 'client']
     cl = CLICommandsLoader(self.mock_ctx, excluded_command_handler_args=ep)
     with CommandGroup(cl, 'test', '{}#{{}}'.format(__name__)) as g:
         g.command('sample-command', '{}.{}'.format(TestCommandRegistration.__name__,
                                                    TestCommandRegistration.sample_command_handler2.__name__))
     self.assertEqual(len(cl.command_table), 1, 'We expect exactly one command in the command table')
     cl.load_arguments(command_name)
     command_metadata = cl.command_table[command_name]
     self.assertEqual(len(command_metadata.arguments), 4, 'We expected exactly 4 arguments')
     self.assertIn(command_name, cl.command_table)
예제 #19
0
 def test_register_command_confirmation_bool(self):
     cl = CLICommandsLoader(self.mock_ctx)
     command_name = 'test sample-command'
     with CommandGroup(cl, 'test', '{}#{{}}'.format(__name__)) as g:
         g.command('sample-command', '{}.{}'.format(TestCommandRegistration.__name__,
                                                    TestCommandRegistration.sample_command_handler.__name__),
                   confirmation=True)
     self.assertEqual(len(cl.command_table), 1, 'We expect exactly one command in the command table')
     cl.load_arguments(command_name)
     command_metadata = cl.command_table[command_name]
     self.assertIn('yes', command_metadata.arguments)
     self.assertEqual(command_metadata.arguments['yes'].type.settings['action'], 'store_true')
     self.assertIs(command_metadata.confirmation, True)
예제 #20
0
 def test_register_ignore_cli_argument(self):
     cl = CLICommandsLoader(self.mock_ctx)
     command_name = 'test register sample-command'
     with CommandGroup(cl, 'test register', '{}#{{}}'.format(__name__)) as g:
         g.command('sample-command', '{}.{}'.format(TestCommandRegistration.__name__,
                                                    TestCommandRegistration.sample_command_handler.__name__))
     with ArgumentsContext(cl, 'test register') as ac:
         ac.argument('resource_name', options_list=['--this'])
     with ArgumentsContext(cl, 'test register sample-command') as ac:
         ac.ignore('resource_name')
         ac.argument('opt_param', options_list=['--this'])
     cl.load_arguments(command_name)
     self.assertNotEqual(cl.command_table[command_name].arguments['resource_name'].options_list,
                         cl.command_table[command_name].arguments['opt_param'].options_list,
                         "Name conflict in options list")
예제 #21
0
def load_admin_commands(cli_command_loader):
    with CommandGroup(cli_command_loader, 'admin',
                      'vsts.cli.admin.common.banner#{}') as g:
        g.command('banner list',
                  'banner_list',
                  table_transformer=transform_banner_table_output)
        g.command('banner show',
                  'banner_show',
                  table_transformer=transform_banner_table_output)
        g.command('banner add',
                  'banner_add',
                  table_transformer=transform_banner_table_output)
        g.command('banner remove', 'banner_remove')
        g.command('banner update',
                  'banner_update',
                  table_transformer=transform_banner_table_output)
예제 #22
0
def load_work_commands(cli_command_loader):
    with CommandGroup(cli_command_loader, 'work',
                      'vsts.cli.work.common.work_item#{}') as g:
        g.command('item show',
                  'show_work_item',
                  table_transformer=transform_work_item_table_output)
        g.command('item create',
                  'create_work_item',
                  table_transformer=transform_work_item_table_output)
        g.command(
            'item query',
            'query_work_items',
            table_transformer=transform_work_item_query_result_table_output)
        g.command('item update',
                  'update_work_item',
                  table_transformer=transform_work_item_table_output)
    def test_command_build_argument_help_text(self):
        def sample_sdk_method_with_weird_docstring(param_a, param_b, param_c):  # pylint: disable=unused-argument
            """
            An operation with nothing good.

            :param dict param_a:
            :param param_b: The name
            of
            nothing.
            :param param_c: The name
            of

            nothing2.
            """
            pass

        cl = CLICommandsLoader(self.mock_ctx)
        command_name = self._set_command_name('test command foo')
        setattr(sys.modules[__name__],
                sample_sdk_method_with_weird_docstring.__name__,
                sample_sdk_method_with_weird_docstring)
        with CommandGroup(cl, 'test command', '{}#{{}}'.format(__name__)) as g:
            g.command('foo', sample_sdk_method_with_weird_docstring.__name__)
        cl.load_arguments(command_name)
        command_metadata = cl.command_table[command_name]
        self.assertEqual(len(command_metadata.arguments), 3,
                         'We expected exactly 3 arguments')
        some_expected_arguments = {
            'param_a':
            CLIArgumentType(dest='param_a', required=True, help=''),
            'param_b':
            CLIArgumentType(dest='param_b',
                            required=True,
                            help='The name of nothing.'),
            'param_c':
            CLIArgumentType(dest='param_c',
                            required=True,
                            help='The name of nothing2.')
        }

        for probe in some_expected_arguments:
            existing = next(arg for arg in command_metadata.arguments
                            if arg == probe)
            contains_subset = _dictContainsSubset(
                some_expected_arguments[existing].settings,
                command_metadata.arguments[existing].options)
            self.assertTrue(contains_subset)
예제 #24
0
def load_release_commands(cli_command_loader):
    with CommandGroup(cli_command_loader, 'release',
                      'vsts.cli.release.common.{}') as g:
        # basic vsts_cli_release commands
        g.command('list',
                  'release#release_list',
                  table_transformer=transform_releases_table_output)
        g.command('create',
                  'release#release_create',
                  table_transformer=transform_release_table_output)
        g.command('show',
                  'release#release_show',
                  table_transformer=transform_release_table_output)

        # basic vsts_cli_release definition commands
        g.command('definition list',
                  'release_definition#release_definition_list',
                  table_transformer=transform_release_definitions_table_output)
        g.command('definition show',
                  'release_definition#release_definition_show',
                  table_transformer=transform_release_definition_table_output)
    def test_register_cli_argument_with_overrides(self):
        cl = CLICommandsLoader(self.mock_ctx)
        base_type = CLIArgumentType(options_list=['--foo', '-f'],
                                    metavar='FOO',
                                    help='help1')
        derived_type = CLIArgumentType(base_type=base_type, help='help2')
        with CommandGroup(cl, 'test', '{}#{{}}'.format(__name__)) as g:
            g.command(
                'sample-get', '{}.{}'.format(
                    TestCommandRegistration.__name__,
                    TestCommandRegistration.sample_command_handler.__name__))
            g.command(
                'command sample-get-1', '{}.{}'.format(
                    TestCommandRegistration.__name__,
                    TestCommandRegistration.sample_command_handler.__name__))
            g.command(
                'command sample-get-2', '{}.{}'.format(
                    TestCommandRegistration.__name__,
                    TestCommandRegistration.sample_command_handler.__name__))
        self.assertEqual(
            len(cl.command_table), 3,
            'We expect exactly three commands in the command table')

        def test_with_command(command, target_value):
            self._set_command_name(command)
            with ArgumentsContext(cl, 'test') as c:
                c.argument('resource_name', base_type)
            with ArgumentsContext(cl, 'test command') as c:
                c.argument('resource_name', derived_type)
            with ArgumentsContext(cl, 'test command sample-get-2') as c:
                c.argument('resource_name', derived_type, help='help3')
            cl.load_arguments(command)
            command1 = cl.command_table[command].arguments['resource_name']
            self.assertEqual(command1.options['help'], target_value)

        test_with_command('test sample-get', 'help1')
        test_with_command('test command sample-get-1', 'help2')
        test_with_command('test command sample-get-2', 'help3')
예제 #26
0
 def load_command_table(self, args):
     super(PreviewTestCommandLoader, self).load_command_table(args)
     with CommandGroup(self, '', '{}#{{}}'.format(__name__)) as g:
         g.command('arg-test', 'example_arg_handler')
     return self.command_table
예제 #27
0
def load_command_table(self, _):
    def operation_group(name):
        return 'azdev.operations.{}#{{}}'.format(name)

    with CommandGroup(self, '', operation_group('setup')) as g:
        g.command('setup', 'setup')

    # TODO: enhance with tox support
    with CommandGroup(self, '', operation_group('testtool')) as g:
        g.command('test', 'run_tests')

    with CommandGroup(self, '', operation_group('style')) as g:
        g.command('style', 'check_style')

    with CommandGroup(self, '', operation_group('linter')) as g:
        g.command('linter', 'run_linter')

    with CommandGroup(self, 'verify', operation_group('pypi')) as g:
        g.command('history', 'check_history')

    with CommandGroup(self, 'cli', operation_group('pypi')) as g:
        g.command('check-versions', 'verify_versions')

    with CommandGroup(self, '', operation_group('code_gen')) as g:
        g.command('cli create', 'create_module')
        g.command('extension create', 'create_extension')

    with CommandGroup(self, 'verify', operation_group('help')) as g:
        g.command('document-map', 'check_document_map')

    with CommandGroup(self, 'verify', operation_group('legal')) as g:
        g.command('license', 'check_license_headers')

    with CommandGroup(self, 'perf', operation_group('performance')) as g:
        g.command('load-times', 'check_load_time')
        g.command('benchmark',
                  'benchmark',
                  is_preview=True,
                  table_transformer=performance_benchmark_data_transformer)

    with CommandGroup(self, 'extension', operation_group('extensions')) as g:
        g.command('add', 'add_extension')
        g.command('remove', 'remove_extension')
        g.command('list', 'list_extensions')
        g.command('build', 'build_extensions')
        g.command('publish', 'publish_extensions')
        g.command('update-index', 'update_extension_index')

    with CommandGroup(self, 'extension repo',
                      operation_group('extensions')) as g:
        g.command('add', 'add_extension_repo')
        g.command('remove', 'remove_extension_repo')
        g.command('list', 'list_extension_repos')

    with CommandGroup(self, 'cli', operation_group('help')) as g:
        g.command('generate-docs', 'generate_cli_ref_docs')

    with CommandGroup(self, 'extension', operation_group('help')) as g:
        g.command('generate-docs', 'generate_extension_ref_docs')
예제 #28
0
    def load_command_table(self, args):  # pylint: disable=too-many-statements
        """Load all Service Fabric commands"""

        # -----------------
        # Standard commands
        # -----------------

        client_func_path = 'azure.servicefabric#ServiceFabricClientAPIs.{}'
        mesh_code_package_func_path = 'azure.servicefabric.operations#MeshCodePackageOperations.{}'
        mesh_gateway_func_path = 'azure.servicefabric.operations#MeshGatewayOperations.{}'
        mesh_secret_func_path = 'azure.servicefabric.operations#MeshSecretOperations.{}'
        mesh_secret_value_func_path = 'azure.servicefabric.operations#MeshSecretValueOperations.{}'
        mesh_network_func_path = 'azure.servicefabric.operations#MeshNetworkOperations.{}'
        mesh_application_func_path = 'azure.servicefabric.operations#MeshApplicationOperations.{}'
        mesh_volume_func_path = 'azure.servicefabric.operations#MeshVolumeOperations.{}'
        mesh_service_func_path = 'azure.servicefabric.operations#MeshServiceOperations.{}'
        mesh_service_replica_func_path = 'azure.servicefabric.operations#MeshServiceReplicaOperations.{}'  #pylint: disable=line-too-long

        with CommandGroup(self,
                          'rpm',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('delete', 'delete_repair_task')
            group.command('list', 'get_repair_task_list')
            group.command('approve-force', 'force_approve_repair_task')

        with CommandGroup(self,
                          'sa-cluster',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('config', 'get_cluster_configuration')
            group.command('upgrade-status',
                          'get_cluster_configuration_upgrade_status')

        with CommandGroup(self,
                          'cluster',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('health', 'get_cluster_health')
            group.command('manifest', 'get_cluster_manifest')
            group.command('code-versions',
                          'get_provisioned_fabric_code_version_info_list')
            group.command('config-versions',
                          'get_provisioned_fabric_config_version_info_list')
            group.command('upgrade-status', 'get_cluster_upgrade_progress')
            group.command('recover-system', 'recover_system_partitions')
            group.command('operation-list', 'get_fault_operation_list')
            group.command('operation-cancel', 'cancel_operation')
            group.command('provision', 'provision_cluster')
            group.command('unprovision', 'unprovision_cluster')
            group.command('upgrade-rollback', 'rollback_cluster_upgrade')
            group.command('upgrade-resume', 'resume_cluster_upgrade')

        with CommandGroup(self,
                          'node',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('list', 'get_node_info_list')
            group.command('info', 'get_node_info')
            group.command('health', 'get_node_health')
            group.command('load', 'get_node_load_info')
            group.command('disable', 'disable_node')
            group.command('enable', 'enable_node')
            group.command('remove-state', 'remove_node_state')
            group.command('restart', 'restart_node')
            group.command('transition', 'start_node_transition')
            group.command('transition-status', 'get_node_transition_progress')
            group.command('add-configuration-parameter-overrides',
                          'add_configuration_parameter_overrides')
            group.command('get-configuration-overrides',
                          'get_configuration_overrides')
            group.command('remove-configuration-overrides',
                          'remove_configuration_overrides')

        with CommandGroup(self,
                          'application',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('type-list', 'get_application_type_info_list')
            group.command('type', 'get_application_type_info_list_by_name')
            group.command('unprovision', 'unprovision_application_type')
            group.command('delete', 'delete_application')
            group.command('list', 'get_application_info_list')
            group.command('info', 'get_application_info')
            group.command('health', 'get_application_health')
            group.command('upgrade-status', 'get_application_upgrade')
            group.command('upgrade-resume', 'resume_application_upgrade')
            group.command('upgrade-rollback', 'rollback_application_upgrade')
            group.command('deployed-list',
                          'get_deployed_application_info_list')
            group.command('deployed', 'get_deployed_application_info')
            group.command('deployed-health', 'get_deployed_application_health')
            group.command('manifest', 'get_application_manifest')
            group.command('load', 'get_application_load_info')

        with CommandGroup(self,
                          'service',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('type-list', 'get_service_type_info_list')
            group.command('manifest', 'get_service_manifest')
            group.command('deployed-type-list',
                          'get_deployed_service_type_info_list')
            group.command('deployed-type',
                          'get_deployed_service_type_info_by_name')
            group.command('list', 'get_service_info_list')
            group.command('info', 'get_service_info')
            group.command('app-name', 'get_application_name_info')
            group.command('delete', 'delete_service')
            group.command('description', 'get_service_description')
            group.command('health', 'get_service_health')
            group.command('resolve', 'resolve_service')
            group.command('recover', 'recover_service_partitions')
            group.command('package-list',
                          'get_deployed_service_package_info_list')
            group.command('package-info',
                          'get_deployed_service_package_info_list_by_name')
            group.command('package-health',
                          'get_deployed_service_package_health')
            group.command('code-package-list',
                          'get_deployed_code_package_info_list')
            group.command('get-container-logs',
                          'get_container_logs_deployed_on_node')

        with CommandGroup(self,
                          'partition',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('list', 'get_partition_info_list')
            group.command('info', 'get_partition_info')
            group.command('svc-name', 'get_service_name_info')
            group.command('health', 'get_partition_health')
            group.command('load', 'get_partition_load_information')
            group.command('load-reset', 'reset_partition_load')
            group.command('recover', 'recover_partition')
            group.command('recover-all', 'recover_all_partitions')
            group.command('data-loss', 'start_data_loss')
            group.command('data-loss-status', 'get_data_loss_progress')
            group.command('quorum-loss', 'start_quorum_loss')
            group.command('quorum-loss-status', 'get_quorum_loss_progress')
            group.command('restart', 'start_partition_restart')
            group.command('restart-status', 'get_partition_restart_progress')
            group.command(
                'move-primary-replica',
                'move_primary_replica',
            )
            group.command(
                'move-secondary-replica',
                'move_secondary_replica',
            )
            group.command(
                'move-instance',
                'move_instance',
            )
            group.command(
                'get-loaded-partition-info-list',
                'get_loaded_partition_info_list',
            )

        with CommandGroup(self,
                          'replica',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('list', 'get_replica_info_list')
            group.command('info', 'get_replica_info')
            group.command('health', 'get_replica_health')
            group.command('deployed-list',
                          'get_deployed_service_replica_info_list')
            group.command('deployed',
                          'get_deployed_service_replica_detail_info')
            group.command('restart', 'restart_replica')
            group.command('remove', 'remove_replica')

        with CommandGroup(self,
                          'compose',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('status', 'get_compose_deployment_status')
            group.command('list', 'get_compose_deployment_status_list')
            group.command('remove', 'remove_compose_deployment')
            group.command('upgrade-status',
                          'get_compose_deployment_upgrade_progress')
            group.command('upgrade-rollback',
                          'start_rollback_compose_deployment_upgrade')

        with CommandGroup(self,
                          'chaos',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('stop', 'stop_chaos')
            group.command('events', 'get_chaos_events')
            group.command('get', 'get_chaos')

        with CommandGroup(self,
                          'chaos schedule',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('get', 'get_chaos_schedule')

        with CommandGroup(self,
                          'store',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('stat', 'get_image_store_content')
            group.command('delete', 'delete_image_store_content')
            group.command('root-info', 'get_image_store_root_content')

        with CommandGroup(self,
                          'property',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('list', 'get_property_info_list')
            group.command('get', 'get_property_info')
            group.command('delete', 'delete_property')

        with CommandGroup(self,
                          'events',
                          client_func_path,
                          client_factory=client_create) as group:
            group.command('cluster-list', 'get_cluster_event_list')
            group.command('all-nodes-list', 'get_nodes_event_list')
            group.command('node-list', 'get_node_event_list')
            group.command('all-applications-list',
                          'get_applications_event_list')
            group.command('application-list', 'get_application_event_list')
            group.command('all-services-list', 'get_services_event_list')
            group.command('service-list', 'get_service_event_list')
            group.command('all-partitions-list', 'get_partitions_event_list')
            group.command('partition-list', 'get_partition_event_list')
            group.command('partition-all-replicas-list',
                          'get_partition_replicas_event_list')
            group.command('partition-replica-list',
                          'get_partition_replica_event_list')

        # ---------------
        # Mesh standard commands
        # ---------------
        with CommandGroup(self,
                          'mesh gateway',
                          mesh_gateway_func_path,
                          client_factory=mesh_gateway_create) as group:
            group.command('show', 'get')
            group.command('delete', 'delete')
            group.command('list', 'list')

        with CommandGroup(self,
                          'mesh network',
                          mesh_network_func_path,
                          client_factory=mesh_network_create) as group:
            group.command('show', 'get')
            group.command('delete', 'delete')
            group.command('list', 'list')

        with CommandGroup(self,
                          'mesh code-package-log',
                          mesh_code_package_func_path,
                          client_factory=mesh_code_package_create) as group:
            group.command('get', 'get_container_logs')

        with CommandGroup(self,
                          'mesh secret',
                          mesh_secret_func_path,
                          client_factory=mesh_secret_create) as group:
            group.command('show', 'get')
            group.command('delete', 'delete')
            group.command('list', 'list')

        with CommandGroup(self,
                          'mesh secretvalue',
                          mesh_secret_value_func_path,
                          client_factory=mesh_secret_value_create) as group:
            group.command('delete', 'delete')
            group.command('list', 'list')

        with CommandGroup(self,
                          'mesh app',
                          mesh_application_func_path,
                          client_factory=mesh_app_create) as group:
            group.command('show', 'get')
            group.command('delete', 'delete')
            group.command('list', 'list')

        with CommandGroup(self,
                          'mesh volume',
                          mesh_volume_func_path,
                          client_factory=mesh_volume_create) as group:
            group.command('show', 'get')
            group.command('delete', 'delete')
            group.command('list', 'list')

        with CommandGroup(self,
                          'mesh service',
                          mesh_service_func_path,
                          client_factory=mesh_service_create) as group:
            group.command('show', 'get')
            group.command('list', 'list')

        with CommandGroup(self,
                          'mesh service-replica',
                          mesh_service_replica_func_path,
                          client_factory=mesh_service_replica_create) as group:
            group.command('list', 'list')
            group.command('show', 'get')
        # ---------------
        # Custom commands
        # ---------------

        with CommandGroup(self,
                          'container',
                          'sfctl.custom_container#{}',
                          client_factory=client_create) as group:
            group.command('invoke-api', 'invoke_api')
            group.command('logs', 'logs')

        with CommandGroup(self,
                          'cluster',
                          'sfctl.custom_cluster_upgrade#{}',
                          client_factory=client_create) as group:
            group.command('upgrade', 'upgrade')
            group.command('upgrade-update', 'update_upgrade')

        with CommandGroup(self,
                          'sa-cluster',
                          'sfctl.custom_cluster_upgrade#{}',
                          client_factory=client_create) as group:
            group.command('config-upgrade', 'sa_configuration_upgrade')

        with CommandGroup(self,
                          'compose',
                          'sfctl.custom_compose#{}',
                          client_factory=client_create) as group:
            group.command('upgrade', 'upgrade')
            group.command('create', 'create')

        with CommandGroup(self,
                          'application',
                          'sfctl.custom_app#{}',
                          client_factory=client_create) as group:
            group.command('create', 'create')
            group.command('upgrade', 'upgrade')

        with CommandGroup(self, 'application', 'sfctl.custom_app#{}') as group:
            group.command('upload', 'upload')

        # Need an empty client for the select and upload operations
        with CommandGroup(self, 'cluster', 'sfctl.custom_cluster#{}') as group:
            group.command('select', 'select')
            group.command('show-connection', 'show_connection')

        with CommandGroup(self,
                          'chaos',
                          'sfctl.custom_chaos#{}',
                          client_factory=client_create) as group:
            group.command('start', 'start')

        with CommandGroup(self,
                          'chaos schedule',
                          'sfctl.custom_chaos_schedule#{}',
                          client_factory=client_create) as group:
            group.command('set', 'set_chaos_schedule')

        with CommandGroup(self,
                          'service',
                          'sfctl.custom_service#{}',
                          client_factory=client_create) as group:
            group.command('create', 'create')
            group.command('update', 'update')
            group.command('package-deploy', 'package_upload')

        with CommandGroup(self,
                          'is',
                          'sfctl.custom_is#{}',
                          client_factory=client_create) as group:
            group.command('command', 'is_command')
            group.command('query', 'is_query')

        with CommandGroup(self,
                          'property',
                          'sfctl.custom_property#{}',
                          client_factory=client_create) as group:
            group.command('put', 'naming_property_put')

        with CommandGroup(self,
                          'application',
                          'sfctl.custom_app_type#{}',
                          client_factory=client_create) as group:
            group.command('provision', 'provision_application_type')

        client_func_path_health = 'sfctl.custom_health#{}'

        with CommandGroup(self,
                          'application',
                          client_func_path_health,
                          client_factory=client_create) as group:
            group.command('report-health', 'report_app_health')

        with CommandGroup(self,
                          'service',
                          client_func_path_health,
                          client_factory=client_create) as group:
            group.command('report-health', 'report_svc_health')

        with CommandGroup(self,
                          'partition',
                          client_func_path_health,
                          client_factory=client_create) as group:
            group.command('report-health', 'report_partition_health')

        with CommandGroup(self,
                          'replica',
                          client_func_path_health,
                          client_factory=client_create) as group:
            group.command('report-health', 'report_replica_health')

        with CommandGroup(self,
                          'node',
                          client_func_path_health,
                          client_factory=client_create) as group:
            group.command('report-health', 'report_node_health')

        with CommandGroup(self,
                          'cluster',
                          client_func_path_health,
                          client_factory=client_create) as group:
            group.command('report-health', 'report_cluster_health')

        with CommandGroup(self,
                          'node',
                          'sfctl.custom_node#{}',
                          client_factory=client_create) as group:
            group.command('add-node-tags', 'add_node_tags')
            group.command('remove-node-tags', 'remove_node_tags')

        # ---------------
        # Mesh custom commands
        # ---------------
        with CommandGroup(self,
                          'mesh secretvalue',
                          'sfctl.custom_secret_value#{}',
                          client_factory=mesh_secret_value_create) as group:
            group.command('show', 'get_secret_value')

        client_func_path_mesh = 'sfctl.custom_deployment#{}'
        with CommandGroup(self,
                          'mesh deployment',
                          client_func_path_mesh,
                          client_factory=client_create) as group:
            group.command('create', 'mesh_deploy')

        # ---------------
        # Settings
        # ---------------

        with CommandGroup(self, 'settings telemetry',
                          'sfctl.custom_settings#{}') as group:
            group.command('set-telemetry', 'set_telemetry')

        return OrderedDict(self.command_table)
예제 #29
0
 def load_command_table(self, args):
     with CommandGroup(self, '', '__main__#{}') as g:
         g.command('serve', 'serve_command_handler', confirmation=False),
         g.command('analyze', 'analyze_command_handler', confirmation=False)
     return super(CommandsLoader, self).load_command_table(args)
예제 #30
0
def load_package_commands(cli_command_loader):
    with CommandGroup(cli_command_loader, 'package universal',
                      'vsts.cli.package.common.universal#{}') as g:
        g.command('publish', 'publish_package')
        g.command('download', 'download_package')