Configuration API: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 19: Line 19:
** validate : a function to validate the value
** validate : a function to validate the value


==server-src/conffile.h==
===server-src/conffile.h===
; confparm_t : global option
; confparm_t : global option
; tapetype_ee, dumptype_ee, interface_ee,holdingdisk_ee : tapetype/dumptype/interface/holding options
; tapetype_ee, dumptype_ee, interface_ee,holdingdisk_ee : tapetype/dumptype/interface/holding options
; tapetype_t, dumptype_t, interface_t, holdingdisk_t: Data structures with following fields
; tapetype_t, dumptype_t, interface_t, holdingdisk_t: Data structures with following fields:
**seen:
**seen:
**name: name of the option
**name: name of the option
Line 31: Line 31:
To retrieve global value, developer must use one of these functions: getconf_int, getconf_long, getconf_size, getconf_time, getconf_am64, getconf_real, getconf_str,
To retrieve global value, developer must use one of these functions: getconf_int, getconf_long, getconf_size, getconf_time, getconf_am64, getconf_real, getconf_str,


==server-src/conffile.c==
===server-src/conffile.c===
  server_keytab: Keytab for the server configuration
; server_keytab : Keytab for the server configuration
  server_var  : Array that describe global server options
; server_var  : Array describing global server options
  holding_var  : Array that describe holdingdisk options
; holding_var  : Array describing holdingdisk options
  dumptype_var : Array that describe dumptype options
; dumptype_var : Array describing dumptype options
  tapetype_var : Array that describe tapetype options
; tapetype_var : Array describing tapetype options
  interface_var: Array that describe interface options
; interface_var : Array describing interface options


=How to add new option=
==How to add a new configuration option==
==How to add a new global option==
==How to add a new global option==
  Add a token in tok_t (CONF_*)
* Add a token in tok_t (CONF_*)
  Add a token in confparm_t (CNF_*)
* Add a token in confparm_t (CNF_*)
  Add an entry in server_keytab
* Add an entry in server_keytab
  Add an entry in server_var
* Add an entry in server_var
  init_defaults(): Set default value.
* Change init_defaults(): Set default value for the option
  User should use the correct getconf_* function according to the type given in server_var
* User should use the correct getconf_* function according to the data type given in server_var


==How to add a dumptype option==
==How to add a dumptype option==
  Add a token in tok_t (CONF_*)
* Add a token in tok_t (CONF_*)
  Add a token in dumptype_ee (DUMPTYPE_*)
* Add a token in dumptype_ee (DUMPTYPE_*)
  Add a macro to retrive the value (dumptype_get_*)
* Add a macro to retrive the value (dumptype_get_*)
  Add an entry in server_keytab
* Add an entry in server_keytab
  Add an entry in dumptype_var
* Add an entry in dumptype_var
  init_dumptype_defaults(): Set default value.
* Change init_dumptype_defaults(): Set default value.
  The dumptype_get_* macro should return the correct field according to the type defined in dumptype_var
* The dumptype_get_* macro should return the correct field according to the type defined in dumptype_var


  Adding a tapetype, holdingdisk or interface option is done similarly.
Adding a tapetype, holdingdisk or interface option is done similar to adding a dumptype option.


  For a dumptype, the value must also be copied to the disk_t struct:
* For a dumptype, the value must also be copied to the disk_t structure.
    add a NEWVAR field in the disk_t struct with the type.
** Add a NEWVAR field in the disk_t struct with the type.
    In diskfile.c(parse_diskline) you must add the following line:
** In diskfile.c(parse_diskline) you must add the following line:
     disk->NEWVAR = dumptype_get_NEWVAR(dtype);
     disk->NEWVAR = dumptype_get_NEWVAR(dtype);
    You can then use disk->NEWVAR as you like.
: You can then use disk->NEWVAR as you like.

Revision as of 19:03, 20 June 2006

This section describes how Amanda reads amanda.conf and amanda-client.conf configuration files.

Data Structures

common/util.h

conftype_t
all possible types of config options.
tok_t
tokens
keytab_t
string to tok_t conversion.
command_option_t
data structure to keep -o command line argument.
val_t
Store the value of a configuration option. It has following fields:
    • v  : value
    • seen : If the value was seen on a config file
    • type : the type of the value
t_conf_var
structure for all configuration options with following fields:
    • token : the internal token use.
    • type : the type of the value
    • read_function : the function to read that value
    • parm : confparm_t, tapetype_ee, dumptype_ee, interface_ee or holdingdisk_ee
    • validate : a function to validate the value

server-src/conffile.h

confparm_t
global option
tapetype_ee, dumptype_ee, interface_ee,holdingdisk_ee
tapetype/dumptype/interface/holding options
tapetype_t, dumptype_t, interface_t, holdingdisk_t
Data structures with following fields:
    • seen:
    • name: name of the option
    • value: all value of that tapetype/dumptype/interface

There are lot of macros tapetype_*, dumptype_*, interface_*, holdingdisk_* to retrieve configuration values.

To retrieve global value, developer must use one of these functions: getconf_int, getconf_long, getconf_size, getconf_time, getconf_am64, getconf_real, getconf_str,

server-src/conffile.c

server_keytab
Keytab for the server configuration
server_var
Array describing global server options
holding_var
Array describing holdingdisk options
dumptype_var
Array describing dumptype options
tapetype_var
Array describing tapetype options
interface_var
Array describing interface options

How to add a new configuration option

How to add a new global option

  • Add a token in tok_t (CONF_*)
  • Add a token in confparm_t (CNF_*)
  • Add an entry in server_keytab
  • Add an entry in server_var
  • Change init_defaults(): Set default value for the option
  • User should use the correct getconf_* function according to the data type given in server_var

How to add a dumptype option

  • Add a token in tok_t (CONF_*)
  • Add a token in dumptype_ee (DUMPTYPE_*)
  • Add a macro to retrive the value (dumptype_get_*)
  • Add an entry in server_keytab
  • Add an entry in dumptype_var
  • Change init_dumptype_defaults(): Set default value.
  • The dumptype_get_* macro should return the correct field according to the type defined in dumptype_var

Adding a tapetype, holdingdisk or interface option is done similar to adding a dumptype option.

  • For a dumptype, the value must also be copied to the disk_t structure.
    • Add a NEWVAR field in the disk_t struct with the type.
    • In diskfile.c(parse_diskline) you must add the following line:
   disk->NEWVAR = dumptype_get_NEWVAR(dtype);
You can then use disk->NEWVAR as you like.