Documentation ¶
Overview ¶
package floatingips enables management and retrieval of Floating IPs from the OpenStack Networking service.
Example to List Floating IPs
listOpts := floatingips.ListOpts{ FloatingNetworkID: "a6917946-38ab-4ffd-a55a-26c0980ce5ee", } allPages, err := floatingips.List(networkClient, listOpts).AllPages() if err != nil { panic(err) } allFIPs, err := floatingips.ExtractFloatingIPs(allPages) if err != nil { panic(err) } for _, fip := range allFIPs { fmt.Printf("%+v\n", fip) }
Example to Create a Floating IP
createOpts := floatingips.CreateOpts{ FloatingNetworkID: "a6917946-38ab-4ffd-a55a-26c0980ce5ee", } fip, err := floatingips.Create(networkingClient, createOpts).Extract() if err != nil { panic(err) }
Example to Update a Floating IP
fipID := "2f245a7b-796b-4f26-9cf9-9e82d248fda7" portID := "76d0a61b-b8e5-490c-9892-4cf674f2bec8" updateOpts := floatingips.UpdateOpts{ PortID: &portID, } fip, err := floatingips.Update(networkingClient, fipID, updateOpts).Extract() if err != nil { panic(err) }
Example to Disassociate a Floating IP with a Port
fipID := "2f245a7b-796b-4f26-9cf9-9e82d248fda7" updateOpts := floatingips.UpdateOpts{ PortID: nil, } fip, err := floatingips.Update(networkingClient, fipID, updateOpts).Extract() if err != nil { panic(err) }
Example to Delete a Floating IP
fipID := "2f245a7b-796b-4f26-9cf9-9e82d248fda7" err := floatingips.Delete(networkClient, fipID).ExtractErr() if err != nil { panic(err) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager
List returns a Pager which allows you to iterate over a collection of floating IP resources. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.
Types ¶
type CreateOpts ¶
type CreateOpts struct { FloatingNetworkID string `json:"floating_network_id" required:"true"` FloatingIP string `json:"floating_ip_address,omitempty"` PortID string `json:"port_id,omitempty"` FixedIP string `json:"fixed_ip_address,omitempty"` TenantID string `json:"tenant_id,omitempty"` }
CreateOpts contains all the values needed to create a new floating IP resource. The only required fields are FloatingNetworkID and PortID which refer to the external network and internal port respectively.
func (CreateOpts) ToFloatingIPCreateMap ¶
func (opts CreateOpts) ToFloatingIPCreateMap() (map[string]interface{}, error)
ToFloatingIPCreateMap allows CreateOpts to satisfy the CreateOptsBuilder interface
type CreateOptsBuilder ¶
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 FloatingIP.
func Create ¶
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create accepts a CreateOpts struct and uses the values provided to create a new floating IP resource. You can create floating IPs on external networks only. If you provide a FloatingNetworkID which refers to a network that is not external (i.e. its `router:external' attribute is False), the operation will fail and return a 400 error.
If you do not specify a FloatingIP address value, the operation will automatically allocate an available address for the new resource. If you do choose to specify one, it must fall within the subnet range for the external network - otherwise the operation returns a 400 error. If the FloatingIP address is already in use, the operation returns a 409 error code.
You can associate the new resource with an internal port by using the PortID field. If you specify a PortID that is not valid, the operation will fail and return 404 error code.
You must also configure an IP address for the port associated with the PortID you have provided - this is what the FixedIP refers to: an IP fixed to a port. Because a port might be associated with multiple IP addresses, you can use the FixedIP field to associate a particular IP address rather than have the API assume for you. If you specify an IP address that is not valid, the operation will fail and return a 400 error code. If the PortID and FixedIP are already associated with another resource, the operation will fail and returns a 409 error code.
func (CreateResult) Extract ¶
func (r CreateResult) Extract() (*FloatingIP, error)
Extract will extract a FloatingIP resource from a result.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult represents the result of an update operation. Call its ExtractErr method to determine if the request succeeded or failed.
func Delete ¶
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult)
Delete will permanently delete a particular floating IP resource. Please ensure this is what you want - you can also disassociate the IP from existing internal ports.
type FloatingIP ¶
type FloatingIP struct { // ID is the unique identifier for the floating IP instance. ID string `json:"id"` // FloatingNetworkID is the UUID of the external network where the floating // IP is to be created. FloatingNetworkID string `json:"floating_network_id"` // FloatingIP is the address of the floating IP on the external network. FloatingIP string `json:"floating_ip_address"` // PortID is the UUID of the port on an internal network that is associated // with the floating IP. PortID string `json:"port_id"` // FixedIP is the specific IP address of the internal port which should be // associated with the floating IP. FixedIP string `json:"fixed_ip_address"` // TenantID is the Owner of the floating IP. Only admin users can specify a // tenant identifier other than its own. TenantID string `json:"tenant_id"` // Status is the condition of the API resource. Status string `json:"status"` // RouterID is the ID of the router used for this floating IP. RouterID string `json:"router_id"` }
FloatingIP represents a floating IP resource. A floating IP is an external IP address that is mapped to an internal port and, optionally, a specific IP address on a private network. In other words, it enables access to an instance on a private network from an external network. For this reason, floating IPs can only be defined on networks where the `router:external' attribute (provided by the external network extension) is set to True.
func ExtractFloatingIPs ¶
func ExtractFloatingIPs(r pagination.Page) ([]FloatingIP, error)
ExtractFloatingIPs accepts a Page struct, specifically a FloatingIPPage struct, and extracts the elements into a slice of FloatingIP structs. In other words, a generic collection is mapped into a relevant slice.
type FloatingIPPage ¶
type FloatingIPPage struct {
pagination.LinkedPageBase
}
FloatingIPPage is the page returned by a pager when traversing over a collection of floating IPs.
func (FloatingIPPage) IsEmpty ¶
func (r FloatingIPPage) IsEmpty() (bool, error)
IsEmpty checks whether a FloatingIPPage struct is empty.
func (FloatingIPPage) NextPageURL ¶
func (r FloatingIPPage) NextPageURL() (string, error)
NextPageURL is invoked when a paginated collection of floating IPs 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 a FloatingIP.
func Get ¶
func Get(c *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves a particular floating IP resource based on its unique ID.
func (GetResult) Extract ¶
func (r GetResult) Extract() (*FloatingIP, error)
Extract will extract a FloatingIP resource from a result.
type ListOpts ¶
type ListOpts struct { ID string `q:"id"` FloatingNetworkID string `q:"floating_network_id"` PortID string `q:"port_id"` FixedIP string `q:"fixed_ip_address"` FloatingIP string `q:"floating_ip_address"` TenantID string `q:"tenant_id"` Limit int `q:"limit"` Marker string `q:"marker"` SortKey string `q:"sort_key"` SortDir string `q:"sort_dir"` RouterID string `q:"router_id"` Status string `q:"status"` }
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 UpdateOpts ¶
type UpdateOpts struct { // Specifies the port ID. PortID *string `json:"port_id"` // Specifies the private IP address of the associated port. FixedIP *string `json:"fixed_ip_address,omitempty"` }
UpdateOpts contains the values used when updating a floating IP resource. The only value that can be updated is which internal port the floating IP is linked to. To associate the floating IP with a new internal port, provide its ID. To disassociate the floating IP from all ports, provide an empty string.
func (UpdateOpts) ToFloatingIPUpdateMap ¶
func (opts UpdateOpts) ToFloatingIPUpdateMap() (map[string]interface{}, error)
ToFloatingIPUpdateMap allows UpdateOpts to satisfy the UpdateOptsBuilder interface
type UpdateOptsBuilder ¶
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 FloatingIP.
func Update ¶
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update allows floating IP resources to be updated. Currently, the only way to "update" a floating IP is to associate it with a new internal port, or disassociated it from all ports. See UpdateOpts for instructions of how to do this.
func (UpdateResult) Extract ¶
func (r UpdateResult) Extract() (*FloatingIP, error)
Extract will extract a FloatingIP resource from a result.