github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/diskconfig/doc.go (about)

     1  /*
     2  Package diskconfig provides information and interaction with the Disk Config
     3  extension that works with the OpenStack Compute service.
     4  
     5  Example of Obtaining the Disk Config of a Server
     6  
     7  	type ServerWithDiskConfig {
     8  		servers.Server
     9  		diskconfig.ServerDiskConfigExt
    10  	}
    11  
    12  	var allServers []ServerWithDiskConfig
    13  
    14  	allPages, err := servers.List(client, nil).AllPages()
    15  	if err != nil {
    16  		panic("Unable to retrieve servers: %s", err)
    17  	}
    18  
    19  	err = servers.ExtractServersInto(allPages, &allServers)
    20  	if err != nil {
    21  		panic("Unable to extract servers: %s", err)
    22  	}
    23  
    24  	for _, server := range allServers {
    25  		fmt.Println(server.DiskConfig)
    26  	}
    27  
    28  Example of Creating a Server with Disk Config
    29  
    30  	serverCreateOpts := servers.CreateOpts{
    31  		Name:      "server_name",
    32  		ImageRef:  "image-uuid",
    33  		FlavorRef: "flavor-uuid",
    34  	}
    35  
    36  	createOpts := diskconfig.CreateOptsExt{
    37  		CreateOptsBuilder: serverCreateOpts,
    38  		DiskConfig:        diskconfig.Manual,
    39  	}
    40  
    41  	server, err := servers.Create(computeClient, createOpts).Extract()
    42  	if err != nil {
    43  		panic("Unable to create server: %s", err)
    44  	}
    45  */
    46  package diskconfig