def _validate_metadata(self, meta_data): if not meta_data.get('type') in ['map', 'tosca:map']: ExceptionCollector.appendException( InvalidTypeError(what='"%s" defined in group for ' 'metadata' % (meta_data.get('type')))) for entry_schema, entry_schema_type in meta_data.items(): if isinstance(entry_schema_type, dict) and not \ entry_schema_type.get('type') == 'string': ExceptionCollector.appendException( InvalidTypeError( what='"%s" defined in group for ' 'metadata "%s"' % (entry_schema_type.get('type'), entry_schema)))
def parent_type(self): '''Return a node this node is derived from.''' if not hasattr(self, 'defs'): return None pnode = self.derived_from(self.defs) if pnode: if pnode and pnode == self.type: # circular reference ExceptionCollector.appendException( InvalidTypeError(what=self.type)) return None return NodeType(pnode, self.custom_def)
def __init__(self, entitytype, prefix, custom_def=None): entire_entitytype = entitytype if not entitytype.startswith(self.TOSCA): entire_entitytype = prefix + entitytype if entire_entitytype in list(self.TOSCA_DEF.keys()): self.defs = self.TOSCA_DEF[entire_entitytype] entitytype = entire_entitytype elif custom_def and entitytype in list(custom_def.keys()): self.defs = custom_def[entitytype] else: ExceptionCollector.appendException( InvalidTypeError(what=entitytype)) self.type = entitytype
def __init__(self, entitytype, prefix, custom_def=None): entire_entitytype = entitytype if UnsupportedType.validate_type(entire_entitytype): self.defs = None else: if entitytype.startswith(self.TOSCA + ":"): entitytype = entitytype[(len(self.TOSCA) + 1):] entire_entitytype = prefix + entitytype if not entitytype.startswith(self.TOSCA): entire_entitytype = prefix + entitytype if entire_entitytype in list(self.TOSCA_DEF.keys()): self.defs = self.TOSCA_DEF[entire_entitytype] entitytype = entire_entitytype elif custom_def and entitytype in list(custom_def.keys()): self.defs = custom_def[entitytype] else: # avoid errors if self.defs = none self.defs = {} ExceptionCollector.appendException( InvalidTypeError(what=entitytype)) self.type = entitytype
def _validate_targets(self, targets_list, custom_def): for nodetype in targets_list: if nodetype not in custom_def: ExceptionCollector.appendException( InvalidTypeError(what='"%s" defined in targets for ' 'policy "%s"' % (nodetype, self.type)))