コード例 #1
0
ファイル: binding.py プロジェクト: BrnoPCmaniak/pulp
 def __init__(self, context):
     m = _('list bindings with consumer actions with a status of pending or failed')
     CriteriaCommand.__init__(self, self.run, 'unconfirmed', m, filtering=False)
     self.add_flag(PulpCliFlag('--bind',
                               _('limit search to bindings with unconfirmed bind actions')))
     self.add_flag(PulpCliFlag('--unbind',
                               _('limit search to bindings with unconfirmed unbind actions')))
     self.context = context
コード例 #2
0
ファイル: criteria_utils.py プロジェクト: ATIX-AG/pulp_rpm
def parse_key_value(args):
    """
    Meant to replace the CriteriaCommand _parse_key_value method. The docstring below was
    copied from that implementation.

    parses the raw user input, taken as a list of strings in the format
    'name=value', into a list of tuples in the format (name, value).

    :param args:    list of raw strings passed by the user on the command
                    line.
    :type  args:    list of basestrings

    :return:    new list of tuples in the format (name, value)
    """

    def translate(key_value_tuple):
        """
        :param key_value_tuple: single key/value tuple to translate
        :return: new key-value tuple to use
        """
        for orig_key, translated_key in TRANSLATIONS.items():
            if key_value_tuple[0] == orig_key:
                encoded_value = version_utils.encode(key_value_tuple[1])
                return translated_key, encoded_value

        return key_value_tuple

    base_parsed_list = CriteriaCommand._parse_key_value(args)
    translated_list = map(translate, base_parsed_list)

    return translated_list
コード例 #3
0
ファイル: criteria_utils.py プロジェクト: mibanescu/pulp_win
def parse_key_value(args):
    """
    Meant to replace the CriteriaCommand _parse_key_value method. The docstring below was
    copied from that implementation.

    parses the raw user input, taken as a list of strings in the format
    'name=value', into a list of tuples in the format (name, value).

    :param args:    list of raw strings passed by the user on the command
                    line.
    :type  args:    list of basestrings

    :return:    new list of tuples in the format (name, value)
    """
    def translate(key_value_tuple):
        """
        :param key_value_tuple: single key/value tuple to translate
        :return: new key-value tuple to use
        """
        for orig_key, translated_key in TRANSLATIONS.items():
            if key_value_tuple[0] == orig_key:
                encoded_value = version_utils.encode(key_value_tuple[1])
                return translated_key, encoded_value

        return key_value_tuple

    base_parsed_list = CriteriaCommand._parse_key_value(args)
    translated_list = map(translate, base_parsed_list)

    return translated_list
コード例 #4
0
ファイル: binding.py プロジェクト: taftsanders/pulp
 def __init__(self, context):
     m = _(
         'list bindings with consumer actions with a status of pending or failed'
     )
     CriteriaCommand.__init__(self,
                              self.run,
                              'unconfirmed',
                              m,
                              filtering=False)
     self.add_flag(
         PulpCliFlag(
             '--bind',
             _('limit search to bindings with unconfirmed bind actions')))
     self.add_flag(
         PulpCliFlag(
             '--unbind',
             _('limit search to bindings with unconfirmed unbind actions')))
     self.context = context
コード例 #5
0
    def __init__(self, context):
        PulpCliSection.__init__(self, 'user', 'manage users')

        self.context = context
        self.prompt = context.prompt # for easier access

        # Common Options
        login_option = PulpCliOption('--login', 'uniquely identifies the user; only alphanumeric, -, ., and _ allowed',
                                     required=True, validate_func=validators.id_validator_allow_dots)
        name_option = PulpCliOption('--name', 'user-readable full name of the user', required=False)

        # Create command
        create_command = PulpCliCommand('create', 'creates a user', self.create)
        create_command.add_option(login_option)
        create_command.add_option(PulpCliOption('--password', 'password for the new user, if you do not want to be prompted for one', required=False))
        create_command.add_option(name_option)
        self.add_command(create_command)

        # Update Command
        update_command = PulpCliCommand('update', 'changes metadata of an existing user', self.update)
        update_command.add_option(PulpCliOption('--login', 'identifies the user to be updated', required=True))
        update_command.add_option(name_option)
        update_command.add_option(PulpCliOption('--password', 'new password for the user, use -p if you want to be prompted for the password', required=False))
        update_command.add_option(PulpCliFlag('-p', 'if specified, you will be prompted to enter new password for the user'))
        self.add_command(update_command)

        # Delete Command
        delete_command = PulpCliCommand('delete', 'deletes a user', self.delete)
        delete_command.add_option(PulpCliOption('--login', 'identifies the user to be deleted', required=True))
        self.add_command(delete_command)

        # List Command
        list_command = PulpCliCommand('list', 'lists summary of users registered to the Pulp server', self.list)
        list_command.add_option(PulpCliFlag('--details', 'if specified, all the user information is displayed'))
        list_command.add_option(PulpCliOption('--fields', 'comma-separated list of user fields; if specified, only the given fields will displayed', required=False))
        self.add_command(list_command)

        # Search Command
        self.add_command(CriteriaCommand(self.search, include_search=True))
