Documentation
¶
Overview ¶
Package nodes provides information and interaction with the nodes through the OpenStack Clustering service.
Example to Create a Node
opts := nodes.CreateOpts{
ClusterID: "e395be1e-8d8e-43bb-bd6c-943eccf76a6d",
Metadata: map[string]interface{}{},
Name: "node-e395be1e-002",
ProfileID: "d8a48377-f6a3-4af4-bbbb-6e8bcaa0cbc0",
Role: "",
}
node, err := nodes.Create(serviceClient, opts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("node", node)
Example to List Nodes
listOpts := nodes.ListOpts{
Name: "testnode",
}
allPages, err := nodes.List(serviceClient, listOpts).AllPages()
if err != nil {
panic(err)
}
allNodes, err := nodes.ExtractNodes(allPages)
if err != nil {
panic(err)
}
for _, node := range allNodes {
fmt.Printf("%+v\n", node)
}
Example to Update a Node
opts := nodes.UpdateOpts{
Name: "new-node-name",
}
nodeID := "82fe28e0-9fcb-42ca-a2fa-6eb7dddd75a1"
node, err := nodes.Update(serviceClient, nodeID, opts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", node)
Example to Delete a Node
nodeID := "6dc6d336e3fc4c0a951b5698cd1236ee"
err := nodes.Delete(serviceClient, nodeID).ExtractErr()
if err != nil {
panic(err)
}
Example to Get a Node
nodeID := "node123"
node, err := nodes.Get(serviceClient, nodeID).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", node)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List instructs OpenStack to provide a list of nodes.
Types ¶
type CreateOpts ¶
type CreateOpts struct {
Role string `json:"role,omitempty"`
ProfileID string `json:"profile_id" required:"true"`
ClusterID string `json:"cluster_id,omitempty"`
Name string `json:"name" required:"true"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
CreateOpts represents options used to create a Node.
func (CreateOpts) ToNodeCreateMap ¶
func (opts CreateOpts) ToNodeCreateMap() (map[string]interface{}, error)
ToNodeCreateMap constructs 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 result of a Create operation. Call its Extract method to intepret it as a Node.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create requests the creation of a new node.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult is the result from a Delete operation. Call ExtractErr method to determine if the call succeeded or failed.
func Delete ¶
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult)
Delete deletes the specified node.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the result of a Get operation. Call its Extract method to interpret it as a Node.
func Get ¶
func Get(client *gophercloud.ServiceClient, id string) (r GetResult)
Get makes a request against senlin to get a details of a node type
type ListOpts ¶
type ListOpts struct {
Limit int `q:"limit"`
Marker string `q:"marker"`
Sort string `q:"sort"`
GlobalProject *bool `q:"global_project"`
ClusterID string `q:"cluster_id"`
Name string `q:"name"`
Status string `q:"status"`
}
ListOpts represents options used to list nodes.
func (ListOpts) ToNodeListQuery ¶
ToNodeListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parmeters to the List request.
type Node ¶
type Node struct {
ClusterID string `json:"cluster_id"`
CreatedAt time.Time `json:"-"`
Data map[string]interface{} `json:"data"`
Dependents map[string]interface{} `json:"dependents"`
Domain string `json:"domain"`
ID string `json:"id"`
Index int `json:"index"`
InitAt time.Time `json:"-"`
Metadata map[string]interface{} `json:"metadata"`
Name string `json:"name"`
PhysicalID string `json:"physical_id"`
ProfileID string `json:"profile_id"`
ProfileName string `json:"profile_name"`
Project string `json:"project"`
Role string `json:"role"`
Status string `json:"status"`
StatusReason string `json:"status_reason"`
UpdatedAt time.Time `json:"-"`
User string `json:"user"`
}
Node represents an OpenStack clustering node.
func ExtractNodes ¶
func ExtractNodes(r pagination.Page) ([]Node, error)
ExtractNodes returns a slice of Nodes from the List operation.
func (*Node) UnmarshalJSON ¶
type NodePage ¶
type NodePage struct {
pagination.LinkedPageBase
}
NodePage contains a single page of all nodes from a List call.
type UpdateOpts ¶
type UpdateOpts struct {
Name string `json:"name,omitempty"`
ProfileID string `json:"profile_id,omitempty"`
Role string `json:"role,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
UpdateOpts represents options used to update a Node.
func (UpdateOpts) ToNodeUpdateMap ¶
func (opts UpdateOpts) ToNodeUpdateMap() (map[string]interface{}, error)
ToClusterUpdateMap constructs a request body from UpdateOpts.
type UpdateOptsBuilder ¶
UpdateOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult is the result of an Update operation. Call its Extract method to interpet it as a Node.
func Update ¶
func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update requests the update of a node.