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
This commit is contained in:
Kirill Zaitsev 2016-05-25 03:36:59 +03:00
parent 48aa35b3ee
commit a0a48f0ace
2 changed files with 23 additions and 0 deletions

View File

@ -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(

View File

@ -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).