Exemple #1
0
 def add_display_criteria_options(self):
     """
     Add the full set of criteria-based search features to this command,
     including limit, skip, sort, and fields.
     """
     self.add_option(PulpCliOption('--limit', _LIMIT_DESCRIPTION,
         required=False, parse_func=int,
         validate_func=validators.positive_int_validator))
     self.add_option(PulpCliOption('--skip', _SKIP_DESCRIPTION,
         required=False, parse_func=int,
         validate_func=validators.non_negative_int_validator))
     self.add_option(PulpCliOption('--sort', _SORT_DESCRIPTION,
         required=False, allow_multiple=True,
         validate_func=self._validate_sort,
         parse_func=self._parse_sort))
     self.add_option(PulpCliOption('--fields', _FIELDS_DESCRIPTION,
         required=False, validate_func=str,
         parse_func=lambda x: x.split(',')))
Exemple #2
0
    def add_filtering(self):
        self.add_option(PulpCliOption('--filters', _FILTERS_DESCRIPTION,
            required=False, parse_func=json.loads))

        filter_group = OptionGroup('Filters', _(_USAGE))

        m = _('match where a named attribute equals a string value exactly.')
        filter_group.add_option(PulpCliOption('--str-eq', m, required=False,
            allow_multiple=True, parse_func=self._parse_key_value))

        m = _('match where a named attribute equals an int value exactly.')
        filter_group.add_option(PulpCliOption('--int-eq', m, required=False,
            allow_multiple=True, parse_func=self._parse_key_value))

        m = _('for a named attribute, match a regular expression using the mongo regex engine.')
        filter_group.add_option(PulpCliOption('--match', m, required=False,
            allow_multiple=True, parse_func=self._parse_key_value))

        m = _('for a named attribute, match where value is in the provided list of values, expressed as one row of CSV')
        filter_group.add_option(PulpCliOption('--in', m, required=False,
            allow_multiple=True, parse_func=self._parse_key_value))

        m = _('field and expression to omit when determining units for inclusion')
        filter_group.add_option(PulpCliOption('--not', m, required=False,
            allow_multiple=True, parse_func=self._parse_key_value))

        m = _('matches resources whose value for the specified field is greater than the given value')
        filter_group.add_option(PulpCliOption('--gt', m, required=False,
            allow_multiple=True, parse_func=self._parse_key_value))

        m = _('matches resources whose value for the specified field is greater than or equal to the given value')
        filter_group.add_option(PulpCliOption('--gte', m, required=False,
            allow_multiple=True, parse_func=self._parse_key_value))

        m = _('matches resources whose value for the specified field is less than the given value')
        filter_group.add_option(PulpCliOption('--lt', m, required=False,
            allow_multiple=True, parse_func=self._parse_key_value))

        m = _('matches resources whose value for the specified field is less than or equal to the given value')
        filter_group.add_option(PulpCliOption ('--lte', m, required=False,
            allow_multiple=True, parse_func=self._parse_key_value))

        self.add_option_group(filter_group)
Exemple #3
0
    def __init__(self, context, *args, **kwargs):
        """
        @param context:
        @type  context: pulp.client.extensions.core.ClientContext
        """
        super(GenericSection, self).__init__(*args, **kwargs)

        self.context = context

        m = _('id of the event listener')
        self.id_option = PulpCliOption('--listener-id', m, required=True)

        m = _('one of "repo.sync.start", "repo.sync.finish", '
              '"repo.publish.start", "repo.publish.finish". May be '
              'specified multiple times. To match all types, use value "*"')
        self.event_types_option = PulpCliOption('--event-type',
                                                m,
                                                required=True,
                                                allow_multiple=True)
Exemple #4
0
 def __init__(self, context, name, description):
     PulpCliCommand.__init__(self, name, description, self.unbind)
     self.context = context
     self.prompt = context.prompt
     self.add_option(
         PulpCliOption('--repo-id', 'repository id', required=True))
     self.add_option(
         PulpCliFlag(
             '--force', 'delete the binding immediately and discontinue '
             'tracking consumer actions'))
