api_errors.py revision 926
#
# 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
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
import urlparse
# EmptyI for argument defaults; can't import from misc due to circular
# dependency.
class ApiException(Exception):
pass
class ImageNotFoundException(ApiException):
"""Used when an image was not found"""
class VersionException(ApiException):
class PlanExistsException(ApiException):
pass
class AlreadyPreparedException(ApiException):
pass
class AlreadyExecutedException(ApiException):
pass
class ImageplanStateException(ApiException):
class IpkgOutOfDateException(ApiException):
pass
pass
class CanceledException(ApiException):
pass
class PlanMissingException(ApiException):
pass
pass
class PermissionsException(ApiException):
return _("Could not operate on %s\nbecause of "
"insufficient permissions. Please try the command "
"again using pfexec\nor otherwise increase your "
else:
return _("""
Could not complete the operation because of insufficient permissions. Please
try the command again using pfexec or otherwise increase your privileges.
""")
assert path
return _("Could not operate on %s\nbecause the file is "
"in use. Please stop using the file and try the\n"
class PlanCreationException(ApiException):
res = []
if self.unfound_fmris:
s = _("""\
pkg: The following pattern(s) did not match any packages in the current
res += [s]
if self.multiple_matches:
s = _("pkg: '%s' matches multiple packages")
s = _("pkg: '%s' matches no installed packages")
s = _("pkg: '%s' is an illegal fmri")
s = _("pkg: the following package(s) violated "
"constraints:")
res += [s]
s = _("'%s' supports the following architectures: %s")
a = _("Image architecture is defined as: %s")
class CatalogRefreshException(ApiException):
class InventoryException(ApiException):
outstr = ""
# Illegal FMRIs have their own __str__ method
outstr += "%s\n" % x
outstr += _("No matching package could be found for "
"the following FMRIs in any of the catalogs for "
"the current publishers:\n")
outstr += "%s\n" % x
return outstr
class IndexingException(ApiException):
""" The base class for all exceptions that can occur while indexing. """
"""This is used when the index is not in a correct state."""
pass
""" This is used when the indexer is unable to create, move, or remove
files or directories it should be able to. """
return "Could not remove or create " \
"%s because of incorrect " \
"permissions. Please correct this issue then " \
class NonLeafPackageException(ApiException):
"""Removal of a package which satisfies dependencies has been attempted.
The first argument to the constructor is the FMRI which we tried to
remove, and is available as the "fmri" member of the exception. The
second argument is the list of dependent packages that prevent the
removal of the package, and is available as the "dependents" member.
"""
"""Raised when the depot doesn't have versions of operations
that the client needs to operate successfully."""
s = "Unable to contact valid package server"
s += "\nEncountered the following error(s):\n%s" % \
return s
class BEException(ApiException):
class DataError(ApiException):
"""Base exception class used for all data related errors."""
if args:
else:
class InvalidP5IFile(DataError):
"""Used to indicate that the specified location does not contain a
valid p5i-formatted file."""
return _("The specified file is in an unrecognized "
"format or does not contain valid publisher "
return _("The specified file is in an unrecognized format or "
"does not contain valid publisher information.")
class UnsupportedP5IFile(DataError):
"""Used to indicate that an attempt to read an unsupported version
of pkg(5) info file was attempted."""
return _("Unsupported pkg(5) publisher information data "
"format.")
class TransportError(ApiException):
"""Base exception class for all transfer exceptions."""
if args:
else:
class RetrievalError(TransportError):
"""Used to indicate that a a requested resource could not be
retrieved."""
if location:
return _("Error encountered while retrieving data from "
return _("Error encountered while retrieving data from: %s") % \
"""Used to indicate that an invalid transport location was provided."""
class InvalidBENameException(BEException):
return _("'%s' is not a valid boot envirnment name." %
class BENamingNotSupported(BEException):
return _("""\
Boot environment naming during package install is not supported on this
version of OpenSolaris. Please image-update without the --be-name option.""")
class UnableToCopyBE(BEException):
return _("Unable to clone the current boot environment.")
class UnableToRenameBE(BEException):
d = {
}
return _("""\
A problem occurred while attempting to rename the boot environment
currently named %(orig)s to %(dest)s.""") % d
class UnableToMountBE(BEException):
return _("Unable to mount %(name)s at %(mt)s") % \
class BENameGivenOnDeadBE(BEException):
return _("""\
Naming a boot environment when operating on a non-live image is
not allowed.""")
s = _("Info does not recognize the following options:")
return s
class PublisherError(ApiException):
"""Base exception class for all publisher exceptions."""
if args:
else:
class BadPublisherPrefix(PublisherError):
"""Used to indicate that a publisher name is not valid."""
"""Used to indicate that the specified repository attribute value is
invalid."""
return _("'%(value)s' is not a valid value for repository "
"attribute '%(attribute)s'.") % {
"""Used to indicate that the specified repository collection type is
invalid."""
return _("'%s' is not a valid repository collection type.") % \
class BadRepositoryURI(PublisherError):
"""Used to indicate that a repository URI is not syntactically valid."""
"""Used to indicate that the priority specified for a repository URI is
not valid."""
return _("'%s' is not a valid URI priority; integer value "
"""Used to indicate that the specified repository URI sort policy is
invalid."""
return _("'%s' is not a valid repository URI sort policy.") % \
class DisabledPublisher(PublisherError):
"""Used to indicate that an attempt to use a disabled publisher occurred
during an operation."""
return _("Publisher '%s' is disabled and cannot be used for "
class DuplicatePublisher(PublisherError):
"""Used to indicate that a publisher with the same name or alias already
exists for an image."""
return _("A publisher with the same name or alias as '%s' "
class DuplicateRepository(PublisherError):
"""Used to indicate that a repository with the same origin uris
already exists for a publisher."""
return _("A repository with the same name or origin URIs "
"""Used to indicate that a repository URI is already in use by another
repository mirror."""
return _("Mirror '%s' already exists for the specified "
"""Used to indicate that a repository URI is already in use by another
repository origin."""
return _("Origin '%s' already exists for the specified "
"""Used to indicate an attempt to remove the preferred publisher was
made."""
return _("The preferred publisher cannot be removed.")
"""Used to indicate that an attempt to remove the selected repository
for a publisher was made."""
return _("Cannot remove the selected repository for a "
"publisher.")
"""Used to indicate an attempt to set a disabled publisher as the
preferred publisher was made."""
return _("Publisher '%(pub)s' is disabled and cannot be set as "
class UnknownLegalURI(PublisherError):
"""Used to indicate that no matching legal URI could be found using the
provided criteria."""
class UnknownPublisher(PublisherError):
"""Used to indicate that no matching publisher could be found using the
provided criteria."""
class UnknownRelatedURI(PublisherError):
"""Used to indicate that no matching related URI could be found using
the provided criteria."""
class UnknownRepository(PublisherError):
"""Used to indicate that no matching repository could be found using the
provided criteria."""
"""Used to indicate that a repository URI could not be found in the
list of repository mirrors."""
"""Used to indicate that a repository URI could not be found in the
list of repository origins."""
"""Used to indicate that the specified repository URI uses an
unsupported scheme."""
return _("The URI '%(uri)s' contains an unsupported "
"scheme": scheme }
return _("The specified URI contains an unsupported scheme.")
"""Used to indicate that the specified repository URI attribute is not
supported for the URI's scheme."""
return _("'%(attr)s' is not supported for '%(scheme)s'.") % {
class CertificateError(ApiException):
"""Base exception class for all certificate exceptions."""
if args:
else:
class ExpiredCertificate(CertificateError):
"""Used to indicate that a certificate has expired."""
if publisher:
if uri:
return _("Certificate '%(cert)s' for publisher "
"'%(pub)s' needed to access '%(uri)s', "
"has expired. Please install a valid "
"uri": uri }
return _("Certificate '%(cert)s' for publisher "
"'%(pub)s', has expired. Please install a valid "
"pub": publisher }
if uri:
return _("Certificate '%(cert)s', needed to access "
"'%(uri)s', has expired. Please install a valid "
return _("Certificate '%s' has expired. Please install a "
class ExpiringCertificate(CertificateError):
"""Used to indicate that a certificate has expired."""
if publisher:
if uri:
return _("Certificate '%(cert)s' for publisher "
"'%(pub)s', needed to access '%(uri)s', "
"will expire in '%(days)s' days.") % {
return _("Certificate '%(cert)s' for publisher "
"'%(pub)s' will expire in '%(days)s' days.") % {
if uri:
return _("Certificate '%(cert)s', needed to access "
"'%(uri)s', will expire in '%(days)s' days.") % {
return _("Certificate '%(cert)s' will expire in "
class InvalidCertificate(CertificateError):
"""Used to indicate that a certificate is invalid."""
if publisher:
if uri:
return _("Certificate '%(cert)s' for publisher "
"'%(pub)s', needed to access '%(uri)s', is "
return _("Certificate '%(cert)s' for publisher "
"pub": publisher }
if uri:
return _("Certificate '%(cert)s' needed to access "
"uri": uri }
class NoSuchCertificate(CertificateError):
"""Used to indicate that a certificate could not be found."""
if publisher:
if uri:
return _("Unable to locate certificate "
"'%(cert)s' for publisher '%(pub)s' needed "
"to access '%(uri)s'.") % {
"uri": uri }
return _("Unable to locate certificate '%(cert)s' for "
"pub": publisher }
if uri:
return _("Unable to locate certificate '%(cert)s' "
"needed to access '%(uri)s'.") % {
"""Used to indicate that a certificate is not yet valid (future
effective date)."""
if publisher:
if uri:
return _("Certificate '%(cert)s' for publisher "
"'%(pub)s', needed to access '%(uri)s', "
"has a future effective date.") % {
"uri": uri }
return _("Certificate '%(cert)s' for publisher "
"'%(pub)s' has a future effective date.") % {
if uri:
return _("Certificate '%(cert)s' needed to access "
"'%(uri)s' has a future effective date.") % {
return _("Certificate '%s' has a future effective date.") % \