CloudVision Portal (CVP) enables you to create Configlets using two different methods. You can create Configlets using the CVP Configlet Builder feature, or you can create them manually. You should use the method that is best suited to your intended use of the Configlet.
For more information, see:
About the Configlet Builder Feature
The Configlet Builder feature enables you to programatically create device configurations (Configlets) for devices that have relatively dynamic configuration requirements. This helps to prevent you from having to manually code Configlets.
The Configlet Builder feature is essentially a set of user interface (UI) widgets and a python script, that when used together, programatically generate Configlets for a device. The python script is embedded into a python interpreter, which is the component that generates Configlets. The UI widgets are essential if you want to use the feature to generate Configlets with user input.
The Configlet Builder can be used to create Configlets for both devices or containers, in the same way that static Configlets can be used with devices or containers. Configlets that are created using the Configlet Builder are executed (including the generation of Configlets) at the point when the Configlet Builder is applied to a device or container, or when a device is added to a container that contains a Configlet Builder.
Creating Configlets Using the Configlet Builder
Complete the following steps to create Configlets using the Configlet Builder:
Create a Configlet Builder from the Configlet page.
(Optional) Define the UI widgets to be associated with the
The widget types are:
- Text Box – Use for single line text entries (for example, descriptions, host name).
- Text Area – Use for multiple lines of text (for example, MOTD, or login banner).
- Drop Down – Use to select a value from a menu as defined in the Value Field.
- Tick Box – Use to select a value from a tick list as defined in the Value Field.
- Radio Button – Use to select one option from a set of options as defined in Value Field.
- IP Address – Use to specify an IP address (this is a Dotted Decimal Address field).
- Password – Use to specify a single line of text (characters are hidden as they are entered).
Write a Python script that reads the inputs you entered in the
previous step and then generates the Configlet.
Note: The figures listed in this table show examples of the steps involved in writing a script, including an example of use of standard Python syntax to build components of the Configlet.
Figure Example of Description Example (Showing Import of CVP-Specific Internal Libraries) Importing CVP-specific internal libraries into the script The CVP-specific internal libraries are used by the script to access form fields and CVP variables. Example (Showing Specification of Field IDs Defined in the Form Builder) Specification of field IDs defined in the Form Builder You must specify the IDs of fields you defined in the Form Builder in Step 2. The fields you specify are included in the Configlet content generated by the script. Example (Showing Use Of Standard Python Script Syntax) Use of standard Python syntax The Configlet Builder supports the use of standard Python syntax to build parts of the Configlet. You can also make calls to external files and database. Example (Showing Print Output) Print output (Configlet content) The script automatically produces print output from the CVP internal libraries you imported and the fields you have defined in the script. The print output is the content of the Configlet.Note: Complete steps 4 and 5 to test the script to make sure it can generate Configlet content.
Fill in the Form Design fields.
The Configlet content is generated and shows in the Built Configlet pane.Note: If it is necessary to select a device to generate the Configlet, then select a device from the list of devices under Form Design.
Validate the generated Configlet on the device by clicking the
icon at the upper-right of the page.
The Validate Device dialog appears.
In the Validate Device pop-up dialog, click Validate.
If the device cannot be validated, the error (or errors) are listed in the Validate Device dialog.
(If needed) Correct any errors and repeat step 7 to validate the
The Validate Device dialog shows a message to indicate a successful validation.
To apply the new Configlet to the container, do the following:
- Go the Network Provisioning page.
- Right-click the container and choose Manage > Configlet.
The list of available Configlets appears on the Configlet page.
Select the Configlet to apply to the device by clicking the checkbox next to
the name of the Configlet.
To add devices to the container, do the following:
- Go the Network Provisioning page.
- Right-click the container and choose Device > Add.
Do one of the following:
- Click Yes to apply the Configlet you selected to all of the devices in the hierarchy.
- Click No if you do not want to apply the Configlet you selected to all of the devices in the hierarchy.
The Configlet page appears showing the Configlet you selected to apply to the container.
To assign the Configlet Builder to the container you selected,
select (click) the
The page loads a form.
Complete (fill in) the form and then click
The Configlet Builder creates the new, device-specific Configlet, and the Configlet is shown in the Built Configlet pane.
Using the Provided Configlet Builder Examples
CloudVision Portal (CVP) provides some Configlet Builder examples to help you get started using this feature.
You can load the examples to your CVP instance using the following commands:
- Log into the primary node's Linux shell as root user.
- Change directory to
/cvpi/tools and import the example Configlets using the cvptool.
./cvptool.py --host <host> --user <user> --password <pass> --objects Configlets --action restore --tarFile examples.tar.
The provided examples include:
- Example 1: Form-based management interface Configlet Builder
- Example 2: eAPI-based management interface Configlet Builder
- Example 3: SSH-based management interface Configlet Builder
- Example 4: MySQL-based management interface Configlet Builder
- Example 5: Device library based management interface Configlet Builder
Example 1: Form-based management interface Configlet Builder
This example uses the form to input the management interface configuration, and generates a new Configlet to preserve the configuration.
Example 2: eAPI-based management interface Configlet Builder
This example uses eAPI to read the management interface configuration that the device received from the DHCP server during the ZTP boot, and generates a new Configlet to preserve the configuration.
Example 3: SSH-based management interface Configlet Builder
This example uses SSH to read the management interface configuration that the device received from the DHCP server during the ZTP boot, and generates a new Configlet to preserve the configuration.
Example 4: MySQL-based management interface Configlet Builder
In this example, the Configlet Builder uses the device’s MAC address to lookup up its Management IP address, netmask, default route, and host name, which are stored on external MySQL server, and generates a new Configlet to preserve the configuration.
Example 5: Device library based management interface Configlet Builder
This example uses Device library to read the management interface configuration that the device received from the DHCP server during the ZTP boot, and generates a new Configlet to preserve the configuration.
Python Execution Environment
The CloudVision Portal (CVP) python execution is supported by several CVP-specific libraries. These libraries provide access to the various CVP services and device state.
This library provides access to the user interface (UI) widgets that can be associated with a Configlet Builder (see the provided examples for usage details).
The supported methods are:
from cvplibrary import Form obj =Form.getFieldById( ‘id' ); print obj.getValue() obj.getFieldById( ‘id' ); - Used to get the UI widget by id obj.getValue() - To get the value obj.getFieldID() - To get the unique id obj.isMandatory() - Gets whether the field is mandatory or not obj.getHelpText() - To get the help text obj.getDependsOn() - To get the depends on obj.getType() - To get the type (TextBox, Dropdown,etc) obj.getDataValidation() - To get the Data validation
CVP Global Variables and Supported Methods
This library give access to the current execution context for Configlet Builders (see the provided examples for usage details).
The supplied global variables are:
from cvplibrary import CVPGlobalVariables, GlobalVariableNames CVPGlobalVariables.getValue(GlobalVariableNames.CVP_USERNAME) Supported GlobalVariableNames: CVP_USERNAME - Username of the current user CVP_PASSWORD - Password of the current user CVP_IP - IP address of the current device CVP_MAC - MAC of the current device CVP_SERIAL - Serial number of the current device CVP_SESSION_ID - Session id of current cvp user ZTP_STATE - ZTP state of the device (true/false) ZTP_USERNAME - Default username to login to ztp enabled device ZTP_PASSWORD - Password to login to ztp enabled device CVP_ALL_LABELS - Labels associated to current device CVP_CUSTOM_LABELS - Custom labels associated to current device CVP_SYSTEM_LABELS - System/Auto generated labels associated to current device
CVP Rest Client
This library allows a Configlet Builder to access any CVP API endpoint. The following is an example:
from cvplibrary import RestClient url='http://localhost/cvpservice/inventory/devices'; method= 'GET'; client= RestClient(url,method); if client.connect(): print client.getResponse()
If no certificates are installed on the server, then add the following lines to ignore ssl warnings:
import ssl ssl._create_default_https_context = ssl._create_unverified_contex
Creating Configlets Manually
Complete these steps to manually create Configlets:
- Select the “+” icon in the grid.
Create Configlet page appears.
- Click Save to save the Configlet.
- This will list the Configlet in the Configlet Management grid.
Validating a Configlet During Creation
CloudVision provides a facility to enter the Configlet code and validate it before saving the codes.
- Enter the Configlet codes in the field provided.
- On the right pane, there is a drop-down menu listing all the switches in CLOUDVISION.
Search for the device to be validated.
Select the switch to validate.
On successful validation, the message Successfully Validated is displayed.