Claiming and Managing Disks
You can add disks to the vSAN cluster during the initial configuration, or you can add them later on.
When claiming disks by using the Configure vSAN wizard in the vSphere Client, you can only see the disks that are eligible, meaning they do not have existing vSAN partitions. vCenter Server filters out the non-eligible disks and these disks are not exposed for adding to the vSAN cluster.
For both hybrid and all-flash vSAN clusters, you assign the devices for cache and capacity tiers.

While claiming disks using the client applications, do the following:
Query for ineligible disks, and if required, clear the existing vSAN partitions on them.
# Enumerate the ineligible disks for host in hosts: disks = [ result.disk for result in hostProps[host]['configManager.vsanSystem'] .QueryDisksForVsan() if result.state == 'ineligible' ] print 'Find ineligible disks {} in host {}'.format( [disk.displayName for disk in disks], hostProps[host]['name']) # For each disk, interactively ask admin whether to individually wipe ineligible disks or not for disk in disks: if yes('Do you want to wipe disk {}?\nPlease Always check the partition table and the data' ' stored on those disks before doing any wipe! (yes/no)?'.format( disk.displayName)): hostProps[host]['configManager.storageSystem'].UpdateDiskPartitions( disk.deviceName, vim.HostDiskPartitionSpec())
If the vSAN cluster is all-flash configuration, then segregate the devices as small and large. If the vSAN cluster is hybrid configuration then divide the devices as flash and HDD.
diskmap = {host: {'cache': [], 'capacity': []} for host in hosts} cacheDisks = [] capacityDisks = [] # For all flash architectures if isallFlash: for host in hosts: ssds = [result.disk for result in hostProps[host] ['configManager.vsanSystem'].QueryDisksForVsan() if result.state == 'eligible' and result.disk.ssd] smallerSize = min([disk.capacity.block * disk.capacity.blockSize for disk in ssds]) for ssd in ssds: size = ssd.capacity.block * ssd.capacity.blockSize if size == smallerSize: diskmap[host]['cache'].append(ssd) cacheDisks.append((ssd.displayName, sizeof_fmt(size), hostProps[host]['name'])) else: diskmap[host]['capacity'].append(ssd) capacityDisks.append((ssd.displayName, sizeof_fmt(size), hostProps[host]['name'])) else: # For hybrid architectures for host in hosts: disks = [result.disk for result in hostProps[host] ['configManager.vsanSystem'].QueryDisksForVsan() if result.state == 'eligible'] ssds = [disk for disk in disks if disk.ssd] hdds = [disk for disk in disks if not disk.ssd] for disk in ssds: diskmap[host]['cache'].append(disk) size = disk.capacity.block * disk.capacity.blockSize cacheDisks.append((disk.displayName, sizeof_fmt(size), hostProps[host]['name'])) for disk in hdds: diskmap[host]['capacity'].append(disk) size = disk.capacity.block * disk.capacity.blockSize capacityDisks.append((disk.displayName, sizeof_fmt(size), hostProps[host]['name'])) for host, disks in diskmap.iteritems(): if disks['cache'] and disks['capacity']: dm = vim.VimVsanHostDiskMappingCreationSpec( cacheDisks=disks['cache'], capacityDisks=disks['capacity'], creationType='allFlash' if isallFlash else 'hybrid', host=host) # Execute the task task = vsanVcDiskManagementSystem.InitializeDiskMappings(dm) tasks.append(task)
""" Demonstrates AddStoragePoolDisks API Add disks to Storage Pool If the task of disk addition fails, any exception will be logged. Args: cluster (vim.ClusterComputeResource): vSAN cluster instance. vdms: vsan-disk-management-system MO instance. spec (vim.vsan.host.AddStoragePoolDiskSpec): Specifies the data evacuation mode. Returns: None. """ def addDiskToStoragePool(cluster, vdms, spec): try: tsk = vdms.AddStoragePoolDisks([spec]) addDiskTask = vim.Task(tsk._moId, cluster._stub) task.WaitForTask(addDiskTask) print("AddDisk to storage pool operation completed") except Exception as e: print("AddDisk to storage pool operation failed: %s" % e)