smf_manifest.py revision 3158
e3ae5c822699ae375f274bec0a24c1a0b36b731fJulian Kornberger# CDDL HEADER START
8020ba658ffa8f8c9a14ba3a7d2e9257ea400becTim Reddehase# The contents of this file are subject to the terms of the
8020ba658ffa8f8c9a14ba3a7d2e9257ea400becTim Reddehase# Common Development and Distribution License (the "License").
8020ba658ffa8f8c9a14ba3a7d2e9257ea400becTim Reddehase# You may not use this file except in compliance with the License.
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger# or http://www.opensolaris.org/os/licensing.
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger# See the License for the specific language governing permissions
0782f0889387f60a6bcf31f9f869c930466db1dbEugen Kuksa# and limitations under the License.
17e57f34169ca7ed023832806a77f0e0613074f1Tim Reddehase# When distributing Covered Code, include this CDDL HEADER in each
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7aa257096578ae891833367f3e2cc75ded9dbd36Eileen Bolloff# If applicable, add the following below this CDDL HEADER, with the
daa05c1ca31894d2bcba80bea773829908efbef8Tim Reddehase# fields enclosed by brackets "[]" replaced with your own identifying
daa05c1ca31894d2bcba80bea773829908efbef8Tim Reddehase# information: Portions Copyright [yyyy] [name of copyright owner]
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger# CDDL HEADER END
ef68dc9d6ba7fc331ecdef35f74cff6bb12835b8Tim Reddehase# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
ef68dc9d6ba7fc331ecdef35f74cff6bb12835b8Tim Reddehasefrom pkg.portable import PD_LOCAL_PATH, PD_PROTO_DIR, PD_PROTO_DIR_LIST
8855a26fb8a7c3743d2ae2cb817e21fb23b674c4Tim Reddehase# A list of locations beneath a given proto_dir where we expect to
8855a26fb8a7c3743d2ae2cb817e21fb23b674c4Tim Reddehase# find SMF manifest files
658c5ac5444dac6fd0b33ea20690fa14103dbaebTim Reddehasemanifest_locations = [ "lib/svc/manifest", "var/svc/manifest" ]
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehaseclass SMFManifestDependency(base.PublishingDependency):
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase # maps SMF fmris to the manifest files that defined them
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase # maps SMF FMRIs to a list the SMF FMRIs they declare as dependencies
8855a26fb8a7c3743d2ae2cb817e21fb23b674c4Tim Reddehase def __init__(self, action, path, pkg_vars, proto_dir):
8855a26fb8a7c3743d2ae2cb817e21fb23b674c4Tim Reddehase """ See __init__ for PublishingDependency.
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase # we can depend on multiple files delivering instances
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase # of a service that was marked as a dependency. If we
a41053781a26a3dafdbbe8b740b48128cdacfb43Tim Reddehase # do, we must specify the full paths to the manifests
a41053781a26a3dafdbbe8b740b48128cdacfb43Tim Reddehase # and not a basenames/paths pair, since SMF does not
a41053781a26a3dafdbbe8b740b48128cdacfb43Tim Reddehase # search for SMF manifests this way.
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase full_paths = [p.replace(proto_dir, "").lstrip("/")
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase raise base.InvalidPublishingDependency("A string or "
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase "tuple must be specified for 'path'.")
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase base.PublishingDependency.__init__(self, action,
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase base_names, paths, pkg_vars, proto_dir, "smf_manifest",
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase return "SMFDep({0}, {1}, {2}, {3})".format(self.action,
dc6831d0eb2d0ab3af7b0268a429562b110e07bbTim Reddehase self.base_names, self.run_paths, self.pkg_vars)
3c4b1bd39fa36d241f2ef0d6f7ebbf2a9a6f4d36henning mueller """Clear our manifest caches. This is primarily provided for
3c4b1bd39fa36d241f2ef0d6f7ebbf2a9a6f4d36henning mueller test code."""
6bbb03b1a673f7709df590df43aaed9e8740f671Tim Reddehase def populate_cache(proto_dirs, force_update=False):
8bc65b8b85b830b0432ea7701f2047acd552cedcTim Reddehase """Build our instance_mf and instance_deps dictionaries
8bc65b8b85b830b0432ea7701f2047acd552cedcTim Reddehase from the known SMF manifests installed on the current system
8bc65b8b85b830b0432ea7701f2047acd552cedcTim Reddehase and those that appear in the proto_dirs.
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger # we want our proto_dirs to be the authoritative source
a06b758dc863e147d288497ee69491afc2d23b7dTim Reddehase # for SMF manifests, so scan the local system first, then
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger # iterate through the proto_dirs, starting from the
836ef862a9f5bd2a1d5c68bbccb11c00b248758aTim Reddehase # oldest, overwriting with progressively newer proto_dirs
6b136443f2bc8ea49192210a7281ffa0f44b14fcTim Reddehase manifest_paths.append(os.path.join("/", location))
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger SMFManifestDependency.__populate_smf_dics(
61467f8ae537212ba3c895868c91235a21985cb8Tim Reddehase """Add a information information about the SMF instances and
61467f8ae537212ba3c895868c91235a21985cb8Tim Reddehase their dependencies from the given manifest_file to a global
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger set of dictionaries."""
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger instance_mf, instance_deps = parse_smf_manifest(
ee9341b3b65f9d567605249940e4948af119e784Eugen Kuksa # more work is needed here when
ee9341b3b65f9d567605249940e4948af119e784Eugen Kuksa # multiple-manifests per service is supported by
ee9341b3b65f9d567605249940e4948af119e784Eugen Kuksa # SMF: we'll need to merge additional
ee9341b3b65f9d567605249940e4948af119e784Eugen Kuksa # service-level dependencies into each service
e437b19c184243f688c2dd9b3bf083a454c804c7Julian Kornberger # instance as each manifest gets added.
if instance_mf:
if instance_deps:
protocol = None
service = None
instance = None
results = []
if instance is not None:
return results
raise ValueError(
results))
raise ValueError(
results))
deps = []
elist = []
if instance_mf is None:
proto_file)], {}
if instance is None:
**locals()))
manifests = []
if instance is not None:
pkg_attrs = {
dependencies = []
if dependency:
return dependencies
return False
return False
return False
return True
instance_mf = {}
instance_deps = {}
manifest_path = None
fmris = []
svc_dependencies = []
svc_deps = []
inst_dependencies = []
fmri = None
if inst_name:
if fmri is not None:
global manifest_locations
if prefix:
return True
return False