monitors

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package monitors provides information and interaction with the Monitors of the Load Balancer as a Service extension for the OpenStack Networking Service.

Example to List Monitors

listOpts: monitors.ListOpts{
	Type: "HTTP",
}

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

allMonitors, err := monitors.ExtractMonitors(allPages)
if err != nil {
	panic(err)
}

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

Example to Create a Monitor

createOpts := monitors.CreateOpts{
	Type:          "HTTP",
	Delay:         20,
	Timeout:       20,
	MaxRetries:    5,
	URLPath:       "/check",
	ExpectedCodes: "200-299",
}

monitor, err := monitors.Create(networkClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Update a Monitor

monitorID := "681aed03-aadb-43ae-aead-b9016375650a"

updateOpts := monitors.UpdateOpts{
	Timeout: 30,
}

monitor, err := monitors.Update(networkClient, monitorID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Member

monitorID := "681aed03-aadb-43ae-aead-b9016375650a"
err := monitors.Delete(networkClient, monitorID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(c *golangsdk.ServiceClient, opts ListOpts) pagination.Pager

List returns a Pager which allows you to iterate over a collection of monitors. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

Default policy settings return only those monitors that are owned by the tenant who submits the request, unless an admin user submits the request.

Types

type CreateOpts

type CreateOpts struct {
	// MonitorType is the type of probe, which is PING, TCP, HTTP, or HTTPS,
	// that is sent by the load balancer to verify the member state.
	Type MonitorType `json:"type" required:"true"`

	// Delay is the time, in seconds, between sending probes to members.
	Delay int `json:"delay" required:"true"`

	// Timeout is the maximum number of seconds for a monitor to wait for a ping
	// reply before it times out. The value must be less than the delay value.
	Timeout int `json:"timeout" required:"true"`

	// MaxRetries is the number of permissible ping failures before changing the
	// member's status to INACTIVE. Must be a number between 1 and 10.
	MaxRetries int `json:"max_retries" required:"true"`

	// URLPath is the URI path that will be accessed if monitor type
	// is HTTP or HTTPS. Required for HTTP(S) types.
	URLPath string `json:"url_path,omitempty"`

	// HTTPMethod is the HTTP method used for requests by the monitor. If this
	// attribute is not specified, it defaults to "GET". Required for HTTP(S)
	// types.
	HTTPMethod string `json:"http_method,omitempty"`

	// ExpectedCodes is the expected HTTP codes for a passing HTTP(S) monitor
	// You can either specify a single status like "200", or a range like
	// "200-202". Required for HTTP(S) types.
	ExpectedCodes string `json:"expected_codes,omitempty"`

	// TenantID is only required if the caller has an admin role and wants
	// to create a pool for another tenant.
	TenantID string `json:"tenant_id,omitempty"`

	// AdminStateUp denotes whether the monitor is administratively up or down.
	AdminStateUp *bool `json:"admin_state_up,omitempty"`
}

CreateOpts contains all the values needed to create a new health monitor.

func (CreateOpts) ToLBMonitorCreateMap

func (opts CreateOpts) ToLBMonitorCreateMap() (map[string]interface{}, error)

ToLBMonitorCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToLBMonitorCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

type CreateResult struct {
	// contains filtered or unexported fields
}

CreateResult represents the result of a create operation. Call its Extract method to interpret it as a Monitor.

func Create

func Create(c *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create is an operation which provisions a new health monitor. There are different types of monitor you can provision: PING, TCP or HTTP(S). Below are examples of how to create each one.

Here is an example config struct to use when creating a PING or TCP monitor:

CreateOpts{Type: TypePING, Delay: 20, Timeout: 10, MaxRetries: 3} CreateOpts{Type: TypeTCP, Delay: 20, Timeout: 10, MaxRetries: 3}

Here is an example config struct to use when creating a HTTP(S) monitor:

CreateOpts{Type: TypeHTTP, Delay: 20, Timeout: 10, MaxRetries: 3,

HttpMethod: "HEAD", ExpectedCodes: "200"}

func (CreateResult) Extract

func (r CreateResult) Extract() (*Monitor, error)

Extract is a function that accepts a result and extracts a monitor.

type DeleteResult

type DeleteResult struct {
	golangsdk.ErrResult
}

DeleteResult represents the result of a delete operation. Call its Extract method to determine if the request succeeded or failed.

func Delete

func Delete(c *golangsdk.ServiceClient, id string) (r DeleteResult)

Delete will permanently delete a particular monitor based on its unique ID.

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult represents the result of a get operation. Call its Extract method to interpret it as a Monitor.

func Get

func Get(c *golangsdk.ServiceClient, id string) (r GetResult)

Get retrieves a particular health monitor based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Monitor, error)

Extract is a function that accepts a result and extracts a monitor.

type ListOpts

type ListOpts struct {
	ID            string `q:"id"`
	TenantID      string `q:"tenant_id"`
	Type          string `q:"type"`
	Delay         int    `q:"delay"`
	Timeout       int    `q:"timeout"`
	MaxRetries    int    `q:"max_retries"`
	HTTPMethod    string `q:"http_method"`
	URLPath       string `q:"url_path"`
	ExpectedCodes string `q:"expected_codes"`
	AdminStateUp  *bool  `q:"admin_state_up"`
	Status        string `q:"status"`
	Limit         int    `q:"limit"`
	Marker        string `q:"marker"`
	SortKey       string `q:"sort_key"`
	SortDir       string `q:"sort_dir"`
}

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 floating IP attributes you want to see returned. SortKey allows you to sort by a particular network attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.

type Monitor

type Monitor struct {
	// ID is the unique ID for the Monitor.
	ID string

	// Name is the monitor name. Does not have to be unique.
	Name string

	// TenantID is the owner of the Monitor.
	TenantID string `json:"tenant_id"`

	// Type is the type of probe sent by the load balancer to verify the member
	// state, which is PING, TCP, HTTP, or HTTPS.
	Type string

	// Delay is the time, in seconds, between sending probes to members.
	Delay int

	// Timeout is the maximum number of seconds for a monitor to wait for a
	// connection to be established before it times out. This value must be less
	// than the delay value.
	Timeout int

	// MaxRetries is the number of allowed connection failures before changing the
	// status of the member to INACTIVE. A valid value is from 1 to 10.
	MaxRetries int `json:"max_retries"`

	// HTTPMethod is the HTTP method that the monitor uses for requests.
	HTTPMethod string `json:"http_method"`

	// URLPath is the HTTP path of the request sent by the monitor to test the
	// health of a member. Must be a string beginning with a forward slash (/).
	URLPath string `json:"url_path"`

	// ExpectedCodes is the expected HTTP codes for a passing HTTP(S) monitor.
	ExpectedCodes string `json:"expected_codes"`

	// AdminStateUp is the administrative state of the health monitor, which is up
	// (true) or down (false).
	AdminStateUp bool `json:"admin_state_up"`

	// Status is the status of the health monitor. Indicates whether the health
	// monitor is operational.
	Status string
}

Monitor represents a load balancer health monitor. A health monitor is used to determine whether or not back-end members of the VIP's pool are usable for processing a request. A pool can have several health monitors associated with it. There are different types of health monitors supported:

PING: used to ping the members using ICMP. TCP: used to connect to the members using TCP. HTTP: used to send an HTTP request to the member. HTTPS: used to send a secure HTTP request to the member.

When a pool has several monitors associated with it, each member of the pool is monitored by all these monitors. If any monitor declares the member as unhealthy, then the member status is changed to INACTIVE and the member won't participate in its pool's load balancing. In other words, ALL monitors must declare the member to be healthy for it to stay ACTIVE.

func ExtractMonitors

func ExtractMonitors(r pagination.Page) ([]Monitor, error)

ExtractMonitors accepts a Page struct, specifically a MonitorPage struct, and extracts the elements into a slice of Monitor structs. In other words, a generic collection is mapped into a relevant slice.

type MonitorPage

type MonitorPage struct {
	pagination.LinkedPageBase
}

MonitorPage is the page returned by a pager when traversing over a collection of health monitors.

func (MonitorPage) IsEmpty

func (r MonitorPage) IsEmpty() (bool, error)

IsEmpty checks whether a PoolPage struct is empty.

func (MonitorPage) NextPageURL

func (r MonitorPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of monitors has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type MonitorType

type MonitorType string

MonitorType is the type for all the types of LB monitors.

const (
	TypePING  MonitorType = "PING"
	TypeTCP   MonitorType = "TCP"
	TypeHTTP  MonitorType = "HTTP"
	TypeHTTPS MonitorType = "HTTPS"
)

Constants that represent approved monitoring types.

type UpdateOpts

type UpdateOpts struct {
	// Delay is the time, in seconds, between sending probes to members.
	Delay int `json:"delay,omitempty"`

	// Timeout is the maximum number of seconds for a monitor to wait for a ping
	// reply before it times out. The value must be less than the delay value.
	Timeout int `json:"timeout,omitempty"`

	// MaxRetries is the number of permissible ping failures before changing the
	// member's status to INACTIVE. Must be a number between 1 and 10.
	MaxRetries int `json:"max_retries,omitempty"`

	// URLPath is the URI path that will be accessed if monitor type
	// is HTTP or HTTPS.
	URLPath string `json:"url_path,omitempty"`

	// HTTPMethod is the HTTP method used for requests by the monitor. If this
	// attribute is not specified, it defaults to "GET".
	HTTPMethod string `json:"http_method,omitempty"`

	// ExpectedCodes is the expected HTTP codes for a passing HTTP(S) monitor
	// You can either specify a single status like "200", or a range like
	// "200-202".
	ExpectedCodes string `json:"expected_codes,omitempty"`

	// AdminStateUp denotes whether the monitor is administratively up or down.
	AdminStateUp *bool `json:"admin_state_up,omitempty"`
}

UpdateOpts contains all the values needed to update an existing monitor. Attributes not listed here but appear in CreateOpts are immutable and cannot be updated.

func (UpdateOpts) ToLBMonitorUpdateMap

func (opts UpdateOpts) ToLBMonitorUpdateMap() (map[string]interface{}, error)

ToLBMonitorUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToLBMonitorUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

type UpdateResult struct {
	// contains filtered or unexported fields
}

UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a Monitor.

func Update

func Update(c *golangsdk.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update is an operation which modifies the attributes of the specified monitor.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Monitor, error)

Extract is a function that accepts a result and extracts a monitor.

Directories

Path Synopsis
monitors unit tests
monitors unit tests

Jump to

Keyboard shortcuts

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