action acceptable

Mode: Configuration Mode

Description:

The action acceptable function is invoked for 2 different purposes:

Return codes:

Action can be used to hide parts of the configuration or keep the user from being able to specify them. However, action acceptable is not the right tool to use when, for example, configuration B can exist only if configuration A is present. Configuration can be added in any order, and the user might configure A after B. In many such cases, you can use the must constraint to achieve the desired effect.

If possible, reusing existing functions is recommended. Available functions can be found in .../src/junos/lib/ddl/junos-actions.

Example 1:

.../src/junos/lib/ddl/junos-actions/jmulti_re_afuncs.c

        DDL_ACTION_FUNCTION(mgd_is_multi_chassis)
        {
            if (mchassis_is_single()) 
                return ACCEPTABLE_EXCLUDE;
            else
                return ACCEPTABLE_OK;
        }


example.cnf.dd:

        # mgd_is_multi_chassis is an existing ddl action function
        # it returns ACCEPTABLE_OK if it is a multi-chassis platform,
        # ACCEPTABLE_EXCLUDE if it is a single-chassis platform

        object newbie {
            help "Newbie settings (only exist in multi-chassis)";
            action acceptable mgd mgd_is_multi_chassis;

            attribute number {
                help "Newbie Number";
                type uint;
            }
        }

Display 1:

m5 is a single-chassis router

        user@m5# show version
        Hostname: m5
        Model: m5

        user@m5# set example ?
        Possible completions:
        > traceoptions         Example service trace options
        [edit]

TX Matrix is a multi-chassis router
        
        user@TX# show version
        Hostname: TX
        scc-re0:
        --------------------------------------------------------------------
        Hostname: TX
        Model: TX Matrix

        user@TX# set example ?
        Possible completions:
        > newbie               Newbie settings (only exist in multi-chassis)
        > traceoptions         Example service trace options
        [edit]
        user@TX# set example newbie number 5

        [edit]
        user@TX# show example
        newbie {
            number 5;
        }

        [edit]

Example 2:

This example hides the 'example newbie' knob in groups configuration,
otherwise, it is not hidden.

        object newbie {
            help "Newbie settings (hidden in groups)";
            action acceptable mgd "{
                if (ddl_path_match(daap, \"*groups*\")) {
                    return ACCEPTABLE_HIDE;
                }
                return ACCEPTABLE_OK;
            }";

            attribute number {
                help "Newbie Number";
                type uint;
            }
        }

Display 2:

        user@router# set example ?
        Possible completions:
        + apply-groups         Groups from which to inherit configuration data
        + apply-groups-except  Don't inherit configuration data from these groups
        > newbie               Newbie settings (hidden in groups)
        [edit]
        user@router# set example newbie number 3 

        [edit]
        user@router# show example
        newbie {
            number 3;
        }
        [edit]
        user@router# delete example 

        [edit]
        user@router# show example

        [edit]
        user@router# set groups newbie example ?
        Possible completions:
        + apply-groups         Groups from which to inherit configuration data
        [edit]
        user@router# set groups newbie example newb?
        No valid completions
        [edit]
        user@router# set groups newbie example newbie number 7 

        [edit]
        user@router# set example apply-groups newbie

        [edit]
        user@router# commit
        commit complete

        [edit]
        user@router# show example | display inheritance
        ##
        ## 'newbie' was inherited from group 'newbie'
        ##
        newbie {
            ##
            ## '7' was inherited from group 'newbie'
            ##
            number 7;
        }

        [edit]

Topics for further reading:

See also:

Reference (to programmers guide/style guide):


2007-2008 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are trademarks of Juniper Networks, Inc.
Generated on Sun May 30 20:23:12 2010 for DDL Reference Guide by doxygen 1.4.5