当前位置: 首页>>代码示例>>Python>>正文


Python defaults.Defaults类代码示例

本文整理汇总了Python中kiwi.defaults.Defaults的典型用法代码示例。如果您正苦于以下问题:Python Defaults类的具体用法?Python Defaults怎么用?Python Defaults使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Defaults类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_disksize_mbytes_empty_volumes

 def test_get_disksize_mbytes_empty_volumes(self):
     assert self.setup_empty_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() + \
         self.size.accumulate_mbyte_file_sizes.return_value
开发者ID:AdamMajer,项目名称:kiwi-ng,代码行数:7,代码来源:storage_setup_test.py

示例2: get_gfxmode

    def get_gfxmode(self, target):
        """
        Graphics mode according to bootloader target

        Bootloaders which support a graphics mode can be configured
        to run graphics in a specific resolution and colors. There
        is no standard for this setup which causes kiwi to create
        a mapping from the kernel vesa mode number to the corresponding
        bootloader graphics mode setup

        :param string target: bootloader name

        :return: boot graphics mode

        :rtype: str
        """
        gfxmode_map = Defaults.get_video_mode_map()

        default_mode = Defaults.get_default_video_mode()
        requested_gfxmode = self.xml_state.build_type.get_vga()

        if requested_gfxmode in gfxmode_map:
            gfxmode = requested_gfxmode
        else:
            gfxmode = default_mode

        if target == 'grub2':
            return gfxmode_map[gfxmode].grub2
        elif target == 'isolinux':
            return gfxmode_map[gfxmode].isolinux
        else:
            return gfxmode
开发者ID:Conan-Kudo,项目名称:kiwi,代码行数:32,代码来源:base.py

示例3: test_get_live_dracut_module_from_flag

 def test_get_live_dracut_module_from_flag(self):
     assert Defaults.get_live_dracut_module_from_flag('foo') == \
         'kiwi-live'
     assert Defaults.get_live_dracut_module_from_flag('overlay') == \
         'kiwi-live'
     assert Defaults.get_live_dracut_module_from_flag('dmsquash') == \
         'dmsquash-live'
开发者ID:adrianschroeter,项目名称:kiwi,代码行数:7,代码来源:defaults_test.py

示例4: _setup_secure_boot_efi_image

 def _setup_secure_boot_efi_image(self, lookup_path):
     """
     Provide the shim loader and the shim signed grub2 loader
     in the required boot path. Normally this task is done by
     the shim-install tool. However, shim-install does not exist
     on all distributions and the script does not operate well
     in e.g CD environments from which we generate live and/or
     install media. Thus shim-install is used if possible at
     install time of the bootloader because it requires access
     to the target block device. In any other case this setup
     code should act as the fallback solution
     """
     log.warning(
         '--> Running fallback setup for shim secure boot efi image'
     )
     if not lookup_path:
         lookup_path = self.root_dir
     shim_image = Defaults.get_shim_loader(lookup_path)
     if not shim_image:
         raise KiwiBootLoaderGrubSecureBootError(
             'Microsoft signed shim loader not found'
         )
     grub_image = Defaults.get_signed_grub_loader(lookup_path)
     if not grub_image:
         raise KiwiBootLoaderGrubSecureBootError(
             'Shim signed grub2 efi loader not found'
         )
     Command.run(
         ['cp', shim_image, self._get_efi_image_name()]
     )
     Command.run(
         ['cp', grub_image, self.efi_boot_path]
     )
开发者ID:adrianschroeter,项目名称:kiwi,代码行数:33,代码来源:grub2.py

示例5: test_get_disksize_mbytes_with_spare_partition

 def test_get_disksize_mbytes_with_spare_partition(self):
     configured_spare_part_size = 42
     assert self.setup_arm.get_disksize_mbytes() == \
         configured_spare_part_size + \
         Defaults.get_default_efi_boot_mbytes() + \
         Defaults.get_default_boot_mbytes() + \
         self.size.accumulate_mbyte_file_sizes.return_value