Exemple #5
0
    def __init__(self, context):
        """
        @param context:
        @type  context: pulp.client.extensions.core.ClientContext
        """
        super(RestApiSection, self).__init__(context, 'http',
                                             _('manage http listeners'))

        m = _('full URL to invoke to send the event info')
        url_option = PulpCliOption('--url', m, required=True)

        m = _('optional username to be passed as basic auth credentials when '
              'the HTTP call is invoked.')
        username_option = PulpCliOption('--username', m, required=False)

        m = _('optional password to be passed as basic auth credentials when '
              'the HTTP call is invoked.')
        password_option = PulpCliOption('--password', m, required=False)

        m = _('optional CA file used instead of the system CA when '
              'the HTTP call is invoked.')
        ca_option = PulpCliOption('--ca-path', m, required=False)

        create_command = PulpCliCommand('create', _('create a listener'),
                                        self.create)
        create_command.add_option(self.event_types_option)
        create_command.add_option(url_option)
        create_command.add_option(username_option)
        create_command.add_option(password_option)
        create_command.add_option(ca_option)
        self.add_command(create_command)

        update_command = PulpCliCommand('update', _('update a listener'),
                                        self.update)
        update_command.add_option(self.id_option)
        update_command.add_option(
            self._copy_flip_required(self.event_types_option))
        update_command.add_option(self._copy_flip_required(url_option))
        update_command.add_option(username_option)
        update_command.add_option(password_option)
        update_command.add_option(ca_option)
        self.add_command(update_command)
Exemple #6
0
    def __init__(self, context):
        super(SearchErrataCommand, self).__init__(self.errata, context, name='errata',
                                                  description=DESC_ERRATA)

        erratum_group = PulpCliOptionGroup(_('Erratum'))

        m = _('if specified, the full details of an individual erratum are '
              'displayed, and all other options are ignored except for '
              '--repo-id.')
        erratum_group.add_option(PulpCliOption('--erratum-id', m, required=False))
        self.add_option_group(erratum_group)
Exemple #7
0
    def __init__(self, context, name='list', description=DESC_LIST, method=None):
        self.context = context
        self.prompt = context.prompt

        if method is None:
            method = self.run

        super(ListRepositoryGroupsCommand, self).__init__(name, description, method)

        self.add_option(PulpCliFlag('--details', _('if specified, all the repo group information is displayed')))
        self.add_option(PulpCliOption('--fields', _('comma-separated list of repo group fields; if specified, only the given fields will displayed'), required=False))
Exemple #8
0
    def __init__(self, context):
        PulpCliSection.__init__(self, 'user', _('add/remove user from the role'))

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

        # Common Options
        id_option = PulpCliOption('--role-id', 'identifies the role', required=True)
        login_option = PulpCliOption('--login', 'identifies the user', required=True)

        # AddUser command
        add_user_command = PulpCliCommand('add', 'adds user to a role', self.add_user)
        add_user_command.add_option(id_option)
        add_user_command.add_option(login_option)
        self.add_command(add_user_command)

        # RemoveUser command
        remove_user_command = PulpCliCommand('remove', 'removes user from a role', self.remove_user)
        remove_user_command.add_option(id_option)
        remove_user_command.add_option(login_option)
        self.add_command(remove_user_command)
Exemple #9
0
    def __init__(self, context, action, content_type, strategy=None):
        assert (content_type
                in (TYPE_ID_RPM, TYPE_ID_ERRATA, TYPE_ID_PKG_GROUP))

        strategy = strategy or YumConsumerContentScheduleStrategy(
            context, action, content_type)
        super(YumConsumerContentCreateScheduleCommand,
              self).__init__(context, action, strategy)

        # This will be substituted by the options below
        self.options.remove(OPTION_CONTENT_TYPE_ID)
        self.options.remove(OPTION_CONTENT_UNIT)

        if content_type == TYPE_ID_RPM:
            self.add_option(
                PulpCliOption(
                    '--name',
                    _('package name; may be repeated for multiple packages'),
                    required=True,
                    allow_multiple=True,
                    aliases=['-n']))
        elif content_type == TYPE_ID_ERRATA:
            self.add_option(
                PulpCliOption(
                    '--errata-id',
                    _('erratum id; may be repeated for multiple errata'),
                    required=True,
                    allow_multiple=True,
                    aliases=['-e']))
        elif content_type == TYPE_ID_PKG_GROUP:
            self.add_option(
                PulpCliOption(
                    '--name',
                    _('package group name; may be repeated for multiple package groups'
                      ),
                    required=True,
                    allow_multiple=True,
                    aliases=['-n']))
