options.py revision 3336
# The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # See the License for the specific language governing permissions # and limitations under the License. # When distributing Covered Code, include this CDDL HEADER in each # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. # List of available options for common option processing. # options for explicit recursion; see description in client.py """"Parse set property options that were specified on the command line into a dictionary. Make sure duplicate properties were not "must be of the form '<name>=<value>'. This is " "be set once in a command. {0} was set twice" """"Parse add or remove property values options that were specified on the command line into a dictionary. Make sure duplicate properties "{add} must be of the form '<name>=<value>'. " "This is what was given: {key}").
format(
# Allow wildcard to support an easy, scriptable # way of removing all existing entries. # Allow wildcard to support an easy, scriptable # way of removing all existing entries. # synthesize require_new_be and deny_new_be into new_be # create a new key called BACKUP_BE in the options array # synthesize require_backup_be and no_backup_be into backup_be # create a new key called BACKUP_BE in the options array # synthesize li_ignore_all and li_ignore_list into li_ignore # check if there's nothing to ignore # can't ignore all and specific images # can't ignore all and target anything. # it doesn't make sense to specify images to ignore if the # user is already specifying images to operate on. # if a target child linked image was specified, the no-parent-sync # option doesn't make sense since we know that both the parent and # child image are accessible # we don't accept linked image target options # Check whether unpackaged and unpackaged_only options are used """"Parse linked image property options that were specified on the command line into a dictionary. Make sure duplicate properties were "property arguments must be of the form " "image property: '{0}'.").
format(p))
"property specified multiple times: " """convert linked image prop list into a dictionary""" # figure out which option the user specified # validate linked image name # figure out which option the user specified # Go through all children and check if they are in the recurse list. _(
"invalid linked image or zone name " # If we use image recursion we need to make sure uninstall and update # ignore non-existing packages in the parent image. # check if we accept the -q option # Be careful not to overwrite global_settings.client_output_quiet # because it might be set "True" from elsewhere, e.g. in # opts_table_cb_parsable. msg=_(
"integer argument expected"))
# if we're attaching a new child then that doesn't affect # any other children, so ignoring them doesn't make sense. # if the user didn't specify linked-md-only we're done # li_md_only implies no li_pkg_updates # if li_md_only is false that means we're not updating any packages # within the current image so there are a ton of options that no # longer apply to the current operation, and hence are incompatible # Use of -g implies -a unless -n is provided. err = _(
"missing required parameter")
# get the original argument value # make sure it is an integer # check the minimum bounds # update the new options array to make the value an integer # not a valid file descriptor # remove concurrency from parameters dict # make sure we have an integer # update global concurrency setting # remove concurrency from parameters dict # make sure we have an integer # 0 is no sync actuators are used (timeout=0) # options common to multiple pkg(1) operations. The format for specifying # options is a list which can contain: # k: the key value for the options dictionary # v: the default value. valid values are: True/False, None, [], 0 # val: the valid argument list. It should be a list, (
ORIGINS, [], [], {
"type":
"array",
"items": {
"type":
"string"}
(
OUTPUT_FORMAT,
None, [
"default",
"tsv"], {
"type": [
"null",
"string"]}),
(
SET_PROPS, [], [], {
"type":
"array",
"items": {
"type":
"string"}
"items": {
"type":
"string"}
"items": {
"type":
"string"}
(
UNSET_PROPS, [], [], {
"type":
"array",
"items": {
"type":
"string"}
(
SSL_KEY,
None, [], {
"type": [
"null",
"string"]}),
(
SSL_CERT,
None, [], {
"type": [
"null",
"string"]}),
"items": {
"type":
"string"}
"items": {
"type":
"string"}
"items": {
"type":
"string"}
(
ORIGIN_URI,
None, [], {
"type": [
"null",
"string"]}),
"items": {
"type":
"string"}
"items": {
"type":
"string"}
"items": {
"type":
"string"}
"items": {
"type":
"string"}
(
REPO_URI,
None, [], {
"type": [
"null",
"string"]}),
(
PROXY_URI,
None, [], {
"type": [
"null",
"string"]}),
(
BE_NAME,
None, [], {
"type": [
"null",
"string"]}),
"items": {
"type":
"string"}
"items": {
"type":
"string"}
"items": {
"type":
"string"}
(
LI_NAME,
None, [], {
"type": [
"null",
"string"]}),
"items": {
"type":
"string"}
"items": {
"type":
"string"}}),
"items": {
"type":
"string"}
(
VERBOSE,
0, [], {
"type":
"integer",
"minimum":
0}),
"minimum":
0,
"maximum":
0 (
ORIGINS, [], [], {
"type":
"array",
"items": {
"type":
"string"}
(
STAGE,
None, [], {
"type": [
"null",
"string"]}),
"items": {
"type":
"string"}
# Options for pkg(1) subcommands. Built by combining the option tables above, # with some optional subcommand unique options defined below. # "update" cmd inherits all main cmd options # "attach-linked" cmd inherits all main cmd options # "set-property-linked" cmd inherits all main cmd options # "sync-linked" cmd inherits all main cmd options """Get the available options for a particular operation specified by 'op'. If the client uses custom pkg_op_opts tables they can be specified """ Get the default value for a certain option 'opt' of a certain operation 'op'. This is useful for clients which toggle boolean options. """Assembly of the options for a specific operation. Options are read in from a dict (see explanation below) and sanity tested. This is the common interface to supply options to the functions of the 'op' is the operation for which the options need to be assembled and verified. The currently supported operations are listed in 'api_inst' is a reference to the API instance, required for some of the 'opts' is the raw options table to be processed. It needs to be a dict in the format: { option_name: argument, ... } # If no valid argument list specified. # for options not given we substitue the default value # If the any of valid_args is integer, we first # try to convert the argument value into # integer. This is for CLI mode where arguments # run the option verification callbacks