Revision dbf466eb

b/image_creator/dialog_main.py
146 146

  
147 147
    MB = 2 ** 20
148 148

  
149
    size = (dev.meta['SIZE'] + MB - 1) // MB
149
    size = (dev.size + MB - 1) // MB
150 150
    shrinked = 'shrinked' in session and session['shrinked']
151 151
    postfix = " (shrinked)" if shrinked else ''
152 152

  
......
205 205
        try:
206 206
            dev = session['device']
207 207
            if "checksum" not in session:
208
                size = dev.meta['SIZE']
208
                size = dev.size
209 209
                md5 = MD5(out)
210 210
                session['checksum'] = md5.compute(session['snapshot'], size)
211 211

  
......
237 237

  
238 238
def upload_image(session):
239 239
    d = session["dialog"]
240
    size = session['device'].meta['SIZE']
240
    size = session['device'].size
241 241

  
242 242
    if "account" not in session:
243 243
        d.msgbox("You need to provide your ~okeanos login username before you "
b/image_creator/dialog_wizard.py
187 187

  
188 188
    #Shrink
189 189
    size = device.shrink()
190
    metadata.update(device.meta)
190 191

  
191 192
    #MD5
192 193
    md5 = MD5(out)
b/image_creator/disk.py
168 168
        self.bootable = bootable
169 169
        self.progress_bar = None
170 170
        self.guestfs_device = None
171
        self.size = 0
171 172
        self.meta = {}
172 173

  
173 174
        self.g = guestfs.GuestFS()
......
213 214
                             "We only support images with one OS.")
214 215
        self.root = roots[0]
215 216
        self.guestfs_device = self.g.part_to_dev(self.root)
216
        self.meta['SIZE'] = self.g.blockdev_getsize64(self.guestfs_device)
217
        self.size = self.g.blockdev_getsize64(self.guestfs_device)
217 218
        self.meta['PARTITION_TABLE'] = \
218 219
            self.g.part_get_parttype(self.guestfs_device)
219 220

  
......
343 344
            # Most disk manipulation programs leave 2048 sectors after the last
344 345
            # partition
345 346
            new_size = last_part['part_end'] + 1 + 2048 * sector_size
346
            self.meta['SIZE'] = min(self.meta['SIZE'], new_size)
347
            self.size = min(self.size, new_size)
347 348
            break
348 349

  
349 350
        if not re.match("ext[234]", fstype):
350 351
            self.out.warn("Don't know how to resize %s partitions." % fstype)
351
            return self.meta['SIZE']
352
            return self.size
352 353

  
353 354
        part_dev = "%s%d" % (self.guestfs_device, last_part['part_num'])
354 355
        self.g.e2fsck_f(part_dev)
......
405 406

  
406 407
        new_size = (end + 1) * sector_size
407 408

  
408
        assert (new_size <= self.meta['SIZE'])
409
        assert (new_size <= self.size)
409 410

  
410 411
        if self.meta['PARTITION_TABLE'] == 'gpt':
411 412
            ptable = GPTPartitionTable(self.real_device)
412
            self.meta['SIZE'] = ptable.shrink(new_size, self.meta['SIZE'])
413
            self.size = ptable.shrink(new_size, self.size)
413 414
        else:
414
            self.meta['SIZE'] = min(new_size + 2048 * sector_size,
415
                                    self.meta['SIZE'])
415
            self.size = min(new_size + 2048 * sector_size, self.size)
416 416

  
417
        self.out.success("new size is %dMB" %
418
                         ((self.meta['SIZE'] + MB - 1) // MB))
417
        self.out.success("new size is %dMB" % ((self.size + MB - 1) // MB))
419 418

  
420
        return self.meta['SIZE']
419
        return self.size
421 420

  
422 421
    def dump(self, outfile):
423 422
        """Dumps the content of device into a file.
......
427 426
        """
428 427
        MB = 2 ** 20
429 428
        blocksize = 4 * MB  # 4MB
430
        size = self.meta['SIZE']
429
        size = self.size
431 430
        progr_size = (size + MB - 1) // MB  # in MB
432 431
        progressbar = self.out.Progress(progr_size, "Dumping image file", 'mb')
433 432

  
b/image_creator/main.py
219 219
        metadata = image_os.meta
220 220
        dev.umount()
221 221

  
222
        size = options.shrink and dev.shrink() or dev.meta['SIZE']
222
        size = options.shrink and dev.shrink() or dev.size
223 223
        metadata.update(dev.meta)
224 224

  
225 225
        # Add command line metadata to the collected ones...

Also available in: Unified diff