Commit 1de7d478 authored by rohitjogvmw's avatar rohitjogvmw

Using hash/fnv to generate the vmName

vSphere has limitation of 80 characters for vmName. with vsphere-k8s prefix and "vmdisk.volumeOptions.Name" vmName can become easily bigger than 80 chars. Used hash funciton just of the "vmdisk.volumeOptions.Name" part as cleanup dummyVm logic depends on prefix "vsphere-k8s"
parent da00e92f
...@@ -18,6 +18,7 @@ package diskmanagers ...@@ -18,6 +18,7 @@ package diskmanagers
import ( import (
"fmt" "fmt"
"hash/fnv"
"strings" "strings"
"github.com/golang/glog" "github.com/golang/glog"
...@@ -95,7 +96,9 @@ func (vmdisk vmDiskManager) Create(ctx context.Context, datastore *vclib.Datasto ...@@ -95,7 +96,9 @@ func (vmdisk vmDiskManager) Create(ctx context.Context, datastore *vclib.Datasto
var dummyVM *vclib.VirtualMachine var dummyVM *vclib.VirtualMachine
// Check if VM already exist in the folder. // Check if VM already exist in the folder.
// If VM is already present, use it, else create a new dummy VM. // If VM is already present, use it, else create a new dummy VM.
dummyVMFullName := vclib.DummyVMPrefixName + "-" + vmdisk.volumeOptions.Name fnvHash := fnv.New32a()
fnvHash.Write([]byte(vmdisk.volumeOptions.Name))
dummyVMFullName := vclib.DummyVMPrefixName + "-" + fmt.Sprint(fnvHash.Sum32())
dummyVM, err = datastore.Datacenter.GetVMByPath(ctx, vmdisk.vmOptions.VMFolder.InventoryPath+"/"+dummyVMFullName) dummyVM, err = datastore.Datacenter.GetVMByPath(ctx, vmdisk.vmOptions.VMFolder.InventoryPath+"/"+dummyVMFullName)
if err != nil { if err != nil {
// Create a dummy VM // Create a dummy VM
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment