github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/aggregates/doc.go (about) 1 /* 2 Package aggregates manages information about the host aggregates in the 3 OpenStack cloud. 4 5 Example of Create Aggregate 6 7 opts := aggregates.CreateOpts{ 8 Name: "name", 9 AvailabilityZone: "london", 10 } 11 12 aggregate, err := aggregates.Create(computeClient, opts).Extract() 13 if err != nil { 14 panic(err) 15 } 16 fmt.Printf("%+v\n", aggregate) 17 18 Example of Show Aggregate Details 19 20 aggregateID := 42 21 aggregate, err := aggregates.Get(computeClient, aggregateID).Extract() 22 if err != nil { 23 panic(err) 24 } 25 fmt.Printf("%+v\n", aggregate) 26 27 Example of Delete Aggregate 28 29 aggregateID := 32 30 err := aggregates.Delete(computeClient, aggregateID).ExtractErr() 31 if err != nil { 32 panic(err) 33 } 34 35 Example of Update Aggregate 36 37 aggregateID := 42 38 opts := aggregates.UpdateOpts{ 39 Name: "new_name", 40 AvailabilityZone: "nova2", 41 } 42 43 aggregate, err := aggregates.Update(computeClient, aggregateID, opts).Extract() 44 if err != nil { 45 panic(err) 46 } 47 fmt.Printf("%+v\n", aggregate) 48 49 Example of Retrieving list of all aggregates 50 51 allPages, err := aggregates.List(computeClient).AllPages() 52 if err != nil { 53 panic(err) 54 } 55 56 allAggregates, err := aggregates.ExtractAggregates(allPages) 57 if err != nil { 58 panic(err) 59 } 60 61 for _, aggregate := range allAggregates { 62 fmt.Printf("%+v\n", aggregate) 63 } 64 65 Example of Add Host 66 67 aggregateID := 22 68 opts := aggregates.AddHostOpts{ 69 Host: "newhost-cmp1", 70 } 71 72 aggregate, err := aggregates.AddHost(computeClient, aggregateID, opts).Extract() 73 if err != nil { 74 panic(err) 75 } 76 fmt.Printf("%+v\n", aggregate) 77 78 Example of Remove Host 79 80 aggregateID := 22 81 opts := aggregates.RemoveHostOpts{ 82 Host: "newhost-cmp1", 83 } 84 85 aggregate, err := aggregates.RemoveHost(computeClient, aggregateID, opts).Extract() 86 if err != nil { 87 panic(err) 88 } 89 fmt.Printf("%+v\n", aggregate) 90 91 Example of Create or Update Metadata 92 93 aggregateID := 22 94 opts := aggregates.SetMetadata{ 95 Metadata: map[string]string{"key": "value"}, 96 } 97 98 aggregate, err := aggregates.SetMetadata(computeClient, aggregateID, opts).Extract() 99 if err != nil { 100 panic(err) 101 } 102 fmt.Printf("%+v\n", aggregate) 103 104 */ 105 package aggregates