Merge "Add parent interfaces to the list of NodeType interfaces"

This commit is contained in:
Zuul 2021-09-29 15:17:28 +00:00 committed by Gerrit Code Review
commit 05732befa2
2 changed files with 30 additions and 10 deletions

View File

@ -169,7 +169,23 @@ class NodeType(StatefulEntityType):
@property
def interfaces(self):
return self.get_value(self.INTERFACES)
interfaces = self.get_value(self.INTERFACES)
if self.parent_type is not None:
if self.parent_type.interfaces is not None:
import copy
parent_interfaces = copy.deepcopy(self.parent_type.interfaces)
parent_interfaces.pop(ifaces.LIFECYCLE, None)
parent_interfaces.pop(ifaces.CONFIGURE, None)
parent_interfaces.pop(ifaces.LIFECYCLE_SHORTNAME, None)
parent_interfaces.pop(ifaces.CONFIGURE_SHORTNAME, None)
if parent_interfaces:
if interfaces:
parent_interfaces.update(interfaces)
interfaces = parent_interfaces
return interfaces
@property
def lifecycle_inputs(self):

View File

@ -264,16 +264,20 @@ class NodeTemplate(EntityTemplate):
value, InterfacesDef.
interfaces_relationship_configure_operations,
'interfaces')
elif name in self.type_definition.interfaces.keys():
self._common_validate_field(
value,
self._collect_custom_iface_operations(name),
'interfaces')
else:
ExceptionCollector.appendException(
UnknownFieldError(
what='"interfaces" of template "%s"' %
self.name, field=name))
interfaces = self.type_definition.interfaces
if interfaces is None:
interfaces = dict()
if name in interfaces.keys():
self._common_validate_field(
value,
self._collect_custom_iface_operations(name),
'interfaces')
else:
ExceptionCollector.appendException(
UnknownFieldError(
what='"interfaces" of template "%s"' %
self.name, field=name))
def _collect_custom_iface_operations(self, name):
allowed_operations = []