本文整理汇总了Python中pulp.client.extensions.extensions.PulpCliOptionGroup类的典型用法代码示例。如果您正苦于以下问题:Python PulpCliOptionGroup类的具体用法?Python PulpCliOptionGroup怎么用?Python PulpCliOptionGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PulpCliOptionGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, context, renderer, distributor_id, name='run', description=DESC_PUBLISH_RUN,
method=None, override_config_options=()):
"""
:param context: Pulp client context
:type context: See okaara
:param renderer: StatusRenderer subclass that will interpret the sync or publish progress
report
:type renderer: StatusRenderer
:param distributor_id: Id of a distributor to be used for publishing
:type distributor_id: str
:param override_config_options: Additional publish options to be accepted from user. These
options will override respective options from the default
publish config. Each entry should be either a PulpCliOption
or PulpCliFlag instance
:type override_config_options: list
"""
super(RunPublishRepositoryCommand, self).__init__(name, description, method, context,
renderer)
self.distributor_id = distributor_id
self.override_config_keywords = []
# Process and add config override options in their own group and save option keywords
if override_config_options:
override_config_group = PulpCliOptionGroup(_("Publish Options"))
self.add_option_group(override_config_group)
for option in override_config_options:
override_config_group.add_option(option)
self.override_config_keywords.append(option.keyword)
示例2: add_erratum_group
def add_erratum_group(command):
"""
Adds the erratum group and all of its options to the given command.
"""
erratum_group = PulpCliOptionGroup(_('Erratum'))
erratum_group.add_option(PulpCliOption('--erratum-id', _('if specified, the full details of an individual erratum are displayed'), required=False))
command.add_option_group(erratum_group)
示例3: add_required_group
def add_required_group(command):
"""
Adds the required group and all of its options to the given command.
"""
required_group = PulpCliOptionGroup(_('Required'))
required_group.add_option(PulpCliOption('--repo-id', _('identifies the repository to search within'), required=True))
command.add_option_group(required_group)
示例4: add_pagination_group
def add_pagination_group(command):
"""
Adds the pagination group and all of its options to the given command.
"""
pagination_group = PulpCliOptionGroup(_('Pagination'))
pagination_group.add_option(PulpCliOption('--limit', _('maximum number of results to display'), aliases=['-l'], required=False))
pagination_group.add_option(PulpCliOption('--skip', _('number of results to skip'), aliases=['-s'], required=False))
command.add_option_group(pagination_group)
示例5: __init__
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)
示例6: __init__
def __init__(
self,
options_bundle=None,
include_sync=True,
include_ssl=True,
include_proxy=True,
include_throttling=True,
include_unit_policy=True,
):
# If the caller didn't dork with any of the options, instantiate one with the defaults
self.options_bundle = options_bundle or OptionsBundle()
# Created now, but won't be added to the command until the include_* flags are checked.
# Stored as instance variables so a class using this mixin can further manipulate them.
self.sync_group = PulpCliOptionGroup(GROUP_NAME_SYNC)
self.ssl_group = PulpCliOptionGroup(GROUP_NAME_SSL)
self.proxy_group = PulpCliOptionGroup(GROUP_NAME_PROXY)
self.throttling_group = PulpCliOptionGroup(GROUP_NAME_THROTTLING)
self.unit_policy_group = PulpCliOptionGroup(GROUP_NAME_UNIT_POLICY)
if include_sync:
self.populate_sync_group()
self.add_option_group(self.sync_group)
if include_ssl:
self.populate_ssl_group()
self.add_option_group(self.ssl_group)
if include_proxy:
self.populate_proxy_group()
self.add_option_group(self.proxy_group)
if include_throttling:
self.populate_throttling_group()
self.add_option_group(self.throttling_group)
if include_unit_policy:
self.populate_unit_policy()
self.add_option_group(self.unit_policy_group)
示例7: __init__
def __init__(self, name, description, method, context, renderer, override_config_options=()):
"""
Initialize the command, and call the superclass __init__().
:param name: The name of the command
:type name: basestring
:param description: The description of the command
:type description: basestring
:param method: The method to be run if the command is used
:type method: callable
:param context: The CLI context from Okaara
:type context: pulp.client.extensions.core.ClientContext
:param renderer: The renderer to be used to print progress reports
:type renderer: StatusRenderer
:param override_config_options: Additional options to be accepted from the user. These
options will override respective options from the default
config. Each entry should be either a PulpCliOption
or PulpCliFlag instance
:type override_config_options: tuple
"""
if method is None:
method = self.run
super(SyncPublishCommand, self).__init__(name, description, method, context)
self.renderer = renderer
self.add_option(options.OPTION_REPO_ID)
self.context = context
self.prompt = context.prompt
self.override_config_keywords = []
# Process and add config override options in their own group and save option keywords
if override_config_options:
override_config_group = PulpCliOptionGroup(_("Options"))
self.add_option_group(override_config_group)
for option in override_config_options:
override_config_group.add_option(option)
self.override_config_keywords.append(option.keyword)
示例8: __init__
def __init__(self, context, renderer, distributor_id, name='run', description=DESC_PUBLISH_RUN,
method=None, override_config_options=[]):
"""
:param context: Pulp client context
:type context: See okaara
:param renderer: StatusRenderer subclass that will interpret the sync or publish progress report
:type renderer: StatusRenderer
:param distributor_id: Id of a distributor to be used for publishing
:type distributor_id: str
:param override_config_options: Additional publish options to be accepted from user. These options will override
respective options from the default publish config.
:type override_config_options: List of PulpCliOption and PulpCliFlag instances
"""
if method is None:
method = self.run
super(RunPublishRepositoryCommand, self).__init__(name, description, method)
self.context = context
self.prompt = context.prompt
self.renderer = renderer
self.distributor_id = distributor_id
self.override_config_keywords = []
self.add_option(options.OPTION_REPO_ID)
self.create_flag('--' + NAME_BACKGROUND, DESC_BACKGROUND)
# Process and add config override options in their own group and save option keywords
if override_config_options:
override_config_group = PulpCliOptionGroup(_("Publish Options"))
self.add_option_group(override_config_group)
for option in override_config_options:
override_config_group.add_option(option)
self.override_config_keywords.append(option.keyword)
示例9: add_display_group
def add_display_group(command, default_fields):
"""
Adds the display group and all of its options to the given command.
"""
d = 'comma-separated list of fields to include for each unit; if unspecified all of the following will be displayed; '
d += 'valid fields: %(f)s'
description = _(d) % {'f' : ', '.join(default_fields)}
display_group = PulpCliOptionGroup(_('Display'))
display_group.add_option(PulpCliOption('--fields', description, aliases=['-f'], required=False, default=','.join(default_fields)))
display_group.add_option(PulpCliOption('--ascending', _('comma-separated list of fields to sort ascending; the order of the fields determines the order priority'), aliases=['-a'], required=False))
display_group.add_option(PulpCliOption('--descending', _('comma-separated list of fields to sort descending; ignored if --ascending is specified'), aliases=['-d'], required=False))
command.add_option_group(display_group)
示例10: ISODistributorConfigMixin
class ISODistributorConfigMixin(object):
def __init__(self):
self.publishing_group = PulpCliOptionGroup(_('Publishing'))
d = _('if "true", the repository will be published over the HTTP protocol')
self.opt_http = PulpCliOption('--serve-http', d, required=False,
parse_func=parsers.parse_boolean)
d = _('if "true", the repository will be published over the HTTPS protocol')
self.opt_https = PulpCliOption('--serve-https', d, required=False,
parse_func=parsers.parse_boolean)
d = _('full path to the CA certificate that should be used to verify client authorization '
'certificates; setting this turns on client authorization for the repository')
self.opt_auth_ca = PulpCliOption('--auth-ca', d, required=False)
d = _(
'relative path the repository will be served from. Only alphanumeric characters, '
'forward slashes, underscores, and dashes are allowed.')
self.opt_relative_url = PulpCliOption('--relative-url', d, required=False)
self.publishing_group.add_option(self.opt_http)
self.publishing_group.add_option(self.opt_https)
self.publishing_group.add_option(self.opt_auth_ca)
self.publishing_group.add_option(self.opt_relative_url)
self.add_option_group(self.publishing_group)
def _parse_distributor_config(self, user_input):
"""
Generate an ISODistributor configuration based on the given parameters (user input).
:param user_input: The keys and values passed to the CLI by the user
:type user_input: dict
"""
key_tuples = (
(constants.CONFIG_SERVE_HTTP, self.opt_http.keyword),
(constants.CONFIG_SERVE_HTTPS, self.opt_https.keyword),
(constants.CONFIG_SSL_AUTH_CA_CERT, self.opt_auth_ca.keyword),
(constants.CONFIG_RELATIVE_URL, self.opt_relative_url.keyword),
)
config = {}
for config_key, input_key in key_tuples:
safe_parse(user_input, config, input_key, config_key)
arg_utils.convert_file_contents((constants.CONFIG_SSL_AUTH_CA_CERT,), config)
return config
示例11: __init__
def __init__(self):
self.publishing_group = PulpCliOptionGroup(_('Publishing'))
d = _('if "true", the repository will be published over the HTTP protocol')
self.opt_http = PulpCliOption('--serve-http', d, required=False,
parse_func=parsers.parse_boolean)
d = _('if "true", the repository will be published over the HTTPS protocol')
self.opt_https = PulpCliOption('--serve-https', d, required=False,
parse_func=parsers.parse_boolean)
d = _('full path to the CA certificate that should be used to verify client authorization '
'certificates; setting this turns on client authorization for the repository')
self.opt_auth_ca = PulpCliOption('--auth-ca', d, required=False)
self.publishing_group.add_option(self.opt_http)
self.publishing_group.add_option(self.opt_https)
self.publishing_group.add_option(self.opt_auth_ca)
self.add_option_group(self.publishing_group)
示例12: add_distributor_config_to_command
def add_distributor_config_to_command(command):
"""
Adds the repository configuration related options to the given command,
organizing them into the appropriate groups.
:param command: command to add options to
:type command: pulp.clients.extensions.extensions.PulpCliCommand
"""
publish_group = PulpCliOptionGroup(NAME_PUBLISHING)
publish_group.add_option(OPT_RELATIVE_URL)
publish_group.add_option(OPT_SERVE_HTTP)
publish_group.add_option(OPT_SERVE_HTTPS)
# Order added indicates order in usage, so pay attention to this order
# when dorking with it to make sure it makes sense
command.add_option_group(publish_group)
示例13: __init__
def __init__(self):
self.publishing_group = PulpCliOptionGroup(_('Publishing'))
d = _('if "true", the repository will be published over the HTTP protocol')
self.opt_http = PulpCliOption('--serve-http', d, required=False,
parse_func=parsers.parse_boolean)
d = _('if "true", the repository will be published over the HTTPS protocol')
self.opt_https = PulpCliOption('--serve-https', d, required=False,
parse_func=parsers.parse_boolean)
d = _('full path to the CA certificate that should be used to verify client authorization '
'certificates; setting this turns on client authorization for the repository')
self.opt_auth_ca = PulpCliOption('--auth-ca', d, required=False)
d = _(
'relative path the repository will be served from. Only alphanumeric characters, '
'forward slashes, underscores, and dashes are allowed.')
self.opt_relative_url = PulpCliOption('--relative-url', d, required=False)
self.publishing_group.add_option(self.opt_http)
self.publishing_group.add_option(self.opt_https)
self.publishing_group.add_option(self.opt_auth_ca)
self.publishing_group.add_option(self.opt_relative_url)
self.add_option_group(self.publishing_group)
示例14: add_to_command
def add_to_command(command):
"""
Adds the repository configuration related options to the given command,
organizing them into the appropriate groups.
:param command: command to add options to
:type command: pulp.clients.extensions.extensions.PulpCliCommand
"""
# Groups
basic_group = PulpCliOptionGroup(NAME_BASIC)
publish_group = PulpCliOptionGroup(NAME_PUBLISHING)
# Order added indicates order in usage, so pay attention to this order when
# dorking with it to make sure it makes sense
command.add_option_group(basic_group)
command.add_option_group(publish_group)
# Metadata Options - Reorganized using standard commands
basic_group.add_option(std_options.OPTION_REPO_ID)
basic_group.add_option(std_options.OPTION_NAME)
basic_group.add_option(std_options.OPTION_DESCRIPTION)
basic_group.add_option(std_options.OPTION_NOTES)
# Publish Options
publish_group.add_option(OPT_RELATIVE_URL)
publish_group.add_option(OPT_SERVE_HTTP)
publish_group.add_option(OPT_SERVE_HTTPS)
publish_group.add_option(OPT_CHECKSUM_TYPE)
示例15: add_repo_options
def add_repo_options(command, is_update):
"""
Adds options/flags for all repo configuration values (repo, importer, and
distributor). This is meant to be called for both create and update commands
to simplify consistency
@param command: command to add options to
"""
# Groups
basic_group = PulpCliOptionGroup('Basic')
throttling_group = PulpCliOptionGroup('Throttling')
ssl_group = PulpCliOptionGroup('Feed Authentication')
proxy_group = PulpCliOptionGroup('Feed Proxy')
sync_group = PulpCliOptionGroup('Synchronization')
publish_group = PulpCliOptionGroup('Publishing')
repo_auth_group = PulpCliOptionGroup('Client Authentication')
# Order added indicates order in usage, so pay attention to this order when
# dorking with it to make sure it makes sense
command.add_option_group(basic_group)
command.add_option_group(sync_group)
command.add_option_group(publish_group)
command.add_option_group(ssl_group)
command.add_option_group(repo_auth_group)
command.add_option_group(proxy_group)
command.add_option_group(throttling_group)
# Metadata Options
basic_group.add_option(PulpCliOption('--repo-id', 'uniquely identifies the repository; only alphanumeric, -, and _ allowed', required=True))
basic_group.add_option(PulpCliOption('--feed', 'URL of the external source repository to sync', required=False))
basic_group.add_option(PulpCliOption('--display-name', 'user-readable display name for the repository', required=False))
basic_group.add_option(PulpCliOption('--description', 'user-readable description of the repo\'s contents', required=False))
d = 'adds/updates/deletes key-value pairs to programmatically 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)
if is_update:
d = d % {'i' : _('changed')}
else:
d = d % {'i' : _('added')}
basic_group.add_option(PulpCliOption('--note', d, required=False, allow_multiple=True))
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"'
basic_group.add_option(PulpCliOption('--auto-publish', _(d), required=False))
# Synchronization Options
sync_group.add_option(PulpCliOption('--only-newest', 'if "true", only the newest version of a given package is downloaded; defaults to false', required=False))
sync_group.add_option(PulpCliOption('--skip-types', 'comma-separated list of types to omit when synchronizing, if not specified all types will be synchronized; valid values are: %s' % ', '.join(VALID_SKIP_TYPES), required=False))
sync_group.add_option(PulpCliOption('--verify-size', 'if "true", the size of each synchronized file will be verified against the repo metadata; defaults to false', required=False))
sync_group.add_option(PulpCliOption('--verify-checksum', 'if "true", the checksum of each synchronized file will be verified against the repo metadata; defaults to false', required=False))
sync_group.add_option(PulpCliOption('--remove-old', 'if "true", removes old packages from the repo; defaults to false', required=False))
sync_group.add_option(PulpCliOption('--retain-old-count', 'count indicating how many old rpm versions to retain; defaults to 0; this count only takes effect when remove-old option is set to true.', required=False))
# Proxy Options
proxy_group.add_option(PulpCliOption('--proxy-url', 'URL to the proxy server to use', required=False))
proxy_group.add_option(PulpCliOption('--proxy-port', 'port on the proxy server to make requests', required=False))
proxy_group.add_option(PulpCliOption('--proxy-user', 'username used to authenticate with the proxy server', required=False))
proxy_group.add_option(PulpCliOption('--proxy-pass', 'password used to authenticate with the proxy server', required=False))
# Throttling Options
throttling_group.add_option(PulpCliOption('--max-speed', 'maximum bandwidth used per download thread, in KB/sec, when synchronizing the repo', required=False))
throttling_group.add_option(PulpCliOption('--num-threads', 'number of threads that will be used to synchronize the repo', required=False))
# SSL Options
ssl_group.add_option(PulpCliOption('--feed-ca-cert', 'full path to the CA certificate that should be used to verify the external repo server\'s SSL certificate', required=False))
ssl_group.add_option(PulpCliOption('--verify-feed-ssl', 'if "true", the feed\'s SSL certificate will be verified against the feed_ca_cert; defaults to false', required=False))
ssl_group.add_option(PulpCliOption('--feed-cert', 'full path to the certificate to use for authentication when accessing the external feed', required=False))
ssl_group.add_option(PulpCliOption('--feed-key', 'full path to the private key for feed_cert', required=False))
# Publish Options
publish_group.add_option(PulpCliOption('--relative-url', 'relative path the repository will be served from; defaults to relative path of the feed URL', required=False))
publish_group.add_option(PulpCliOption('--serve-http', 'if "true", the repository will be served over HTTP; defaults to false', required=False))
publish_group.add_option(PulpCliOption('--serve-https', 'if "true", the repository will be served over HTTPS; defaults to true', required=False))
publish_group.add_option(PulpCliOption('--checksum-type', 'type of checksum to use during metadata generation', required=False))
publish_group.add_option(PulpCliOption('--gpg-key', 'GPG key used to sign and verify packages in the repository', required=False))
publish_group.add_option(PulpCliOption('--regenerate-metadata', 'if "true", when the repository is published the repo metadata will be regenerated instead of reusing the metadata downloaded from the feed; defaults to true', required=False))
# Publish Security Options
repo_auth_group.add_option(PulpCliOption('--host-ca', 'full path to the CA certificate that signed the repository hosts\'s SSL certificate when serving over HTTPS', required=False))
repo_auth_group.add_option(PulpCliOption('--auth-ca', 'full path to the CA certificate that should be used to verify client authentication certificates; setting this turns on client authentication for the repository', required=False))
repo_auth_group.add_option(PulpCliOption('--auth-cert', 'full path to the entitlement certificate that will be given to bound consumers to grant access to this repository', required=False))