mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Remove vmUUID check in VSphere cloud provider
This commit is contained in:
parent
5636634879
commit
63826000c5
@ -375,14 +375,6 @@ func newControllerNode(cfg VSphereConfig) (*VSphere, error) {
|
|||||||
if cfg.Global.VCenterPort == "" {
|
if cfg.Global.VCenterPort == "" {
|
||||||
cfg.Global.VCenterPort = "443"
|
cfg.Global.VCenterPort = "443"
|
||||||
}
|
}
|
||||||
if cfg.Global.VMUUID == "" {
|
|
||||||
// This needs root privileges on the host, and will fail otherwise.
|
|
||||||
cfg.Global.VMUUID, err = getvmUUID()
|
|
||||||
if err != nil {
|
|
||||||
glog.Errorf("Failed to get VM UUID. err: %+v", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vsphereInstanceMap, err := populateVsphereInstanceMap(&cfg)
|
vsphereInstanceMap, err := populateVsphereInstanceMap(&cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -19,7 +19,6 @@ package vsphere
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -128,30 +127,6 @@ func GetgovmomiClient(conn *vclib.VSphereConnection) (*govmomi.Client, error) {
|
|||||||
return client, err
|
return client, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// getvmUUID gets the BIOS UUID via the sys interface. This UUID is known by vsphere
|
|
||||||
func getvmUUID() (string, error) {
|
|
||||||
id, err := ioutil.ReadFile(UUIDPath)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("error retrieving vm uuid: %s", err)
|
|
||||||
}
|
|
||||||
uuidFromFile := string(id[:])
|
|
||||||
//strip leading and trailing white space and new line char
|
|
||||||
uuid := strings.TrimSpace(uuidFromFile)
|
|
||||||
// check the uuid starts with "VMware-"
|
|
||||||
if !strings.HasPrefix(uuid, UUIDPrefix) {
|
|
||||||
return "", fmt.Errorf("Failed to match Prefix, UUID read from the file is %v", uuidFromFile)
|
|
||||||
}
|
|
||||||
// Strip the prefix and while spaces and -
|
|
||||||
uuid = strings.Replace(uuid[len(UUIDPrefix):(len(uuid))], " ", "", -1)
|
|
||||||
uuid = strings.Replace(uuid, "-", "", -1)
|
|
||||||
if len(uuid) != 32 {
|
|
||||||
return "", fmt.Errorf("Length check failed, UUID read from the file is %v", uuidFromFile)
|
|
||||||
}
|
|
||||||
// need to add dashes, e.g. "564d395e-d807-e18a-cb25-b79f65eb2b9f"
|
|
||||||
uuid = fmt.Sprintf("%s-%s-%s-%s-%s", uuid[0:8], uuid[8:12], uuid[12:16], uuid[16:20], uuid[20:32])
|
|
||||||
return uuid, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the accessible datastores for the given node VM.
|
// Returns the accessible datastores for the given node VM.
|
||||||
func getAccessibleDatastores(ctx context.Context, nodeVmDetail *NodeDetails, nodeManager *NodeManager) ([]*vclib.DatastoreInfo, error) {
|
func getAccessibleDatastores(ctx context.Context, nodeVmDetail *NodeDetails, nodeManager *NodeManager) ([]*vclib.DatastoreInfo, error) {
|
||||||
accessibleDatastores, err := nodeVmDetail.vm.GetAllAccessibleDatastores(ctx)
|
accessibleDatastores, err := nodeVmDetail.vm.GetAllAccessibleDatastores(ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user