Exemple #10
0
    def __init__(self):
        super(PkgRepoOptionsBundle, self).__init__()
        self.opt_remove_missing.description += _('; defaults to false')

        # Add custom options
        d = _(
            'distribution releases (suites or codenames) to sync; defaults to stable'
        )
        self.opt_releases = PulpCliOption('--releases', d, required=False)
        d = _('components to sync')
        self.opt_components = PulpCliOption('--components', d, required=False)
        d = _('Comma separated list of architectures')
        self.opt_architectures = PulpCliOption('--architectures',
                                               d,
                                               required=False)
        d = _('Require that Release files are signed and verified')
        self.opt_require_signature = PulpCliOption('--require-signature',
                                                   d,
                                                   required=False)
        d = _('fingerprints of gpg-keys to verify releases signature against')
        self.opt_allowed_keys = PulpCliOption('--allowed-keys',
                                              d,
                                              required=False)
Exemple #11
0
    def __init__(self, context, name='list', description=DESC_LIST, method=None,
                 repos_title=None, other_repos_title=None, include_all_flag=True):
        self.context = context
        self.prompt = context.prompt

        if method is None:
            method = self.run

        self.repos_title = repos_title
        if self.repos_title is None:
            self.repos_title = _('Repositories')

        self.other_repos_title = other_repos_title
        if self.other_repos_title is None:
            self.other_repos_title = _('Other Pulp Repositories')

        super(ListRepositoriesCommand, self).__init__(name, description, method)

        d = _('if specified, a condensed view with just the repository ID and name is displayed')
        self.add_option(PulpCliFlag('--summary', d, aliases=['-s']))

        d = _('if specified, detailed configuration information is displayed for each repository')
        self.add_option(PulpCliFlag('--details', d))

        d = _('comma-separated list of repository fields; '
              'Example: "id,description,display_name,content_unit_counts". '
              'If specified, only the given fields will be displayed.')
        self.add_option(PulpCliOption('--fields', d, required=False))

        d = _('if specified, configuration information is displayed for one repository')
        self.add_option(PulpCliOption('--repo-id', d, required=False))

        self.supports_all = include_all_flag
        if self.supports_all:
            d = _('if specified, information on all Pulp repositories, '
                  'regardless of type, will be displayed')
            self.add_option(PulpCliFlag('--all', d, aliases=['-a']))
Exemple #12
0
    def __init__(self,
                 context,
                 name='list',
                 description=DESC_LIST,
                 method=None):
        self.context = context
        self.prompt = context.prompt

        if method is None:
            method = self.run

        super(ListConsumerGroupsCommand,
              self).__init__(name, description, method)

        self.add_option(
            PulpCliOption(
                '--fields',
                _('comma-separated list of repo group fields; if specified, only the given fields will '
                  'displayed'),
                required=False))
Exemple #13
0
    def __init__(self, context):
        super(AMQPSection, self).__init__(context, 'amqp',
                                          _('manage amqp listeners'))

        m = _('optional name of an exchange that overrides the setting from '
              'server.conf')
        self.exchange_option = PulpCliOption('--exchange', m, required=False)

        create_command = PulpCliCommand('create', _('create a listener'),
                                        self.create)
        create_command.add_option(self.event_types_option)
        create_command.add_option(self.exchange_option)
        self.add_command(create_command)

        m = _('update an event listener')
        update_command = PulpCliCommand('update', m, self.update)
        update_command.add_option(self.id_option)
        update_command.add_option(
            self._copy_flip_required(self.event_types_option))
        update_command.add_option(self.exchange_option)
        self.add_command(update_command)
Exemple #14
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))
Exemple #15
0
class CatalogDeleteCommand(PulpCliCommand):
    """
    Delete catalog entries command.
    :ivar context: The client context.
    :type context: pulp.client.extensions.core.ClientContext
    """

    NAME = 'delete'
    DESCRIPTION = _('delete entries from the catalog')
    SOURCE_ID_OPTION = PulpCliOption('--source-id', _('contributing content source'), aliases='-s')
    DELETED_MSG = _('Successfully deleted [%(deleted)s] catalog entries.')
    NONE_MATCHED_MSG = _('No catalog entries matched.')

    def __init__(self, context):
        """
        :param context: The client context.
        :type context: pulp.client.extensions.core.ClientContext
        """
        super(CatalogDeleteCommand, self).__init__(self.NAME, self.DESCRIPTION, self._run)
        self.add_option(self.SOURCE_ID_OPTION)
        self.context = context

    def _run(self, **kwargs):
        """
        Delete the content catalog for the specified source.
        Supported options:
          - source-id
        :param kwargs: User specified options.
        :type kwargs: dict
        """
        source_id = kwargs[self.SOURCE_ID_OPTION.keyword]
        response = self.context.server.content_catalog.delete(source_id)
        if response.response_body['deleted']:
            self.context.prompt.render_success_message(self.DELETED_MSG % response.response_body)
        else:
            self.context.prompt.render_success_message(self.NONE_MATCHED_MSG)
