Chapter 3. Accessing SCR

Now that we know how the SCR-landscape can be navigated we will take a look at how the data that is dug in there can be accessed. The accessing methods already implied above shall now be defined more precisely.

There are four accessing methods.

As a rule all SCR-agents implement some of the four accessing methods listed above. However depending on the task the agent was made for, not all of them may be provided.

For convenient use from YCP the accessing methods are realized by means of an API, i.e. a defined set of YCP-functions that are understood. You can call these functions from YCP if you prepend the commands with the name space identifier SCR:: which causes redirection to the SCR.

Table 3.1. The SCR-commands

FunctionWhat it does
Read(path p) -> any Reads the data represented by the node at path p. The value returned can be any YCP data type but it is always one single value.
Write(path p, any v) -> boolean Writes the value v to the node at path p. The boolean return value is true on success. On error the return value is false and a log entry is generated in the log file. Reasons for errors can be a mistyped value v or some problem with the periphery that lies behind the data-node.
Execute(path p) -> boolean This command is mostly used with the system-agent (see Chapter 6, Useful SCR Agents). Usually the return value indicates success or failure of the executed command.
Dir(path p) -> list(string) Returns a list of all subtree nodes immediately below the node p. For each such node the list contains a string denoting its name. If p does not point to a map node, i.e. the last path component is a leaf, the command will return an empty list or nil.



[1] Unfortunately not all SCR-agents do support this command properly. There may be agents that wrongly return an empty list or even nil when queried this way.