You can configure a vSAN stretched cluster or two-host cluster.
Following is the process for configuring an existing vSAN cluster as a stretched cluster:
To configure a stretched cluster or two-host setup by using the vSAN Management API, enumerate the hosts in the cluster, select which hosts to add to each fault domain, and then save this data to an array.
preferedFd = args.preferdomain secondaryFd = args.seconddomain firstFdHosts = [] secondFdHosts = [] for host in hosts: if yes('Add host {} to preferred fault domain ? (yes/no)'.format(hostProps[host]['name'])): firstFdHosts.append(host) for host in set(hosts) - set(firstFdHosts): if yes('Add host {} to second fault domain ? (yes/no)'.format(hostProps[host]['name'])): secondFdHosts.append(host) faultDomainConfig = vim.VimClusterVSANStretchedClusterFaultDomainConfig( firstFdHosts=firstFdHosts, firstFdName=preferedFd, secondFdHosts=secondFdHosts, secondFdName=secondaryFd)
The next step is to define the eligible disks for the witness host.
disks = [result.disk for result in witnessHost.configManager.vsanSystem.QueryDisksForVsan() if result.state == 'eligible'] diskMapping = None if disks: ssds = [disk for disk in disks if disk.ssd] nonSsds = [disk for disk in disks if not disk.ssd] # host with hybrid disks if len(ssds) > 0 and len(nonSsds) > 0: diskMapping = vim.VsanHostDiskMapping( ssd=ssds[0], nonSsd=nonSsds ) # host with all-flash disks,choose the ssd with smaller capacity for cache layer. if len(ssds) > 0 and len(nonSsds) == 0: smallerSize = min([disk.capacity.block * disk.capacity.blockSize for disk in ssds]) smallSsds = [] biggerSsds = [] for ssd in ssds: size = ssd.capacity.block * ssd.capacity.blockSize if size == smallerSize: smallSsds.append(ssd) biggerSsds.append(ssd) diskMapping = vim.VsanHostDiskMapping( ssd=smallSsds[0] nonSsd = biggerSsds )
After adding the host to the fault domain arrays and defining the eligible disks for the witness host, configure the stretched cluster.
print 'start to create stretched cluster' task = vsanScSystem.VSANVcConvertToStretchedCluster( cluster=cluster, faultDomainConfig=faultDomainConfig, witnessHost=witnessHost, preferredFd=preferedFd, diskMapping=diskMapping) vsanapiutils.WaitForTasks([task], si)