From a0a48f0ace42b84a56234f45bf34ad354b22fc9b Mon Sep 17 00:00:00 2001 From: Kirill Zaitsev Date: Wed, 25 May 2016 03:36:59 +0300 Subject: [PATCH] Store transitive inheritance information in glare Before this patch only local inheritance information was stored in the 'inherits' field in glare. This means, that requesting all the packages, that inherit from class X would only yield immediate relatives, rather than all. This patch adds transitive inheritance information to the same field. Change-Id: I5096a2dd105dd70ff42b35eebbd850a9b66c9274 Closes-Bug: #1585419 --- muranoclient/v1/artifact_packages.py | 19 +++++++++++++++++++ .../global-inherits-fix-6da007ec44a774f2.yaml | 4 ++++ 2 files changed, 23 insertions(+) create mode 100644 releasenotes/notes/global-inherits-fix-6da007ec44a774f2.yaml diff --git a/muranoclient/v1/artifact_packages.py b/muranoclient/v1/artifact_packages.py index acdc66af..cf95f638 100644 --- a/muranoclient/v1/artifact_packages.py +++ b/muranoclient/v1/artifact_packages.py @@ -12,6 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +import collections + from glanceclient import exc as glance_exc import six import yaml @@ -54,6 +56,23 @@ class ArtifactRepo(object): inherits = self._get_local_inheritance(package.classes) + # check for global inheritance + ancestor_queue = collections.deque(inherits.keys()) + while ancestor_queue: + ancestor_name = ancestor_queue.popleft() + child_classes = inherits[ancestor_name] + + ancestors = self.list(class_definitions=ancestor_name) + for ancestor in ancestors: + # check if ancestor inherits anything + ancestor_inherits = \ + ancestor.type_specific_properties.get('inherits', {}) + for name, value in ancestor_inherits.items(): + # check if this is the class we actually inherit + if ancestor_name in value: + ancestor_queue.append(name) + inherits[name] = child_classes + package_draft['inherits'] = inherits keywords = self._keywords_from_display_name( diff --git a/releasenotes/notes/global-inherits-fix-6da007ec44a774f2.yaml b/releasenotes/notes/global-inherits-fix-6da007ec44a774f2.yaml new file mode 100644 index 00000000..62b8e97f --- /dev/null +++ b/releasenotes/notes/global-inherits-fix-6da007ec44a774f2.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - Importing a package into glare, now fills 'inherited' field with full + inheritance info (previously it only contained immediate parent classes).