This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tagList, err := clt.tagMgr.GetAttachedTags(ctx, mor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _, t := range tagList { | |
if t.CategoryID == catID && t.ID != tagID { | |
if err := clt.tagMgr.DetachTag(ctx, t.ID, mor); err != nil { | |
return err | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
err = vsClient.tagMgr.AttachTag(ctx, tagID, vmMOR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func eventVmMOR(req []byte) (*types.ManagedObjectReference, error) { | |
var ce cloudEvent | |
var mor types.ManagedObjectReference | |
err := json.Unmarshal(req, &ce) | |
if err != nil { | |
return nil, fmt.Errorf("parse request: %w", err) | |
} | |
if ce.Data.Vm == nil || ce.Data.Vm.Vm.Value == "" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func newClient(ctx context.Context, cfg *vcConfig) (*vsClient, error) { | |
u := url.URL{ | |
Scheme: "https", | |
Host: cfg.VCenter.Server, | |
Path: "sdk", | |
} | |
u.User = url.UserPassword(cfg.VCenter.User, cfg.VCenter.Password) | |
insecure := cfg.VCenter.Insecure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tagObjs, err := vsClt.attachedTags(ctx, *vmMOR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func currentConfigs(ctx context.Context, moVM mo.VirtualMachine) []vmConfig { | |
configs := make([]vmConfig, 6) | |
configs[0] = vmConfig{name: "numCPU", valInt: int(moVM.Config.Hardware.NumCPU)} | |
configs[1] = vmConfig{name: "memoryMB", valInt: int(moVM.Config.Hardware.MemoryMB)} | |
configs[2] = vmConfig{name: "numCoresPerSocket", valInt: int(moVM.Config.Hardware.NumCoresPerSocket)} | |
if moVM.Config.MemoryHotAddEnabled != nil { | |
configs[3] = vmConfig{name: "memoryHotAddEnabled", valBool: *moVM.Config.MemoryHotAddEnabled} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
catObj, err := c.tagMgr.GetCategory(ctx, attTag.CategoryID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c *vsClient) applyCfgs(ctx context.Context, moVM mo.VirtualMachine, mor types.ManagedObjectReference, cfgs []vmConfig) (*object.Task, error) { | |
vm := object.NewVirtualMachine(c.govmomi.Client, mor) | |
desiredSpec := generateDesiredSpec(cfgs, moVM) | |
task, err := vm.Reconfigure(ctx, desiredSpec) | |
if err != nil { | |
return nil, err | |
} | |
if debug { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vm := object.NewVirtualMachine(vsClt.govmomi.Client, vmMOR) |