nodes

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

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)

Example to Perform an Operation on a Node

serviceClient.Microversion = "1.4"
nodeID := "node123"
operationOpts := nodes.OperationOpts{
	Operation: nodes.RebootOperation,
	Params:    nodes.OperationParams{"type": "SOFT"},
}
actionID, err := nodes.Ops(serviceClient, nodeID, operationOpts).Extract()
if err != nil {
	panic(err)
}

Example to Recover a Node

nodeID := "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
check := true
recoverOpts := nodes.RecoverOpts{
	Operation:     nodes.RebuildRecovery,
	Check:         &check,
}
actionID, err := nodes.Recover(computeClient, nodeID, recoverOpts).Extract()
if err != nil {
	panic(err)
}
fmt.Println("action=", actionID)

Example to Check a Node

nodeID := "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
actionID, err := nodes.Check(serviceClient, nodeID).Extract()
if err != nil {
	panic(err)
}
fmt.Println("action=", actionID)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List instructs OpenStack to provide a list of nodes.

Types

type ActionResult

type ActionResult struct {
	gophercloud.Result
}

ActionResult is the response of Senlin actions. Call its Extract method to obtain the Action ID of the action.

func Check

func Check(client *gophercloud.ServiceClient, id string) (r ActionResult)

func Ops

func Recover

func Recover(client *gophercloud.ServiceClient, id string, opts RecoverOpts) (r ActionResult)

func (ActionResult) Extract

func (r ActionResult) Extract() (string, error)

Extract interprets any Action result as an Action.

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

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

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.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Node, error)

Extract interprets any commonResult-based result as a 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

func (GetResult) Extract

func (r GetResult) Extract() (*Node, error)

Extract interprets any commonResult-based result as a Node.

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

func (opts ListOpts) ToNodeListQuery() (string, error)

ToNodeListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToNodeListQuery() (string, error)
}

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

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

type NodePage

type NodePage struct {
	pagination.LinkedPageBase
}

NodePage contains a single page of all nodes from a List call.

func (NodePage) IsEmpty

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

IsEmpty determines if a NodePage contains any results.

type OperationName

type OperationName string

OperationName represents valid values for node operation

const (
	// Nova Profile Op Names
	RebootOperation         OperationName = "reboot"
	RebuildOperation        OperationName = "rebuild"
	ChangePasswordOperation OperationName = "change_password"
	PauseOperation          OperationName = "pause"
	UnpauseOperation        OperationName = "unpause"
	SuspendOperation        OperationName = "suspend"
	ResumeOperation         OperationName = "resume"
	LockOperation           OperationName = "lock"
	UnlockOperation         OperationName = "unlock"
	StartOperation          OperationName = "start"
	StopOperation           OperationName = "stop"
	RescueOperation         OperationName = "rescue"
	UnrescueOperation       OperationName = "unrescue"
	EvacuateOperation       OperationName = "evacuate"

	// Heat Pofile Op Names
	AbandonOperation OperationName = "abandon"
)

type OperationOpts

type OperationOpts struct {
	Operation OperationName   `json:"operation" required:"true"`
	Params    OperationParams `json:"params,omitempty"`
}

OperationOpts represents options used to perform an operation on a node

func (OperationOpts) ToNodeOperationMap

func (opts OperationOpts) ToNodeOperationMap() (map[string]interface{}, error)

ToNodeOperationMap constructs a request body from OperationOpts.

type OperationOptsBuilder

type OperationOptsBuilder interface {
	ToNodeOperationMap() (map[string]interface{}, error)
}

OperationOptsBuilder allows extensions to add additional parameters to the Op request.

type OperationParams

type OperationParams map[string]interface{}

type RecoverAction

type RecoverAction string

RecoverAction represents valid values for recovering a node.

const (
	RebootRecovery  RecoverAction = "REBOOT"
	RebuildRecovery RecoverAction = "REBUILD"
	// RECREATE currently is NOT supported. See https://github.com/openstack/senlin/blob/b30b2b8496b2b8af243ccd5292f38aec7a95664f/senlin/profiles/base.py#L533
	RecreateRecovery RecoverAction = "RECREATE"
)

type RecoverOpts

type RecoverOpts struct {
	Operation RecoverAction `json:"operation,omitempty"`
	Check     *bool         `json:"check,omitempty"`
}

func (RecoverOpts) ToNodeRecoverMap

func (opts RecoverOpts) ToNodeRecoverMap() (map[string]interface{}, error)

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)

ToNodeUpdateMap constructs a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToNodeUpdateMap() (map[string]interface{}, error)
}

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.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Node, error)

Extract interprets any commonResult-based result as a Node.

Directories

Path Synopsis
clustering_nodes_v1
clustering_nodes_v1

Jump to

Keyboard shortcuts

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