action assign

Mode: Configuration Mode

Description:

The action assign statement executes the specified function called just after a value is placed in the database. This allows the value to be manipulated, rewritten, or otherwise modified. It is most often invoked after a user performs the set command on a configuration object (stripping paths, converting plain text to encrypted text, and so on.)

Example:

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

        /* mgd_assign_prepare_url(): prepare the URL in such a way it */
        /* becomes usable for background tasks.                       */
        /* e.g. fetching host-keys for scp:// schemes and presenting  */ 
        /* the fingerprint to the user for verification.              */

        DDL_ACTION_FUNCTION(mgd_assign_prepare_url)
        {
            int rc;
            char *url_str;
            struct url *url_p;

            DB_EXTRACT_STRING(daap->daa_dbmp, daap->daa_child_object, url_str);

            url_p = fetchParseURL(url_str);
            if (!url_p) {
                js_warning("can't parse URL: %s", fetchLastErrString);
                return 0;
            }

            rc = 0;

            if (streq(url_p->scheme, SCHEME_SCP)
                && daap->daa_peer && !js_client_apimode()
                && daap->daa_gram_data && daap->daa_gram_data->gd_style == S_CONFIG_MODE)
                rc = fetch_update_ssh_known_host(daap->daa_peer, daap->daa_dbmp, url_p->host);

            fetchFreeURL(url_p);

            return rc;
        }

src/junos/lib/ddl/input/exampled.cnf.dd

        object newbie {
            help "Newbie settings";

            attribute newbie-url {
                help "Newbie URL";
                action assign mgd mgd_assign_prepare_url;
                type string;
            }
        }

Display:

mgd_assign_prepare_url parses strings in URL formats. Once the URL is 
stored in the configuration database, it can be used by exampled and 
other processes. Without this action assign statement, entering such 
URLs in string fields are not understood by the CLI and will be rejected.

        user@router# set example newbie newbie-url ?
        Possible completions:
          <newbie-url>         Newbie URL
        [edit]
        user@router# set example newbie newbie-url ftp://www-in/~newbie/newbie.cfg

        [edit]
        user@router# show example
        newbie {
            newbie-url "ftp://www-in/~newbie/newbie.cfg";
        }
        [edit]

Topics for further reading:

See also:
action pre-assign

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