github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/mrs/v1/cluster/ListHosts.go (about)

     1  package cluster
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/openstack"
     7  )
     8  
     9  type ListHostsOpts struct {
    10  	// Cluster ID
    11  	ClusterId string
    12  	// Maximum number of clusters displayed on a page
    13  	// Value range: [1-2147483646].
    14  	// The default value is 10.
    15  	PageSize string `q:"pageSize,omitempty"`
    16  	// Current page number
    17  	// The default value is 1.
    18  	CurrentPage string `q:"currentPage,omitempty"`
    19  }
    20  
    21  func ListHosts(client *golangsdk.ServiceClient, opts ListHostsOpts) (*ListHostsResponse, error) {
    22  	url, err := golangsdk.NewURLBuilder().WithEndpoints("clusters", opts.ClusterId, "hosts").WithQueryParams(&opts).Build()
    23  	if err != nil {
    24  		return nil, err
    25  	}
    26  
    27  	// GET /v1.1/{project_id}/clusters/{cluster_id}/hosts
    28  	raw, err := client.Get(client.ServiceURL(url.String()), nil, openstack.StdRequestOpts())
    29  	if err != nil {
    30  		return nil, err
    31  	}
    32  
    33  	var res ListHostsResponse
    34  	err = extract.Into(raw.Body, &res)
    35  	return &res, err
    36  }
    37  
    38  type ListHostsResponse struct {
    39  	// Total number of hosts in a list
    40  	Total int `json:"total,omitempty"`
    41  	// Host parameters
    42  	Hosts []Hosts `json:"hosts,omitempty"`
    43  }
    44  
    45  type Hosts struct {
    46  	// VM ID
    47  	Id string `json:"id,omitempty"`
    48  	// VM IP address
    49  	Ip string `json:"ip,omitempty"`
    50  	// VM flavor ID
    51  	Flavor string `json:"flavor,omitempty"`
    52  	// VM type
    53  	// Currently, MasterNode, CoreNode, and TaskNode are supported.
    54  	Type string `json:"type,omitempty"`
    55  	// VM name
    56  	Name string `json:"name,omitempty"`
    57  	// Current VM state
    58  	Status string `json:"status,omitempty"`
    59  	// Memory
    60  	Mem string `json:"mem,omitempty"`
    61  	// Number of CPU cores
    62  	Cpu string `json:"cpu,omitempty"`
    63  	// OS disk capacity
    64  	RootVolumeSize string `json:"root_volume_size,omitempty"`
    65  	// Data disk type
    66  	DataVolumeType string `json:"data_volume_type,omitempty"`
    67  	// Data disk capacity
    68  	DataVolumeSize int `json:"data_volume_size,omitempty"`
    69  	// Number of data disks
    70  	DataVolumeCount int `json:"data_volume_count,omitempty"`
    71  }