Revision ce1bd841 src/oca/ruby/OpenNebula/ImageRepository.rb

View differences:

src/oca/ruby/OpenNebula/ImageRepository.rb
4 4
module OpenNebula
5 5
    class ImageRepository
6 6

  
7
        def create(image, template, copy=true)
7
        def create(image, template)
8 8
            if image.nil?
9 9
                error_msg = "Image could not be found, aborting."
10 10
                return OpenNebula::Error.new(error_msg)
......
21 21
            # ------ Copy the Image file ------
22 22
            image.info
23 23

  
24
            if image['TEMPLATE/PATH']
25
                if copy
26
                    # --- CDROM, DATABLOCK or OS based on a PATH ---
27
                    file_path = image['TEMPLATE/PATH']
24
            if image['TEMPLATE/PATH'] and image['TEMPLATE/SOURCE'].nil?
25
                # --- CDROM, DATABLOCK or OS based on a PATH ---
26
                file_path = image['TEMPLATE/PATH']
28 27

  
29
                    if !File.exists?(file_path)
30
                        error_msg = "Image file could not be found, aborting."
31
                        return OpenNebula::Error.new(error_msg)
32
                    end
33

  
34
                    result = copy(file_path, image['SOURCE'])
28
                if !File.exists?(file_path)
29
                    error_msg = "Image file could not be found, aborting."
30
                    return OpenNebula::Error.new(error_msg)
35 31
                end
32

  
33
                result = copy(file_path, image['SOURCE'])
36 34
            elsif image['TEMPLATE/SIZE'] and image['TEMPLATE/FSTYPE'] and  \
37 35
                            image['TEMPLATE/TYPE'] == 'DATABLOCK'
38 36
                # --- Empty DATABLOCK ---
......
41 39
                if !OpenNebula.is_error?(result)
42 40
                    result = mkfs(image['TEMPLATE/FSTYPE'], image['SOURCE'])
43 41
                end
44
            else
45
                error_msg = "Image not present, aborting."
42
            elsif image['TEMPLATE/PATH'].nil? and image['TEMPLATE/SOURCE'].nil?
43
                error_msg = "Image path not present, aborting."
44
                result = OpenNebula::Error.new(error_msg)
45
            elsif image['TEMPLATE/PATH'] and image['TEMPLATE/SOURCE']
46
                error_msg = "Template malformed, PATH and SOURCE are" <<
47
                            " mutuallly exclusive"
46 48
                result = OpenNebula::Error.new(error_msg)
47 49
            end
48 50

  

Also available in: Unified diff