#
# CDDL HEADER START
#
# 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.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.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
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# 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]
#
# CDDL HEADER END
#
#
#
"""module describing a license packaging object
This module contains the LicenseAction class, which represents a license
packaging object. This contains a payload of the license text, and a single
attribute, 'license', which is the name of the license. Licenses are
installed on the system in the package's directory."""
import errno
import os
from . import generic
import zlib
"""Class representing a license packaging object."""
# Set attrs["path"] so filelist can handle this action;
# the path must be relative to the root of the image.
"""Client-side method that installs the license."""
owner = 0
group = 0
# ensure "path" is initialized. it may not be if we've loaded
# a plan that was previously prepared.
# make sure the directory exists and the file is writable
try:
"decompressing payload: {0}").format(
finally:
"data hash verification failure: expected: "
"{expected} computed: {actual} action: "
"{action}").format(
))
try:
except OSError as e:
raise
# We always want to download the license
return True
"""Returns a tuple of lists of the form (errors, warnings,
info). The error list will be empty if the action has been
correctly installed in the given image."""
errors = []
warnings = []
info = []
try:
except EnvironmentError as e:
raise
try:
# Make file writable so it can be deleted
except OSError as e:
raise
"""Generates the indices needed by the search dictionary. See
generic.py for a more detailed explanation."""
# we already have an index entry for self.hash
if attr == "hash":
continue
return indices
"""Retrieves and returns the payload of the license (which
should be text). This may require remote retrieval of
resources and so this could raise a TransportError or other
ApiException.
'alt_pub' is an optional alternate Publisher to use for
any required transport operations.
"""
try:
if chash == hash_attr_val:
except EnvironmentError as e:
raise
# If we get here, either the license file wasn't on disk, or the
# hash didn't match. In either case, go retrieve it from the
# publisher.
try:
if not alt_pub:
finally:
"""Return an opener for the license text from the local disk or
None if the data for the text is not on-disk."""
# Older images stored licenses without accounting for
# '/', spaces, etc. properly.
else:
# Newer images ensure licenses are stored with encoded
# name so that '/', spaces, etc. are properly handled.
""))
return path
"""Returns a boolean value indicating whether this license
action requires acceptance of its payload by clients."""
"""Returns a boolean value indicating whether this license
action requires its payload to be displayed by clients."""
"""Performs additional validation of action attributes that
for performance or other reasons cannot or should not be done
during Action object creation. An ActionError exception (or
subclass of) will be raised if any attributes are not valid.
This is primarily intended for use during publication or during
error handling to provide additional diagonostics.
'fmri' is an optional package FMRI (object or string) indicating
what package contained this action."""