Exemple #16
0
    ' is %(limit)s' % {'limit': REPO_HISTORY_LIMIT})
DESC_PUBLISH_HISTORY = _(
    'displays the history of publish operations on a repository')
DESC_SORT = _(
    'indicates the sort direction ("ascending" or "descending") based on the timestamp'
)
DESC_SYNC_HISTORY = _(
    'displays the history of sync operations on a repository')
DESC_START_DATE = _(
    'only return entries that occur on or after the given date in iso8601 format'
    ' (yyyy-mm-ddThh:mm:ssZ)')

# Options
OPTION_END_DATE = PulpCliOption(
    '--end-date',
    DESC_END_DATE,
    required=False,
    validate_func=validators.iso8601_datetime_validator)
OPTION_LIMIT = PulpCliOption('--limit',
                             DESC_LIMIT,
                             required=False,
                             validate_func=validators.positive_int_validator)
OPTION_SORT = PulpCliOption('--sort', DESC_SORT, required=False)
OPTION_DISTRIBUTOR_ID = PulpCliOption('--distributor-id',
                                      DESC_DISTRIBUTOR_ID,
                                      required=True,
                                      validate_func=validators.id_validator)
OPTION_START_DATE = PulpCliOption(
    '--start-date',
    DESC_START_DATE,
    required=False,
Exemple #17
0
from pulp.client.commands.repo.cudl import CreateAndConfigureRepositoryCommand
from pulp.client.commands.repo.cudl import ListRepositoriesCommand
from pulp.client.commands.repo.cudl import UpdateRepositoryCommand
from pulp.client.commands.repo.importer_config import ImporterConfigMixin
from pulp.common.constants import REPO_NOTE_TYPE_KEY
from pulp.client.extensions.extensions import PulpCliOption

from pulp_ostree.common import constants


description = \
    _('if "true", on each successful sync the repository will automatically be '
      'published; if "false" content will only be available after manually publishing '
      'the repository; defaults to "true"')

OPT_AUTO_PUBLISH = PulpCliOption(
    '--auto-publish', description, required=False, parse_func=okaara_parsers.parse_boolean)

description = _('determines the path component of the published url; defaults to the repo ID')
OPT_RELATIVE_PATH = PulpCliOption('--relative-path', description, required=False)

DESC_FEED = _('URL for the upstream ostree repo')

description = _("a branch to sync from the upstream repository. This option "
                "may be specified multiple times")

OPT_BRANCH = PulpCliOption(
    '--branch', description, aliases=['-b'], required=False, allow_multiple=True)

description = _("the absolute path to an exported GPG key. This option "
                "may be specified multiple times")
Exemple #18
0
from gettext import gettext as _

from pulp.client import arg_utils, parsers
from pulp.client.commands import options
from pulp.client.commands.repo.importer_config import ImporterConfigMixin
from pulp.client.extensions.extensions import PulpCliOption
from pulp.client.commands.repo.cudl import (CreateRepositoryCommand, ListRepositoriesCommand,
                                            UpdateRepositoryCommand)

from pulp_puppet.common import constants


DESC_FEED = _('URL of the external source from which to import Puppet modules')
OPTION_FEED = PulpCliOption('--feed', DESC_FEED, required=False)

DESC_QUERY = _(
    '(deprecated) ignored if "--queries" is specified. '
    'query to issue against the feed\'s modules.json file to scope which '
    'modules are imported; multiple queries may be added by specifying this '
    'argument multiple times'
)
OPTION_QUERY = PulpCliOption('--query', DESC_QUERY, required=False, allow_multiple=True)

DESC_QUERIES = _(
    'comma-separated list of queries to issue against the feed\'s modules.json '
    'file to scope which modules are imported. ignored when feed is static files.'
)
OPTION_QUERIES = PulpCliOption(
    '--queries', DESC_QUERIES, required=False, allow_multiple=False,
    parse_func=parsers.csv)
Exemple #19
0
        return self.api.add_schedule(self.action, consumer_id, schedule, units,
                                     failure_threshold, enabled, options)

    def delete_schedule(self, schedule_id, kwargs):
        consumer_id = kwargs[OPTION_CONSUMER_ID.keyword]
        return self.api.delete_schedule(self.action, consumer_id, schedule_id)

    def retrieve_schedules(self, kwargs):
        consumer_id = kwargs[OPTION_CONSUMER_ID.keyword]
        return self.api.list_schedules(self.action, consumer_id)

    def update_schedule(self, schedule_id, **kwargs):
        consumer_id = kwargs.pop(OPTION_CONSUMER_ID.keyword)
        return self.api.update_schedule(self.action, consumer_id, schedule_id,
                                        **kwargs)


# common options and flags -----------------------------------------------------

OPTION_CONTENT_TYPE_ID = PulpCliOption('--content-type-id',
                                       DESC_ID,
                                       required=True,
                                       validate_func=validators.id_validator)

OPTION_CONTENT_UNIT = PulpCliOption(
    '--content-unit',
    _('content unit id; may be repeated for multiple content units'),
    required=True,
    allow_multiple=True)
Exemple #20
0
    def __init__(self, context):
        PulpCliSection.__init__(
            self, 'permission',
            'manage granting, revoking and listing permissions for resources')

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

        # List Command
        list_command = PulpCliCommand(
            'list', 'lists permissions for a particular resource', self.list)
        list_command.add_option(
            PulpCliOption('--resource',
                          'uniquely identifies a resource',
                          required=True))
        self.add_command(list_command)

        # Grant Command
        usage_description = 'you can specify either login or role-id in this command; both cannot be specified at the same time'
        grant_command = PulpCliCommand(
            'grant',
            'grants resource permissions to given user or given role',
            self.grant,
            usage_description=usage_description)
        grant_command.add_option(
            PulpCliOption(
                '--resource',
                'resource REST API path whose permissions are being manipulated',
                required=True))
        grant_command.add_option(
            PulpCliOption(
                '--login',
                'login of the user to which access to given resource is being granted',
                required=False))
        grant_command.add_option(
            PulpCliOption(
                '--role-id',
                'id of the role to which access to given resource is being granted',
                required=False))
        grant_command.add_option(
            PulpCliOption(
                '-o',
                'type of permissions being granted, valid permissions: create, read, update, delete, execute',
                required=True,
                allow_multiple=True))
        self.add_command(grant_command)

        # Revoke Command
        revoke_command = PulpCliCommand(
            'revoke',
            'revokes resource permissions from given user or given role',
            self.revoke,
            usage_description=usage_description)
        revoke_command.add_option(
            PulpCliOption(
                '--resource',
                'resource REST API path whose permissions are being manipulated',
                required=True))
        revoke_command.add_option(
            PulpCliOption(
                '--login',
                'login of the user from which access to given resource is being revoked',
                required=False))
        revoke_command.add_option(
            PulpCliOption(
                '--role-id',
                'id of the role from which access to given resource is being revoked',
                required=False))
        revoke_command.add_option(
            PulpCliOption(
                '-o',
                'type of permissions being revoked, valid permissions: create, read, update, delete, execute',
                required=True,
                allow_multiple=True))
        self.add_command(revoke_command)
Exemple #21
0
                                    start_date, end_date)
        event_list = response.response_body

        filters = order = self._ALL_FIELDS

        for event in event_list:
            self.context.prompt.render_document(event,
                                                filters=filters,
                                                order=order)


