-
Notifications
You must be signed in to change notification settings - Fork 16
8‐4. Rename Commands
Since you will be editing the Master file directly, be sure to back up the Master file before proceeding.
You can run the following rename command from the CLI
- rename area
- rename attribute_bulk *Added in Ver 2.6.2
- rename device
- rename l3_instance
- rename port
- rename port_info_bulk *Added in Ver 2.6.2f
python [file path]/network_sketcher.py [command] --master [master file path]- The location of [command] 、--master [master file path] can be changed as follows:
python [file path]/network_sketcher.py -master [master file path] [command]
Change the area name.
python [file path]/network_sketcher.py rename area [Original area name] [Updated area name] --master [master file path] - ex.
+BEFORE+
#python .\network_sketcher.py show area --master "C:\work\[MASTER]test.xlsx"
Area1
Area2
Area3
+Device renamed+
#python .\network_sketcher.py rename area 'Area3' 'Area99' --master "C:\work\[MASTER]test.xlsx"
--- Area renamed --- Area3 -> Area99
+AFTER+
#python .\network_sketcher.py show area --master "C:\work\[MASTER]test.xlsx"
Area1
Area2
Area99
Change device attributes (including header row) in bulk. This command allows you to update multiple devices and their attribute values in a single operation.
Syntax
python [file path]/network_sketcher.py rename attribute_bulk [attribute_array] --master [master file path]
Array Format
The attribute array uses the following format:
For device attribute rows (with RGB color values): [device_name, "['attribute_value',[R,G,B]]", "['attribute_value',[R,G,B]]", ...]
For header row (column names without RGB values): ['Device Name', 'Column1', 'Column2', 'Column3', ...]
Combined format for multiple entries: [[device1_entry],[device2_entry],['Device Name', header_columns...]]
Parameters
| Parameter | Description |
|---|---|
| device_name | The name of the device to update |
| attribute_value | The text value of the attribute |
| R,G,B | RGB color values (0-255) for the attribute cell background |
| 'Device Name' | Special identifier for the header row |
Notes
- RGB values must be integers between 0 and 255
- Empty attributes should use "['', [255, 255, 255]]" (white background)
- The header row entry must start with 'Device Name'
- Device entries and header row can be mixed in the same command
- Each device/header entry must have up to 9 attribute columns (excluding the device name column)
Examples
Example 1: Update single device attributes
#python .\network_sketcher.py rename attribute_bulk "[['L3SW1', "['DEVICE',[235, 241, 222]]", "['Cisco', [255,183,219]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]"]]" --master "C:\work[MASTER]test.xlsx"
Example 2: Update multiple devices
#python .\network_sketcher.py rename attribute_bulk "[['ACCESS-SW1', "['DEVICE',[235, 241, 222]]", "['Catalyst9200', [255,183,219]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]"],['WLC-9800', "['DEVICE',[235, 241, 222]]", "['Catalyst9800', [255,183,219]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]"]]" --master "C:\work[MASTER]test.xlsx"
Example 3: Update devices and header row together
#python .\network_sketcher.py rename attribute_bulk "[['ACCESS-SW1', "['DEVICE',[235, 241, 222]]", "['Catalyst9200', [255,183,219]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['TEST-Value', [235, 241, 22]]"],['WLC-9800', "['DEVICE',[235, 241, 222]]", "['Catalyst9800', [255,183,219]]", "['LAST VALUE', [100, 100, 100]]", "['', [255, 255, 255]]", "['TEST333', [200, 200, 200]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]"],['Device Name', 'Model name', 'Model', 'Attribute-B', 'Attribute-C', 'Attribute-D', 'Attribute-E', 'Attribute-F', 'LAST CHECK', 'TEST-B-NAME']]" --master "C:\work[MASTER]test.xlsx"
Full Example with Before/After
+BEFORE+
#python .\network_sketcher.py show attribute --master "C:\work[MASTER]test.xlsx"
['Device Name', 'Default', 'Model', 'OS', 'Attribute-C', 'Attribute-D', 'Attribute-E', 'Attribute-F', 'Attribute-G', 'Others']
['ACCESS-SW1', "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]"]
['WLC-9800', "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]"]
+Attribute bulk renamed+
#python .\network_sketcher.py rename attribute_bulk "[['ACCESS-SW1', "['DEVICE',[235, 241, 222]]", "['Catalyst9200', [255,183,219]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['TEST-Value', [235, 241, 22]]"],['WLC-9800', "['DEVICE',[235, 241, 222]]", "['Catalyst9800', [255,183,219]]", "['LAST VALUE', [100, 100, 100]]", "['', [255, 255, 255]]", "['TEST333', [200, 200, 200]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]"],['Device Name', 'Model name', 'Model', 'Attribute-B', 'Attribute-C', 'Attribute-D', 'Attribute-E', 'Attribute-F', 'LAST CHECK', 'TEST-B-NAME']]" --master "C:\work[MASTER]test.xlsx"
--- Attribute bulk rename completed ---
Successfully updated: 3 entry(ies)
Updated: ACCESS-SW1, WLC-9800, Device Name (Header)
+AFTER+
#python .\network_sketcher.py show attribute --master "C:\work[MASTER]test.xlsx"
['Device Name', 'Model name', 'Model', 'Attribute-B', 'Attribute-C', 'Attribute-D', 'Attribute-E', 'Attribute-F', 'LAST CHECK', 'TEST-B-NAME']
['ACCESS-SW1', "['DEVICE', [235, 241, 222]]", "['Catalyst9200', [255, 183, 219]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['TEST-Value', [235, 241, 22]]"]
['WLC-9800', "['DEVICE', [235, 241, 222]]", "['Catalyst9800', [255, 183, 219]]", "['LAST VALUE', [100, 100, 100]]", "['', [255, 255, 255]]", "['TEST333', [200, 200, 200]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]", "['', [255, 255, 255]]"]
Common RGB Color Examples
| Color | RGB Value | Usage Example |
|---|---|---|
| White (empty) | [255, 255, 255] | "['', [255, 255, 255]]" |
| Light Green | [235, 241, 222] | "['DEVICE', [235, 241, 222]]" |
| Light Pink | [255, 183, 219] | "['Catalyst9200', [255, 183, 219]]" |
| Light Gray | [200, 200, 200] | "['TEST', [200, 200, 200]]" |
| Light Yellow | [235, 241, 22] | "['WARNING', [235, 241, 22]]" |
Change the device name.
python [file path]/network_sketcher.py rename device [Original device name] [Updated device name] --master [master file path] - ex.
+BEFORE+
#python .\network_sketcher.py show device --master "C:\work\[MASTER]test.xlsx"
L3SW1
L3SW2
+Device renamed+
#python .\network_sketcher.py rename device 'L3SW1' 'L3SW100' --master "C:\work\[MASTER]test.xlsx"
--- Device Name renamed --- L3SW1 -> L3SW100
+AFTER+
#python .\network_sketcher.py show device --master "C:\work\[MASTER]test.xlsx"
L3SW100
L3SW2
Change the l3_instance, such as the VRF to which the Layer 3 interface belongs. By default, all Layer 3 interfaces are set to blank'' which means "Default" If you change the l3_instance name of one Layer 3 interface, all other l3_instances that are set to blank"" are implicitly set to the "default" l3_instance.
python [file path]/network_sketcher.py rename l3_instance [device name] [layer3 port name] [Renamed l3_instance name] --master [master file path] - ex.
+BEFORE+
#python .\network_sketcher.py show l3_interface --master "C:\work\[MASTER]test.xlsx"
['devcie1', 'GigabitEthernet 0/0', '', '']
+l3_interface renamed+
#python .\network_sketcher.py rename l3_instance 'devcie1' 'GigabitEthernet 0/0' 'VRF-1' --master "C:\work\[MASTER]test.xlsx"
--- l3 instance renamed --- devcie1,GigabitEthernet 0/0,VRF-10
+AFTER+
#python .\network_sketcher.py show l3_interface --master "C:\work\[MASTER]test.xlsx"
['devcie1', 'GigabitEthernet 0/0', 'VRF-1', '']
Change the port name and port number.
python [file path]/network_sketcher.py rename port [device name] [Original port name] [Updated port name] --master [master file path] - ex.
+BEFORE+
#python .\network_sketcher.py show l1_interface --master "C:\work\[MASTER]test.xlsx"
['L3SW1', 'GE 0/0', 'GigabitEthernet 0/0', 'Auto', 'Auto', '1000BASE-T']
['L3SW2', 'GE 0/0', 'GigabitEthernet 0/0', 'Auto', 'Auto', '1000BASE-T']
#python .\network_sketcher.py show l2_interface --master "C:\work\[MASTER]test.xlsx"
['L3SW1', '', 'Vlan 201', 'Vlan100', '']
['L3SW1', '', 'Vlan 200', 'Vlan200', '']
['L3SW1', '', 'Vlan 300', 'Vlan300', '']
['L3SW1', 'GigabitEthernet 0/0', '', 'Vlan100,Vlan200,Vlan300', '']
['L3SW2', '', 'Vlan 201', 'Vlan100', '']
['L3SW2', '', 'Vlan 200', 'Vlan200', '']
['L3SW2', '', 'Vlan 202', 'Vlan300', '']
['L3SW2', 'GigabitEthernet 0/0', '', 'Vlan100,Vlan200,Vlan300', '']
#python .\network_sketcher.py show l3_interface --master "C:\work\[MASTER]test.xlsx"
['L3SW1', 'Vlan 201', '', '']
['L3SW1', 'Vlan 200', '', '']
['L3SW1', 'Vlan 300', '', '']
['L3SW2', 'Vlan 201', '', '']
['L3SW2', 'Vlan 200', '', '']
['L3SW2', 'Vlan 202', '', '']
+Port renamed+
#python .\network_sketcher.py rename port 'L3SW1' 'GigabitEthernet 0/0' 'FastEthernet 1/1' --master "C:\work\[MASTER]test.xlsx"
--- Physical Port Name renamed --- L3SW1 GigabitEthernet 0/0 -> FastEthernet 1/1
#python .\network_sketcher.py rename port 'L3SW2' 'Vlan 200' 'Vlan 999' --master "C:\work\[MASTER]test.xlsx"
--- Virtual Port Name renamed --- L3SW2 Vlan 200 -> Vlan 999
+AFTER+
#python .\network_sketcher.py show l1_interface --master "C:\work\[MASTER]test.xlsx"
['L3SW1', 'FE 1/1', 'FastEthernet 1/1', 'Auto', 'Auto', '1000BASE-T']
['L3SW2', 'GE 0/0', 'GigabitEthernet 0/0', 'Auto', 'Auto', '1000BASE-T']
#python .\network_sketcher.py show l2_interface --master "C:\work\[MASTER]test.xlsx"
['L3SW1', '', 'Vlan 201', 'Vlan100', '']
['L3SW1', '', 'Vlan 200', 'Vlan200', '']
['L3SW1', '', 'Vlan 300', 'Vlan300', '']
['L3SW1', 'FastEthernet 1/1', '', 'Vlan100,Vlan200,Vlan300', '']
['L3SW2', '', 'Vlan 201', 'Vlan100', '']
['L3SW2', '', 'Vlan 999', 'Vlan200', '']
['L3SW2', '', 'Vlan 202', 'Vlan300', '']
['L3SW2', 'GigabitEthernet 0/0', '', 'Vlan100,Vlan200,Vlan300', '']
#python .\network_sketcher.py show l3_interface --master "C:\work\[MASTER]test.xlsx"
['L3SW1', 'Vlan 201', '', '']
['L3SW1', 'Vlan 200', '', '']
['L3SW1', 'Vlan 300', '', '']
['L3SW2', 'Vlan 201', '', '']
['L3SW2', 'Vlan 999', '', '']
['L3SW2', 'Vlan 202', '', '']
Change the port information (Speed, Duplex, Port_Type) for multiple ports in bulk.
Syntax
python [file path]/network_sketcher.py rename port_info_bulk [port_info_array] --master [master file path] Array Format
The port info array uses the following format:
[["device_name1","port_name1",["Speed1","Duplex1","Port_Type1"]],["device_name2","port_name2",["Speed2","Duplex2","Port_Type2"]]]Parameters
| Parameter | Description |
|---|---|
| device_name | The name of the device |
| port_name | The port name (abbreviated form like "TE 1/0/1" or full form like "TenGigabitEthernet 1/0/1") |
| Speed | Port speed value (e.g., "Auto", "1Gbps", "10Gbps", "N/A") |
| Duplex | Duplex mode (e.g., "Auto", "Full", "Half", "N/A") |
| Port_Type | Port type (e.g., "1000BASE-T", "10GBASE-SR", "N/A") |
Notes
- Port name can be specified in abbreviated form (e.g., "TE 1/0/1") or full form (e.g., "TenGigabitEthernet 1/0/1")
- Multiple ports can be updated in a single command
- If a port is not found, it will be reported in the result message
Examples
Example 1: Update single port info
#python .\network_sketcher.py rename port_info_bulk "[['DIST-CORE-SW1','TE 1/0/1',['10Gbps','Full','10GBASE-SR']]]" --master "C:\work[MASTER]test.xlsx"
Example 2: Update multiple ports
python .\network_sketcher.py rename port_info_bulk "[['DIST-CORE-SW1','TE 1/0/1',['10Gbps','Full','10GBASE-SR']],['DIST-CORE-SW2','TE 1/0/1',['10Gbps','Full','10GBASE-SR']],['ACCESS-SW1','GE 1/0/1',['1Gbps','Full','1000BASE-T']]]" --master "C:\work[MASTER]test.xlsx"
Full Example with Before/After
+BEFORE+
#python .\network_sketcher.py show l1_interface --master "C:\work[MASTER]test.xlsx" ['DIST-CORE-SW1', 'TE 1/0/1', 'TenGigabitEthernet 1/0/1', 'N/A', 'N/A', 'N/A'] ['DIST-CORE-SW1', 'TE 1/0/2', 'TenGigabitEthernet 1/0/2', 'N/A', 'N/A', 'N/A'] ['DIST-CORE-SW2', 'TE 1/0/1', 'TenGigabitEthernet 1/0/1', 'N/A', 'N/A', 'N/A'] ['ACCESS-SW1', 'GE 1/0/1', 'GigabitEthernet 1/0/1', 'N/A', 'N/A', 'N/A']
+Port info bulk renamed+
#python .\network_sketcher.py rename port_info_bulk "[['DIST-CORE-SW1','TE 1/0/1',['10Gbps','Full','10GBASE-SR']],['DIST-CORE-SW1','TE 1/0/2',['10Gbps','Full','10GBASE-LR']],['ACCESS-SW1','GE 1/0/1',['1Gbps','Full','1000BASE-T']]]" --master "C:\work[MASTER]test.xlsx" --- Port info bulk rename completed --- Successfully updated: 3 port(s) Updated: DIST-CORE-SW1 TE 1/0/1, DIST-CORE-SW1 TE 1/0/2, ACCESS-SW1 GE 1/0/1
+AFTER+
#python .\network_sketcher.py show l1_interface --master "C:\work[MASTER]test.xlsx" ['DIST-CORE-SW1', 'TE 1/0/1', 'TenGigabitEthernet 1/0/1', '10Gbps', 'Full', '10GBASE-SR'] ['DIST-CORE-SW1', 'TE 1/0/2', 'TenGigabitEthernet 1/0/2', '10Gbps', 'Full', '10GBASE-LR'] ['DIST-CORE-SW2', 'TE 1/0/1', 'TenGigabitEthernet 1/0/1', 'N/A', 'N/A', 'N/A'] ['ACCESS-SW1', 'GE 1/0/1', 'GigabitEthernet 1/0/1', '1Gbps', 'Full', '1000BASE-T']
Common Port Info Values
| Category | Common Values(not limited to the listed values) |
|---|---|
| Speed | Auto, N/A, 100Mbps, 1Gbps, 10Gbps, 25Gbps, 40Gbps, 100Gbps |
| Duplex | Auto, N/A, Full, Half |
| Port_Type | N/A, 1000BASE-T, 10GBASE-SR, 10GBASE-LR, 25GBASE-SR, 40GBASE-SR4, 100GBASE-SR4 |
- Yusuke Ogawa - Security Architect, Cisco | CCIE#17583
SPDX-License-Identifier: Apache-2.0
Copyright 2023 Cisco Systems, Inc. and its affiliates
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.