User Tools

Site Tools


esmith:configdb

esmith::ConfigDB

In a root terminal you can do the command below if you want to display the up-to-date content

perldoc -U esmith::ConfigDB

NAME

esmith::ConfigDB - interface to esmith configuration database<br />

SYNOPSIS

         use esmith::ConfigDB;
         my $db = esmith::ConfigDB->open;
         my $db = esmith::ConfigDB->open_ro;

         my @services = $db->services();

         # Singleton Records
         my $record = $db->get($key);
         my $value = $record->value;
         $record->set_value($value);

         # BAD!
         my $value = $db->get($key)->value() # Throws a runtime error if $key
                                             # doesn’t exist
         $value = $db->get($key)->prop($p)   # Throws a runtime error if $key
                                             # doesn’t exist

         # GOOD
         my $record = $db->get($key);
         my $value;
         if ($record)
         {
             $value = $record->prop($prop);
         }

         # Typed Records (eventually they all will be)
         my $prop = $record->prop($p);
         $record->set_prop($prop, $propvalue);
         my $value = $db->get_value($key)    # Returns undef if record doesn’t exist
         $value = $db->get_prop($key, $p)    # Returns undef if record doesn’t exist

DESCRIPTION

This module provides an abstracted interface to the esmith master configuration database.

Unless otherwise noted, esmith::ConfigDB acts like esmith::DB::db.

open()

Like esmith::DB→open, but if given no $file it will try to open the file in the ESMITH_CONFIG_DB environment variable or configuration.

open_ro()

Like esmith::DB→open_ro, but if given no $file it will try to open the file in the ESMITH_CONFIG_DB environment variable or configuration.

new_record()

This method creates a new record in the configuration database. As arguments, it expects the key to the record, followed by a hash references with its properties, including the type.

     my $db = esmith::ConfigDB->open; my $record = $db->new_record(’zope’, {
     type => ’service’,
                                            status => ’disabled’ });

     my %defaults = qw(
         type => ’service’,
         status => ’disabled’,
         maintainer => ’admin@domain.com’
         ); my $record = $db->get(’zope’); unless ($record) {
         $record = $db->new_record(’zope’, \%defaults); }

get()

Like their esmith::DB counterparts except they return esmith::ConfigDB::Record objects which have a few extra methods.

     my $record = $db->get(’zope’);

getLocale()

Retrieves the locale and keyboard settings from the configuration database. Returns ($lang, $kbdtype, $keytable) on success. Returns undef if the record doesn’t exist.

hosts_allow_spec ($service [,$daemon])

Given a service, return the string suitable for /etc/hosts.allow, checking to see if the service is defined, whether it is enabled and whether access is set to public, private, or localhost.

An optional argument provides the tag which appears in hosts.allow. If not given, the service name is used.

For example, one of the following:

     # ’oidentd’ is not defined in the configuration database # ’oidentd’ is
     disabled in the configuration database in.identd: 127.0.0.1 in.identd:
     127.0.0.1 192.168.1.1/255.255.255.0 in.identd: ALL

And here’s the hosts.allow fragment:

     {
         $OUT = $DB->hosts_allow_spec(’oidentd’, ’in.identd’);
     }

wins_server

Return the value of the WINS server from the config db or undef if we don’t have a WINS server set and we are not the domain master

services()

Returns a list of services in the configuration database

_loadDefaults ($forceReset)

Behaves just like the esmith::DB method of the same name. This is a private method used internally.

record_has_defaults ($name)

Behaves just like the esmith::DB method of the same name.

migrate

Just like the esmith::DB method of the same name.

AUTHOR

esmith/configdb.txt · Last modified: 2015/05/22 09:23 by stephdl