# options and flags ------------------------------------------------------------

OPTION_FIELDS = PulpCliOption(
    '--fields',
    _('comma-separated list of consumer fields; Example: "id,'
      'display_name". If specified, only the given fields will be '
      'displayed.'),
    required=False)

OPTION_EVENT_TYPE = PulpCliOption(
    '--event-type',
    _('limits displayed history entries to the given type; supported '
      'types: ("consumer_registered", "consumer_unregistered", '
      '"repo_bound", "repo_unbound", "content_unit_installed", '
      '"content_unit_uninstalled", "unit_profile_changed", '
      '"added_to_group", "removed_from_group")'),
    required=False)

OPTION_LIMIT = PulpCliOption(
    '--limit',
    _('limits displayed history entries to the given amount'
Exemple #22
0
        msg = msg % {'t': ', '.join(sorted(VALID_SKIP_TYPES))}
        raise ValueError(msg)

    return parsed

# group names
NAME_PUBLISHING = _('Publishing')
NAME_AUTH = _('Consumer Authentication')

ALL_GROUP_NAMES = (NAME_PUBLISHING, NAME_AUTH)

# synchronization options
d = _('comma-separated list of types to omit when synchronizing, if not '
      'specified all types will be synchronized; valid values are: %(t)s')
d = d % {'t': ', '.join(sorted(VALID_SKIP_TYPES))}
OPT_SKIP = PulpCliOption('--skip', d, required=False,
                         parse_func=parse_skip_types)

# publish options
d = _('if "true", on each successful sync the repository will automatically be '
      'published on the configured protocols; if "false" synchronized content '
      'will only be available after manually publishing the repository; '
      'defaults to "true"')
OPT_AUTO_PUBLISH = PulpCliOption('--auto-publish', d, required=False,
                                 parse_func=parsers.parse_boolean)

d = _(
    'relative path the repository will be served from. Only alphanumeric '
    'characters, forward slashes, underscores '
    'and dashes are allowed. It defaults to the relative path of the feed URL')
OPT_RELATIVE_URL = PulpCliOption('--relative-url', d, required=False)
Exemple #23
0
    return parsed


# group names
NAME_PUBLISHING = _('Publishing')
NAME_AUTH = _('Consumer Authentication')

ALL_GROUP_NAMES = (NAME_PUBLISHING, NAME_AUTH)

# synchronization options
d = _('comma-separated list of types to omit when synchronizing, if not '
      'specified all types will be synchronized; valid values are: %(t)s')
d = d % {'t': ', '.join(VALID_SKIP_TYPES)}
OPT_SKIP = PulpCliOption('--skip',
                         d,
                         required=False,
                         parse_func=parse_skip_types)

# publish options
d = _(
    'if "true", on each successful sync the repository will automatically be '
    'published on the configured protocols; if "false" synchronized content '
    'will only be available after manually publishing the repository; '
    'defaults to "true"')
OPT_AUTO_PUBLISH = PulpCliOption('--auto-publish',
                                 d,
                                 required=False,
                                 parse_func=parsers.parse_boolean)

d = _(
    'relative path the repository will be served from. Only alphanumeric characters, '
Exemple #24
0
DESC_LIST = _('lists in-progress and paused uploads')
DESC_CANCEL = _('cancels an outstanding upload request')

# Options
DESC_FORCE = _(
    'removes the client-side tracking file for the upload regardless of '
    'whether or not it was able to be deleted on the server; this should '
    'only be used in the event that the server\'s knowledge of an upload '
    'has been removed')
FLAG_FORCE = PulpCliFlag('--force', DESC_FORCE)

DESC_FILE = _('full path to a file to upload; may be specified multiple times '
              'for multiple files')
OPTION_FILE = PulpCliOption('--file',
                            DESC_FILE,
                            aliases=['-f'],
                            allow_multiple=True,
                            required=False)

DESC_DIR = _('full path to a directory containing files to upload; '
             'may be specified multiple times for multiple directories')
OPTION_DIR = PulpCliOption('--dir',
                           DESC_DIR,
                           aliases=['-d'],
                           allow_multiple=True,
                           required=False)

DESC_VERBOSE = _('display extra information about the upload process')
FLAG_VERBOSE = PulpCliFlag('-v', DESC_VERBOSE)

Exemple #25
0
def initialize(context):

    # Common Options
    d = 'uniquely identifies the consumer; only alphanumeric, ., -, and _ allowed'
    id_option = PulpCliOption('--consumer-id',
                              _(d),
                              required=True,
                              validate_func=validators.id_validator_allow_dots)

    d = 'user-readable display name for the consumer'
    name_option = PulpCliOption('--display-name', _(d), required=False)

    d = 'user-readable description for the consumer'
    description_option = PulpCliOption('--description', _(d), required=False)

    d = 'adds/updates/deletes key-value pairs to pragmatically identify the repository; '
    d += 'pairs must be separated by an equal sign (e.g. key=value); multiple notes can '
    d += 'be %(i)s by specifying this option multiple times; notes are deleted by '
    d += 'specifying "" as the value'
    d = _(d)

    update_note_d = d % {'i': _('changed')}
    add_note_d = d % {'i': _('added')}

    update_note_option = PulpCliOption('--note',
                                       update_note_d,
                                       required=False,
                                       allow_multiple=True)
    add_note_option = PulpCliOption('--note',
                                    add_note_d,
                                    required=False,
                                    allow_multiple=True)

    # Register Command
    d = 'registers this consumer to the Pulp server'
    register_command = RegisterCommand(context, 'register', _(d))
    register_command.add_option(id_option)
    register_command.add_option(name_option)
    register_command.add_option(description_option)
    register_command.add_option(add_note_option)
    context.cli.add_command(register_command)

    # Update Command
    d = 'changes metadata of this consumer'
    update_command = UpdateCommand(context, 'update', _(d))
    update_command.add_option(name_option)
    update_command.add_option(description_option)
    update_command.add_option(update_note_option)
    update_command.add_option(OPTION_EXCHANGE_KEYS)
    context.cli.add_command(update_command)

    # Unregister Command
    d = 'unregisters this consumer from the Pulp server'
    unregister_command = UnregisterCommand(context, 'unregister', _(d))
    context.cli.add_command(unregister_command)

    # History Retrieval Command
    d = 'lists history of this consumer'
    context.cli.add_command(HistoryCommand(context, 'history', _(d)))

    d = 'displays the registration status of this consumer'
    context.cli.add_command(StatusCommand(context, 'status', _(d)))
Exemple #26
0
    def __init__(self):
        # synchronization options
        d = _('URL of the external source repository to sync')
        self.opt_feed = PulpCliOption('--feed', d, required=False)

        d = _('if "true", the size and checksum of each synchronized file will be verified against '
              'the repo metadata')
        self.opt_validate = PulpCliOption('--validate', d, required=False,
                                          parse_func=parsers.pulp_parse_optional_boolean)

        # proxy options
        d = _('proxy server url to use')
        self.opt_proxy_host = PulpCliOption('--proxy-host', d, required=False)

        d = _('port on the proxy server to make requests')
        self.opt_proxy_port = PulpCliOption('--proxy-port', d, required=False,
                                            parse_func=parsers.pulp_parse_optional_positive_int)

        d = _('username used to authenticate with the proxy server')
        self.opt_proxy_user = PulpCliOption('--proxy-user', d, required=False)

        d = _('password used to authenticate with the proxy server')
        self.opt_proxy_pass = PulpCliOption('--proxy-pass', d, required=False)

        # throttling options
        d = _('maximum bandwidth used per download thread, in bytes/sec, when '
              'synchronizing the repo')
        self.opt_max_speed = PulpCliOption('--max-speed', d, required=False,
                                           parse_func=parsers.pulp_parse_optional_positive_int)

        d = _('maximum number of downloads that will run concurrently')
        self.opt_max_downloads = PulpCliOption('--max-downloads', d, required=False,
                                               parse_func=parsers.pulp_parse_optional_positive_int)

        # ssl options
        d = _('full path to the CA certificate that should be used to verify the '
              'external repo server\'s SSL certificate')
        self.opt_feed_ca_cert = PulpCliOption('--feed-ca-cert', d, required=False)

        d = _('if "true", the feed\'s SSL certificate will be verified against the '
              'feed_ca_cert')
        self.opt_verify_feed_ssl = PulpCliOption('--verify-feed-ssl', d, required=False,
                                                 parse_func=parsers.pulp_parse_optional_boolean)

        d = _('full path to the certificate to use for authorization when accessing the external '
              'feed')
        self.opt_feed_cert = PulpCliOption('--feed-cert', d, required=False)

        d = _('full path to the private key for feed_cert')
        self.opt_feed_key = PulpCliOption('--feed-key', d, required=False)

        # unit policy
        d = _('if "true", units that were previously in the external feed but are no longer '
              'found will be removed from the repository')
        self.opt_remove_missing = PulpCliOption('--remove-missing', d, required=False,
                                                parse_func=parsers.pulp_parse_optional_boolean)

        d = _('count indicating how many non-latest versions of a unit to keep in a repository')
        self.opt_retain_old_count = PulpCliOption(
            '--retain-old-count',
            d, required=False,
            parse_func=parsers.pulp_parse_optional_nonnegative_int
        )
Exemple #27
0
    def __init__(self, context):
        PulpCliSection.__init__(self, 'role', 'manage user roles')

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

        # Common Options
        id_option = PulpCliOption(
            '--role-id',
            'uniquely identifies the role; only alphanumeric, -, and _ allowed',
            required=True,
            validate_func=validators.id_validator)

        # Create command
        create_command = PulpCliCommand('create', 'creates a role',
                                        self.create)
        create_command.add_option(id_option)
        create_command.add_option(
            PulpCliOption('--display-name',
                          'user-friendly name for the role',
                          required=False))
        create_command.add_option(
            PulpCliOption('--description',
                          'user-friendly text describing the role',
                          required=False))
        self.add_command(create_command)

        # Update command
        update_command = PulpCliCommand('update', 'updates a role',
                                        self.update)
        update_command.add_option(
            PulpCliOption('--role-id',
                          'identifies the role to be updated',
                          required=True))
        update_command.add_option(
            PulpCliOption('--display-name',
                          'user-friendly name for the role',
                          required=False))
        update_command.add_option(
            PulpCliOption('--description',
                          'user-friendly text describing the role',
                          required=False))
        self.add_command(update_command)

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

        # List Command
        list_command = PulpCliCommand(
            'list', 'lists summary of roles on the Pulp server', self.list)
        list_command.add_option(
            PulpCliFlag('--details',
                        'if specified, all the role information is displayed'))
        list_command.add_option(
            PulpCliOption(
                '--fields',
                'comma-separated list of role fields; if specified, only the given fields will displayed',
                required=False))
        self.add_command(list_command)
Exemple #28
0
from pulp.client import arg_utils
from pulp.client.commands.repo.cudl import CreateAndConfigureRepositoryCommand
from pulp.client.commands.repo.cudl import ListRepositoriesCommand
from pulp.client.commands.repo.cudl import UpdateRepositoryCommand
from pulp.client.commands.repo.importer_config import ImporterConfigMixin
from pulp.client.extensions.extensions import PulpCliOption
from pulp.common.constants import REPO_NOTE_TYPE_KEY

from pulp_npm.common import constants

d = _(
    'if "true", on each successful sync the repository will automatically be '
    'published; if "false" content will only be available after manually publishing '
    'the repository; defaults to "true"')
OPT_AUTO_PUBLISH = PulpCliOption('--auto-publish',
                                 d,
                                 required=False,
                                 parse_func=parsers.parse_boolean)
d = _('a comma separated list of package names you wish Pulp to sync')
OPT_PACKAGE_NAMES = PulpCliOption('--package-names', d, required=False)

DESC_FEED = _('URL for the upstream npm repo')

IMPORTER_CONFIGURATION_FLAGS = dict(include_ssl=False,
                                    include_sync=True,
                                    include_unit_policy=False,
                                    include_proxy=False,
                                    include_throttling=False)


class NpmRepositoryOptions(object):
    """
Exemple #29
0
from gettext import gettext as _
import os
import sys

from okaara import parsers
from pulp.client.commands.options import OPTION_REPO_ID
from pulp.client.commands.repo.upload import UploadCommand
from pulp.client.extensions.extensions import PulpCliOption

from pulp_rpm.common.ids import TYPE_ID_PKG_GROUP

NAME = 'group'
DESC = _('creates a new package group')

d = _('id of the package group')
OPT_GROUP_ID = PulpCliOption('--group-id', d, aliases=['-i'], required=True)

d = _('name of the package group')
OPT_NAME = PulpCliOption('--name', d, aliases=['-n'], required=True)

d = _('description of the package group')
OPT_DESCRIPTION = PulpCliOption('--description',
                                d,
                                aliases=['-d'],
                                required=True)

d = _('conditional package name to include in the package group, specified as '
      '"pkg_name : required_package"; multiple may '
      'be indicated by specifying the argument multiple times')
OPT_CONDITIONAL_NAME = PulpCliOption('--cond-name',
                                     d,
Exemple #30
0
NAME_NEXT_RUN = 'next'
DESC_NEXT_RUN = _(
    'displays the next time the operation will run across all schedules')

# Order for render_document_list
SCHEDULE_ORDER = ['schedule', 'id', 'enabled', 'last_run', 'next_run']
DETAILED_SCHEDULE_ORDER = [
    'schedule', 'id', 'enabled', 'remaining_runs', 'consecutive_failures',
    'failure_threshold', 'first_run', 'last_run', 'next_run'
]

# Options
DESC_SCHEDULE_ID = _('identifies an existing schedule')
OPT_SCHEDULE_ID = PulpCliOption('--schedule-id',
                                DESC_SCHEDULE_ID,
                                required=True)

DESC_SCHEDULE = _('time to execute in iso8601 format '
                  '(yyyy-mm-ddThh:mm:ssZ/PiuT); the number of recurrences may '
                  'be specified in this value')
OPT_SCHEDULE = PulpCliOption('--schedule',
                             DESC_SCHEDULE,
                             aliases=['-s'],
                             required=True,
                             validate_func=interval_iso6801_validator)

DESC_FAILURE_THRESHOLD = _(
    'number of failures before the schedule is automatically '
    'disabled; unspecified means the schedule will never '
    'be automatically disabled')