本文整理汇总了Python中kiwi.defaults.Defaults.get_min_volume_mbytes方法的典型用法代码示例。如果您正苦于以下问题:Python Defaults.get_min_volume_mbytes方法的具体用法?Python Defaults.get_min_volume_mbytes怎么用?Python Defaults.get_min_volume_mbytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kiwi.defaults.Defaults
的用法示例。
在下文中一共展示了Defaults.get_min_volume_mbytes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _accumulate_volume_size
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get_min_volume_mbytes [as 别名]
def _accumulate_volume_size(self, root_mbytes):
"""
Calculate number of mbytes to add to the disk to allow
the creaton of the volumes with their configured size
"""
disk_volume_mbytes = 0
data_volume_mbytes = self._calculate_volume_mbytes()
root_volume = self._get_root_volume_configuration()
# For oem types we only add the default min volume size
# because their target size request is handled on first boot
# of the disk image in oemboot/repart
if self.build_type_name == 'oem':
for volume in self.volumes:
disk_volume_mbytes += Defaults.get_min_volume_mbytes()
return disk_volume_mbytes
# For vmx types we need to add the configured volume
# sizes because the image is used directly as it is without
# being deployed and resized on a target disk
for volume in self.volumes:
if volume.realpath and not volume.realpath == '/' and volume.size:
[size_type, req_size] = volume.size.split(':')
disk_add_mbytes = 0
if size_type == 'freespace':
disk_add_mbytes += int(req_size)
else:
disk_add_mbytes += int(req_size) - \
data_volume_mbytes.volume[volume.realpath]
if disk_add_mbytes > 0:
disk_volume_mbytes += disk_add_mbytes + \
Defaults.get_min_volume_mbytes()
else:
log.warning(
'volume size of %s MB for %s is too small, skipped',
int(req_size), volume.realpath
)
if root_volume:
if root_volume.size_type == 'freespace':
disk_add_mbytes = root_volume.req_size
else:
disk_add_mbytes = root_volume.req_size - \
root_mbytes + data_volume_mbytes.total
if disk_add_mbytes > 0:
disk_volume_mbytes += disk_add_mbytes + \
Defaults.get_min_volume_mbytes()
else:
log.warning(
'root volume size of %s MB is too small, skipped',
root_volume.req_size
)
return disk_volume_mbytes
示例2: test_get_disksize_mbytes_volumes
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get_min_volume_mbytes [as 别名]
def test_get_disksize_mbytes_volumes(self, mock_log_warn, mock_exists):
mock_exists.return_value = True
root_size = self.size.accumulate_mbyte_file_sizes.return_value
assert self.setup_volumes.get_disksize_mbytes() == \
Defaults.get_default_legacy_bios_mbytes() + \
Defaults.get_default_efi_boot_mbytes() + \
Defaults.get_default_boot_mbytes() + \
root_size + \
1024 - root_size + \
500 + Defaults.get_min_volume_mbytes() + \
30 + Defaults.get_min_volume_mbytes()
assert mock_log_warn.called
示例3: test_create_volumes
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get_min_volume_mbytes [as 别名]
def test_create_volumes(
self, mock_mount, mock_mapped_device, mock_fs, mock_command,
mock_size, mock_os_exists
):
mock_mapped_device.return_value = 'mapped_device'
size = mock.Mock()
size.customize = mock.Mock(
return_value=42
)
mock_size.return_value = size
mock_os_exists.return_value = False
self.volume_manager.volume_group = 'volume_group'
self.volume_manager.create_volumes('ext3')
myvol_size = 500
etc_size = 200 + 42 + Defaults.get_min_volume_mbytes()
root_size = 100 + 42 + Defaults.get_min_volume_mbytes()
assert mock_mount.call_args_list == [
call(device='/dev/volume_group/LVRoot', mountpoint='tmpdir'),
call(device='/dev/volume_group/myvol', mountpoint='tmpdir//data'),
call(device='/dev/volume_group/LVetc', mountpoint='tmpdir//etc'),
call(device='/dev/volume_group/LVhome', mountpoint='tmpdir//home')
]
assert mock_command.call_args_list == [
call(['mkdir', '-p', 'root_dir/etc']),
call(['mkdir', '-p', 'root_dir/data']),
call(['mkdir', '-p', 'root_dir/home']),
call([
'lvcreate', '-L', format(root_size), '-n', 'LVRoot',
'volume_group'
]),
call([
'lvcreate', '-L', format(myvol_size), '-n', 'myvol',
'volume_group'
]),
call([
'lvcreate', '-L', format(etc_size), '-n', 'LVetc',
'volume_group'
]),
call([
'lvcreate', '-l', '+100%FREE', '-n', 'LVhome', 'volume_group'
])
]
assert mock_fs.call_args_list == [
call('ext3', 'mapped_device'),
call('ext3', 'mapped_device'),
call('ext3', 'mapped_device'),
call('ext3', 'mapped_device')
]
self.volume_manager.volume_group = None
示例4: test_get_disksize_mbytes_oem_volumes
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get_min_volume_mbytes [as 别名]
def test_get_disksize_mbytes_oem_volumes(self, mock_exists):
mock_exists.return_value = True
root_size = self.size.accumulate_mbyte_file_sizes.return_value
assert self.setup_oem_volumes.get_disksize_mbytes() == \
Defaults.get_lvm_overhead_mbytes() + \
Defaults.get_default_legacy_bios_mbytes() + \
Defaults.get_default_efi_boot_mbytes() + \
Defaults.get_default_boot_mbytes() + \
root_size + \
5 * Defaults.get_min_volume_mbytes()
示例5: get_volume_mbsize
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get_min_volume_mbytes [as 别名]
def get_volume_mbsize(
self, volume, all_volumes, filesystem_name, image_type=None
):
"""
Implements size lookup for the given path and desired
filesystem according to the specified size type
:param tuple volume: volume to check size for
:param list all_volumes: list of all volume tuples
:param str filesystem_name: filesystem name
:param image_type: build type name
:return: mbsize
:rtype: int
"""
[size_type, mbsize] = volume.size.split(':')
lookup_path = volume.realpath
if image_type and image_type == 'oem':
# only for vmx types we need to create the volumes in the
# configured size. oem disks are self expandable and will
# resize to the configured sizes on first boot of the disk
# image. Therefore the requested size is set to null
# and we add the required minimum size to hold the data
size_type = 'freespace'
mbsize = 0
if size_type == 'freespace':
exclude_paths = []
for volume in all_volumes:
volume_path = volume.realpath
if lookup_path == volume_path:
continue
if lookup_path == os.sep:
# exclude any sub volume path if lookup_path is / [LVRoot]
exclude_paths.append(
os.path.normpath(self.root_dir + os.sep + volume_path)
)
elif volume_path.startswith(lookup_path):
# exclude any sub volume path below lookup_path
exclude_paths.append(
os.path.normpath(self.root_dir + os.sep + volume_path)
)
volume_size = SystemSize(
os.path.normpath(self.root_dir + os.sep + lookup_path)
)
mbsize = int(mbsize) + \
Defaults.get_min_volume_mbytes()
mbsize += volume_size.customize(
volume_size.accumulate_mbyte_file_sizes(exclude_paths),
filesystem_name
)
return mbsize
示例6: test_create_volumes
# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get_min_volume_mbytes [as 别名]
def test_create_volumes(
self, mock_attrs, mock_mount, mock_mapped_device, mock_fs,
mock_command, mock_size, mock_os_exists
):
self.volume_manager.mountpoint = 'tmpdir'
mock_mapped_device.return_value = 'mapped_device'
size = mock.Mock()
size.customize = mock.Mock(
return_value=42
)
mock_size.return_value = size
mock_os_exists.return_value = False
self.volume_manager.volume_group = 'volume_group'
self.volume_manager.create_volumes('ext3')
myvol_size = 500
etc_size = 200 + 42 + Defaults.get_min_volume_mbytes()
root_size = 100 + 42 + Defaults.get_min_volume_mbytes()
assert mock_attrs.call_args_list == [
call(
'root_dir', self.volume_type(
name='LVRoot', size='freespace:100', realpath='/',
mountpoint=None, fullsize=False, attributes=[]
)
),
call(
'root_dir', self.volume_type(
name='myvol', size='size:500', realpath='/data',
mountpoint='LVdata', fullsize=False, attributes=[]
)
),
call(
'root_dir', self.volume_type(
name='LVetc', size='freespace:200', realpath='/etc',
mountpoint='/etc', fullsize=False, attributes=[]
)
)
]
assert mock_mount.call_args_list == [
call(device='/dev/volume_group/LVRoot', mountpoint='tmpdir'),
call(device='/dev/volume_group/myvol', mountpoint='tmpdir//data'),
call(device='/dev/volume_group/LVetc', mountpoint='tmpdir//etc'),
call(device='/dev/volume_group/LVhome', mountpoint='tmpdir//home')
]
assert mock_command.call_args_list == [
call(['mkdir', '-p', 'root_dir/etc']),
call(['mkdir', '-p', 'root_dir/data']),
call(['mkdir', '-p', 'root_dir/home']),
call([
'lvcreate', '-L', format(root_size), '-n', 'LVRoot',
'volume_group'
]),
call([
'lvcreate', '-L', format(myvol_size), '-n', 'myvol',
'volume_group'
]),
call([
'lvcreate', '-L', format(etc_size), '-n', 'LVetc',
'volume_group'
]),
call([
'lvcreate', '-l', '+100%FREE', '-n', 'LVhome', 'volume_group'
])
]
assert mock_fs.call_args_list == [
call(
custom_args={'create_options': [], 'mount_options': ['a,b,c']},
device_provider='mapped_device',
name='ext3'
),
call(
custom_args={'create_options': [], 'mount_options': ['a,b,c']},
device_provider='mapped_device',
name='ext3'
),
call(
custom_args={'create_options': [], 'mount_options': ['a,b,c']},
device_provider='mapped_device',
name='ext3'
),
call(
custom_args={'create_options': [], 'mount_options': ['a,b,c']},
device_provider='mapped_device',
name='ext3'
)
]
self.volume_manager.volume_group = None