Rename a vSwitch via ESXi Command Line Interface (CLI) in vSphere ESXi host
search cancel

Rename a vSwitch via ESXi Command Line Interface (CLI) in vSphere ESXi host

book

Article ID: 426705

calendar_today

Updated On:

Products

VMware vSphere ESXi VMware vSphere ESXi 8.0

Issue/Introduction

As part of the bigger goal of moving away from using stickybit files, VMware have moved the configuration stored in these files to ConfigStore. These files are used just as cache files by the services, the configurations in these files are now stored in the ConfigStore. The ConfigStore is the single source of truth in ESXi 7.0 Update 3 and later.

This article guides through the process of managing and renaming a vSphere Standard Switch (vSS) using the configstorecli utility. This procedure is useful when a vSwitch needs to be renamed without deleting/ recreating/ fixing naming inconsistencies that may affect management.

Resolution

Note : The ConfigStore utilizes JSON-formatted schemas. Renaming a switch requires exporting the specific networking group, modifying the key-value pair, and committing the change back to the database by importing it after modifying.

  1. Place the host in the maintenance mode, refer Place an ESXi Host in Maintenance Mode in the VMware Host Client 
  2. Log in to the ESXi host via SSH using root account and execute the following command to export the current networking schema into a JSON file :

    configstorecli config current get -c esx -g network_vss -k switches > vswitch.json

  3. Edit the newly created vswitch.json file using a text editor (such as vi editor).
  4. Update the parameter that needs to be changed.
    Example : Changing name from vSwitch_Test to vSwitch0.
    Current configuration from vswitch.json : 

     9       "mtu": 1500,
    10       "name": "vSwitch_Test",
    11       "num_ports": 1024,

    After updating the switch name : 

     9       "mtu": 1500,

    10       "name": "vSwitch0",
    11       "num_ports": 1024,

  5. Apply the modified configuration back to the ConfigStore using the --overwrite flag:

    configstorecli config current set -c esx -g network_vss -k switches -j vswitch.json --overwrite

  6. Reboot the host.

Additional Information

Modify ESXi Configuration Files