コード例 #6
0
ファイル: pulp_cli.py プロジェクト: ehelms/pulp
    def __init__(self, context):
        super(ConsumerGroupMemberSection, self).__init__('members', _('manage members of consumer groups'))
        self.context = context
        self.prompt = context.prompt

        id_option = PulpCliOption('--consumer-group-id', _('id of a consumer group'), required=True)

        list_command = PulpCliCommand('list', _('list of consumers in a particular group'), self.list)
        list_command.add_option(id_option)
        self.add_command(list_command)

        add_command = CriteriaCommand(self.add, name='add', include_search=False,
            description=_('add consumers based on search parameters'))
        add_command.add_option(id_option)
        self.add_command(add_command)

        remove_command = CriteriaCommand(self.remove, name='remove', include_search=False,
            description=_('remove consumers based on search parameters'))
        remove_command.add_option(id_option)
        self.add_command(remove_command)
コード例 #7
0
 def test_valid(self):
     CriteriaCommand._validate_sort(['name,descending'])
コード例 #8
0
 def test_empty(self):
     ret = CriteriaCommand._parse_sort([])
     self.assertEqual(ret, [])
コード例 #9
0
 def test_multiple_args(self):
     ret = CriteriaCommand._parse_key_value(['id=repo1', 'name=foo'])
     self.assertEqual(ret, [['id', 'repo1'], ['name', 'foo']])
コード例 #10
0
 def test_empty(self):
     CriteriaCommand._validate_sort([])
コード例 #11
0
ファイル: binding.py プロジェクト: taftsanders/pulp
 def __init__(self, context):
     CriteriaCommand.__init__(self, self.run)
     self.context = context
コード例 #12
0
 def test_multiple_args(self):
     ret = CriteriaCommand._parse_key_value(['id=repo1', 'name=foo'])
     self.assertEqual(ret, [['id', 'repo1'], ['name', 'foo']])
コード例 #13
0
 def test_empty(self):
     ret = CriteriaCommand._parse_sort([])
     self.assertEqual(ret, [])
コード例 #14
0
 def test_trailing_comma(self):
     field_name, direction = CriteriaCommand._explode_sort_arg_pieces('name,')
     self.assertEqual(field_name, 'name')
     self.assertEqual(direction, 'ascending')
コード例 #15
0
 def test_empty(self):
     CriteriaCommand._validate_sort([])
コード例 #16
0
 def test_valid(self):
     CriteriaCommand._validate_sort(['name,descending'])
コード例 #17
0
 def test_without_criteria(self):
     self.command = CriteriaCommand(mock.MagicMock(), include_search=False)
     self.assertEqual(len(self.command.option_groups), 1)
     options_present = set([option.name for option in self.command.options])
     self.assertEqual(options_present, set(['--filters']))
コード例 #18
0
    def test_without_filtering(self):
        self.command = CriteriaCommand(mock.MagicMock(), filtering=False)
        self.assertEqual(len(self.command.option_groups), 0)

        options_present = set([option.name for option in self.command.options])
        self.assertTrue('--filters' not in options_present)
コード例 #19
0
 def setUp(self):
     self.command = CriteriaCommand(mock.MagicMock())
コード例 #20
0
 def test_valid(self):
     DATA = ('name', 'id,descending')
     ret = CriteriaCommand._parse_sort(DATA)
     self.assertEqual(ret, [('name', 'ascending'), ('id', 'descending')])
コード例 #21
0
ファイル: binding.py プロジェクト: BrnoPCmaniak/pulp
 def __init__(self, context):
     CriteriaCommand.__init__(self, self.run)
     self.context = context
コード例 #22
0
 def test_simple(self):
     field_name, direction = CriteriaCommand._explode_sort_arg_pieces('name,descending')
     self.assertEqual(field_name, 'name')
     self.assertEqual(direction, 'descending')
コード例 #23
0
 def test_basic(self):
     ret = CriteriaCommand._parse_key_value(['id=repo1'])
     self.assertEqual(ret, [['id', 'repo1']])
コード例 #24
0
 def test_basic(self):
     ret = CriteriaCommand._parse_key_value(['id=repo1'])
     self.assertEqual(ret, [['id', 'repo1']])
コード例 #25
0
 def test_trailing_comma(self):
     field_name, direction = CriteriaCommand._explode_sort_arg_pieces(
         'name,')
     self.assertEqual(field_name, 'name')
     self.assertEqual(direction, 'ascending')
コード例 #26
0
 def test_multiple_equals(self):
     # the second '=' should not be split
     ret = CriteriaCommand._parse_key_value(['id=repo=1'])
     self.assertEqual(ret, [['id', 'repo=1']])
コード例 #27
0
 def test_multiple_equals(self):
     # the second '=' should not be split
     ret = CriteriaCommand._parse_key_value(['id=repo=1'])
     self.assertEqual(ret, [['id', 'repo=1']])
コード例 #28
0
 def test_valid(self):
     DATA = ('name', 'id,descending')
     ret = CriteriaCommand._parse_sort(DATA)
     self.assertEqual(ret, [('name', 'ascending'), ('id', 'descending')])
コード例 #29
0
 def test_simple(self):
     field_name, direction = CriteriaCommand._explode_sort_arg_pieces(
         'name,descending')
     self.assertEqual(field_name, 'name')
     self.assertEqual(direction, 'descending')