Documentation ¶
Overview ¶
Package subnets contains functionality for working with Neutron subnet resources. A subnet represents an IP address block that can be used to assign IP addresses to virtual instances. Each subnet must have a CIDR and must be associated with a network. IPs can either be selected from the whole subnet CIDR or from allocation pools specified by the user.
A subnet can also have a gateway, a list of DNS name servers, and host routes. This information is pushed to instances whose interfaces are associated with the subnet.
Index ¶
- Constants
- func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type AdminState
- type AllocationPool
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type HostRoute
- type ListOpts
- type ListOptsBuilder
- type Subnet
- type SubnetPage
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
const ( IPv4 = 4 IPv6 = 6 )
Valid IP types
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List returns a Pager which allows you to iterate over a collection of subnets. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.
Default policy settings return only those subnets that are owned by the tenant who submits the request, unless the request is submitted by a user with administrative rights.
Types ¶
type AdminState ¶
type AdminState *bool
AdminState gives users a solid type to work with for create and update operations. It is recommended that users use the `Up` and `Down` enums.
var ( Up AdminState = &iTrue Down AdminState = &iFalse )
Convenience vars for AdminStateUp values.
type AllocationPool ¶
AllocationPool represents a sub-range of cidr available for dynamic allocation to ports, e.g. {Start: "10.0.0.2", End: "10.0.0.254"}
type CreateOpts ¶
type CreateOpts struct { // Required NetworkID string CIDR string // Optional Name string TenantID string AllocationPools []AllocationPool GatewayIP string IPVersion int EnableDHCP *bool DNSNameservers []string HostRoutes []HostRoute }
CreateOpts represents the attributes used when creating a new subnet.
func (CreateOpts) ToSubnetCreateMap ¶
func (opts CreateOpts) ToSubnetCreateMap() (map[string]interface{}, error)
ToSubnetCreateMap casts a CreateOpts struct to a map.
type CreateOptsBuilder ¶
CreateOptsBuilder is the interface options structs have to satisfy in order to be used in the main Create operation in this package. Since many extensions decorate or modify the common logic, it is useful for them to satisfy a basic interface in order for them to be used.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult represents the result of a create operation.
func Create ¶
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult
Create accepts a CreateOpts struct and creates a new subnet using the values provided. You must remember to provide a valid NetworkID, CIDR and IP version.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult represents the result of a delete operation.
func Delete ¶
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult
Delete accepts a unique ID and deletes the subnet associated with it.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult represents the result of a get operation.
func Get ¶
func Get(c *gophercloud.ServiceClient, id string) GetResult
Get retrieves a specific subnet based on its unique ID.
type HostRoute ¶
type HostRoute struct { DestinationCIDR string `json:"destination"` NextHop string `json:"nexthop"` }
HostRoute represents a route that should be used by devices with IPs from a subnet (not including local subnet route).
type ListOpts ¶
type ListOpts struct { Name string `q:"name"` EnableDHCP *bool `q:"enable_dhcp"` NetworkID string `q:"network_id"` TenantID string `q:"tenant_id"` IPVersion int `q:"ip_version"` GatewayIP string `q:"gateway_ip"` CIDR string `q:"cidr"` ID string `q:"id"` 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 subnet attributes you want to see returned. SortKey allows you to sort by a particular subnet attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.
func (ListOpts) ToSubnetListQuery ¶
ToSubnetListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type Subnet ¶
type Subnet struct { // UUID representing the subnet ID string `mapstructure:"id" json:"id"` // UUID of the parent network NetworkID string `mapstructure:"network_id" json:"network_id"` // Human-readable name for the subnet. Might not be unique. Name string `mapstructure:"name" json:"name"` // IP version, either `4' or `6' IPVersion int `mapstructure:"ip_version" json:"ip_version"` // CIDR representing IP range for this subnet, based on IP version CIDR string `mapstructure:"cidr" json:"cidr"` // Default gateway used by devices in this subnet GatewayIP string `mapstructure:"gateway_ip" json:"gateway_ip"` // DNS name servers used by hosts in this subnet. DNSNameservers []string `mapstructure:"dns_nameservers" json:"dns_nameservers"` // Sub-ranges of CIDR available for dynamic allocation to ports. See AllocationPool. AllocationPools []AllocationPool `mapstructure:"allocation_pools" json:"allocation_pools"` // Routes that should be used by devices with IPs from this subnet (not including local subnet route). HostRoutes []HostRoute `mapstructure:"host_routes" json:"host_routes"` // Specifies whether DHCP is enabled for this subnet or not. EnableDHCP bool `mapstructure:"enable_dhcp" json:"enable_dhcp"` // Owner of network. Only admin users can specify a tenant_id other than its own. TenantID string `mapstructure:"tenant_id" json:"tenant_id"` }
Subnet represents a subnet. See package documentation for a top-level description of what this is.
func ExtractSubnets ¶
func ExtractSubnets(page pagination.Page) ([]Subnet, error)
ExtractSubnets accepts a Page struct, specifically a SubnetPage struct, and extracts the elements into a slice of Subnet structs. In other words, a generic collection is mapped into a relevant slice.
type SubnetPage ¶
type SubnetPage struct {
pagination.LinkedPageBase
}
SubnetPage is the page returned by a pager when traversing over a collection of subnets.
func (SubnetPage) IsEmpty ¶
func (p SubnetPage) IsEmpty() (bool, error)
IsEmpty checks whether a SubnetPage struct is empty.
func (SubnetPage) NextPageURL ¶
func (p SubnetPage) NextPageURL() (string, error)
NextPageURL is invoked when a paginated collection of subnets 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 UpdateOpts ¶
type UpdateOpts struct { Name string GatewayIP string DNSNameservers []string HostRoutes []HostRoute EnableDHCP *bool }
UpdateOpts represents the attributes used when updating an existing subnet.
func (UpdateOpts) ToSubnetUpdateMap ¶
func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error)
ToSubnetUpdateMap casts an UpdateOpts struct to a map.
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.
func Update ¶
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult
Update accepts a UpdateOpts struct and updates an existing subnet using the values provided.