lib/autoyast.pm

autoyast

Provide translations for autoyast XML file

expand_patterns

expand_patterns();

Expand patterns for sle12 and sle15. Returns a list of patterns to be installed.

get_product_version

get_product_version();

Return product version from SCC and product name, so-called unversioned products like asmm, contm, lgm, tcm, wsm if product version number lower than 15

expand_addons

expand_addons();

Returns hash of all SCC_ADDONS with name, version and architecture.

expand_extra_repos

expand_extra_repo();

Returns array of hashes of all EXTRA_CUSTOMER_REPOS with repo name and url.

e.g. from EXTRA_CUSTOMER_REPOS
15-SP4-TERADATA-Updates;http://dist.suse.de/ibs/SUSE/Updates/SLE-Product-SLES/15-SP4-TERADATA/x86_64/update/

expand_template

expand_template($profile);

Expand and returns template including autoyast profile and it's varialbes like addons, repos, patterns, get_var

$profile is the autoyast profile 'autoinst.xml'.

init_autoyast_profile

init_autoyast_profile();

Initialize or create a new autoyast profile by 'yast2 clone_system' if doesn't exist and returns the path of autoyast profile

validate_autoyast_profile

validate_autoyast_profile($profile);

Validate XML AutoYaST profile traversing YAML test data $profile is the root node in the test data

Expected YAML data should mimic structure of XML file for the AutoYaST profile, so hashes and arrays in the yaml should represent nodes in the xml file.

Generates a list of XPATH expressions based on the YAML file provided, run those expressions and create a summary based with the errors found and all the expressions.

There are special keys to handle xml attributes for the node types, or in case exact number of nodes has to be validated, e.g. _t for the type, __text for the text value of the node, __count to specify exact number of child nodes.

See 'has_properties' and 'generate_expressions' functions for the further info.

In order to validate following xml: <profile> <suse_register t="map"> <addons t="list"> <addon t="map"> <name>sle-module-server-applications</name> </addon> <addon t="map"> <arch>ppc64le</arch> <name>sle-module-basesystem</name> </addon> </addons> <do_registration t="boolean">true</do_registration> <install_updates t="boolean">false</install_updates> </suse_register> </profile>

YAML example to validate given xml: profile: suse_register: addons: _t: list __count: 2 addon: - name: sle-module-server-applications - name: sle-module-basesystem do_registration: _t: boolean __text: 'true'

is_processable

  is_processable($node);

A node is considered 'processable' when:
 - is a simple key-value pair where value is text:
   quotas: 'true'
 - has properties:
   quotas:
     _t: boolean
     __text: 'true'
In other words, a node is not processable when just needs to be traversed in the YAML.

has_properties

has_properties($node);

- A XML node can be specified in YAML along with its attributes from XML: XML: <subvolumes t="list"> YAML: subvolumes: _t: list XPATH: ns:subvolumes[@t='list']

- XPATH functions can be used:

'count': when you want to explicitly count the element in a list
XML:  <subvolumes t="list">
        <subvolume t="map">
YAML: subvolumes:
        __count: 8
        subvolume:
            ...
XPATH: ns:subvolumes[count(ns:subvolume)=8]

'text': when you want to check some attribute and the text itself
XML:  <quotas t="boolean">true</quotas>
YAML: quotas:
        _t: boolean
        __text: true
XPATH: ns:quotas[text()='true' and @t='boolean']

'descendant': by default the algorithm will try to identify an element
in a list using direct children, but with this property is it possible to
add children which are descendant but not necessarily direct children.
It is useful when XML structure are almost exactly the same for different
list items and the only difference is found in more deeper descendants,
therefore avoiding to return multiple result for an XPATH expression.

YAML:
        drive:
        - label:
            _descendant: any
            __text: root_multi_btrfs
            disklabel: none
            partitions:
            partition:
            - filesystem: btrfs
                label: root_multi_btrfs
        - label:
            _descendant: any
            __text: test_multi_btrfs
            disklabel: none
            partitions:
            partition:
            - filesystem: btrfs
                label: test_multi_btrfs

create_xpath_predicate

create_xpath_predicate($node);

Based on the properties of the node will create a predicate for the XPATH expression.

close_predicate

close_predicate(@array);

Joins a list of intermediate predicates and closes it to create one XPATH predicate.

ns

ns($node);

Add XML namespace to the node declared in YAML file to be able to build the correct XPATH expression with namespaces.

get_traversable

get_traversable($node);

Return the node 'traversable' of a node which contains properties, so it returns the key of the hash needed to continue traversing the YAML.

Example which would return 'subvolume' as the key to continue traversing. YAML: subvolumes: _t: list __count: 8 subvolume: - path: var

get_descendant

get_descendant($node);

It will apply the right separator in case direct children nodes (default) or any descendant is applied ('' also means ./ for direct children)

generate_expressions

generate_expressions($node);

Recursive algorithm to traverse YAML file and create a list of XPATH expressions.

run_expressions

run_expressions($args);

Run XPATH expressions. Errors handled are 'no node found' and 'more than one node found'

create_report

create_report($args);

Create a report with the errors found and listing all the XPATH expressions executed.

detect_profile_directory

detect_profile_directory(profile => $profile, path => $path)

Try to detect profile directory (autoyast_opensuse/, autoyast_sle{12,15}/, autoyast_sles11/)
and returns its path.
TODO: autoyast_{kvm,qam,xen}

$profile is the autoyast profile 'autoinst.xml'.
$path is AutoYaST profile path

expand_version

expand_version($profile);

Expand VERSION, as e.g. 15-SP1 has to be mapped to 15.1

$profile is the autoyast profile 'autoinst.xml'.

adjust_network_conf

adjust_network_conf($profile);

For s390x and svirt backends need to adjust network configuration

$profile is the autoyast profile 'autoinst.xml'.

expand_variables

expand_variables($profile);

Expand variables from job settings which do not require further processing

$profile is the autoyast profile 'autoinst.xml'.

adjust_user_password

adjust_user_password($profile);

Password is defined at first, see lib/main_common.pm like below:
---
$testapi::password = "xxxxxx";
$testapi::password = get_var("PASSWORD") if defined get_var("PASSWORD");
---

$profile is the autoyast profile 'autoinst.xml'.

upload_profile

upload_profile(profile => $profile, path => $path)

Upload modified profile
Update path
Make available profile in job logs

$profile is the AutoYaST profile 'autoinst.xml'
$path is the path of the AutoYaST profile or one of the xml files when
using rules and classes.

inject_registration

inject_registration($profile);

$profile is the autoyast profile 'autoinst.xml'.

test_ayp_url

test_ayp_url();

Test if the autoyast profile url is reachable, before the autoyast installation begins.

get_test_data_files get_test_data($dir_relative_path)

Returns list of all relative xml file paths for a relative directory path.

Example: get_test_data_files('autoyast_sle15/rule-based_example/') This could return a reference to an array with content: - autoyast_sle15/rule-based_example/profile_a.xml - autoyast_sle15/rule-based_example/profile_b.xml - autoyast_sle15/rule-based_example/rules/rules.xml - autoyast_sle15/rule-based_example/classes/swap/smallswap.xml - autoyast_sle15/rule-based_example/classes/swap/bigswap.xml - autoyast_sle15/rule-based_example/classes/general/software.xml - autoyast_sle15/rule-based_example/classes/general/registration.xml - autoyast_sle15/rule-based_example/classes/general/users.xml

prepare_ay_file

prepare_ay_file(profile => $profile, path => $path)

Get profile from autoyast template Map version names Get IP address from system variables Get values from SCC_REGCODE SCC_REGCODE_HA SCC_REGCODE_GEO SCC_REGCODE_HPC SCC_URL ARCH LOADER_TYPE Adjust user password Modify profile with obtained values Return new path in case of using AutoYaST templates

$path is the path of the AutoYaST profile or one of the xml files when
using rules and classes.

generate_xml

generate_xml(addons => $addons)

Get maintenance updates addons Generate one xml file Get values from MAINT_TEST_REPO Return string with xml format

$addons is maintenance updates URL