common.py revision 3339
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# CDDL HEADER START
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen# The contents of this file are subject to the terms of the
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen# Common Development and Distribution License (the "License").
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen# You may not use this file except in compliance with the License.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# See the License for the specific language governing permissions
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# and limitations under the License.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# When distributing Covered Code, include this CDDL HEADER in each
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# If applicable, add the following below this CDDL HEADER, with the
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# fields enclosed by brackets "[]" replaced with your own identifying
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# information: Portions Copyright [yyyy] [name of copyright owner]
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# CDDL HEADER END
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenLinked image module classes.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenThe following classes for manipulating linked images are defined here:
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen LinkedImageChild
ad850190d946d34966a56838cfdb216e021b5b5fTimo SirainenThe following template classes which linked image plugins should inherit from
ad850190d946d34966a56838cfdb216e021b5b5fTimo Sirainenare also defined here:
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen LinkedImagePlugin
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen LinkedImageChildPlugin
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# standard python classes
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Redefining built-in 'reduce', 'zip'; pylint: disable=W0622
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# import-error: six.moves; pylint: disable=F0401
abe7afb8f1766fbcef1b9df513109e43d7d16e49Timo Sirainen# linked image relationship types (returned by LinkedImage.list_related())
abe7afb8f1766fbcef1b9df513109e43d7d16e49Timo Sirainen# linked image properties
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen# properties that never get saved
df6478c4cf605bd81b3891c148b84c14eb6c4035Timo Sirainen# special linked image name values (PROP_NAME)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# linked image model values (PROP_MODEL)
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen# files which contain linked image data
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo SirainenPATH_PFACETS = os.path.join(__DATA_DIR, "linked_pfacets")
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo SirainenPATH_PPKGS = os.path.join(__DATA_DIR, "linked_ppkgs")
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo SirainenPATH_PROP = os.path.join(__DATA_DIR, "linked_prop")
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo SirainenPATH_PUBS = os.path.join(__DATA_DIR, "linked_ppubs")
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen# we define PATH_TRANSFORM_NONE as a tuple instead of just None because this
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen# will prevent it from being accidently serialized to json.
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo SirainenLI_RVTuple = collections.namedtuple("LI_RVTuple", "rvt_rv rvt_e rvt_p_dict")
6b85bc4b03e552cfaeeae872d63c2d8ac5fcb7c4Timo Sirainen """Sanity check a linked image operation return value tuple.
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen The format of said tuple is:
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen process return code
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen LinkedImageException exception (optional)
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen json dictionary containing planned image changes
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # make sure we're using the LI_RVTuple class
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # decode the tuple
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # rv must be an integer
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen # any exception returned must be a LinkedImageException
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen assert e is None or type(e) == apx.LinkedImageException
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen # if specified, p_dict must be a dictionary
e192a3b1ca8ae857e7d87298ea507d32977ba570Timo Sirainen # some child return codes should never be associated with an exception
e192a3b1ca8ae857e7d87298ea507d32977ba570Timo Sirainen assert rv not in [pkgdefs.EXIT_OK, pkgdefs.EXIT_NOP] or e is None
811f2e26d9782d9cb99fdf82e18ffa0a77564fe2Timo Sirainen # a p_dict can only be returned if the child returned EXIT_OK
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen assert rv == pkgdefs.EXIT_OK or p_dict is None
c4877db8b6559846f4b58be8e42422dc734c193fTimo Sirainen # return the value that was passed in
8b9342aa96b2f297e23afb261f9f7dd859800952Timo Sirainen """Given a linked image return value dictionary, sanity check all the
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen ("Unexpected rvdict key: ", k)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # return the value that was passed in
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen """Given a linked image return value dictionary, return a list of any
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen exceptions that were encountered while processing children."""
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # sanity check rvdict
56f45b3f3ae20e5c933701f4657dda5ef1916855Timo Sirainen # get a list of exceptions
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen """If an exception was encountered while operating on a linked
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen child then raise that exception. If multiple exceptions were
6b85bc4b03e552cfaeeae872d63c2d8ac5fcb7c4Timo Sirainen encountered while operating on multiple children, then bundle
6b85bc4b03e552cfaeeae872d63c2d8ac5fcb7c4Timo Sirainen those exceptions together and raise them."""
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen # get a list of exceptions
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen # one exception encountered
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen # multiple exceptions encountered
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen raise apx.LinkedImageException(bundle=exceptions)
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen """This class is a template that all linked image plugins should
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen inherit from. Linked image plugins derived from this class are
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen designed to manage linked aspects of the current image (vs managing
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen linked aspects of a specific child of the current image).
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen All the interfaces exported by this class and its descendants are
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen private to the linked image subsystem and should not be called
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen directly by any other subsystem."""
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen # functionality flags
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen # Unused argument; pylint: disable=W0613
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen """Initialize a linked image plugin.
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen 'pname' is the name of the plugin class derived from this
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen 'linked' is the LinkedImage object initializing this plugin.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen """Called when the path to the image that we're operating on
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen is changing. This normally occurs when we clone an image
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen after we've planned and prepared to do an operation."""
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # return value: None
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen def guess_path_transform(self, ignore_errors=False):
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen """If the linked image plugin is able to detect that we're
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen operating on an image in an alternate root then return an
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen transform that can be used to translate between the original
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen image path and the current one."""
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # return value: string or None
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen def get_child_list(self, nocache=False, ignore_errors=False):
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen """Return a list of the child images and paths associated with
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen the current image. The paths that are returned should be
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen absolute paths to the original child image locations."""
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # return value: list
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen """Get the linked image properties associated with the
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen specified child image."""
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # return value: dict
f519e4c2ad4ef826f1b08f3e0138b9b287a52c80Timo Sirainen def attach_child_inmemory(self, props, allow_relink):
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen """Attach the specified child image. This operation should
df6478c4cf605bd81b3891c148b84c14eb6c4035Timo Sirainen only affect in-memory state of the current image. It should
d565eaa943f29a49b97230ced57eec40ee65b4f9Timo Sirainen not update any persistent on-disk linked image state or access
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen the child image in any way. This routine should assume that
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen the linked image properties have already been validated."""
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # return value: None
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen """Detach the specified child image. This operation should
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen only affect in-memory state of the current image. It should
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen not update any persistent on-disk linked image state or access
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen the child image in any way."""
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen # return value: None
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen """Sync out the in-memory linked image state of this image to
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # return value: LI_RVTuple()
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen """This class is a template that all linked image child plugins should
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen inherit from. Linked image child plugins derived from this class are
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen designed to manage linked aspects of children of the current image.
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen (vs managing linked aspects of the current image itself).
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen All the interfaces exported by this class and its descendants are
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen private to the linked image subsystem and should not be called
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen directly by any other subsystem."""
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen def __init__(self, lic): # Unused argument; pylint: disable=W0613
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen """Initialize a linked image child plugin.
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen 'lic' is the LinkedImageChild object initializing this plugin.
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen """Called before a parent image saves linked image properties
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen into a child image. Gives the linked image child plugin a
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen chance to update the properties that will be saved within the
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen child image."""
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # return value: None
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen """A class for naming child linked images. Linked image names are
f239eb76f77afcbc0bfc97c9b52b4407d1bc3fe6Timo Sirainen used for all child images (and only child images), and they encode two
a835194f9a9dae88528367a791cbc282589f6c01Timo Sirainen pieces of information. The name of the plugin used to manage the
13c6532dc104d23061e6901783ceb1ff8872c206Timo Sirainen image and a linked image name. Linked image names have the following
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen format "<linked_image_plugin>:<linked_image_name>"""
13c6532dc104d23061e6901783ceb1ff8872c206Timo Sirainen self.lin_type, self.lin_name = name.split(":")
ce19e80b5a907d51a7cdf081e09699af8367dbfaTimo Sirainen raise apx.LinkedImageException(lin_malformed=name)
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen if len(self.lin_type) == 0 or len(self.lin_name) == 0 :
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen raise apx.LinkedImageException(lin_malformed=name)
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen if self.lin_type not in pkg.client.linkedimage.p_types:
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen raise apx.LinkedImageException(lin_malformed=name)
5626ae5e3316eced244adb6485c0927f1c7fdc41Timo Sirainen """Returns the serialized state of this object in a format
9315dd69233d554452df0c12bc57002d2042a8f4Timo Sirainen that that can be easily stored using JSON, pickle, etc."""
9315dd69233d554452df0c12bc57002d2042a8f4Timo Sirainen # Unused argument; pylint: disable=W0613
f23298fea47eecbeded985ee2537a34c4c4ef56bTimo Sirainen """Allocate a new object using previously serialized state
f23298fea47eecbeded985ee2537a34c4c4ef56bTimo Sirainen obtained via getstate()."""
f23298fea47eecbeded985ee2537a34c4c4ef56bTimo Sirainen # Unused argument; pylint: disable=W0613
f239eb76f77afcbc0bfc97c9b52b4407d1bc3fe6Timo Sirainen return "{0}:{1}".format(self.lin_type, self.lin_name)
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen """A LinkedImage object is used to manage the linked image aspects of
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen an image. This image could be a child image, a parent image, or both
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen a parent and child. This object allows for access to linked image
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen properties and also provides routines that allow operations to be
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen performed on child images."""
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen # Properties that a parent image with push children should save locally.
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen # Properties that a pull child image should save locally.
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen # Properties that a parent image with push children should save in
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen # those children.
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen # make sure there is no invalid overlap
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen assert not (temporal_props & (
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen """Initialize a new LinkedImage object."""
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen # variables reset by self.__update_props()
df6478c4cf605bd81b3891c148b84c14eb6c4035Timo Sirainen # variables reset by self.__recursion_init()
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen # variables reset by self._init_root()
ba482d3624ca4f1b3d638e6e8470ba5134f21493Timo Sirainen # initialize with no properties
df6478c4cf605bd81b3891c148b84c14eb6c4035Timo Sirainen # initialize linked image plugin objects
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen # if the image has a path setup, we can load data from it.
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen """Get a pointer to the image object associated with this
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen linked image object."""
2af769daebd83719ac696a440e06f6020471cec0Timo Sirainen """Called during object initialization and by
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen image.py`__set_root() to let us know when we're changing the
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen root location of the image. (The only time we change the root
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen path is when changes BEs during operations which clone BEs.
df6478c4cf605bd81b3891c148b84c14eb6c4035Timo Sirainen So when this happens most our metadata shouldn't actually
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen # Check if this is our first time accessing the current image
21455709020274a628faa9b9bd7839cb8efe3c73Timo Sirainen # or if we're just re-initializing ourselves.
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen # figure out the new root image path
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen root = self.__img.root.rstrip(os.sep) + os.sep
114a0f74e0f825c6bd8aeadfafb248a030762a1fTimo Sirainen # initialize paths for linked image data files
114a0f74e0f825c6bd8aeadfafb248a030762a1fTimo Sirainen imgdir = self.__img.imgdir.rstrip(os.sep) + os.sep
114a0f74e0f825c6bd8aeadfafb248a030762a1fTimo Sirainen self.__path_ppkgs = os.path.join(imgdir, PATH_PPKGS)
7981779f9aebd25728d3c26555d598ff842cf2e2Timo Sirainen self.__path_prop = os.path.join(imgdir, PATH_PROP)
7981779f9aebd25728d3c26555d598ff842cf2e2Timo Sirainen self.__path_ppubs = os.path.join(imgdir, PATH_PUBS)
7981779f9aebd25728d3c26555d598ff842cf2e2Timo Sirainen self.__path_pfacets = os.path.join(imgdir, PATH_PFACETS)
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen # if this isn't a reset, then load data from the image
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen # the first time around we load non-temporary data (if
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen # there is any) so that we can audit ourselves and see
6fdf8b5e4e71a69f5974f59eec2b8c19bc421fe2Timo Sirainen # if we're in currently in sync.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # now re-load all the data taking into account any
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen # temporary new data associated with an in-progress
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen # if we're not linked we're done
1a21e7049796c98d6d998fcf7a438d7a97193dc4Timo Sirainen # if this is a reset, update temporal properties
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen self.__set_current_path(self.__props, update=True)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # Tell linked image plugins about the updated paths
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen # Unused variable 'plugin'; pylint: disable=W0612
1a21e7049796c98d6d998fcf7a438d7a97193dc4Timo Sirainen for plugin, lip in six.iteritems(self.__plugins):
1a21e7049796c98d6d998fcf7a438d7a97193dc4Timo Sirainen # pylint: enable=W0612
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen # Tell linked image children about the updated paths
a817fdcc43aedf423e2134091d5f83f91d64bcc9Timo Sirainen """Internal helper routine used when we want to update any
a817fdcc43aedf423e2134091d5f83f91d64bcc9Timo Sirainen linked image properties. This routine sanity check the
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen new properties, updates them, and resets any cached state
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen that is affected by property values."""
62cfc346eb7b0a4fd9e1ab6edd63b98711161229Timo Sirainen # all temporal properties must exist
a817fdcc43aedf423e2134091d5f83f91d64bcc9Timo Sirainen # PROP_CURRENT_PARENT_PATH can only be set if
62cfc346eb7b0a4fd9e1ab6edd63b98711161229Timo Sirainen # we have PROP_PARENT_PATH.
a817fdcc43aedf423e2134091d5f83f91d64bcc9Timo Sirainen assert p in props, \
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen # update state
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen """Perform internal consistency checks for a set of linked
a817fdcc43aedf423e2134091d5f83f91d64bcc9Timo Sirainen image properties. Don't update any state."""
dbd9604da561399cc6255289d5b6f6f662ab2d00Timo Sirainen # if we're not a child image ourselves, then we're done
dbd9604da561399cc6255289d5b6f6f662ab2d00Timo Sirainen if (props_set - temporal_props) == self.__parent_props:
dbd9604da561399cc6255289d5b6f6f662ab2d00Timo Sirainen # make sure PROP_MODEL was specified
9566c1b4506d49778659e3dc65997f3c0399cb7eTimo Sirainen # validate the linked image name
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen # make sure PROP_MODEL was specified
if update:
if path is not None:
elif current_path is not None:
p_transforms = []
if not p_transforms:
return PATH_TRANSFORM_NONE
return props
return props
if pfacets is None:
return rv
fmri_strs = None
if fmri_strs is None:
return frozenset([
for s in fmri_strs
ppubs = None
return ppubs
if not props:
if ppkgs is not None:
if pfacets is not None:
def __validate_prop_recurse(v):
return True
return True
return False
validate_props = {
errs = []
if k not in validate_props:
attach_bad_prop=k))
if not validate_props[k](v):
attach_bad_prop_value=(k, v)))
if k not in allowed_props:
attach_bad_prop=k))
if errs:
except OSError:
return pimg
paths = [
return False
return True
if li_ondisk_props == None:
return False
paths = [
return False
return True
return False
return False
return False
return False
return True
if ppubs == None:
if p == pp:
if not catch_exception:
paths = [
return path
if lin == None:
return props
return True
if raise_except:
return False
if not allow_unknown:
return lin
if li_ignore == []:
li_children = []
if li_ignore == None:
return li_children
errs = [
if errs:
li_list = [
if path is not None:
return li_list
if props == None:
if k not in props:
props[k] = v
if not force:
props = None
sync_fmris = []
parent_deps = [
if parent_deps:
if not sync_fmris:
return True
return False
return False
return True
if not latest_md:
return False
return True
if not rvdict:
if not rv_map:
p_dicts = [
errs = [
elif errs:
err = None
rv_map = [
rv_map = [
except OSError as e:
if not img_prefix:
if be_name:
except OSError as e:
def abort_if_imgdir(d):
except OSError as e:
if tmp:
api.py`gen_plan_*"""
if props == None:
except OSError as e:
if k not in child_props:
child_props[k] = v
rvdict = {}
return rvtuple
return rvtuple2
return rvtuple
if lin_list == []:
lin_list = None
return rvdict
if progtrack is None:
if lin_list == []:
lin_list = None
rvdict = {}
return rvdict
if lin_list == []:
lin_list = None
if noexecute:
return rvdict
yield p_dict
if lic_num:
if _pd is not None:
lic_setup = []
_pmd = None
yield p_dict
lic_running = []
while lic_setup and (
if progtrack_update:
done)
yield p_dict
if lic_num:
if lin_list is None:
lin_list = [
rvdict = {}
lic_dict = {}
if failfast:
return lic_dict
if repos:
rvdict = {}
lic_op_vectors = []
lic_list = []
for l in lin_list:
except KeyError:
rvdict = {}
yield p_dict
pkg_op_erecurse = None
kwargs = {}
return kwargs
if erecurse_list:
assert pkg_op_erecurse
yield p_dict
if props:
if li_ignore is None:
li_ignore = []
return False
return True
except OSError as e:
if not imgdir:
if old_data is not None:
return updated
if not tmp:
except OSError as e:
return True
if stage not in [
return True
return False
return True
if updated:
return True
return False
api.py`gen_plan_*"""
if li_md_only:
backup_be=None,
backup_be_name=None,
be_name=None,
li_ignore=None,
li_target_list=[],
new_be=None,
origins=[],
# client.py`update()
if pkgs_update is None:
pkgs_update = []
backup_be=None,
backup_be_name=None,
be_name=None,
li_erecurse=None,
li_ignore=None,
new_be=None,
origins=[],
backup_be=None,
backup_be_name=None,
be_name=None,
li_erecurse=None,
li_ignore=None,
new_be=None,
origins=[],
backup_be=None,
backup_be_name=None,
be_name=None,
li_erecurse=None,
li_ignore=None,
new_be=None,
if variants:
op,
backup_be=None,
backup_be_name=None,
be_name=None,
li_erecurse=None,
li_ignore=None,
new_be=None,
origins=[],
li_target_list=[],
li_target_list=[],
raise RuntimeError(
_pkg_op))
return True
return True
return (rvtuple, None, None)
not expect_plan:
p_dict = None
except ValueError as e:
if pd is not None:
if src:
if dst:
if not matching_facets:
if pfmri is None:
del faceted_deps
for k, v in facets:
return pfacets
except OSError as e:
if catch_exception:
object_hook = None
if decode:
except OSError as e:
if catch_exception:
return data
rvdct = {}
v = True
v = False
rvdct[k] = v
return rvdct
return dict([
if k not in keys
bad_cp=None,
bad_iup=None,
bad_lin_type=None,
bad_prop=None,
missing_props=None,
multiple_transforms=None,
saved_temporal_props=None):
if bad_cp:
assert err == None
elif bad_iup:
assert err == None
elif bad_lin_type:
assert err == None
elif bad_prop:
assert err == None
elif missing_props:
assert err == None
elif multiple_transforms:
assert err == None
elif saved_temporal_props:
assert err == None
assert err != None
if li:
if lic:
if lin:
path)
elif path:
raise RuntimeError(
except OSError as e:
except OSError as e:
except OSError as e:
except OSError as e:
return True
return True
return False
return path
return PATH_TRANSFORM_NONE