renameLocalStorageDatastore.pl

Version 1

    Have a bunch of ESX(i) hosts in vCenter? When you view their datastores, do you see a bunch of localstorage (x) ? Would you like to rename it to something more useful like which local storage it belongs to? This script is for you!

     

    Note: Please test this out in your environment before using.

     

    This script requires vCenter and host(s) under a vCenter cluster and will look at all hosts datastores and find local storage and rename to the following format: "hostname-local-storage-X". It will try to use the short hostname on the ESX(i) host, but if it's not configured, it will use the ESX(i) display name and append the proper count if there are more than one local VMFS volume. There is a just kidding mode which can be enabled to see what volumes it locates and show you the rename without actually executing the rename. If you set *jkmode*_ to 0, the rename will execute, please run with 1 if you're not sure.

     

    Requirement:

    vCenter 2.5 / 4.0

    ESX(i) 3.5 / 4.0

    vSphere SDK for Perl or vMA 4.0

     

    Sample Execution:

     

    Just Kidding mode:

    [vi-admin@optimus]$ ./renameLocalStorageDatastore.pl --server teletron1.primp-industries.com --username primp --cluster autobots --jk_mode 1
    This could take a few minutes depending on the size of the cluster ...
    
    Cluster: autobots
    Just Kidding Mode ENABLED! - Will not rename datastors but display what it would be renamed to
    
         Host: sideswipe.primp-industries.com
              Localstorage: local-storage (2)
              Rename to: [sideswipe-local-storage-1]
         Total # of local datastores on host: 1
    
         Host: jetfire.primp-industries.com
              Localstorage: local-storage
              Rename to: [jetfire-local-storage-1]
              Localstorage: local-storage (1)
              Rename to: [jetfire-local-storage-2]
         Total # of local datastores on host: 2
    

     

    Rename mode:

    [vi-admin@optimus]$ ./renameLocalStorageDatastore.pl --server teletron1.primp-industries.com --username primp --cluster autobots --jk_mode 0
    This could take a few minutes depending on the size of the cluster ...
    
    Cluster: autobots
    
         Host: sideswipe.primp-industries.com
              Localstorage: local-storage (2)
              Rename to: [sideswipe-local-storage-1]
         Total # of local datastores on host: 1
    
         Host: jetfire.primp-industries.com
              Localstorage: local-storage
              Rename to: [jetfire-local-storage-1]
              Localstorage: local-storage (1)
              Rename to: [jetfire-local-storage-2]
         Total # of local datastores on host: 2