vsphere

package
v0.0.0-...-60b8127 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetricProperties = []string{"numcpu", "memorysizemb", "disks", "shaping_input", "shaping_output"}

MetricProperties are properties that are sent as metrics

View Source
var Properties = map[string]map[string][]string{
	"datastore": {
		"Datastore":      {"name"},
		"VirtualMachine": {"datastore"},
	},
	"urls": {
		"Datastore": {"summary.url"},
	},
	"host": {
		"HostSystem":     {"name", "parent"},
		"VirtualMachine": {"name", "runtime.host"},
	},
	"cluster": {
		"ClusterComputeResource": {"name"},
	},
	"network": {
		"DistributedVirtualPortgroup": {"name", "config.defaultPortConfig.inShapingPolicy", "config.defaultPortConfig.outShapingPolicy"},
		"Network":                     {"name"},
		"VirtualMachine":              {"network", "config.hardware.device"},
	},
	"resourcepool": {
		"ResourcePool": {"name", "parent", "vm"},
	},
	"folder": {
		"Folder":         {"name", "parent"},
		"VirtualMachine": {"parent"},
	},
	"tags": {
		"VirtualMachine": {"tag"},
		"HostSystem":     {"tag"},
	},
	"numcpu": {
		"VirtualMachine": {"summary.config.numCpu"},
	},
	"memorysizemb": {
		"VirtualMachine": {"summary.config.memorySizeMB"},
	},
	"disks": {
		"VirtualMachine": {"guest.disk"},
	},
}

Properties describes know relation to properties to related objects and properties

View Source
var PropertiesSections = map[string]string{
	"summary.url":                 "urls",
	"name":                        "names",
	"datastore":                   "datastores",
	"network":                     "networks",
	"runtime.host":                "hosts",
	"parent":                      "parents",
	"vm":                          "vms",
	"tag":                         "tags",
	"summary.config.numCpu":       "cpus",
	"summary.config.memorySizeMB": "memories",
	"guest.disk":                  "disks",
	"runtime.connectionState":     "connections",
	"runtime.powerState":          "powers",
	"config.defaultPortConfig.inShapingPolicy":  "shaping_inputs",
	"config.defaultPortConfig.outShapingPolicy": "shaping_outputs",
	"config.hardware.device":                    "devices",
}

PropertiesSections represent the mapping of attributes to sections in the cache

Functions

func ExecuteQueries

func ExecuteQueries(ctx context.Context, id int, r soap.RoundTripper, cache *Cache, queryperf *types.QueryPerf, timeStamp int64, replacepoint bool, domain string, vcName string, channel *chan backend.Point, wg *sync.WaitGroup)

ExecuteQueries : Query a vcenter for performances

func InitMetrics

func InitMetrics(metrics []*Metric, perfmanager *mo.PerformanceManager)

InitMetrics : maps metric keys to requested metrics

func ProcessMetric

func ProcessMetric(cache *Cache, pem *types.PerfEntityMetric, timeStamp int64, replacepoint bool, domain string, vcName string, channel *chan backend.Point, wg *sync.WaitGroup)

ProcessMetric : Process Metric to metric queue

Types

type Cache

type Cache map[string]interface{}

Cache will hold some information's in memory

func (*Cache) Add

func (c *Cache) Add(vcenter, section, i string, v interface{})

Add a value to the cache

func (*Cache) Clean

func (c *Cache) Clean(vcenter string, section string, refs []string)

Clean cache of unknown references

func (*Cache) CleanAll

func (c *Cache) CleanAll(vcenter string, refs []string)

CleanAll cleans all sections of unknown references poolpaths and metrics are ignored as they will be cleaned real time

func (*Cache) FindHostAndCluster

func (c *Cache) FindHostAndCluster(vcenter, moref string) (string, string)

FindHostAndCluster finds host and cluster of a host or a vm

func (*Cache) FindMetricName

func (c *Cache) FindMetricName(vcenter string, id int32) string

FindMetricName find metricname from cache

func (*Cache) FindName

func (c *Cache) FindName(vcenter, section, moref string) string

FindName finds an object in cache and resolves its name

func (*Cache) FindNames

func (c *Cache) FindNames(vcenter, section, moref string) []string

FindNames finds objects in cache and resolves their names

func (*Cache) FindString

func (c *Cache) FindString(vcenter, section, moref string) string

FindString finds and return a string

func (*Cache) FindTags

func (c *Cache) FindTags(vcenter, moref string) []string

FindTags finds objects in cache and create a tag array

func (*Cache) GetConnectionState

func (c *Cache) GetConnectionState(vcenter, section, i string) *string

GetConnectionState gets the connection state of a host or a virtual machine

func (*Cache) GetDevices

func (c *Cache) GetDevices(vcenter, section, i string) *types.ArrayOfVirtualDevice

GetDevices gets the devices from a VM

func (*Cache) GetDiskInfos

func (c *Cache) GetDiskInfos(vcenter, section, i string) *[]types.GuestDiskInfo

GetDiskInfos gets an array of diskinfos from cache

func (*Cache) GetHostSystemConnectionState

func (c *Cache) GetHostSystemConnectionState(vcenter, section, i string) *types.HostSystemConnectionState

GetHostSystemConnectionState gets a host system connection state from cache

func (*Cache) GetHostSystemPowerState

func (c *Cache) GetHostSystemPowerState(vcenter, section, i string) *types.HostSystemPowerState

GetHostSystemPowerState gets a host system power state from cache

func (*Cache) GetInt32

func (c *Cache) GetInt32(vcenter, section, i string) *int32

GetInt32 get an int32 from cache

func (*Cache) GetMoref

func (c *Cache) GetMoref(vcenter, section, i string) *types.ManagedObjectReference

GetMoref gets a managed object reference from cache

func (*Cache) GetMorefs

func (c *Cache) GetMorefs(vcenter, section, i string) *[]types.ManagedObjectReference

GetMorefs gets an array of managed references from cache

func (*Cache) GetNetworkShapingInfo

func (c *Cache) GetNetworkShapingInfo(vcenter, section, i string) *types.DVSTrafficShapingPolicy

GetNetworkShapingInfo gets the shaping data from a DistributedVirtualPortGroup

func (*Cache) GetPowerState

func (c *Cache) GetPowerState(vcenter, section, i string) *string

GetPowerState gets the power state of a host or a virtual machine

func (*Cache) GetString

func (c *Cache) GetString(vcenter, section, i string) *string

GetString gets a string from cache

func (*Cache) GetStrings

func (c *Cache) GetStrings(vcenter, section, i string) *[]string

GetStrings gets an array of strings from cache

func (*Cache) GetTags

func (c *Cache) GetTags(vcenter, section, i string) *[]types.Tag

GetTags gets an array of vsphere tags from cache

func (*Cache) GetVirtualMachineConnectionState

func (c *Cache) GetVirtualMachineConnectionState(vcenter, section, i string) *types.VirtualMachineConnectionState

GetVirtualMachineConnectionState gets a virtual machine connection state from cache

func (*Cache) GetVirtualMachinePowerState

func (c *Cache) GetVirtualMachinePowerState(vcenter, section, i string) *types.VirtualMachinePowerState

GetVirtualMachinePowerState gets a virtual machine power state from cache

func (*Cache) LookupMorefs

func (c *Cache) LookupMorefs(vcenter, section string) *map[string]*[]types.ManagedObjectReference

LookupMorefs looks for items in the cache of type Morefs

func (*Cache) LookupString

func (c *Cache) LookupString(vcenter, section string) *map[string]*string

LookupString looks for items in the cache of type string

func (*Cache) Purge

func (c *Cache) Purge(vcenter, section string)

Purge purges a section of the cache

type Metric

type Metric struct {
	ObjectType []string
	Definition []*MetricDef
}

Metric description in config

type MetricDef

type MetricDef struct {
	Metric    string
	Instances string
	Key       int32
}

MetricDef Definition

type MetricGroup

type MetricGroup struct {
	ObjectType string
	Metrics    []*MetricDef
	Mor        []*types.ManagedObjectReference
}

MetricGroup Grouping for retrieval

type VCenter

type VCenter struct {
	Hostname     string
	Username     string
	Password     string
	MetricGroups []*MetricGroup
}

VCenter description

func (*VCenter) AddMetric

func (vcenter *VCenter) AddMetric(metric MetricDef, mtype string)

AddMetric : add a metric definition to a metric group

func (*VCenter) Connect

func (vcenter *VCenter) Connect() (*govmomi.Client, error)

Connect : Connect to vcenter

func (*VCenter) Init

func (vcenter *VCenter) Init(metrics []*Metric)

Init : initialize vcenter

func (*VCenter) Query

func (vcenter *VCenter) Query(interval int, domain string, replacepoint bool, properties []string, resultLimit int, instanceRatio float64, channel *chan backend.Point, wg *sync.WaitGroup)

Query : Query a vcenter

func (*VCenter) ToString

func (vcenter *VCenter) ToString() string

ToString : represents the vcenter as a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL