On Wed, 2005-07-27 at 20:15 -0400, Robert Story wrote:
> On Mon, 25 Jul 2005 17:21:20 +0100 Dave wrote:
> DS> We should probably ensure that the hard-coded and interactive
> DS> defaults match - either bringing the hard-coded settings into
> DS> line with the interactive versions (my preference), or vice versa.
> 
> Agreed.

Actually, I've got a slightly different suggestion w.r.t. this.
While experimenting with the interactive mib2c config driver,
I found it somewhat inconvenient to have to work through all
the questions, in order to change one setting.

I've put together a "menu-driven" version of this driver (attached),
which provides a list of the things that can be configured,
together with their current settings.   It relies on a couple
of changes to the mib2c script (which have been committed to
the CVS tree), but ought to be a drop-in replacement for the
current mfd-interactive-setup.conf file.

Let me know what you think.

Dave
#######################################################################
## generic include for XXX. Do not use directly.
##
## $Id: mfd-interactive-setup.m2c,v 1.16 2005/07/25 15:39:15 dts12 Exp $
########################################################################
@if $m2c_mark_boundary == 1@
/** START code generated by $RCSfile: mfd-interactive-setup.m2c,v $ $Revision: 
1.16 $ */
@end@
########################################################################
@eval $m2c_temp_table_writable = table_is_writable($context)@
@eval $m2c_temp_table_create   = table_has_create($context)@
@eval $m2c_temp_settable = $m2c_table_settable@
@eval $m2c_temp_create   = $m2c_table_row_creation@
@eval $m2c_temp_dependencies = $m2c_table_dependencies@
@eval $m2c_temp_persistent   = $m2c_table_persistent@
@eval $m2c_temp_context_reg  = "$mfd_default_context_reg"@
@eval $m2c_temp_data_context = "$mfd_default_data_context"@
@eval $m2c_temp_data_allocate = $mfd_default_data_allocate@
@eval $m2c_temp_data_cache = $mfd_default_data_cache@
@eval $m2c_temp_undo_embed = $mfd_default_undo_embed@
@eval $m2c_temp_data_init = $mfd_default_data_init@
@eval $m2c_temp_table_access = "$mfd_default_table_access"@
@eval $m2c_temp_data_transient = $mfd_default_data_transient@
@eval $m2c_temp_include_examples = $mfd_default_include_examples@
@eval $m2c_temp_table_skip_mapping = $mfd_default_table_skip_mapping@
@eval $m2c_temp_table_sparse = $mfd_default_data_sparse@
@eval $m2c_temp_generate_makefile = $mfd_default_generate_makefile@
@eval $m2c_temp_generate_subagent = $mfd_default_generate_subagent@
##
@if $mfd_interactive_setup != 0@
@open -@
@eval $m2c_interactive_loop = 1@

@while $m2c_interactive_loop == 1@
@ if $m2c_temp_table_writable == 1@
@   if $m2c_temp_settable == 1@
@     eval $current01 = "yes"@
@   else@
@     eval $current01 = "no"@
@   end@
@ else@
@     eval $current01 = "n/a"@
@ end@
@ if $m2c_temp_settable == 1@
@   if $m2c_temp_persistent == 1@
@     eval $current02 = "yes"@
@   else@
@     eval $current02 = "no"@
@   end@
@ else@
@     eval $current02 = "n/a"@
@ end@
@ if $m2c_temp_settable == 1@
@   if $m2c_temp_dependencies == 1@
@     eval $current03 = "yes"@
@   else@
@     eval $current03 = "no"@
@   end@
@ else@
@     eval $current03 = "n/a"@
@ end@
@ if $m2c_temp_table_create == 1 && $m2c_temp_settable == 1@
@   if $m2c_temp_create == 1@
@     eval $current04 = "yes"@
@   else@
@     eval $current04 = "no"@
@   end@
@ else@
@     eval $current04 = "n/a"@
@ end@
@ if $m2c_temp_data_allocate == 1@
@     eval $current07 = "allocated"@
@ else@
@     eval $current07 = "embedded"@
@ end@
@ if $m2c_temp_data_init == 1@
@     eval $current08 = "yes"@
@ else@
@     eval $current08 = "no"@
@ end@
@ if $m2c_temp_skip_mapping == 1@
@     eval $current09 = "no"@
@ else@
@     eval $current09 = "yes"@
@ end@
@     eval $current10 = "$m2c_temp_table_access"@
@if $m2c_temp_data_cache == 0  && $current10 eq "container-cached"@
@     eval $current10 = "container"@
@end@
@ if $m2c_temp_data_transient == 1@
@     eval $current11 = "transient"@
@ elsif $m2c_temp_data_transient == 1@
@     eval $current11 = "semi-transient"@
@ else@
@     eval $current11 = "persistent"@
@ end@
@ if $m2c_temp_include_examples == 1@
@     eval $current12 = "yes"@
@ else@
@     eval $current12 = "no"@
@ end@
@ if $m2c_temp_table_sparse == 1@
@     eval $current13 = "yes"@
@ else@
@     eval $current13 = "no"@
@ end@
@ if $m2c_temp_generate_makefile == 1@
@     eval $current14 = "yes"@
@ else@
@     eval $current14 = "no"@
@ end@
Current settings
================
 1: Writeable columns                [$current01]
 2:   Persistent rows                [$current02]
 3:   Inter-column dependencies      [$current03]
 4:   Dynamic row creation           [$current04]
 5: Table information structure      [$m2c_temp_context_reg]
 6: Per-row data structure           [$m2c_temp_data_context]
 7: Embedded rows/Dynamic allocation [$current07]
 8: Initialise row contents          [$current08]
 9: Map MIB values                   [$current09]
