1933N/A# The contents of this file are subject to the terms of the 1933N/A# Common Development and Distribution License (the "License"). 1933N/A# You may not use this file except in compliance with the License. 1933N/A# See the License for the specific language governing permissions 1933N/A# and limitations under the License. 1933N/A# When distributing Covered Code, include this CDDL HEADER in each 1933N/A# If applicable, add the following below this CDDL HEADER, with the 1933N/A# fields enclosed by brackets "[]" replaced with your own identifying 1933N/A# information: Portions Copyright [yyyy] [name of copyright owner] 3356N/A# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. 1933N/A# A list of locations beneath a given proto_dir where we expect to 1933N/A # maps SMF fmris to the manifest files that defined them 1933N/A # maps SMF FMRIs to a list the SMF FMRIs they declare as dependencies 1933N/A """ See __init__ for PublishingDependency. 2682N/A # we can depend on multiple files delivering instances 2682N/A # of a service that was marked as a dependency. If we 2682N/A # do, we must specify the full paths to the manifests 2682N/A # search for SMF manifests this way. 2682N/A "tuple must be specified for 'path'.")
2501N/A """Clear our manifest caches. This is primarily provided for 1933N/A """Build our instance_mf and instance_deps dictionaries 1933N/A from the known SMF manifests installed on the current system 1933N/A and those that appear in the proto_dirs. 1933N/A # we want our proto_dirs to be the authoritative source 1933N/A # for SMF manifests, so scan the local system first, then 1933N/A # iterate through the proto_dirs, starting from the 1933N/A # oldest, overwriting with progressively newer proto_dirs 1933N/A """Add a information information about the SMF instances and 1933N/A their dependencies from the given manifest_file to a global 1933N/A # more work is needed here when 1933N/A # multiple-manifests per service is supported by 1933N/A # SMF: we'll need to merge additional 1933N/A # service-level dependencies into each service 1933N/A # instance as each manifest gets added. 1933N/A """Split an SMF FMRI into constituent parts, returning the svc protocol, 1933N/A the service name, and the instance name, if any.""" 1933N/A """Search a dictionary of SMF FMRI mappings, returning a list of 1933N/A results. If the FMRI points to an instance, we can return quickly. If 1933N/A the FMRI points to a service, we return all matching instances. Note 1933N/A if the dictionary contains service FMRIs, those won't appear in the 1933N/A results - we only ever return instances.""" 1933N/A # return all matching instances of this service 1933N/A """Given an instance FMRI, determine the FMRIs it depends on. If we 1933N/A match more than one fmri, we raise an exception. """ 1933N/A # this can only happen if we've been asked to resolve a 1933N/A # service-level FMRI, not a fully qualified instance FMRI 3158N/A _(
"more than one set of dependencies found: {0}").
format(
3158N/A _(
"more than one set of dependencies found: {0}").
format(
1933N/A """Given an SMF FMRI that satisfies a given SMF dependency, determine 1933N/A which file(s) deliver that dependency using both the provided 1933N/A instance_mf dictionary and the global SmfManifestDependency dictionary. 1933N/A If multiple files match, we have a problem.""" 1933N/A # we can't satisfy the dependency at all 1933N/A """Given an action and a place to find the file it references, if the 1933N/A file is an SMF manifest, we return a list of SmfManifestDependencies 1933N/A pointing to the SMF manifests in the proto area that would satisfy each 1933N/A dependency, a list of errors, and a dictionary containing the SMF FMRIs 1933N/A that were contained in the SMF manifest that this action delivers. 1933N/A Note that while we resolve SMF dependencies from SMF FMRIs to the files 1933N/A that deliver them, we don't attempt to further resolve those files to 3356N/A pkg(7) packages at this point. 1933N/A That stage is done using the normal "pkgdepend resolve" mechanism.""" 1933N/A # we don't report an error here, as SMF manifest files may be delivered 1933N/A # to a location specifically not intended to be imported to the SMF 3158N/A return [], [ _(
"Unable to parse SMF manifest {0}").
format(
1933N/A # we're only interested in trying to resolve 1933N/A # dependencies that instances have declared 1933N/A # determine the set of SMF FMRIs we depend on 3158N/A _(
"Problem determining dependencies for {fmri}:" 1933N/A # determine the file paths that deliver those dependencies 1933N/A # we've declared an SMF dependency, but can't 1933N/A # determine what file delivers it from the known 1933N/A # SMF manifests in either the proto area or the 1933N/A _(
"Unable to generate SMF dependency on " 3158N/A "{dep_fmri} declared in {proto_file} by " 2682N/A # This should never happen, as it implies a 2682N/A # service FMRI, not an instance FMRI has been 2682N/A # returned from search_smf_dic via 2682N/A _(
"Unable to generate SMF " 2682N/A "dependency on the service FMRI " 2682N/A "SMF dependencies should always " 2682N/A "resolve to SMF instances rather " 2682N/A "than SMF services and multiple " 2682N/A "files deliver instances of this " 1933N/A """Given a minidom Element deps, search for the <service_fmri> elements 1933N/A inside it, and return the values as a list of strings.""" 1933N/A # we don't include SMF path dependencies as these are often 1933N/A """Quickly determine if smf_file is a valid SMF manifest.""" 1933N/A # catching ValueError, as minidom has been seen to raise this on some 1933N/A """Returns a tuple of two dictionaries. The first maps the SMF FMRIs 1933N/A found in that manifest to the path of the manifest file. The second maps 1933N/A each SMF FMRI found in the file to the list of FMRIs that are declared 1933N/A Note this method makes no distinction between service FMRIs and instance 1933N/A FMRIs; both get added to the dictionaries, but only the instance FMRIs 1933N/A should be used to determine dependencies. 1933N/A Calling this with a path to the file, we include manifest_paths in the 1933N/A first dictionary, otherwise with raw file data, we don't. 1933N/A If we weren't handed an SMF XML file, or have trouble parsing it, we 1933N/A return a tuple of None, None. 1933N/A # catching ValueError, as minidom has been seen to raise this on some 1933N/A # no defined service name, so no dependencies here 1933N/A # Get the FMRIs we declare dependencies on. When splitting SMF 1933N/A # services across multiple manifests is supported, more work 1933N/A # create_default_instance tag but we've 1933N/A # also explicitly created an instance 1933N/A # we can use getElementsByTagName here, since 1933N/A # there are no nested <dependency> tags that 1933N/A # won't apply, unlike for <service> above, when 1933N/A # we needed to look strictly at immediate 1933N/A """Determine if the given path string contains any of the directories 1933N/A where SMF manifests are usually delivered. An optional named parameter 1933N/A prefix gets stripped from the path before checking.