コード例 #1
0
 def create_lvm_image(base, size):
     base_size = disk.get_disk_size(base)
     self.verify_base_size(base, size, base_size=base_size)
     resize = size > base_size
     size = size if resize else base_size
     lvm.create_volume(self.vg, self.lv, size, sparse=self.sparse)
     if self.ephemeral_key_uuid is not None:
         encrypt_lvm_image()
     images.convert_image(base, self.path, 'raw', run_as_root=True)
     if resize:
         disk.resize2fs(self.path, run_as_root=True)
コード例 #2
0
ファイル: imagebackend.py プロジェクト: hsluoyz/patron
 def create_lvm_image(base, size):
     base_size = disk.get_disk_size(base)
     self.verify_base_size(base, size, base_size=base_size)
     resize = size > base_size
     size = size if resize else base_size
     lvm.create_volume(self.vg, self.lv,
                                  size, sparse=self.sparse)
     if self.ephemeral_key_uuid is not None:
         encrypt_lvm_image()
     images.convert_image(base, self.path, 'raw', run_as_root=True)
     if resize:
         disk.resize2fs(self.path, run_as_root=True)
コード例 #3
0
    def test_get_disk_size(self, mock_execute, mock_exists):
        path = '/some/path'
        example_output = """image: 00000001
file format: raw
virtual size: 4.4M (4592640 bytes)
disk size: 4.4M
"""
        mock_execute.return_value = (example_output, '')
        self.assertEqual(4592640, disk.get_disk_size('/some/path'))
        mock_execute.assert_called_once_with('env', 'LC_ALL=C', 'LANG=C',
                                             'qemu-img', 'info', path)
        mock_exists.assert_called_once_with(path)
コード例 #4
0
ファイル: test_utils.py プロジェクト: hsluoyz/patron
    def test_get_disk_size(self, mock_execute, mock_exists):
        path = '/some/path'
        example_output = """image: 00000001
file format: raw
virtual size: 4.4M (4592640 bytes)
disk size: 4.4M
"""
        mock_execute.return_value = (example_output, '')
        self.assertEqual(4592640, disk.get_disk_size('/some/path'))
        mock_execute.assert_called_once_with('env', 'LC_ALL=C', 'LANG=C',
                                             'qemu-img', 'info', path)
        mock_exists.assert_called_once_with(path)
コード例 #5
0
 def get_disk_size(self, name):
     return disk.get_disk_size(name)
コード例 #6
0
ファイル: imagebackend.py プロジェクト: hsluoyz/patron
 def get_disk_size(self, name):
     return disk.get_disk_size(name)