options.py revision 2925
2875N/A# The contents of this file are subject to the terms of the 2875N/A# Common Development and Distribution License (the "License"). 2875N/A# You may not use this file except in compliance with the License. 2875N/A# See the License for the specific language governing permissions 2875N/A# and limitations under the License. 2875N/A# When distributing Covered Code, include this CDDL HEADER in each 2875N/A# If applicable, add the following below this CDDL HEADER, with the 2875N/A# fields enclosed by brackets "[]" replaced with your own identifying 2875N/A# information: Portions Copyright [yyyy] [name of copyright owner] 2875N/A# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 2875N/A# List of available options for common option processing. 2875N/A # synthesize require_new_be and deny_new_be into new_be 2875N/A # create a new key called BACKUP_BE in the options array 2875N/A # synthesize require_backup_be and no_backup_be into backup_be 2875N/A # create a new key called BACKUP_BE in the options array 2875N/A # synthesize li_ignore_all and li_ignore_list into li_ignore 2875N/A # check if there's nothing to ignore 2875N/A # can't ignore all and specific images 2875N/A # can't ignore all and target anything. 2875N/A # it doesn't make sense to specify images to ignore if the 2875N/A # user is already specifying images to operate on. 2875N/A # if a target child linked image was specified, the no-parent-sync 2875N/A # option doesn't make sense since we know that both the parent and 2875N/A # child image are accessible 2875N/A # we don't accept linked image target options 2875N/A """"Parse linked image property options that were specified on the 2875N/A command line into a dictionary. Make sure duplicate properties were 2875N/A "property arguments must be of the form " 2875N/A "image property: '%s'.") % p)
2875N/A "property specified multiple times: '%s'.") % p)
2875N/A """convert linked image prop list into a dictionary""" 2875N/A # figure out which option the user specified 2875N/A # validate linked image name 2875N/A # figure out which option the user specified 2875N/A # check if we accept the -q option 2875N/A # Be careful not to overwrite global_settings.client_output_quiet 2875N/A # because it might be set "True" from elsewhere, e.g. in 2875N/A # if we're attaching a new child then that doesn't affect 2875N/A # any other children, so ignoring them doesn't make sense. 2875N/A # if the user didn't specify linked-md-only we're done 2875N/A # li_md_only implies no li_pkg_updates 2875N/A # if li_md_only is false that means we're not updating any packages 2875N/A # within the current image so there are a ton of options that no 2875N/A # longer apply to the current operation, and hence are incompatible 2875N/A # Use of -g implies -a unless -n is provided. 2875N/A # get the original argument value 2875N/A # make sure it is an integer 2875N/A # update the new options array to make the value an integer 2875N/A # not a valid file descriptor 2875N/A # remove concurrency from parameters dict 2875N/A # make sure we have an integer 2875N/A # update global concurrency setting 2875N/A # remove concurrency from parameters dict 2875N/A# options common to multiple pkg(1) operations. The format for specifying 2875N/A# options is a list which can contain: 2875N/A# k: the key value for the options dictionary 2875N/A# Options for pkg(1) subcommands. Built by combining the option tables above, 2875N/A# with some optional subcommand unique options defined below. 2875N/A# "update" cmd inherits all "install" cmd options 2875N/A# "attach-linked" cmd inherits all "install" cmd options 2875N/A# "set-property-linked" cmd inherits all "install" cmd options 2875N/A# "sync-linked" cmd inherits all "install" cmd options 2875N/A """Get the available options for a particular operation specified by 2875N/A 'op'. If the client uses custom pkg_op_opts tables they can be specified 2875N/A """ Get the default value for a certain option 'opt' of a certain 2875N/A operation 'op'. This is useful for clients which toggle boolean options. 2875N/A """Assembly of the options for a specific operation. Options are read in 2875N/A from a dict (see explanation below) and sanity tested. 2875N/A This is the common interface to supply options to the functions of the 2875N/A 'op' is the operation for which the options need to be assembled and 2875N/A verified. The currently supported operations are listed in 2875N/A 'api_inst' is a reference to the API instance, required for some of the 2875N/A 'opts' is the raw options table to be processed. It needs to be a dict 2875N/A in the format: { option_name: argument, ... } 2875N/A # for options not given we substitue the default value 2875N/A # run the option verification callbacks