diff --git a/app/models/miq_ae_yaml_import.rb b/app/models/miq_ae_yaml_import.rb index 231ac5865..abd932b51 100644 --- a/app/models/miq_ae_yaml_import.rb +++ b/app/models/miq_ae_yaml_import.rb @@ -15,6 +15,9 @@ def initialize(domain, options) def import if @options.key?('import_dir') && !File.directory?(@options['import_dir']) raise MiqAeException::DirectoryNotFound, "Directory [#{@options['import_dir']}] not found" + elsif !User.current_user.nil? && @options['zip_file'] && domain_locked?(@options['import_as']) + # raises exception only for a local import into the locked domain + raise MiqAeException::DomainNotAccessible, 'locked domain' end start_import(@options['preview'], @domain_name) end @@ -247,4 +250,10 @@ def update_attributes(domain_obj) attrs = @options.slice('enabled', 'source') domain_obj.update_attributes(attrs) unless attrs.empty? end + + private + + def domain_locked?(domain_name) + MiqAeDomain.find_by(:name => domain_name)&.contents_locked? ? true : false + end end # class