YaST and YaST Development

Stanislav Visnovsky

YaST Prague Team Leader

Novell

Contents

What will be presented?

concepts

high level overview

guidelines and best practices

This is not a tutorial

see YaST hands-on session

Contents

YaST and why develop using YaST

YaST architecture overview

Programming languages used for YaST development

User interface

System configuration access

Tips and Tricks

What is YaST?

YaST (Yet another Setup Tool) is installation and configuration platform

Features:

modular design

user interface independence

hardware independence

incorporated knowledge about SUSE Linux-based systems

YaST History

1999	1st YaST2 appearance, installation only

(SUSE® LINUX 6.3)

2000	YaST2 for running system (SUSE LINUX 7.1)

2001	SLES 7 – 39 standalone modules

2002	SLES 8 – 45 standalone modules

2004	SLES 9 – 75 standalone modules

YaST Today

Automatic installation (AutoYaST)

LDAP-based configuration support

Command line support

Automatic testing framework

Hardware configuration

RAID, LVM, Wi-Fi, Bluetooth, ...

Server configuration

DNS, DHCP, Samba, Apache2,...

...

YaST as Development Platform

How can YaST be used for development

ISV configuration modules

ISV installation wizards

YaST Development Benefits

Benefits

advanced infrastructure for configuration tasks on Linux

system configuration abstraction

rapid user interface development

extensive libraries

powerful scripting language (YCP)

support for other scripting languages

Why another scripting language

Required features:

small (used during installation)

easy to learn and understand

interpreted

rapid prototyping

can be covered by YaST2 license (now GPL)

Other nice argument:

direct control of language features

YaST Internal Architecture

Overall architecture

R 0

G 98

B 90

YaST

Module

System

Configuration

Repository

User

Interface

Target system

Look & Feel

Uniform Data Model

Control & Logic

Installation source

YaST Module

User Interface

User Interface Handling

Module Logic

System Configuration Repository

Dialogs

Functions

Data

Configuration File Access

Programming Languages

Programming languages

YaST supports multiple programming languages

“Choose the right language” approach

YCP

Perl

any standard input/output-capable language

YaST Module

User Interface

User Interface Handling

Module Logic

System Configuration Repository

Dialogs

Functions

Data

Configuration File Access

YCP, Perl

YCP

Any standard input/output-capable language, e.g., C++, Perl

YCP Language

YCP

YaST Control Protocol

“Native” YaST programming language

Used for development of user interface and logic

Features:

C-like interpreted scripting language (can be precompiled)

modular, imperative

statically typed

full range of types tailored for configuration manipulation

default values

YCP Example

import “Service”;

boolean service = Service::Enabled (“cron”);

boolean locate_enabled = false;

string locate_value = (string) SCR::Read (...);

if (locate_value == “yes”)

{

locate_enabled = true;

}

YCP Language

Data types

lists

maps

terms

functions including function pointers

no objects

Built-in functions

list/map iterators

regular expressions

...

Perl

Used for

module logic

direct system access in system configuration repository

Features supported:

system configuration access

access to other YCP and Perl YaST modules

full access to YaST value types

Perl Example

use YaST::YCP;

YaST::YCP::Import (“Service”);

YaST::YCP::Import (“SCR”);

my $service = Service->Enabled (“cron”);

my $locate_enabled = 0;

my $locate_value = SCR->Read (...);

if ($locate_value == “yes”)

{

$locate_enabled = 1;

}

System Configuration Repository

SCR Purpose

provides system abstraction

for configuration files

for command execution

hardware access

advantages

configuration file format changes

file locations

security

System Abstraction

Root

.target

.etc

.etc.exports

.etc.hosts

SCR Architecture

Root

.target

.etc

.etc.exports

.etc.hosts

SCR

Library

exports agent

hosts agent

SCR Methods

Reading

SCR::Read (path)

Writing

SCR::Write (path, value)

Executing actions

SCR::Execute (path, value)

Listing contents

SCR::Dir (path)

Standard SCR Access

Generic agents

line-oriented configuration files (INI-agent)

sysconfig agent

System agent (.target)

execution of commands

temporary files

file/directory status

SCR Example

string locate_value = (string) SCR::Read (

.sysconfig.cron-locate.RUN_UPDATEDB

);

SCR::Write (

.sysconfig.cron-locate.RUN_UPDATEDB

, locate_value

);

SCR::Execute (

.target.bash

, “SuSEconfig –module cron”

);

User Interface

User Interface

Design Goals

interactive

abstraction (don't bother developer with details)

Features

same code for textual and graphical user interface

predefined set of widgets

intelligent automatic layout management

simplified event handling

UI Example

textdomain “example”

UI::OpenDialog (

`VBox (

`CheckBox ( `id (`enable)

, _(“&Enable index update”) ),

`HBox (

`PushButton (`id(`ok) , _(“&OK”) ),

`PushButton (`id(`cancel) , _(“&Cancel”) )

)

)

);

any result = UI::UserInput ();

UI::CloseDialog ();

UI Example Result

Text frontend

Graphical frontend

Fancy UI Example

textdomain "example";

import "Label";

import "Wizard";

Wizard::CreateDialog ();

Wizard::SetContentsButtons ( _("Fancy dialog title"),

`CheckBox ( `id (`enable) ,

_("&Enable index update") ),

_("Help"), Label::CancelButton(), Label::OKButton()

);

any result = UI::UserInput ();

Wizard::CloseDialog ();

Fancy UI Example Result

Complete Example

textdomain “example”;

string locate_value =

(string) SCR::Read (.sysconfig.cron-locate.RUN_UPDATEDB);

UI::OpenDialog (

`VBox ( `CheckBox ( `id (`enable) , _(“Enable index update”) ),

`HBox ( `PushButton (`id(`ok) , _(“&OK”) ),

`PushButton (`id(`cancel) , _(“&Cancel”) )

)) );

UI::ChangeWidget (`enable, locale_value == yes );

any result = UI::UserInput ();

UI::CloseDialog ();

if ( result == `ok ) {

boolean enable = UI::QueryWidget (`enable);

SCR::Write (.sysconfig.cron-locate.RUN_UPDATED, enable );

}

SCR::Execute ( .target.bash, “SuSEconfig –module cron”);

YaST Module Development

Steps to Develop YaST Module

configuration file access

design SCR agents

user interface design

design UI dialogs

design UI sequences/wizards

implement logic

design API needed by UI

develop logic implementing API using data accessed via SCR

Tips and Tricks

Build environment

Useful packages found on SUSE Linux-based systems

yast2-devtools

automake/autoconf

helper scripts

yast2-core-devel

documentation for system agent

yast2-devel

library documentation

yast2-testsuite

support for automatic testsuites

Useful Libraries

From yast2 package:

Popup – standardized popup dialogs

IP, Hostname, URL – validation and parsing

Package – package manager access

Report – advanced error reporting incl. logging

Progress – progress dialogs

Sequencer – automatic dialog sequencer

Wizard – dialog look & feel library

Logging

Several severities

y2error

y2milestone

y2debug

Non-root support

for root /var/log/YaST2/y2log

for non-root $HOME/.y2log

Full debugging

environment variable Y2DEBUG=1

References

Novell Forge YaST2 project

http://forge.novell.com

Cool Solutions

http://www.novell.com/coolsolutions

BSE_Template_2004

2003-12-08T12:43:39