github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/cce/v3/nodes/doc.go (about)

     1  /*
     2  Package nodes enables management and retrieval of nodes
     3  CCE service.
     4  
     5  Example to List nodes
     6  
     7      clusterID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
     8  
     9  	listNodes := nodes.ListOpts{}
    10      allNodes, err := nodes.List(client,clusterID).ExtractNode(listNodes)
    11  
    12  	if err != nil {
    13  		panic(err)
    14  	}
    15  
    16  	for _, node := range allNodes {
    17  		fmt.Printf("%+v\n", node)
    18  	}
    19  
    20  Example to Create a node
    21  
    22      createOpts := nodes.CreateOpts{Kind:"Node",
    23  	   					   ApiVersion:"v3",
    24  	   					   Metadata:nodes.CreateMetaData{Name:"node_1"},
    25  	   					   Spec:nodes.Spec{Flavor:"s1.medium",
    26  	   					                   Az:"az1.dc1",
    27  	   					                   Login:nodes.LoginSpec{"myKeypair"},
    28  	   					                   Count:1,
    29  	   					                   RootVolume:nodes.VolumeSpec{Size:10,VolumeType:"SATA"},
    30  	   					                   DataVolumes:[]nodes.VolumeSpec{{Size:10,VolumeType:"SATA"}},
    31  								},
    32  		}
    33   	node,err := nodes.Create(client,clusterID,createOpts).Extract()
    34  	if err != nil {
    35  		panic(err)
    36  	}
    37  
    38  Example to Update a cluster
    39  
    40      clusterID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
    41  
    42  	nodeID := "3c8e5957-649f-477b-9e5b-f1f75b21c011"
    43  
    44  	updateOpts := nodes.UpdateOpts{Metadata:nodes.UpdateMetadata{Name:"node_1"}}
    45  	node,err := nodes.Update(client,clusterID,nodeID,updateOpts).Extract()
    46  	if err != nil {
    47  		panic(err)
    48  	}
    49  
    50  Example to Delete a cluster
    51  
    52  	clusterID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
    53  
    54  	nodeID := "3c8e5957-649f-477b-9e5b-f1f75b21c011"
    55  
    56  	err := nodes.Delete(client,clusterID,nodeID).Extract()
    57  	if err != nil {
    58  		panic(err)
    59  	}
    60  */
    61  
    62  package nodes