Categorygithub.com/0x0BSoD/vmwarego
modulepackage
0.0.0-20200730183019-e0f0dff24c6c
Repository: https://github.com/0x0bsod/vmwarego.git
Documentation: pkg.go.dev

# README

vmwarego

Small wrapper around govmomi for getting VM info simpler

Connections parameters and client:

vmw, err := NewClient(ClientParams{
    URL:      "https://HOST",
    Insecure: true,
    User:     "USER",
    Password: "PASS",
    Ctx:      context.Background(),
})

Some examples

Find VM by name:

vm, err := vmw.VmInfo("golden-w2k16")
// vm =>
/*
{
    "Vm": {
      "Type": "VirtualMachine",
      "Value": "vm-152148"
    },
    "Runtime": {
      "Device": [
        {
...
*/

Find VMs by a mask and get a custom field:

vms, err := vmw.VmsFilter("base-w2k16-*")
if err != nil {
    t.Fatal(err)
}

err = vmw.VmRetrieve(vms, []string{"summary"})
if err != nil {
    t.Fatal(err)
}

type Tags struct {
    Template string `json:"Template"`
}
var tags Tags

for _, vm := range vms {
    err = vmC.VmCustomFields(vm, &tags)
    if err != nil {
        t.Fatal(err)
    }
    fmt.Printf("%s || Template => %s\n", vm.Summary.Config.Name, tags.Template)
}
// vm =>
/*
base-w2k16-123 || Template => true
base-w2k16-1234 || Template => true
base-w2k16-12345 || Template => true
...
*/
}

# Functions

AddTags appends a tag to the tags field of ms.
MapStrUnion creates a new MapStr containing the union of the key-value pairs of the two maps.
MergeFields merges the top-level keys and values in each source map (it does not perform a deep merge).
NewClient creates a govmomi.Client.
No description provided by the author
No description provided by the author

# Constants

Event metadata constants.
Event metadata constants.

# Variables

ErrKeyNotFound indicates that the specified key was not found.

# Structs

No description provided by the author
EventMetadata contains fields and tags that can be added to an event via configuration.
No description provided by the author

# Type aliases

MapStr is a map[string]interface{} wrapper with utility methods for common map operations like converting to JSON.