예제 #1
0
 def test_extend_fs_ok_ext4(self, mock_exec):
     fu.extend_fs('ext4', '/dev/fake')
     expected_calls = [
         mock.call('e2fsck', '-yf', '/dev/fake', check_exit_code=[0]),
         mock.call('resize2fs', '/dev/fake', check_exit_code=[0]),
         mock.call('e2fsck', '-pf', '/dev/fake', check_exit_code=[0])
     ]
     self.assertEqual(mock_exec.call_args_list, expected_calls)
예제 #2
0
    def do_copyimage(self):
        LOG.debug('--- Copying images (do_copyimage) ---')
        for image in self.driver.image_scheme.images:
            LOG.debug('Processing image: %s' % image.uri)
            processing = au.Chain()

            LOG.debug('Appending uri processor: %s' % image.uri)
            processing.append(image.uri)

            if image.uri.startswith('http://'):
                LOG.debug('Appending HTTP processor')
                processing.append(au.HttpUrl)
            elif image.uri.startswith('file://'):
                LOG.debug('Appending FILE processor')
                processing.append(au.LocalFile)

            if image.container == 'gzip':
                LOG.debug('Appending GZIP processor')
                processing.append(au.GunzipStream)

            LOG.debug('Appending TARGET processor: %s' % image.target_device)

            error = None
            if not os.path.exists(image.target_device):
                error = "TARGET processor '{0}' does not exist."
            elif not hw.is_block_device(image.target_device):
                error = "TARGET processor '{0}' is not a block device."
            if error:
                error = error.format(image.target_device)
                LOG.error(error)
                raise errors.WrongDeviceError(error)

            processing.append(image.target_device)

            LOG.debug('Launching image processing chain')
            processing.process()

            if image.size and image.md5:
                LOG.debug('Trying to compare image checksum')
                actual_md5 = utils.calculate_md5(image.target_device,
                                                 image.size)
                if actual_md5 == image.md5:
                    LOG.debug('Checksum matches successfully: md5=%s' %
                              actual_md5)
                else:
                    raise errors.ImageChecksumMismatchError(
                        'Actual checksum %s mismatches with expected %s for '
                        'file %s' % (actual_md5, image.md5,
                                     image.target_device))
            else:
                LOG.debug('Skipping image checksum comparing. '
                          'Ether size or hash have been missed')

            LOG.debug('Extending image file systems')
            if image.format in ('ext2', 'ext3', 'ext4', 'xfs'):
                LOG.debug('Extending %s %s' %
                          (image.format, image.target_device))
                fu.extend_fs(image.format, image.target_device)
예제 #3
0
    def do_copyimage(self):
        LOG.debug('--- Copying images (do_copyimage) ---')
        for image in self.driver.image_scheme.images:
            LOG.debug('Processing image: %s' % image.uri)
            processing = au.Chain()

            LOG.debug('Appending uri processor: %s' % image.uri)
            processing.append(image.uri)

            if image.uri.startswith('http://'):
                LOG.debug('Appending HTTP processor')
                processing.append(au.HttpUrl)
            elif image.uri.startswith('file://'):
                LOG.debug('Appending FILE processor')
                processing.append(au.LocalFile)

            if image.container == 'gzip':
                LOG.debug('Appending GZIP processor')
                processing.append(au.GunzipStream)

            LOG.debug('Appending TARGET processor: %s' % image.target_device)

            error = None
            if not os.path.exists(image.target_device):
                error = "TARGET processor '{0}' does not exist."
            elif not hw.is_block_device(image.target_device):
                error = "TARGET processor '{0}' is not a block device."
            if error:
                error = error.format(image.target_device)
                LOG.error(error)
                raise errors.WrongDeviceError(error)

            processing.append(image.target_device)

            LOG.debug('Launching image processing chain')
            processing.process()

            if image.size and image.md5:
                LOG.debug('Trying to compare image checksum')
                actual_md5 = utils.calculate_md5(image.target_device,
                                                 image.size)
                if actual_md5 == image.md5:
                    LOG.debug('Checksum matches successfully: md5=%s' %
                              actual_md5)
                else:
                    raise errors.ImageChecksumMismatchError(
                        'Actual checksum %s mismatches with expected %s for '
                        'file %s' % (actual_md5, image.md5,
                                     image.target_device))
            else:
                LOG.debug('Skipping image checksum comparing. '
                          'Ether size or hash have been missed')

            LOG.debug('Extending image file systems')
            if image.format in ('ext2', 'ext3', 'ext4', 'xfs'):
                LOG.debug('Extending %s %s' %
                          (image.format, image.target_device))
                fu.extend_fs(image.format, image.target_device)
예제 #4
0
    def do_copyimage(self):
        LOG.debug("--- Copying images (do_copyimage) ---")
        for image in self.driver.image_scheme.images:
            LOG.debug("Processing image: %s" % image.uri)
            processing = au.Chain()

            LOG.debug("Appending uri processor: %s" % image.uri)
            processing.append(image.uri)

            if image.uri.startswith("http://"):
                LOG.debug("Appending HTTP processor")
                processing.append(au.HttpUrl)
            elif image.uri.startswith("file://"):
                LOG.debug("Appending FILE processor")
                processing.append(au.LocalFile)

            if image.container == "gzip":
                LOG.debug("Appending GZIP processor")
                processing.append(au.GunzipStream)

            LOG.debug("Appending TARGET processor: %s" % image.target_device)

            error = None
            if not os.path.exists(image.target_device):
                error = "TARGET processor '{0}' does not exist."
            elif not hw.is_block_device(image.target_device):
                error = "TARGET processor '{0}' is not a block device."
            if error:
                error = error.format(image.target_device)
                LOG.error(error)
                raise errors.WrongDeviceError(error)

            processing.append(image.target_device)

            LOG.debug("Launching image processing chain")
            processing.process()

            if image.size and image.md5:
                LOG.debug("Trying to compare image checksum")
                actual_md5 = utils.calculate_md5(image.target_device, image.size)
                if actual_md5 == image.md5:
                    LOG.debug("Checksum matches successfully: md5=%s" % actual_md5)
                else:
                    raise errors.ImageChecksumMismatchError(
                        "Actual checksum %s mismatches with expected %s for "
                        "file %s" % (actual_md5, image.md5, image.target_device)
                    )
            else:
                LOG.debug("Skipping image checksum comparing. " "Ether size or hash have been missed")

            LOG.debug("Extending image file systems")
            if image.format in ("ext2", "ext3", "ext4", "xfs"):
                LOG.debug("Extending %s %s" % (image.format, image.target_device))
                fu.extend_fs(image.format, image.target_device)
예제 #5
0
 def test_extend_fs_ok_xfs(self, mock_exec):
     fu.extend_fs('xfs', '/dev/fake')
     mock_exec.assert_called_once_with(
         'xfs_growfs', '/dev/fake', check_exit_code=[0])