def _check_attr(self, name, allow_ro):
        cls_name = reflection.get_class_name(self, fully_qualified=False)
        if name not in self._get_attributes():
            raise ex.CMApiAttributeError(
                _('Invalid property %(attname)s for class %(classname)s.')
                % {'attname': name, 'classname': cls_name})
        attr = self._get_attributes()[name]
        if not allow_ro and attr and not attr.rw:
            raise ex.CMApiAttributeError(
                _('Attribute %(attname)s of class %(classname)s '
                  'is read only.')
                % {'attname': name, 'classname': cls_name})
        return attr
dataset/ETHPy150Open openstack/sahara/sahara/plugins/cdh/client/types.py/BaseApiObject._check_attr/original