floatingips

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2021 License: Apache-2.0 Imports: 4 Imported by: 328

Documentation

Overview

Package floatingips provides the ability to manage floating ips through the Nova API.

This API has been deprecated and will be removed from a future release of the Nova API service.

For environements that support this extension, this package can be used regardless of if either Neutron or nova-network is used as the cloud's network service.

Example to List Floating IPs

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

allFloatingIPs, err := floatingips.ExtractFloatingIPs(allPages)
if err != nil {
	panic(err)
}

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

Example to Create a Floating IP

createOpts := floatingips.CreateOpts{
	Pool: "nova",
}

fip, err := floatingips.Create(computeClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Floating IP

err := floatingips.Delete(computeClient, "floatingip-id").ExtractErr()
if err != nil {
	panic(err)
}

Example to Associate a Floating IP With a Server

associateOpts := floatingips.AssociateOpts{
	FloatingIP: "10.10.10.2",
}

err := floatingips.AssociateInstance(computeClient, "server-id", associateOpts).ExtractErr()
if err != nil {
	panic(err)
}

Example to Disassociate a Floating IP From a Server

disassociateOpts := floatingips.DisassociateOpts{
	FloatingIP: "10.10.10.2",
}

err := floatingips.DisassociateInstance(computeClient, "server-id", disassociateOpts).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List returns a Pager that allows you to iterate over a collection of FloatingIPs.

Types

type AssociateOpts

type AssociateOpts struct {
	// FloatingIP is the Floating IP to associate with an instance.
	FloatingIP string `json:"address" required:"true"`

	// FixedIP is an optional fixed IP address of the server.
	FixedIP string `json:"fixed_address,omitempty"`
}

AssociateOpts specifies the required information to associate a Floating IP with an instance

func (AssociateOpts) ToFloatingIPAssociateMap

func (opts AssociateOpts) ToFloatingIPAssociateMap() (map[string]interface{}, error)

ToFloatingIPAssociateMap constructs a request body from AssociateOpts.

type AssociateOptsBuilder

type AssociateOptsBuilder interface {
	ToFloatingIPAssociateMap() (map[string]interface{}, error)
}

AssociateOptsBuilder allows extensions to add additional parameters to the Associate request.

type AssociateResult

type AssociateResult struct {
	gophercloud.ErrResult
}

AssociateResult is the response from a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.

func AssociateInstance

func AssociateInstance(client *gophercloud.ServiceClient, serverID string, opts AssociateOptsBuilder) (r AssociateResult)

AssociateInstance pairs an allocated Floating IP with a server.

type CreateOpts

type CreateOpts struct {
	// Pool is the pool of Floating IPs to allocate one from.
	Pool string `json:"pool" required:"true"`
}

CreateOpts specifies a Floating IP allocation request.

func (CreateOpts) ToFloatingIPCreateMap

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

ToFloatingIPCreateMap constructs a request body from CreateOpts.

type CreateOptsBuilder

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

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

type CreateResult

type CreateResult struct {
	FloatingIPResult
}

CreateResult is the response from a Create operation. Call its Extract method to interpret it as a FloatingIP.

func Create

func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create requests the creation of a new Floating IP.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the response from a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.

func Delete

func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult)

Delete requests the deletion of a previous allocated Floating IP.

type DisassociateOpts

type DisassociateOpts struct {
	FloatingIP string `json:"address" required:"true"`
}

DisassociateOpts specifies the required information to disassociate a Floating IP with a server.

func (DisassociateOpts) ToFloatingIPDisassociateMap

func (opts DisassociateOpts) ToFloatingIPDisassociateMap() (map[string]interface{}, error)

ToFloatingIPDisassociateMap constructs a request body from DisassociateOpts.

type DisassociateOptsBuilder

type DisassociateOptsBuilder interface {
	ToFloatingIPDisassociateMap() (map[string]interface{}, error)
}

DisassociateOptsBuilder allows extensions to add additional parameters to the Disassociate request.

type DisassociateResult

type DisassociateResult struct {
	gophercloud.ErrResult
}

DisassociateResult is the response from a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.

func DisassociateInstance

func DisassociateInstance(client *gophercloud.ServiceClient, serverID string, opts DisassociateOptsBuilder) (r DisassociateResult)

DisassociateInstance decouples an allocated Floating IP from an instance

type FloatingIP

type FloatingIP struct {
	// ID is a unique ID of the Floating IP
	ID string `json:"-"`

	// FixedIP is a specific IP on the server to pair the Floating IP with.
	FixedIP string `json:"fixed_ip,omitempty"`

	// InstanceID is the ID of the server that is using the Floating IP.
	InstanceID string `json:"instance_id"`

	// IP is the actual Floating IP.
	IP string `json:"ip"`

	// Pool is the pool of Floating IPs that this Floating IP belongs to.
	Pool string `json:"pool"`
}

A FloatingIP is an IP that can be associated with a server.

func ExtractFloatingIPs

func ExtractFloatingIPs(r pagination.Page) ([]FloatingIP, error)

ExtractFloatingIPs interprets a page of results as a slice of FloatingIPs.

func (*FloatingIP) UnmarshalJSON

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

type FloatingIPPage

type FloatingIPPage struct {
	pagination.SinglePageBase
}

FloatingIPPage stores a single page of FloatingIPs from a List call.

func (FloatingIPPage) IsEmpty

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

IsEmpty determines whether or not a FloatingIPsPage is empty.

type FloatingIPResult

type FloatingIPResult struct {
	gophercloud.Result
}

FloatingIPResult is the raw result from a FloatingIP request.

func (FloatingIPResult) Extract

func (r FloatingIPResult) Extract() (*FloatingIP, error)

Extract is a method that attempts to interpret any FloatingIP resource response as a FloatingIP struct.

type GetResult

type GetResult struct {
	FloatingIPResult
}

GetResult is the response from a Get operation. Call its Extract method to interpret it as a FloatingIP.

func Get

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

Get returns data about a previously created Floating IP.

Directories

Path Synopsis
floatingips unit tests
floatingips unit tests

Jump to

Keyboard shortcuts

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