Skip to content

Commit

Permalink
Merge d41742a into d9dcef8
Browse files Browse the repository at this point in the history
  • Loading branch information
pkomanek committed Dec 4, 2018
2 parents d9dcef8 + d41742a commit 3fa59af
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/models/miq_ae_yaml_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 3fa59af

Please sign in to comment.