10: Data access method               [$current10]
11: Transient data                   [$current11]
12: Example code                     [$current12]
13: Sparse tables                    [$current13]
14: AgentX subagent/Makefile         [$current14]

 0: Generate code template
 X: Exit without generating code

@prompt $select Please enter selection: @
@if "$select" eq "X" || "$select" eq "x" || "$select" eq "Q" || "$select" eq 
"q" @
@   quit@
@elsif $select == 0@ 
@   eval $m2c_interactive_loop = 0@

## ---------------------------------------------------
@elsif $select == 1@ 
@  if $m2c_temp_table_writable == 1@
This table has writable columns. Do you want to generate
code for writeable columns, or restrict the table to read-only?

  1) generate code with writeable columns
  2) generate code with read-only columns

@      eval $default = 2-$m2c_temp_settable@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 1@
@        eval $m2c_temp_settable = 1@
@      elsif $ans == 2@
@        eval $m2c_temp_settable = 0@
@        eval $m2c_temp_create = 0@
@        eval $m2c_temp_dependencies = 0@
@        eval $m2c_temp_persistent = 0@
@      end@
@  else@
This table is defined as read-only in the MIB file.
It is not appropriate to generate code for writeable columns.
@  end@ # writable

## ---------------------------------------------------
@elsif $select == 2@ 
@  if $m2c_temp_table_writable == 1@
@    if $m2c_temp_settable == 1@
Since your table is writable, do you want to generate code to save and
restore rows in the Net-SNMP persistent store? You should only use this
option if the agent 'owns' the data, and doesn't get the data from an
external source.

  1) do not generate persistent store code
  2) generate persistent store code

@      eval $default = 1+$m2c_temp_persistent@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 1@
@        eval $m2c_temp_persistent = 0@
@      elsif $ans == 2@
@        eval $m2c_temp_persistent = 1@
@      end@


@    else@
The system is currently configured to generate read-only code for
this table.  It is not appropriate to generate code for persistent
storage unless this is changed.
@    end@
@  else@
This table is defined as read-only in the MIB file.
It is not appropriate to generate code for persistent storage.
@  end@ # persistent

## ---------------------------------------------------
@elsif $select == 3@ 
@  if $m2c_temp_table_writable == 1@
@    if $m2c_temp_settable == 1@
Writable tables sometimes have dependencies beteen columns or
with other tables. If there are no dependencies in this table,
you probably do not want the extra code.

  1) do not generate dependency code
  2) generate dependency code

@      eval $default = 1+$m2c_temp_dependencies@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 1@
@        eval $m2c_temp_dependencies = 0@
@      elsif $ans == 2@
@        eval $m2c_temp_dependencies = 1@
@      end@


@    else@
The system is currently configured to generate read-only code for
this table.  It is not appropriate to generate code for column
dependencies unless this is changed.
@    end@
@  else@
This table is defined as read-only in the MIB file.
It is not appropriate to generate code for column dependencies.
@  end@ # dependencies

## ---------------------------------------------------
@elsif $select == 4@ 
@  if $m2c_temp_table_create == 1@
@    if $m2c_temp_settable == 1@
This table has read-create columns. Do you want to generate
code for dynamic row creation?

  1) generate code for row creation
  2) do not generate code for row creation

