Documentation
¶
Overview ¶
Package trunks provides the ability to retrieve and manage trunks through the Neutron API. Trunks allow you to multiplex multiple ports traffic on a single port. For example, you could have a compute instance port be the parent port of a trunk and inside the VM run workloads using other ports, without the need of plugging those ports.
Example of a new empty Trunk creation
iTrue := true
createOpts := trunks.CreateOpts{
Name: "gophertrunk",
Description: "Trunk created by gophercloud",
AdminStateUp: &iTrue,
PortID: "a6f0560c-b7a8-401f-bf6e-d0a5c851ae10",
}
trunk, err := trunks.Create(networkClient, trunkOpts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", trunk)
Example of a new Trunk creation with 2 subports
iTrue := true
createOpts := trunks.CreateOpts{
Name: "gophertrunk",
Description: "Trunk created by gophercloud",
AdminStateUp: &iTrue,
PortID: "a6f0560c-b7a8-401f-bf6e-d0a5c851ae10",
Subports: []trunks.Subport{
{
SegmentationID: 1,
SegmentationType: "vlan",
PortID: "bf4efcc0-b1c7-4674-81f0-31f58a33420a",
},
{
SegmentationID: 10,
SegmentationType: "vlan",
PortID: "2cf671b9-02b3-4121-9e85-e0af3548d112",
},
},
}
trunk, err := trunks.Create(client, trunkOpts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", trunk)
Example of deleting a Trunk
trunkID := "c36e7f2e-0c53-4742-8696-aee77c9df159"
err := trunks.Delete(networkClient, trunkID).ExtractErr()
if err != nil {
panic(err)
}
Example of listing Trunks
listOpts := trunks.ListOpts{}
allPages, err := trunks.List(networkClient, listOpts).AllPages()
if err != nil {
panic(err)
}
allTrunks, err := trunks.ExtractTrunks(allPages)
if err != nil {
panic(err)
}
for _, trunk := range allTrunks {
fmt.Printf("%+v\n", trunk)
}
Example of getting a Trunk
trunkID = "52d8d124-3dc9-4563-9fef-bad3187ecf2d"
trunk, err := trunks.Get(networkClient, trunkID).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", trunk)
Index ¶
Constants ¶
This section is empty.
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 trunks. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.
Default policy settings return only those trunks that are owned by the tenant who submits the request, unless the request is submitted by a user with administrative rights.
Types ¶
type CreateOpts ¶
type CreateOpts struct {
TenantID string `json:"tenant_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
PortID string `json:"port_id" required:"true"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
AdminStateUp *bool `json:"admin_state_up,omitempty"`
Subports []Subport `json:"sub_ports"`
}
CreateOpts represents the attributes used when creating a new trunk.
func (CreateOpts) ToTrunkCreateMap ¶
func (opts CreateOpts) ToTrunkCreateMap() (map[string]interface{}, error)
ToTrunkCreateMap builds a request body from CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult is the response from a Create operation. Call its Extract method to interpret it as a Trunk.
func Create ¶
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult is the response from a Delete operation. Call its ExtractErr to determine if the request succeeded or failed.
func Delete ¶
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult)
Delete accepts a unique ID and deletes the trunk associated with it.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the response from a Get operation. Call its Extract method to interpret it as a Trunk.
func Get ¶
func Get(c *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves a specific trunk based on its unique ID.
type ListOpts ¶
type ListOpts struct {
AdminStateUp *bool `q:"admin_state_up"`
Description string `q:"description"`
ID string `q:"id"`
Name string `q:"name"`
PortID string `q:"port_id"`
RevisionNumber string `q:"revision_number"`
Status string `q:"status"`
TenantID string `q:"tenant_id"`
ProjectID string `q:"project_id"`
SortDir string `q:"sort_dir"`
SortKey string `q:"sort_key"`
Tags string `q:"tags"`
TagsAny string `q:"tags-any"`
NotTags string `q:"not-tags"`
NotTagsAny string `q:"not-tags-any"`
}
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 trunk attributes you want to see returned. SortKey allows you to sort by a particular trunk attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.
func (ListOpts) ToTrunkListQuery ¶
ToTrunkListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type Trunk ¶
type Trunk struct {
// Indicates whether the trunk is currently operational. Possible values include
// `ACTIVE', `DOWN', `BUILD', 'DEGRADED' or `ERROR'.
Status string `json:"status"`
// A list of ports associated with the trunk
Subports []Subport `json:"sub_ports"`
// Human-readable name for the trunk. Might not be unique.
Name string `json:"name,omitempty"`
// The administrative state of the trunk. If false (down), the trunk does not
// forward packets.
AdminStateUp bool `json:"admin_state_up,omitempty"`
// ProjectID is the project owner of the trunk.
ProjectID string `json:"project_id"`
// TenantID is the project owner of the trunk.
TenantID string `json:"tenant_id"`
// The date and time when the resource was created.
CreatedAt time.Time `json:"created_at"`
// The date and time when the resource was updated,
// if the resource has not been updated, this field will show as null.
UpdatedAt time.Time `json:"updated_at"`
RevisionNumber int `json:"revision_number"`
// UUID of the trunk's parent port
PortID string `json:"port_id"`
// UUID for the trunk resource
ID string `json:"id"`
// Display description.
Description string `json:"description"`
// A list of tags associated with the trunk
Tags []string `json:"tags,omitempty"`
}
func ExtractTrunks ¶
func ExtractTrunks(page pagination.Page) ([]Trunk, error)
type TrunkPage ¶
type TrunkPage struct {
pagination.LinkedPageBase
}
TrunkPage is the page returned by a pager when traversing a collection of trunk resources.