hypervisors

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 5 Imported by: 184

Documentation

Overview

Package hypervisors returns details about list of hypervisors, shows details for a hypervisor and shows summary statistics for all hypervisors over all compute nodes in the OpenStack cloud.

Example of Show Hypervisor Details

hypervisorID := "42"
hypervisor, err := hypervisors.Get(computeClient, hypervisorID).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", hypervisor)

Example of Show Hypervisor Details when using Compute API microversion greater than 2.53

computeClient.Microversion = "2.53"

hypervisorID := "c48f6247-abe4-4a24-824e-ea39e108874f"
hypervisor, err := hypervisors.Get(computeClient, hypervisorID).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", hypervisor)

Example of Retrieving Details of All Hypervisors

allPages, err := hypervisors.List(computeClient, nil).AllPages()
if err != nil {
	panic(err)
}

allHypervisors, err := hypervisors.ExtractHypervisors(allPages)
if err != nil {
	panic(err)
}

for _, hypervisor := range allHypervisors {
	fmt.Printf("%+v\n", hypervisor)
}

Example of Retrieving Details of All Hypervisors when using Compute API microversion 2.33 or greater.

computeClient.Microversion = "2.53"

iTrue := true
listOpts := hypervisors.ListOpts{
	WithServers: &true,
}

allPages, err := hypervisors.List(computeClient, listOpts).AllPages()
if err != nil {
	panic(err)
}

allHypervisors, err := hypervisors.ExtractHypervisors(allPages)
if err != nil {
	panic(err)
}

for _, hypervisor := range allHypervisors {
	fmt.Printf("%+v\n", hypervisor)
}

Example of Show Hypervisors Statistics

hypervisorsStatistics, err := hypervisors.GetStatistics(computeClient).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", hypervisorsStatistics)

Example of Show Hypervisor Uptime

hypervisorID := "42"
hypervisorUptime, err := hypervisors.GetUptime(computeClient, hypervisorID).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", hypervisorUptime)

Example of Show Hypervisor Uptime with Compute API microversion greater than 2.53

computeClient.Microversion = "2.53"

hypervisorID := "c48f6247-abe4-4a24-824e-ea39e108874f"
hypervisorUptime, err := hypervisors.GetUptime(computeClient, hypervisorID).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", hypervisorUptime)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List makes a request against the API to list hypervisors.

Types

type CPUInfo

type CPUInfo struct {
	Vendor   string   `json:"vendor"`
	Arch     string   `json:"arch"`
	Model    string   `json:"model"`
	Features []string `json:"features"`
	Topology Topology `json:"topology"`
}

CPUInfo represents CPU information of the hypervisor.

type Hypervisor

type Hypervisor struct {
	// A structure that contains cpu information like arch, model, vendor,
	// features and topology.
	CPUInfo CPUInfo `json:"-"`

	// The current_workload is the number of tasks the hypervisor is responsible
	// for. This will be equal or greater than the number of active VMs on the
	// system (it can be greater when VMs are being deleted and the hypervisor is
	// still cleaning up).
	CurrentWorkload int `json:"current_workload"`

	// Status of the hypervisor, either "enabled" or "disabled".
	Status string `json:"status"`

	// State of the hypervisor, either "up" or "down".
	State string `json:"state"`

	// DiskAvailableLeast is the actual free disk on this hypervisor,
	// measured in GB.
	DiskAvailableLeast int `json:"disk_available_least"`

	// HostIP is the hypervisor's IP address.
	HostIP string `json:"host_ip"`

	// FreeDiskGB is the free disk remaining on the hypervisor, measured in GB.
	FreeDiskGB int `json:"-"`

	// FreeRAMMB is the free RAM in the hypervisor, measured in MB.
	FreeRamMB int `json:"free_ram_mb"`

	// HypervisorHostname is the hostname of the hypervisor.
	HypervisorHostname string `json:"hypervisor_hostname"`

	// HypervisorType is the type of hypervisor.
	HypervisorType string `json:"hypervisor_type"`

	// HypervisorVersion is the version of the hypervisor.
	HypervisorVersion int `json:"-"`

	// ID is the unique ID of the hypervisor.
	ID string `json:"-"`

	// LocalGB is the disk space in the hypervisor, measured in GB.
	LocalGB int `json:"-"`

	// LocalGBUsed is the used disk space of the  hypervisor, measured in GB.
	LocalGBUsed int `json:"local_gb_used"`

	// MemoryMB is the total memory of the hypervisor, measured in MB.
	MemoryMB int `json:"memory_mb"`

	// MemoryMBUsed is the used memory of the hypervisor, measured in MB.
	MemoryMBUsed int `json:"memory_mb_used"`

	// RunningVMs is the The number of running vms on the hypervisor.
	RunningVMs int `json:"running_vms"`

	// Service is the service this hypervisor represents.
	Service Service `json:"service"`

	// Servers is a list of Server object.
	// The requires microversion 2.53 or later.
	Servers *[]Server `json:"servers"`

	// VCPUs is the total number of vcpus on the hypervisor.
	VCPUs int `json:"vcpus"`

	// VCPUsUsed is the number of used vcpus on the hypervisor.
	VCPUsUsed int `json:"vcpus_used"`
}

Hypervisor represents a hypervisor in the OpenStack cloud.

func ExtractHypervisors

func ExtractHypervisors(p pagination.Page) ([]Hypervisor, error)

ExtractHypervisors interprets a page of results as a slice of Hypervisors.

