YaST/Web/Development/Service

From openSUSE

Contents

Creating YaST web service plugins

See install from source on how to install and run the WebYaST client components from GIT.


The YaST web service is a web application exposing a RESTful API which allows to configure the target system. This enables any http enabled client to talk to YaST.

Using REST plugin skeleton

Package yast2-devtools >= 2.18.6 contains a new skeleton for REST plugins.

How to use the REST skeleton

  1. Install yast2-devtools package
  2. Go to webservice's plugins directory in the checked out GIT repository
  3. Call y2tool create-new-package rest-plugin <plugin_name> <author> <email>, e.g. y2tool create-new-package rest-plugin printers "My Name" "email@example.com"
    (Note the plural plugin name, webservice expects plural service names, for singular service add singular: true line to config/resources/plugin.yml file)
  4. Start/restart the webservice (the new plugin will be available after restart)
  5. Test the new REST API: http://localhost:8080/plugin_name.xml will download list of all items, http://localhost:8080/plugin_name/first.xml will download details of the item with ID first (there are some testing data in the generated code, so you can immediately check whether the created skeleton works)

Adapting the skeleton to your Yast module

  1. Your YaST module must have high level stateless API (e.g. YaPI:: modules), if it doesn't exist yet you have to add it. (You can start with stateful API first, but you should definitely add and use the stateless API later, see YaST DBus service documentation for more details.)
  2. Define .policy kit files for the needed functions in defined in the previous step (see general PolicyKit documentation, see YaST DBus service documentation how to get the action ID for a specific Yast DBus service call)
  3. Go through all generated files (the most important are in app/controllers and app/models subdirectory) and adapt/fix the code marked by FIXME string. Replace also the testing data with appropriate Yast calls.


Acceptance criteria

Before committing a new service component to the GIT master branch, it must pass the acceptance criteria.