Revision ce1bd841

View differences:

src/cli/oneimage
266 266
        table=ShowTable.new(ShowTableImage)
267 267
        table.print_help
268 268
    end
269
    
270
    def special_options(opts, options)
271
        opts.on_tail("-n", "--no-cp", "Do not copy the source") do |o|
272
            options[:no_cp]=true
273
        end
274
    end
275 269
end
276 270

  
277 271

  
......
330 324
    
331 325
    image = OpenNebula::Image.new(OpenNebula::Image.build_xml, get_one_client)
332 326

  
333
    result = img_repo.create(image, template, !ops[:no_cp])    
327
    result = img_repo.create(image, template)    
334 328
    if is_successful?(result)
335 329
        puts "ID: " + image.id.to_s if ops[:verbose]
336 330
    end
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