github.com/gophercloud/gophercloud@v1.11.0/openstack/clustering/v1/nodes/doc.go (about)

     1  /*
     2  Package nodes provides information and interaction with the nodes through
     3  the OpenStack Clustering service.
     4  
     5  Example to Create a Node
     6  
     7  	createOpts := nodes.CreateOpts{
     8  		ClusterID: "e395be1e-8d8e-43bb-bd6c-943eccf76a6d",
     9  		Metadata:  map[string]interface{}{},
    10  		Name:      "node-e395be1e-002",
    11  		ProfileID: "d8a48377-f6a3-4af4-bbbb-6e8bcaa0cbc0",
    12  		Role:      "",
    13  	}
    14  
    15  	node, err := nodes.Create(serviceClient, createOpts).Extract()
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  
    20  	fmt.Printf("node", node)
    21  
    22  Example to List Nodes
    23  
    24  	listOpts := nodes.ListOpts{
    25  		Name: "testnode",
    26  	}
    27  
    28  	allPages, err := nodes.List(serviceClient, listOpts).AllPages()
    29  	if err != nil {
    30  		panic(err)
    31  	}
    32  
    33  	allNodes, err := nodes.ExtractNodes(allPages)
    34  	if err != nil {
    35  		panic(err)
    36  	}
    37  
    38  	for _, node := range allNodes {
    39  		fmt.Printf("%+v\n", node)
    40  	}
    41  
    42  Example to Update a Node
    43  
    44  	opts := nodes.UpdateOpts{
    45  		Name: "new-node-name",
    46  	}
    47  
    48  	nodeID := "82fe28e0-9fcb-42ca-a2fa-6eb7dddd75a1"
    49  	node, err := nodes.Update(serviceClient, nodeID, opts).Extract()
    50  	if err != nil {
    51  		panic(err)
    52  	}
    53  
    54  	fmt.Printf("%+v\n", node)
    55  
    56  Example to Delete a Node
    57  
    58  	nodeID := "6dc6d336e3fc4c0a951b5698cd1236ee"
    59  	err := nodes.Delete(serviceClient, nodeID).ExtractErr()
    60  	if err != nil {
    61  		panic(err)
    62  	}
    63  
    64  Example to Get a Node
    65  
    66  	nodeID := "node123"
    67  	node, err := nodes.Get(serviceClient, nodeID).Extract()
    68  	if err != nil {
    69  		panic(err)
    70  	}
    71  
    72  	fmt.Printf("%+v\n", node)
    73  
    74  Example to Perform an Operation on a Node
    75  
    76  	serviceClient.Microversion = "1.4"
    77  	nodeID := "node123"
    78  	operationOpts := nodes.OperationOpts{
    79  		Operation: nodes.RebootOperation,
    80  		Params:    nodes.OperationParams{"type": "SOFT"},
    81  	}
    82  	actionID, err := nodes.Ops(serviceClient, nodeID, operationOpts).Extract()
    83  	if err != nil {
    84  		panic(err)
    85  	}
    86  
    87  Example to Recover a Node
    88  
    89  	nodeID := "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
    90  	check := true
    91  	recoverOpts := nodes.RecoverOpts{
    92  		Operation:     nodes.RebuildRecovery,
    93  		Check:         &check,
    94  	}
    95  	actionID, err := nodes.Recover(computeClient, nodeID, recoverOpts).Extract()
    96  	if err != nil {
    97  		panic(err)
    98  	}
    99  	fmt.Println("action=", actionID)
   100  
   101  Example to Check a Node
   102  
   103  	nodeID := "b7b870e3-d3c5-4a93-b9d7-846c53b2c2da"
   104  	actionID, err := nodes.Check(serviceClient, nodeID).Extract()
   105  	if err != nil {
   106  		panic(err)
   107  	}
   108  	fmt.Println("action=", actionID)
   109  */
   110  package nodes