Introduction to Embedded Menu Manager
From CT3
Embedded Menu Manager (EMM) is a component of Cisco IOS introduced in release 12.4(20)T. It supersedes the functionality of the menu global configuration command and provides a versatile multi-level menu system. EMM also supports wizards through which the operator can enter parameters that are used by the menu code (typically implemented in Tcl) to execute complex actions.
The menu content, including the necessary Tcl code, is described in XML. The individual menu items could trigger IOS exec-level commands, configuration commands or Tcl scripts. The integration of Tcl interpreter with the menu system minimizes the number of individual files needed to support the complete solution.
A sample screenshot generated with the menu included in the Basic menu elements section is included below.
================================================================================
Simple IP troubleshooting menu
Enter ?# for item help
--------------------------------------------------------------------------------
1. Show RIP routes
2. Show interface status
3. Shut down loopback 0
4. Enable loopback 0
Enter selection:
Contents |
Menu Definition File (MDF) overview
The menu definition is stored in XML format in a file residing in flash (or any other local file system) or downloaded through any file transfer method supported by Cisco IOS. The menu definition has to be a valid XML document encoded in UTF-8.
The menu definition could be downloaded when needed (when the user executes the emm mdf filename command). A menu could also be preloaded with the emm mdf filename global configuration command and later on execute with the emm menu-name exec-level command.
Basic menu elements
Every menu definition must have the following XML elements:
- Root element Menu
- Child elements MenuTitle and Item.
The Menu element might contain children elements, including HelpString, DefaultSelection and CustomPrompt. A simple menu is included in the following printout and the individual menu elements are described in the following sections.
<?xml version="1.0" encoding="UTF-8"?>
<Menu Standalone="true" Main="true" MenuName="Test" schemaVersion="1.1">
<MenuTitle>
<Constant String="Simple IP troubleshooting menu" />
</MenuTitle>
<Item ContinuePrompt="true">
<ItemTitle>
<Constant String="Show RIP routes" />
</ItemTitle>
<HelpString>
<Constant String="This will display the RIP-learnt routes"/>
</HelpString>
<IOSExecCommand>show ip route rip</IOSExecCommand>
</Item>
<Item ContinuePrompt="true">
<ItemTitle>
<Constant String="Show interface status" />
</ItemTitle>
<HelpString>
<Constant String="Displays the status of individual interfaces"/>
</HelpString>
<IOSExecCommand>show ip interface brief</IOSExecCommand>
</Item>
<Item>
<ItemTitle><Constant String="Shut down loopback 0" /></ItemTitle>
<IOSConfigCommand>"interface loopback 0" "shutdown"</IOSConfigCommand>
</Item>
<Item>
<ItemTitle><Constant String="Enable loopback 0" /></ItemTitle>
<IOSConfigCommand>"interface loopback 0" "no shutdown"</IOSConfigCommand>
</Item>
</Menu>
The Menu element
The Menu element (the root element of the XML document) must have the following attribute:
| Attribute name | Description | Value |
|---|---|---|
| MenuName | The name of the menu (mandatory). The menu name is used in the emm menu-name exec-level command or in multi-level menus. | String |
| schemaVersion | Defines the XSD schema version used in the menu definition. The value of this attribute has to match the value expected by Cisco IOS. | 1.1 |
The Menu element might also have these attributes:
| Attribute name | Description | Value |
|---|---|---|
| TitleJustification | Defines the justification of the menu title; by default the menu title is centered | LEFT, RIGHT or CENTER |
| Main | Defines the main menu when multiple menu definitions are present in the same XML file. | TRUE or FALSE |
| Standalone | Specifies a standalone menu that can be launched from the emm mdf filename or emm menu-name exec commands. | TRUE or FALSE |
The MenuTitle element
The MenuTitle element specifies the title (heading line) of the menu. It should have a single child (the value of the menu title) and no attributes. In simple menus, the value of the MenuTitle element is usually constant and thus specified with a Constant child with the String attribute (see the … section for other value options).
To specify a simple menu title with the value “This is a menu”, use the following XML fragment:
<MenuTitle> <Constant String="This is a menu" /> </MenuTitle>
The Item element
The Item element must have an ItemTitle child specifying the text of the menu selection and one of IOSExecCommand, IOSConfigCommand or EmbeddedTCL children specifying the action to be taken when the user selects this menu item
The Item element might also have a number of HelpString children, each one of them representing a single line in the help text.
The ItemTitle and HelpString children must have an EMM value child (Constant or EmbTCLValue child), whereas the IOSExecCommand, IOSConfigCommand and EmbeddedTCL children expect their value (commands to be executed) in the text within the XML element (simple text between the opening and closing XML tags).
To complicate matters further, the IOSConfigCommand accept commands enclosed in double quotes, allowing you to execute multiple commands with the same action.
For example, to shut down the loopback interface from a menu item, use the following XML code (two configuration commands are executed from the IOSConfigCommand child).
<Item> <ItemTitle><Constant String="Shut down loopback 0" /></ItemTitle> <IOSConfigCommand>"interface loopback 0" "shutdown"</IOSConfigCommand> </Item>
Specifying values of EMM elements
The value of most EMM element can be specified in two ways:
- Constant value is specified with a Constant child with String, Integer, Long, Float, IP or IPv6 attribute.
- Computed value is specified with the EmbTCLValue child which contains Tcl code that computes the desired value. The Tcl code shall return the computed value to the EMM with the return statement.
Running the embedded menu
Privileged users can run the MDF files with the exec-level emm mdf filename command. For example, the emm mdf http://10.0.0.10/EMM/sample.mdf will download the MDF file, parse it and execute the menu.
Non-privileged users can run only the menus that have been preloaded with the emm mdf filename global configuration command. The names of the preloaded menus (but not their contents) can be inspected with the show mdf command.
In the following printout, a privileged user enters the configuration mode to preload an EMM menu, uses the show mdf command to verify the menu has been loaded and exits the enable mode to execute the emm menu command as a non-privileged user.
EMT#configure terminal Enter configuration commands, one per line. End with CNTL/Z. EMT(config)#emm mdf http://10.0.0.10/EMM/menu.xml EMT(config)#^Z EMT#show mdf Menu Name / URL: Test / http://10.0.0.10/EMM/menu.xml EMT#disable EMT>emm ? Test Simple IP troubleshooting menu EMT>emm Test
When a user tries to execute that is not allowed in the current privilege level (for example, a non-privileged user trying to execute an Item with the IOSConfigCommand child), the EMM fails, displays an error and returns to the command prompt.
Using EMM menu with autocommand
You can use the EMM functionality to give end-users or entry-level technicians a comprehensive menu after they log into Cisco IOS. To start an EMM menu after the user logs into the router, use the username autocommand global configuration command. The next printout contains a sample configuration:
username menu password menu username menu autocommand emm Test
If you want to have a simple menu available to anyone who connects to the router, you could advertise the availability of the public username in the incoming banner and use the username nopassword command to create a username without a password.
BlogMarks
del.icio.us
digg
Newsvine
reddit
Slashdot