func (*Hypervisor) UnmarshalJSON

func (r *Hypervisor) UnmarshalJSON(b []byte) error

type HypervisorPage

type HypervisorPage struct {
	pagination.SinglePageBase
}

HypervisorPage represents a single page of all Hypervisors from a List request.

func (HypervisorPage) IsEmpty

func (page HypervisorPage) IsEmpty() (bool, error)

IsEmpty determines whether or not a HypervisorPage is empty.

type HypervisorResult

type HypervisorResult struct {
	gophercloud.Result
}

func Get

func Get(client *gophercloud.ServiceClient, hypervisorID string) (r HypervisorResult)

Get makes a request against the API to get details for specific hypervisor.

func (HypervisorResult) Extract

func (r HypervisorResult) Extract() (*Hypervisor, error)

Extract interprets any HypervisorResult as a Hypervisor, if possible.

type ListOpts added in v0.19.0

type ListOpts struct {
	// Limit is an integer value for the limit of values to return.
	// This requires microversion 2.33 or later.
	Limit *int `q:"limit"`

	// Marker is the ID of the last-seen item as a UUID.
	// This requires microversion 2.53 or later.
	Marker *string `q:"marker"`

	// HypervisorHostnamePattern is the hypervisor hostname or a portion of it.
	// This requires microversion 2.53 or later
	HypervisorHostnamePattern *string `q:"hypervisor_hostname_pattern"`

	// WithServers is a bool to include all servers which belong to each hypervisor
	// This requires microversion 2.53 or later
	WithServers *bool `q:"with_servers"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the server attributes you want to see returned. Marker and Limit are used for pagination.

func (ListOpts) ToHypervisorListQuery added in v0.19.0

func (opts ListOpts) ToHypervisorListQuery() (string, error)

ToHypervisorListQuery formats a ListOpts into a query string.

type ListOptsBuilder added in v0.19.0

type ListOptsBuilder interface {
	ToHypervisorListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Server added in v0.19.0

type Server struct {
	Name string `json:"name"`
	UUID string `json:"uuid"`
}

Server represents an instance running on the hypervisor

type Service

type Service struct {
	Host           string `json:"host"`
	ID             string `json:"-"`
	DisabledReason string `json:"disabled_reason"`
}

Service represents a Compute service running on the hypervisor.

func (*Service) UnmarshalJSON

func (r *Service) UnmarshalJSON(b []byte) error

type Statistics

type Statistics struct {
	// The number of hypervisors.
	Count int `json:"count"`

	// The current_workload is the number of tasks the hypervisor is responsible for
	CurrentWorkload int `json:"current_workload"`

	// The actual free disk on this hypervisor(in GB).
	DiskAvailableLeast int `json:"disk_available_least"`

	// The free disk remaining on this hypervisor(in GB).
	FreeDiskGB int `json:"free_disk_gb"`

	// The free RAM in this hypervisor(in MB).
	FreeRamMB int `json:"free_ram_mb"`

	// The disk in this hypervisor(in GB).
	LocalGB int `json:"local_gb"`

	// The disk used in this hypervisor(in GB).
	LocalGBUsed int `json:"local_gb_used"`

	// The memory of this hypervisor(in MB).
	MemoryMB int `json:"memory_mb"`

	// The memory used in this hypervisor(in MB).
	MemoryMBUsed int `json:"memory_mb_used"`

	// The total number of running vms on all hypervisors.
	RunningVMs int `json:"running_vms"`

	// The number of vcpu in this hypervisor.
	VCPUs int `json:"vcpus"`

	// The number of vcpu used in this hypervisor.
	VCPUsUsed int `json:"vcpus_used"`
}

Statistics represents a summary statistics for all enabled hypervisors over all compute nodes in the OpenStack cloud.

type StatisticsResult

type StatisticsResult struct {
	gophercloud.Result
}

func GetStatistics

func GetStatistics(client *gophercloud.ServiceClient) (r StatisticsResult)

Statistics makes a request against the API to get hypervisors statistics.

func (StatisticsResult) Extract

func (r StatisticsResult) Extract() (*Statistics, error)

Extract interprets any StatisticsResult as a Statistics, if possible.

type Topology

type Topology struct {
	Sockets int `json:"sockets"`
	Cores   int `json:"cores"`
	Threads int `json:"threads"`
}

Topology represents a CPU Topology.

type Uptime

type Uptime struct {
	// The hypervisor host name provided by the Nova virt driver.
	// For the Ironic driver, it is the Ironic node uuid.
	HypervisorHostname string `json:"hypervisor_hostname"`

	// The id of the hypervisor.
	ID string `json:"-"`

	// The state of the hypervisor. One of up or down.
	State string `json:"state"`

	// The status of the hypervisor. One of enabled or disabled.
	Status string `json:"status"`

	// The total uptime of the hypervisor and information about average load.
	Uptime string `json:"uptime"`
}

Uptime represents uptime and additional info for a specific hypervisor.

func (*Uptime) UnmarshalJSON

func (r *Uptime) UnmarshalJSON(b []byte) error

type UptimeResult

type UptimeResult struct {
	gophercloud.Result
}

func GetUptime

func GetUptime(client *gophercloud.ServiceClient, hypervisorID string) (r UptimeResult)

GetUptime makes a request against the API to get uptime for specific hypervisor.

func (UptimeResult) Extract

func (r UptimeResult) Extract() (*Uptime, error)

Extract interprets any UptimeResult as a Uptime, if possible.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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