@      eval $default = 2-$m2c_temp_create@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 1@
@        eval $m2c_temp_create = 1@
@      elsif $ans == 2@
@        eval $m2c_temp_create = 0@
@      end@


@    else@
The system is currently configured to generate read-only code for
this table.  It is not appropriate to generate code for row
creation unless this is changed.
@    end@
@  else@
@    if $m2c_temp_table_writable == 1@
This table is defined as read-write in the MIB file.
@    else@
This table is defined as read-only in the MIB file.
@    end@
It is not appropriate to generate code for row creation.
@  end@ # create

## ---------------------------------------------------
@elsif $select == 5@ 
Do you want to use an existing data structure for the USER context?
This would be a structure used to track data for the entire table,
(similar to a global variable) not individual rows.

@      prompt $ans Enter the type of your structure [$m2c_temp_context_reg]: @

@      if $ans ne ""@
@        eval $m2c_temp_context_reg = "$ans"@
@      end@

## ---------------------------------------------------
@elsif $select == 6@ 
Do you want to use an existing data structure for the DATA context?
The DATA context holds the data for each MIB column. By default,
a new data structure will be created with an element for each column.

Note: Do not enter a pointer type. Use the base structure name. For
example, use 'struct widget', not 'struct widget *'. If you will be
using a pointer to the structure, select dynamic allocation in the
next question.

@      prompt $ans Enter the type of your structure [$m2c_temp_data_context]: @

@      if $ans ne ""@
@        eval $m2c_temp_data_context = "$ans"@
@      end@


## ---------------------------------------------------
@elsif $select == 7@ 
@    if "x$m2c_temp_data_context" ne "x$mfd_default_data_context"@
Do you want to allocate your '$m2c_temp_data_context' DATA context, or
embed it directly? If your data is INTERNAL (controlled by the agent), you
probably want embedded. If your data is EXTERNAL (controlled by another
process) and you have pointers to the data, you probably want allocated.

  1) directly embed structure
  2) dynamically allocate structure

@      eval $default = 1+$m2c_temp_data_allocate@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 1@
@        eval $m2c_temp_data_allocate = 0@
@      elsif $ans == 2@
@        eval $m2c_temp_data_allocate = 1@
@      end@
@    else@
This system only supports embedding '$mfd_default_data_context' DATA
contexts directly.
@    end@

## ---------------------------------------------------
@elsif $select == 8@ 
Do you need to initialize elements in the '$m2c_temp_data_context' when
a new instance is created (eg default values, or other structures you are
going to add that might need initialization to the row request context?
(The most common reasons you might need to do this is are if you want to keep
some non-MIB data for every row, or some columns have default values.)

  1) no, no initialization needed
  2) yes, initilization is needed

@      eval $default = 1+$m2c_temp_data_init@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 1@
@        eval $m2c_temp_data_init = 0@
@      elsif $ans == 2@
@        eval $m2c_temp_data_init = 1@
@      end@


## ---------------------------------------------------
@elsif $select == 9@ 
Do you plan on keeping all data in the format defined by the MIB? If so,
no functions will be generated to map values. If some data will be
stored in a different format, the mapping functions will be generated.
If your MIB has integers with enumerations, mapping functions are more
likely to be needed. (e.g. A TruthValue object will hold the value
1 or 2, but a C boolean would be 1 or 0.)

  1) All values will be stored as defined by the MIB
  2) I need to map values to the format defined by the MIB.

@      if $m2c_temp_skip_mapping == 1@
@        eval $default = 1@
@      else@
@        eval $default = 2@
@      end@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 1@
@        eval $m2c_temp_skip_mapping = 1@
@      elsif $ans == 2@
@        eval $m2c_temp_skip_mapping = -1@   # ??? why not 0?
@      end@


## ---------------------------------------------------
@elsif $select == 10@ 
Which method would you like to use to gather data about available rows? 

  1) container :  This access method uses a netsnmp_container
     to store all row data in memory. This method is best for:
         - Internal data (maintained by the agent)
         - Access speed is important
         - Sufficient memory exists to contain all rows

  2) container-cached : This access method uses a netsnmp_container
     to keep track of the indexes (and data, usually) for each 
     row. This method is best for:
         - External data (maintained by another process)
         - Access speed is important
         - Sufficient memory exists to contain all indexes
     
  3) unsorted-external : This access method iterates over all of your data
     to find the row with the appropriate index. This method is good for
         - External data (maintained by another process)
         - Using less memory is much more important than access speed
     

@      prompt $ans Select your choice [$current10]: @
@      if $ans == 3 || $ans eq "unsorted-external"@
@        eval $m2c_temp_table_access = "unsorted-external"@
@      elsif $ans == 2 || $ans eq "container-cached"@
@        eval $m2c_temp_table_access = "container-cached"@
@        eval $m2c_temp_data_cache = 1@
@      elsif $ans == 1 || $ans eq "container"@
@        eval $m2c_temp_table_access = "container-cached"@
@        eval $m2c_temp_data_cache = 0@
@      end@


## ---------------------------------------------------
@elsif $select == 11@ 
When accessing your data, is your data TRANSIENT?

  1) Yes. My data is TRANSIENT (e.g. a pointer to a static buffer that
     my be overwritten during a request) and needs to be copied during
     processing.

  2) Yes. My data is SEMI-TRANSIENT (e.g. an allocated pointer to a
     copy of the data).

  3) No, my data is PERSISTENT (e.g. an allocated pointer to the actual
     data, which is under the agent's control)
  
@      eval $default = 3-$m2c_temp_data_transient@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 3@
@        eval $m2c_temp_data_transient = 0@
@      elsif $ans == 2@
@        eval $m2c_temp_data_transient = 1@
@      else@
@        eval $m2c_temp_data_transient = 2@
@      end@


## ---------------------------------------------------
@elsif $select == 12@ 
Do you want example code to be generated?

  1) generate example code
  2) do not generate example code

@      eval $default = 2-$m2c_temp_include_examples@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 1@
@        eval $m2c_temp_include_examples = 1@
@      elsif $ans == 2@
@        eval $m2c_temp_include_examples = 0@
@      end@

## ---------------------------------------------------
@elsif $select == 13@ 
Is your table sparse? (A sparse table is a table where some
columns might not exist for all rows.)

  1) No, all columns always exist for every row
  2) Yes, my table is sparse

@      eval $default = 1+$m2c_temp_table_sparse@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 1@
@        eval $m2c_temp_table_sparse = 0@
@      elsif $ans == 2@
@        eval $m2c_temp_table_sparse = 1@
@      end@

## ---------------------------------------------------
@elsif $select == 14@ 
Do you want a makefile and AgentX subagent source file generated?
This will let you test your table without having to link it into
snmpd. (You can still link it in later.)

  1) do not generate makefile/AgentX code
  2) generate makefile/AgentX code

@      eval $default = 1+$m2c_temp_generate_makefile@
@      prompt $ans Select your choice [$default]: @
@      if $ans == 1@
@        eval $m2c_temp_generate_makefile = 0@
@        eval $m2c_temp_generate_subagent = 0@
@      elsif $ans == 2@
@        eval $m2c_temp_generate_makefile = 1@
@        eval $m2c_temp_generate_subagent = 1@
@      end@

@   end@ # option selection
@ end@   # $mfd_interactive_loop
@end@ # $mfd_interactive_setup == 1
##################################
##
## save values
##      Note: if you add a var here, add it in m2c_table_save_defaults.m2i too
##
@eval $m2c_context_reg = "$m2c_temp_context_reg"@
@eval $m2c_data_allocate = $m2c_temp_data_allocate@
@eval $m2c_data_cache = $m2c_temp_data_cache@
@eval $m2c_data_context = "$m2c_temp_data_context"@
@eval $m2c_data_init = $m2c_temp_data_init@
@eval $m2c_data_transient = $m2c_temp_data_transient@
@eval $m2c_include_examples = $m2c_temp_include_examples@
@eval $m2c_irreversible_commit = $m2c_irreversible_commit@
@eval $m2c_table_access = "$m2c_temp_table_access"@
@eval $m2c_table_dependencies = $m2c_temp_dependencies@
@eval $m2c_table_persistent = $m2c_temp_persistent@
@eval $m2c_table_row_creation = $m2c_temp_create@
@eval $m2c_table_settable = $m2c_temp_settable@
@eval $m2c_table_skip_mapping = $m2c_temp_table_skip_mapping@
@eval $m2c_table_sparse = $m2c_temp_table_sparse@
@eval $mfd_generate_makefile = $m2c_temp_generate_makefile@
@eval $mfd_generate_subagent = $m2c_temp_generate_subagent@
##
## write them back
##
@include m2c_table_save_defaults.m2i@
##
########################################################################
@if $m2c_mark_boundary == 1@
/** END code generated by $RCSfile: mfd-interactive-setup.m2c,v $ $Revision: 
1.16 $ */
@end@

Reply via email to