github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/deh/v1/hosts/doc.go (about)

     1  package hosts
     2  
     3  /*
     4  Package hosts enables management and retrieval of Dedicated Hosts
     5  
     6  Example to Allocate Hosts
     7  	opts := hosts.AllocateOpts{Name:"c2c-test",HostType:"h1",AvailabilityZone:"eu-de-02",AutoPlacement:"off",Quantity:1}
     8  	allocatedHosts ,err := hosts.Allocate(client,opts).Extract()
     9  	if err != nil {
    10  		panic(err)
    11  	}
    12  	fmt.Println(allocatedHosts)
    13  
    14  
    15  Example to Update Hosts
    16  	updateopts := hosts.UpdateOpts{Name:"NewName3",AutoPlacement:"on"}
    17  	update := hosts.Update(client,"8ea7381e-8d84-4f9f-a7ad-d32f1e1bb5b7",updateopts)
    18  		if err != nil {
    19  			panic(update.Err)
    20  		}
    21  	fmt.Println(update)
    22  
    23  Example to delete Hosts
    24  	delete := hosts.Delete(client,"94d94259-3734-4ad5-bc3b-5f9f3e96d5e8")
    25  	if err != nil {
    26  		panic(delete.Err)
    27  	}
    28  	fmt.Println(delete)
    29  
    30  Example to List Hosts
    31  	listdeh := hosts.ListOpts{}
    32  	alldehs, err := hosts.List(client,listdeh).AllPages()
    33  	if err != nil {
    34  		panic(err)
    35  	}
    36  
    37  	list,err:=hosts.ExtractHosts(alldehs)
    38  	if err != nil {
    39  		panic(err)
    40  	}
    41  	fmt.Println(list)
    42  
    43  Example to Get Host
    44  	result := hosts.Get(client, "66156a61-27c2-4169-936b-910dd9c73da3")
    45  	out, err := result.Extract()
    46  	fmt.Println(out)
    47  
    48  Example to List Servers
    49  	listOpts := hosts.ListServerOpts{}
    50  	allServers, err := hosts.ListServer(client, "671611d2-b45c-4648-9e78-06eb24522291",listOpts)
    51  	if err != nil {
    52  		panic(err)
    53  	}
    54  
    55  	for _, server := range allServers {
    56  		fmt.Printf("%+v\n", server)
    57  	}
    58  */