eBox developers guide

Javier Uruen

Ricardo Muñoz

Jorge Arcas

Isaac Clerencia

Guillermo Ontañón

Javier Amor

Enrique J. Hernández

This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.


Table of Contents

1. Introduction
1.1. Intended audience
1.2. What is eBox?
1.3. Terminology
1.4. How a module works
1.5. A Model-View-Controller module
1.5.1. Model creation
1.5.1.1. User input management
1.5.2. Model view
1.5.3. Data model publishing and access
1.5.4. When is this approach suitable?
2. Basic API
2.1. EBox::Global
2.2. Exceptions
2.3. Data validation
2.4. i18n
2.4.1. i18n developers
2.4.2. i18n for translators
3. Module backend
3.1. The base module
3.1.1. Module constructor
3.2. Root commands
3.3. EBox::GConfModule
3.4. Ordering stuff
3.5. Controlling a daemon
3.5.1. Configuration file generation
3.5.2. Controlling execution
3.6. gconf schemas
3.6.1. Minimal gconf schema
3.6.2. Default values
3.6.3. Module dependencies
3.7. Backups
3.8. Administrative logging
3.9. Migration scripts
4. Interacting with other components
4.1. Introduction
4.1.1. Observers
4.2. Objects module
4.3. Network module
4.4. Firewall module
4.5. Defining new observers
5. Web frontend
5.1. CGIs
5.2. Mason templates
5.2.1. Standard GUI elements
5.3. The menu
5.4. Summary
6. LDAP based modules
6.1. Introduction
6.2. Fetching the configuration parameters
6.3. Access to the LDAP server
6.4. Implementing an LDAP based module
6.5. Adding functionality to the user interface
6.6. Including your own LDAP schemas
6.7. Adding your own access control list
7. Model-View-Controller internals
7.1. Model
7.1.1. Model relationship
7.1.2. Developing eBox types
7.2. View
7.3. Controller
7.4. Publishing models and CGI mapping
8. How to create a module
8.1. Long way to create a small module
8.1.1. Studying the NTP service and its features
8.1.2. Create a new module from the module template.
8.1.3. Defining and implementing the API
8.1.4. Creating CGIs and templates
8.1.5. Showing the menu and the Summary page
8.1.6. Generating config files and managing the NTP server
8.1.7. Setting up proper firewall rules
8.1.8. Conclusion
8.2. Short way to create a small module
8.2.1. Define data model
8.2.2. Define module web GUI using Composites
8.2.3. Publishing model and composite from this module
8.2.4. Common tasks
8.2.4.1. Configuring Apache2 service
8.2.4.2. Manage Apache2 daemon execution
8.2.4.3. Web service inclusion in eBox menu and summary
8.2.4.4. Establish rules through services and firewall modules to use Web service in eBox
8.2.5. Expose module API
8.2.6. Conclusion
9. Event architecture
9.1. Event watchers
9.2. Event dispatchers

List of Figures

7.1. Data model class diagram
7.2. eBox types class diagram
7.3. View template system class diagram

List of Examples

1.1. Object model definition
1.2. Object member model definition
1.3. Jabber dispatcherconfiguration form data model definition
1.4. A sample model composite definition
1.5. Model and composite publishing example
1.6. Rows dumped result
2.1. Creating a read-only module instance
2.2. Functions for instantiating more than one module
2.3. Throwing a generic internal exception
2.4. Catching an exception
2.5. Using data validation functions
2.6. Using data validation functions with automatic error handling
2.7. Using __n function
3.1. Simple module constructor
3.2. Using EBox::Sudo::root()
3.3. Setting a string key
3.4. Setting a string list
3.5. Getting and using a unique identifier
3.6. Ordering firewall rules
3.7. Generating a configuration file
3.8. Sample _regenConfig implementation
3.9. Sample _stopService implementation
3.10. Minimal gconf schema
3.11. Creating a module instance
3.12. Setting a default value in gconf schemas
3.13. Setting module dependencies
3.14. Overriding backup functions
3.15. Overriding functions for extended backups
3.16. Including LogAdmin package
3.17. Creating an object with administrative logging support
3.18. Adding actions to log
3.19. Calling logAdminDeferred method
4.1. EBox::ObjectsObserver subclass implementation
4.2. Implementing a EBox::NetworkObserver
4.3. Creating custom firewall rules
4.4. Defining an observer that may be implemented by other modules
4.5. Calling observer modules
5.1. Hello world CGI
5.2. Setting the mason template for a CGI
5.3. Passing arguments to a mason template
5.4. Setting the 'msg' attribute
5.5. Using parameters from the HTTP request
5.6. Redirecting a request to a different CGI
5.7. Setting the gettext domain in a CGI
5.8. Declaring arguments in a mason template
5.9. init section in mason templates
5.10. Embedding perl code in a mason template
5.11. Printing strings in a mason template
5.12. HTML snippet for displaying messages
5.13. A table to display data
5.14. Data entry form
5.15. Adding folders and items to the menu
5.16. summary sample implementation
5.17. statusSummary sample implementation
6.1. _groupAddOns implementation
6.2. Implementing _includeLDAPSchemas
7.1. GConf structure from a model
7.2. Component call main
8.1. EBox::NTP constructor
8.2. Enabling the NTP server
8.3. Reading the state of the NTP server
8.4. Enabling the external NTP synchronisation
8.5. Fetching the configuration for external synchronization
8.6. Setting the external NTP servers
8.7. Getting the list of external NTP servers
8.8. Setting a new system time and date
8.9. Setting a new time zone
8.10. Restarting eBox modules and system services
8.11. Constructor for EBox::CGI::NTP::Index
8.12. Feeding the configuration of the NTP server to the mason template
8.13. CGI to enable and disable the NTP server
8.14. Mason template for enabling the NTP server
8.15. datetime.mas template
8.16. Adding entries to the eBox menu
8.17. statusSummary in EBox::NTP
8.18. Generating the /etc/ntp.conf configuration file
8.19. Template to generate /etc/ntp.conf
8.20. _regenConfig method
8.21. NTP daemon management method
8.22. tools/runit/ntpd file
8.23. _stopService method.
8.24. Telling whether the NTP daemon is running or not.
8.25. Firewall configuration
8.26. General configuration settings description
8.27. Virtual host data model description
8.28. Adding name resolution to the virtual host
8.29. General composite to display Web service configuration page
8.30. Publishing models and composites from web server module
8.31. WebServer module constructor
8.32. _regenConfig for web service
8.33. Generating web server configuration files
8.34. Setting up the web server
8.35. ports.conf.mas template
8.36. vhost.mas template
8.37. Web daemon management method
8.38. tools/runit/apache2 file
8.39. tools/runit/apache2.finish file
8.40. Stop web service with _stopService method
8.41. Adding WebServer to the menu
8.42. onInstall and onRemove methods to configure web service
8.43. Debian scripts
8.44. virtualHosts method
8.45. _exposedMethods method
8.46. _exposedMethods usage by a Perl script
9.1. EBox::Event::Watcher::DiskFreeSpace constructor