本文整理汇总了Python中kiwi.xml_state.XMLState类的典型用法代码示例。如果您正苦于以下问题:Python XMLState类的具体用法?Python XMLState怎么用?Python XMLState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XMLState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_volumes
def test_get_volumes(self):
description = XMLDescription('../data/example_lvm_default_config.xml')
xml_data = description.load()
state = XMLState(xml_data)
volume_type = namedtuple(
'volume_type', [
'name',
'size',
'realpath',
'mountpoint',
'fullsize'
]
)
assert state.get_volumes() == [
volume_type(
name='LVusr_lib', size='size:1024',
realpath='usr/lib',
mountpoint=None, fullsize=False
),
volume_type(
name='LVRoot', size='freespace:500',
realpath='/',
mountpoint=None, fullsize=False
),
volume_type(
name='etc_volume', size='freespace:30',
realpath='etc',
mountpoint='LVetc', fullsize=False
),
volume_type(
name='bin_volume', size=None,
realpath='/usr/bin',
mountpoint='LVusr_bin', fullsize=True
)
]
示例2: test_get_build_type_vmconfig_entries_for_vmx_type
def test_get_build_type_vmconfig_entries_for_vmx_type(self):
description = XMLDescription('../data/example_config.xml')
xml_data = description.load()
state = XMLState(xml_data, ['vmxFlavour'], 'vmx')
assert state.get_build_type_vmconfig_entries() == [
'numvcpus = "4"', 'cpuid.coresPerSocket = "2"'
]
示例3: test_get_volumes_no_explicit_root_setup_other_fullsize_volume
def test_get_volumes_no_explicit_root_setup_other_fullsize_volume(self):
description = XMLDescription(
'../data/example_lvm_no_root_full_usr_config.xml'
)
xml_data = description.load()
state = XMLState(xml_data)
volume_type = namedtuple(
'volume_type', [
'name',
'size',
'realpath',
'mountpoint',
'fullsize'
]
)
assert state.get_volumes() == [
volume_type(
name='LVusr', size=None, realpath='usr',
mountpoint=None, fullsize=True
),
volume_type(
name='LVRoot', size='freespace:30', realpath='/',
mountpoint=None, fullsize=False
)
]
示例4: TestRuntimeChecker
class TestRuntimeChecker(object):
def setup(self):
description = XMLDescription("../data/example_runtime_checker_config.xml")
self.xml_state = XMLState(description.load())
self.runtime_checker = RuntimeChecker(self.xml_state)
@raises(KiwiRuntimeError)
def test_check_image_include_repos_http_resolvable(self):
self.runtime_checker.check_image_include_repos_http_resolvable()
@raises(KiwiRuntimeError)
def test_check_target_directory_not_in_shared_cache_1(self):
self.runtime_checker.check_target_directory_not_in_shared_cache("/var/cache//kiwi/foo")
@raises(KiwiRuntimeError)
def test_check_target_directory_not_in_shared_cache_2(self):
self.runtime_checker.check_target_directory_not_in_shared_cache("/var/cache/kiwi")
@raises(KiwiRuntimeError)
@patch("os.getcwd")
def test_check_target_directory_not_in_shared_cache_3(self, mock_getcwd):
mock_getcwd.return_value = "/"
self.runtime_checker.check_target_directory_not_in_shared_cache("var/cache/kiwi")
@raises(KiwiRuntimeError)
def test_check_target_directory_not_in_shared_cache_4(self):
self.runtime_checker.check_target_directory_not_in_shared_cache("//var/cache//kiwi/foo")
@raises(KiwiRuntimeError)
def test_check_repositories_configured(self):
self.xml_state.delete_repository_sections()
self.runtime_checker.check_repositories_configured()
示例5: test_build_type_size_with_unpartitioned
def test_build_type_size_with_unpartitioned(self):
state = XMLState(self.description.load(), ['vmxFlavour'], 'vmx')
result = state.get_build_type_size()
assert result.mbytes == 3072
assert not result.additive
result = state.get_build_type_size(include_unpartitioned=True)
assert result.mbytes == 4096
assert not result.additive
示例6: test_get_users
def test_get_users(self):
description = XMLDescription('../data/example_multiple_users_config.xml')
xml_data = description.load()
state = XMLState(xml_data)
users = state.get_users()
assert len(users) == 3
assert any(u.get_name() == 'root' for u in users)
assert any(u.get_name() == 'tux' for u in users)
assert any(u.get_name() == 'kiwi' for u in users)
示例7: test_get_build_type_docker_containerconfig_section
def test_get_build_type_docker_containerconfig_section(self):
xml_data = self.description.load()
state = XMLState(xml_data, ['vmxFlavour'], 'docker')
containerconfig = state.get_build_type_containerconfig_section()
assert containerconfig.get_name() == \
'container_name'
assert containerconfig.get_maintainer() == \
'tux'
assert containerconfig.get_workingdir() == \
'/root'
示例8: test_copy_bootdelete_packages_no_delete_section_in_boot_descr
def test_copy_bootdelete_packages_no_delete_section_in_boot_descr(self):
boot_description = XMLDescription(
'../data/isoboot/example-distribution-no-delete-section/config.xml'
)
boot_state = XMLState(
boot_description.load()
)
self.state.copy_bootdelete_packages(boot_state)
to_delete_packages = boot_state.get_to_become_deleted_packages()
assert 'vim' in to_delete_packages
示例9: test_copy_bootincluded_packages_with_image_packages
def test_copy_bootincluded_packages_with_image_packages(self):
boot_description = XMLDescription(
'../data/isoboot/example-distribution/config.xml'
)
boot_state = XMLState(boot_description.load(), ['std'])
self.state.copy_bootincluded_packages(boot_state)
image_packages = boot_state.get_system_packages()
assert 'plymouth-branding-openSUSE' in image_packages
assert 'grub2-branding-openSUSE' in image_packages
assert 'gfxboot-branding-openSUSE' in image_packages
to_delete_packages = boot_state.get_to_become_deleted_packages()
assert 'gfxboot-branding-openSUSE' not in to_delete_packages
示例10: setup
def setup(self, mock_machine):
mock_machine.return_value = 'x86_64'
description = XMLDescription(
'../data/example_config.xml'
)
self.state = XMLState(
description.load()
)
boot_description = XMLDescription(
'../data/isoboot/example-distribution/config.xml'
)
self.boot_state = XMLState(
boot_description.load()
)
示例11: test_get_system_packages_some_arch
def test_get_system_packages_some_arch(self, mock_machine):
mock_machine.return_value = 's390'
state = XMLState(
self.description.load()
)
assert state.get_system_packages() == [
'foo',
'gfxboot-branding-openSUSE',
'grub2-branding-openSUSE',
'ifplugd',
'iputils',
'kernel-default',
'openssh',
'plymouth-branding-openSUSE',
'vim'
]
示例12: test_get_container_config_clear_commands
def test_get_container_config_clear_commands(self):
expected_config = {
'maintainer': ['--author=tux'],
'entry_subcommand': [
'--clear=config.cmd'
],
'container_name': 'container_name',
'container_tag': 'container_tag',
'workingdir': ['--config.workingdir=/root'],
'user': ['--config.user=root'],
'entry_command': [
'--clear=config.entrypoint',
]
}
xml_data = self.description.load()
state = XMLState(xml_data, ['derivedContainer'], 'docker')
assert state.get_container_config() == expected_config
示例13: setup
def setup(self):
self.description = XMLDescription(
'../data/example_runtime_checker_config.xml'
)
self.xml_state = XMLState(
self.description.load()
)
self.runtime_checker = RuntimeChecker(self.xml_state)
示例14: test_get_initrd_system
def test_get_initrd_system(self):
xml_data = self.description.load()
state = XMLState(xml_data, ['vmxFlavour'], 'vmx')
assert state.get_initrd_system() == 'dracut'
state = XMLState(xml_data, ['vmxFlavour'], 'iso')
assert state.get_initrd_system() == 'dracut'
state = XMLState(xml_data, ['vmxFlavour'], 'docker')
assert state.get_initrd_system() is None
state = XMLState(xml_data, [], 'oem')
assert state.get_initrd_system() == 'kiwi'
示例15: load_xml_description
def load_xml_description(self, description_directory):
"""
Load, upgrade, validate XML description
Attributes
* :attr:`xml_data`
instance of XML data toplevel domain (image), stateless data
* :attr:`config_file`
used config file path
* :attr:`xml_state`
Instance of XMLState, stateful data
"""
from ..logger import log
log.info('Loading XML description')
config_file = description_directory + '/config.xml'
if not os.path.exists(config_file):
# alternative config file lookup location
config_file = description_directory + '/image/config.xml'
if not os.path.exists(config_file):
# glob config file search, first match wins
glob_match = description_directory + '/*.kiwi'
for kiwi_file in glob.iglob(glob_match):
config_file = kiwi_file
break
if not os.path.exists(config_file):
raise KiwiConfigFileNotFound(
'no XML description found in %s' % description_directory
)
description = XMLDescription(
config_file
)
self.xml_data = description.load()
self.config_file = config_file.replace('//', '/')
self.xml_state = XMLState(
self.xml_data,
self.global_args['--profile'],
self.global_args['--type']
)
log.info('--> loaded %s', self.config_file)
if self.xml_state.build_type:
log.info(
'--> Selected build type: %s',
self.xml_state.get_build_type_name()
)
if self.xml_state.profiles:
log.info(
'--> Selected profiles: %s',
','.join(self.xml_state.profiles)
)
self.runtime_checker = RuntimeChecker(self.xml_state)