def _validate_data(cls, interfaces): if not isinstance(interfaces, list): raise errors.InvalidInterfacesInfo( "Meta.interfaces should be list", log_message=True ) return interfaces
def validate_update(cls, interfaces): interfaces = cls._validate_data(interfaces) for nic in interfaces: if not isinstance(nic, dict): raise errors.InvalidInterfacesInfo( "Interface in meta.interfaces must be dict", log_message=True) return interfaces
def validate_create(cls, meta): cls._validate_data(meta) if 'interfaces' in meta: meta['interfaces'] = MetaInterfacesValidator.validate_create( meta['interfaces']) else: raise errors.InvalidInterfacesInfo( "Failed to discover node: " "invalid interfaces info", log_message=True) return meta