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

     1  package nodes
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/openstack/common/tags"
     6  )
     7  
     8  //Describes the Node Structure of cluster
     9  type ListNode struct {
    10  	// API type, fixed value "List"
    11  	Kind string `json:"kind"`
    12  	// API version, fixed value "v3"
    13  	Apiversion string `json:"apiVersion"`
    14  	// all Clusters
    15  	Nodes []Nodes `json:"items"`
    16  }
    17  
    18  // Individual nodes of the cluster
    19  type Nodes struct {
    20  	//  API type, fixed value " Host "
    21  	Kind string `json:"kind"`
    22  	// API version, fixed value v3
    23  	Apiversion string `json:"apiVersion"`
    24  	// Node metadata
    25  	Metadata Metadata `json:"metadata"`
    26  	// Node detailed parameters
    27  	Spec Spec `json:"spec"`
    28  	// Node status information
    29  	Status Status `json:"status"`
    30  }
    31  
    32  // Metadata required to create a node
    33  type Metadata struct {
    34  	//Node name
    35  	Name string `json:"name"`
    36  	//Node ID
    37  	Id string `json:"uid"`
    38  	// Node tag, key value pair format
    39  	Labels map[string]string `json:"labels,omitempty"`
    40  	//Node annotation, keyvalue pair format
    41  	Annotations map[string]string `json:"annotations,omitempty"`
    42  }
    43  
    44  // Spec describes Nodes specification
    45  type Spec struct {
    46  	// Node specifications
    47  	Flavor string `json:"flavor" required:"true"`
    48  	// The value of the available partition name
    49  	Az string `json:"az" required:"true"`
    50  	// The OS of the node
    51  	Os string `json:"os,omitempty"`
    52  	// ID of the dedicated host to which nodes will be scheduled
    53  	DedicatedHostID string `json:"dedicatedHostId,omitempty"`
    54  	// Node login parameters
    55  	Login LoginSpec `json:"login" required:"true"`
    56  	// System disk parameter of the node
    57  	RootVolume VolumeSpec `json:"rootVolume" required:"true"`
    58  	// The data disk parameter of the node must currently be a disk
    59  	DataVolumes []VolumeSpec `json:"dataVolumes" required:"true"`
    60  	// Elastic IP parameters of the node
    61  	PublicIP PublicIPSpec `json:"publicIP,omitempty"`
    62  	// The billing mode of the node: the value is 0 (on demand)
    63  	BillingMode int `json:"billingMode,omitempty"`
    64  	// Number of nodes when creating in batch
    65  	Count int `json:"count" required:"true"`
    66  	// The node nic spec
    67  	NodeNicSpec NodeNicSpec `json:"nodeNicSpec,omitempty"`
    68  	// Extended parameter
    69  	ExtendParam map[string]interface{} `json:"extendParam,omitempty"`
    70  	// UUID of an ECS group
    71  	EcsGroupID string `json:"ecsGroupId,omitempty"`
    72  	// Tag of a VM, key value pair format
    73  	UserTags []tags.ResourceTag `json:"userTags,omitempty"`
    74  	// Tag of a Kubernetes node, key value pair format
    75  	K8sTags map[string]string `json:"k8sTags,omitempty"`
    76  	// The runtime spec
    77  	RunTime *RunTimeSpec `json:"runtime,omitempty"`
    78  	// taints to created nodes to configure anti-affinity
    79  	Taints []TaintSpec `json:"taints,omitempty"`
    80  }
    81  
    82  // Gives the Nic spec of the node
    83  type NodeNicSpec struct {
    84  	// The primary Nic of the Node
    85  	PrimaryNic PrimaryNic `json:"primaryNic,omitempty"`
    86  }
    87  
    88  // Gives the Primary Nic of the node
    89  type PrimaryNic struct {
    90  	// The Subnet ID of the primary Nic
    91  	SubnetId string `json:"subnetId,omitempty"`
    92  	// Fixed ips of the primary Nic
    93  	FixedIps []string `json:"fixedIps,omitempty"`
    94  }
    95  
    96  // TaintSpec to created nodes to configure anti-affinity
    97  type TaintSpec struct {
    98  	Key   string `json:"key" required:"true"`
    99  	Value string `json:"value" required:"true"`
   100  	// Available options are NoSchedule, PreferNoSchedule, and NoExecute
   101  	Effect string `json:"effect" required:"true"`
   102  }
   103  
   104  // Gives the current status of the node
   105  type Status struct {
   106  	// The state of the Node
   107  	Phase string `json:"phase"`
   108  	// The virtual machine ID of the node in the ECS
   109  	ServerID string `json:"ServerID"`
   110  	// Elastic IP of the node
   111  	PublicIP string `json:"PublicIP"`
   112  	//Private IP of the node
   113  	PrivateIP string `json:"privateIP"`
   114  	// The ID of the Job that is operating asynchronously in the Node
   115  	JobID string `json:"jobID"`
   116  	// Reasons for the Node to become current
   117  	Reason string `json:"reason"`
   118  	// Details of the node transitioning to the current state
   119  	Message string `json:"message"`
   120  	//The status of each component in the Node
   121  	Conditions Conditions `json:"conditions"`
   122  }
   123  
   124  type LoginSpec struct {
   125  	// Select the key pair name when logging in by key pair mode
   126  	SshKey string `json:"sshKey,omitempty"`
   127  	// Select the user/password when logging in
   128  	UserPassword UserPassword `json:"userPassword,omitempty"`
   129  }
   130  
   131  type UserPassword struct {
   132  	Username string `json:"username" required:"true"`
   133  	Password string `json:"password" required:"true"`
   134  }
   135  
   136  type VolumeSpec struct {
   137  	// Disk size in GB
   138  	Size int `json:"size" required:"true"`
   139  	// Disk type
   140  	VolumeType string `json:"volumetype" required:"true"`
   141  	//hw:passthrough
   142  	HwPassthrough bool `json:"hw:passthrough,omitempty"`
   143  	// Disk extension parameter
   144  	ExtendParam map[string]interface{} `json:"extendParam,omitempty"`
   145  }
   146  
   147  type PublicIPSpec struct {
   148  	// List of existing elastic IP IDs
   149  	Ids []string `json:"ids,omitempty"`
   150  	// The number of elastic IPs to be dynamically created
   151  	Count int `json:"count,omitempty"`
   152  	// Elastic IP parameters
   153  	Eip EipSpec `json:"eip,omitempty"`
   154  }
   155  
   156  type EipSpec struct {
   157  	// The value of the iptype keyword
   158  	IpType string `json:"iptype,omitempty"`
   159  	// Elastic IP bandwidth parameters
   160  	Bandwidth BandwidthOpts `json:"bandwidth,omitempty"`
   161  }
   162  
   163  type RunTimeSpec struct {
   164  	// the name of runtime: docker or containerd
   165  	Name string `json:"name,omitempty"`
   166  }
   167  
   168  type BandwidthOpts struct {
   169  	ChargeMode string `json:"chargemode,omitempty"`
   170  	Size       int    `json:"size,omitempty"`
   171  	ShareType  string `json:"sharetype,omitempty"`
   172  }
   173  
   174  type Conditions struct {
   175  	//The type of component
   176  	Type string `json:"type"`
   177  	//The state of the component
   178  	Status string `json:"status"`
   179  	//The reason that the component becomes current
   180  	Reason string `json:"reason"`
   181  }
   182  
   183  // Describes the Job Structure
   184  type Job struct {
   185  	// API type, fixed value "Job"
   186  	Kind string `json:"kind"`
   187  	// API version, fixed value "v3"
   188  	Apiversion string `json:"apiVersion"`
   189  	// Node metadata
   190  	Metadata JobMetadata `json:"metadata"`
   191  	// Node detailed parameters
   192  	Spec JobSpec `json:"spec"`
   193  	//Node status information
   194  	Status JobStatus `json:"status"`
   195  }
   196  
   197  type JobMetadata struct {
   198  	// ID of the job
   199  	ID string `json:"uid"`
   200  }
   201  
   202  type JobSpec struct {
   203  	// Type of job
   204  	Type string `json:"type"`
   205  	// ID of the cluster where the job is located
   206  	ClusterID string `json:"clusterUID"`
   207  	// ID of the IaaS resource for the job operation
   208  	ResourceID string `json:"resourceID"`
   209  	// The name of the IaaS resource for the job operation
   210  	ResourceName string `json:"resourceName"`
   211  	// List of child jobs
   212  	SubJobs []Job `json:"subJobs"`
   213  	// ID of the parent job
   214  	OwnerJob string `json:"ownerJob"`
   215  }
   216  
   217  type JobStatus struct {
   218  	// Job status
   219  	Phase string `json:"phase"`
   220  	// The reason why the job becomes the current state
   221  	Reason string `json:"reason"`
   222  	// The job becomes the current state details
   223  	Message string `json:"message"`
   224  }
   225  
   226  type AddNodeResponse struct {
   227  	JobID string `json:"jobid"`
   228  }
   229  
   230  func (r commonResult) ExtractAddNode() (*AddNodeResponse, error) {
   231  	var s AddNodeResponse
   232  	err := r.ExtractInto(&s)
   233  	return &s, err
   234  }
   235  
   236  type commonResult struct {
   237  	golangsdk.Result
   238  }
   239  
   240  // Extract is a function that accepts a result and extracts a node.
   241  func (r commonResult) Extract() (*Nodes, error) {
   242  	var s Nodes
   243  	err := r.ExtractInto(&s)
   244  	return &s, err
   245  }
   246  
   247  // ExtractNode is a function that accepts a ListOpts struct, which allows you to filter and sort
   248  // the returned collection for greater efficiency.
   249  func (r commonResult) ExtractNode() ([]Nodes, error) {
   250  	var s ListNode
   251  	err := r.ExtractInto(&s)
   252  	if err != nil {
   253  		return nil, err
   254  	}
   255  	return s.Nodes, nil
   256  }
   257  
   258  // ExtractJob is a function that accepts a result and extracts a job.
   259  func (r commonResult) ExtractJob() (*Job, error) {
   260  	var s Job
   261  	err := r.ExtractInto(&s)
   262  	return &s, err
   263  }
   264  
   265  // ListResult represents the result of a list operation. Call its ExtractNode
   266  // method to interpret it as a Nodes.
   267  type ListResult struct {
   268  	commonResult
   269  }
   270  
   271  // CreateResult represents the result of a create operation. Call its Extract
   272  // method to interpret it as a Node.
   273  type CreateResult struct {
   274  	commonResult
   275  }
   276  
   277  type AddResult struct {
   278  	commonResult
   279  }
   280  
   281  // GetResult represents the result of a get operation. Call its Extract
   282  // method to interpret it as a Node.
   283  type GetResult struct {
   284  	commonResult
   285  }
   286  
   287  // UpdateResult represents the result of an update operation. Call its Extract
   288  // method to interpret it as a Node.
   289  type UpdateResult struct {
   290  	commonResult
   291  }
   292  
   293  // DeleteResult represents the result of a delete operation. Call its ExtractErr
   294  // method to determine if the request succeeded or failed.
   295  type DeleteResult struct {
   296  	golangsdk.ErrResult
   297  }