Saturday, October 30, 2010

Add Comments in a Configuration

You can include comments in a configuration to describe any statement in the configuration. You can add commands interactively in the CLI and by editing the ASCII configuration file.
When you add comments in configuration mode, they are associated with a statement at the current level. Each statement can have one single-line comment associated with it. Before you can associate a comment with a statement, the statement must exist. The comment is placed on the line preceding the statement.
To add comments to a configuration, use the annotate configuration mode command:
annotate statement "comment-string" 

statement is the configuration statement to which you are attaching the comment; it must be at the current hierarchy level. If a comment for the specified statement already exists, it is deleted and replaced with the new comment.
comment-string is the text of the comment. The comment text can be any length, and you must type it on a single line. If the comment contains spaces, you must enclose it in quotation marks. In the comment string, you can include the comment delimiters /* */ or #. If you do not specify any, the comment string is enclosed with the /* */ comment delimiters.
To delete an existing comment, specify an empty comment string:
annotate statement "" 

When you edit the ASCII configuration file and add comments, they can be one or more lines and must precede the statement they are associated with. If you place the comments in other places in the file, such as on the same line following a statement or on a separate line following a statement, they are removed when you use the load command to open the configuration into the CLI.
When you include comments in the configuration file directly, you can format comments in the following ways:
  • Start the comment with a /* and end it with a */. The comment text can be on a single line or can span multiple lines.
  • Start the comment with a # and end it with a new line (carriage return).
If you add comments with the annotate command, you can view the comments within the configuration by entering the show configuration mode command or the show configuration operational mode command.
When configuring interfaces, you can add comments about the interface by including the description statement at the [edit interfaces interface-name] hierarchy level. Any comments you include appear in the output of the show interfaces commands. For more information about the description statement, see the JUNOS Internet Software Configuration Guide: Interfaces and Class of Service.

Examples: Include Comments in Configurations

Add comments to a configuration:
[edit]
user@host# show
protocols {
    ospf {
        area 0.0.0.0 {
            interface so-0/0/0 {
                hello-interval 5;
            }
        }
    }
}
[edit]
user@host# edit protocols ospf 
[edit protocols ospf]
user@host# set area 0.0.0.0 
user@host# annotate area 0.0.0.0 "Backbone area configuration added June 15, 1998" 
[edit protocols ospf]
user@host# edit area 0.0.0.0
[edit protocols ospf area 0.0.0.0]
user@host# annotate interface so0 "Interface from router sj1 to router sj2"
[edit protocols ospf area 0.0.0.0]
user@host# top
[edit]
user@host# show 
protocols {
    ospf {
        /* Backbone area configuration added June 15, 1998 */
        area 0.0.0.0 {
            /* Interface from router sj1 to router sj2 */
            interface so-0/0/0 {
                hello-interval 5;
            }
        }
    }
}
[edit]
user@host# 

The following excerpt from a configuration example illustrates how to enter comments in a configuration file:
/* This comment goes with routing-options */
routing-options {
    /* This comment goes with routing-options traceoptions */
    traceoptions {
        /* This comment goes with routing-options traceoptions tracefile */
        tracefile rpd size 1m files 10;
        /* This comment goes with routing-options traceoptions traceflag task */
        traceflag task;
        /* This comment goes with routing-options traceoptions traceflag general */
        traceflag general;
        }
    autonomous-system 10458;    /* This comment is dropped */ 
}
routing-options {
    rib-groups {
        ifrg {
            import-rib [ inet.0 inet.2 ];
            /* A comment here is dropped */
        }
        dvmrp-rib {
            import-rib inet.2;
            export-rib inet.2;
            /* A comment here is dropped */
        }
    /* A comment here is dropped */
    }
/* A comment here is dropped */
} 

No comments: