agents

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package agents provides the ability to retrieve and manage Agents through the Neutron API.

Example of Listing Agents

listOpts := agents.ListOpts{
    AgentType: "Open vSwitch agent",
}

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

allAgents, err := agents.ExtractAgents(allPages)
if err != nil {
    panic(err)
}

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

Example to Get an Agent

agentID = "76af7b1f-d61b-4526-94f7-d2e14e2698df"
agent, err := agents.Get(networkClient, agentID).Extract()
if err != nil {
    panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

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

Default policy settings return only the agents owned by the project of the user submitting the request, unless the user has the administrative role.

Types

type Agent

type Agent struct {
	// ID is the id of the agent.
	ID string `json:"id"`

	// AdminStateUp is an administrative state of the agent.
	AdminStateUp bool `json:"admin_state_up"`

	// AgentType is a type of the agent.
	AgentType string `json:"agent_type"`

	// Alive indicates whether agent is alive or not.
	Alive bool `json:"alive"`

	// AvailabilityZone is a zone of the agent.
	AvailabilityZone string `json:"availability_zone"`

	// Binary is an executable binary of the agent.
	Binary string `json:"binary"`

	// Configurations is a configuration specific key/value pairs that are
	// determined by the agent binary and type.
	Configurations map[string]interface{} `json:"configurations"`

	// CreatedAt is a creation timestamp.
	CreatedAt time.Time `json:"-"`

	// StartedAt is a starting timestamp.
	StartedAt time.Time `json:"-"`

	// HeartbeatTimestamp is a last heartbeat timestamp.
	HeartbeatTimestamp time.Time `json:"-"`

	// Description contains agent description.
	Description string `json:"description"`

	// Host is a hostname of the agent system.
	Host string `json:"host"`

	// Topic contains name of AMQP topic.
	Topic string `json:"topic"`
}

Agent represents a Neutron agent.

func ExtractAgents

func ExtractAgents(r pagination.Page) ([]Agent, error)

ExtractAgents interprets the results of a single page from a List() API call, producing a slice of Agents structs.

func (*Agent) UnmarshalJSON

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

UnmarshalJSON helps to convert the timestamps into the time.Time type.

type AgentPage

type AgentPage struct {
	pagination.LinkedPageBase
}

AgentPage stores a single page of Agents from a List() API call.

func (AgentPage) IsEmpty

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

IsEmpty determines whether or not a AgentPage is empty.

func (AgentPage) NextPageURL

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

NextPageURL is invoked when a paginated collection of agent 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 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 an Agent.

func Get

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

Get retrieves a specific agent based on its ID.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts an agent resource.

type ListOpts

type ListOpts struct {
	ID               string `json:"id"`
	AgentType        string `json:"agent_type"`
	Alive            *bool  `json:"alive"`
	AvailabilityZone string `json:"availability_zone"`
	Binary           string `json:"binary"`
	Description      string `json:"description"`
	Host             string `json:"host"`
	Topic            string `json:"topic"`
	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 Neutron API. Filtering is achieved by passing in struct field values that map to the agent attributes you want to see returned. SortKey allows you to sort by a particular agent attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for the pagination.

func (ListOpts) ToAgentListQuery

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

ToAgentListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

Directories

Path Synopsis
agents unit tests
agents unit tests

Jump to

Keyboard shortcuts

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