开发者ID:AdamMajer,项目名称:kiwi-ng,代码行数:7,代码来源:storage_setup_test.py

示例6: translate

    def translate(self, check_build_environment=True):
        """
        Translate repository location according to their URI type

        Depending on the URI type the provided location needs to
        be adapted e.g loop mounted in case of an ISO or updated
        by the service URL in case of an open buildservice project
        name

        :raises KiwiUriStyleUnknown: if the uri scheme can't be detected, is
            unknown or it is inconsistent with the build environment
        :param bool check_build_environment: specify if the uri translation
            should depend on the environment the build is called in. As of
            today this only effects the translation result if the image
            build happens inside of the Open Build Service

        :rtype: str
        """
        uri = urlparse(self.uri)
        if not uri.scheme:
            raise KiwiUriStyleUnknown(
                'URI scheme not detected {uri}'.format(uri=self.uri)
            )
        elif uri.scheme == 'obs':
            if check_build_environment and Defaults.is_buildservice_worker():
                return self._buildservice_path(
                    name=''.join([uri.netloc, uri.path]).replace(':/', ':'),
                    fragment=uri.fragment,
                    urischeme=uri.scheme
                )
            else:
                return self._obs_project_download_link(
                    ''.join([uri.netloc, uri.path]).replace(':/', ':')
                )
        elif uri.scheme == 'obsrepositories':
            if not Defaults.is_buildservice_worker():
                raise KiwiUriStyleUnknown(
                    'Only the buildservice can use the {0} schema'.format(
                        uri.scheme
                    )
                )
            return self._buildservice_path(
                name=''.join([uri.netloc, uri.path]).replace(':/', ':'),
                fragment=uri.fragment,
                urischeme=uri.scheme
            )
        elif uri.scheme == 'dir':
            return self._local_path(uri.path)
        elif uri.scheme == 'file':
            return self._local_path(uri.path)
        elif uri.scheme == 'iso':
            return self._iso_mount_path(uri.path)
        elif uri.scheme.startswith('http') or uri.scheme == 'ftp':
            return ''.join([uri.scheme, '://', uri.netloc, uri.path])
        else:
            raise KiwiUriStyleUnknown(
                'URI schema %s not supported' % self.uri
            )
开发者ID:Conan-Kudo,项目名称:kiwi,代码行数:58,代码来源:uri.py

示例7: test_get_grub_boot_directory_name

 def test_get_grub_boot_directory_name(self, mock_which):
     mock_which.return_value = 'grub2-install-was-found'
     assert Defaults.get_grub_boot_directory_name(
         lookup_path='lookup_path'
     ) == 'grub2'
     mock_which.return_value = None
     assert Defaults.get_grub_boot_directory_name(
         lookup_path='lookup_path'
     ) == 'grub'
开发者ID:adrianschroeter,项目名称:kiwi,代码行数:9,代码来源:defaults_test.py

示例8: test_get_disksize_mbytes_root_volume

 def test_get_disksize_mbytes_root_volume(self, mock_log_warn, mock_exists):
     mock_exists.return_value = True
     root_size = self.size.accumulate_mbyte_file_sizes.return_value
     assert self.setup_root_volume.get_disksize_mbytes() == \
         Defaults.get_default_legacy_bios_mbytes() + \
         Defaults.get_default_efi_boot_mbytes() + \
         Defaults.get_default_boot_mbytes() + \
         root_size
     assert mock_log_warn.called
开发者ID:ChrisBr,项目名称:kiwi,代码行数:9,代码来源:storage_setup_test.py

示例9: _accumulate_volume_size

    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
开发者ID:Conan-Kudo,项目名称:kiwi,代码行数:56,代码来源:setup.py

示例10: test_get_disksize_mbytes_oem_volumes

 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()
开发者ID:AdamMajer,项目名称:kiwi-ng,代码行数:10,代码来源:storage_setup_test.py

示例11: TestDefaults

class TestDefaults(object):
    def setup(self):
        self.defaults = Defaults()

    def test_get(self):
        assert self.defaults.get('kiwi_align') == 1048576
        assert self.defaults.get('kiwi_startsector') == 2048
        assert self.defaults.get('kiwi_sectorsize') == 512
        assert self.defaults.get('kiwi_inode_size') == 256
        assert self.defaults.get('kiwi_inode_ratio') == 16384
        assert self.defaults.get('kiwi_min_inodes') == 20000
        assert self.defaults.get('kiwi_revision')

    def test_to_profile(self):
        profile = mock.MagicMock()
        self.defaults.to_profile(profile)
        profile.add.assert_any_call('kiwi_align', 1048576)
        profile.add.assert_any_call('kiwi_startsector', 2048)
        profile.add.assert_any_call('kiwi_sectorsize', 512)
        profile.add.assert_any_call(
            'kiwi_revision', self.defaults.get('kiwi_revision')
        )

    def test_get_preparer(self):
        assert Defaults.get_preparer() == 'KIWI - http://suse.github.com/kiwi'

    def test_get_publisher(self):
        assert Defaults.get_publisher() == 'SUSE LINUX GmbH'
开发者ID:k0da,项目名称:kiwi-1,代码行数:28,代码来源:defaults_test.py

示例12: test_get_disksize_mbytes_configured_additive

 def test_get_disksize_mbytes_configured_additive(self):
     self.setup.configured_size = mock.Mock()
     self.setup.build_type_name = 'vmx'
     self.setup.configured_size.additive = True
     self.setup.configured_size.mbytes = 42
     root_size = self.size.accumulate_mbyte_file_sizes.return_value
     assert self.setup.get_disksize_mbytes() == \
         Defaults.get_default_legacy_bios_mbytes() + \
         Defaults.get_default_efi_boot_mbytes() + \
         Defaults.get_default_boot_mbytes() + \
         root_size + 42 + \
         200 * 1.7
开发者ID:AdamMajer,项目名称:kiwi-ng,代码行数:12,代码来源:storage_setup_test.py

示例13: prepare

 def prepare(self):
     """
     Prepare kiwi profile environment to be included in dracut initrd
     """
     profile = Profile(self.xml_state)
     defaults = Defaults()
     defaults.to_profile(profile)
     setup = SystemSetup(
         self.xml_state, self.boot_root_directory
     )
     setup.import_shell_environment(profile)
     self.dracut_options.append('--install')
     self.dracut_options.append('/.profile')
开发者ID:AdamMajer,项目名称:kiwi-ng,代码行数:13,代码来源:dracut.py

示例14: test_create_volumes

    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
开发者ID:toabctl,项目名称:kiwi,代码行数:50,代码来源:volume_manager_lvm_test.py

示例15: sync_data

    def sync_data(self):
        """
        Synchronize data from the given base image to the target root
        directory.
        """
        self.extract_oci_image()
        Command.run([
            'umoci', 'unpack', '--image',
            '{0}:base_layer'.format(self.oci_layout_dir), self.oci_unpack_dir
        ])

        synchronizer = DataSync(
            os.sep.join([self.oci_unpack_dir, 'rootfs', '']),
            ''.join([self.root_dir, os.sep])
        )
        synchronizer.sync_data(options=['-a', '-H', '-X', '-A'])

        # A copy of the uncompressed image and its checksum are
        # kept inside the root_dir in order to ensure the later steps
        # i.e. system create are atomic and don't need any third
        # party archive.
        image_copy = Defaults.get_imported_root_image(self.root_dir)
        Path.create(os.path.dirname(image_copy))
        image_tar = ArchiveTar(image_copy)
        image_tar.create(self.oci_layout_dir)
        self._make_checksum(image_copy)
开发者ID:Conan-Kudo,项目名称:kiwi,代码行数:26,代码来源:oci.py


注:本文中的kiwi.defaults.Defaults类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。