github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cce/v3/nodes/results.go (about)

     1  package nodes
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags"
     6  )
     7  
     8  // ListNode 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  // 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, key/value 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 ExtendParam `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  	// taints to created nodes to configure anti-affinity
    77  	Taints []TaintSpec `json:"taints,omitempty"`
    78  	// Container runtime. The default value is docker.
    79  	Runtime RuntimeSpec `json:"runtime,omitempty"`
    80  }
    81  
    82  type RuntimeSpec struct {
    83  	// Container runtime. The default value is docker.
    84  	// Enumeration values: docker, containerd
    85  	Name string `json:"name,omitempty"`
    86  }
    87  
    88  // NodeNicSpec spec of the node
    89  type NodeNicSpec struct {
    90  	// The primary Nic of the Node
    91  	PrimaryNic PrimaryNic `json:"primaryNic,omitempty"`
    92  }
    93  
    94  // PrimaryNic of the node
    95  type PrimaryNic struct {
    96  	// The Subnet ID of the primary Nic
    97  	SubnetId string `json:"subnetId,omitempty"`
    98  
    99  	// FixedIPs define list of private IPs
   100  	FixedIPs []string `json:"fixedIps,omitempty"`
   101  }
   102  
   103  // TaintSpec to created nodes to configure anti-affinity
   104  type TaintSpec struct {
   105  	Key   string `json:"key" required:"true"`
   106  	Value string `json:"value" required:"true"`
   107  	// Available options are NoSchedule, PreferNoSchedule, and NoExecute
   108  	Effect string `json:"effect" required:"true"`
   109  }
   110  
   111  // Status gives the current status of the node
   112  type Status struct {
   113  	// The state of the Node
   114  	Phase string `json:"phase"`
   115  	// The virtual machine ID of the node in the ECS
   116  	ServerID string `json:"ServerID"`
   117  	// Elastic IP of the node
   118  	PublicIP string `json:"PublicIP"`
   119  	// Private IP of the node
   120  	PrivateIP string `json:"privateIP"`
   121  	// The ID of the Job that is operating asynchronously in the Node
   122  	JobID string `json:"jobID"`
   123  	// Reasons for the Node to become current
   124  	Reason string `json:"reason"`
   125  	// Details of the node transitioning to the current state
   126  	Message string `json:"message"`
   127  	// The status of each component in the Node
   128  	Conditions Conditions `json:"conditions"`
   129  }
   130  
   131  type LoginSpec struct {
   132  	// Select the key pair name when logging in by key pair mode
   133  	SshKey string `json:"sshKey,omitempty"`
   134  	// Select the user/password when logging in
   135  	UserPassword UserPassword `json:"userPassword,omitempty"`
   136  }
   137  
   138  type UserPassword struct {
   139  	Username string `json:"username" required:"true"`
   140  	Password string `json:"password" required:"true"`
   141  }
   142  
   143  type VolumeSpec struct {
   144  	// Disk Size in GB
   145  	Size int `json:"size" required:"true"`
   146  	// Disk VolumeType
   147  	VolumeType string `json:"volumetype" required:"true"`
   148  	// Metadata contains data disk encryption information
   149  	Metadata map[string]interface{} `json:"metadata,omitempty"`
   150  	// Disk extension parameter
   151  	ExtendParam map[string]interface{} `json:"extendParam,omitempty"`
   152  }
   153  
   154  type ExtendParam struct {
   155  	// Node charging mode, 0 is on-demand charging.
   156  	ChargingMode int `json:"chargingMode,omitempty"`
   157  	// Specifies the IAM agency name.
   158  	AgencyName string `json:"agency_name,omitempty"`
   159  	// Classification of cloud server specifications.
   160  	EcsPerformanceType string `json:"ecs:performancetype,omitempty"`
   161  	// Order ID, mandatory when the node payment type is the automatic payment package period type.
   162  	OrderID string `json:"orderID,omitempty"`
   163  	// The Product ID.
   164  	ProductID string `json:"productID,omitempty"`
   165  	// The Public Key.
   166  	PublicKey string `json:"publicKey,omitempty"`
   167  	// The maximum number of instances a node is allowed to create.
   168  	MaxPods int `json:"maxPods,omitempty"`
   169  	// Script required before the installation.
   170  	PreInstall string `json:"alpha.cce/preInstall,omitempty"`
   171  	// Script required after the installation.
   172  	PostInstall string `json:"alpha.cce/postInstall,omitempty"`
   173  	// Whether auto-renew is enabled.
   174  	IsAutoRenew *bool `json:"isAutoRenew,omitempty"`
   175  	// Whether to deduct fees automatically.
   176  	IsAutoPay *bool `json:"isAutoPay,omitempty"`
   177  	// Available disk space of a single Docker container on the node using the device mapper.
   178  	DockerBaseSize int `json:"dockerBaseSize,omitempty"`
   179  	// ConfigMap of the Docker data disk.
   180  	DockerLVMConfigOverride string `json:"DockerLVMConfigOverride,omitempty"`
   181  }
   182  
   183  type PublicIPSpec struct {
   184  	// List of existing elastic IP IDs
   185  	Ids []string `json:"ids,omitempty"`
   186  	// The number of elastic IPs to be dynamically created
   187  	Count int `json:"count,omitempty"`
   188  	// Elastic IP parameters
   189  	Eip EipSpec `json:"eip,omitempty"`
   190  }
   191  
   192  type EipSpec struct {
   193  	// The value of the iptype keyword
   194  	IpType string `json:"iptype,omitempty"`
   195  	// Elastic IP bandwidth parameters
   196  	Bandwidth BandwidthOpts `json:"bandwidth,omitempty"`
   197  }
   198  
   199  type BandwidthOpts struct {
   200  	ChargeMode string `json:"chargemode,omitempty"`
   201  	Size       int    `json:"size,omitempty"`
   202  	ShareType  string `json:"sharetype,omitempty"`
   203  }
   204  
   205  type Conditions struct {
   206  	// The type of component
   207  	Type string `json:"type"`
   208  	// The state of the component
   209  	Status string `json:"status"`
   210  	// The reason that the component becomes current
   211  	Reason string `json:"reason"`
   212  }
   213  
   214  // Job Structure
   215  type Job struct {
   216  	// API type, fixed value "Job"
   217  	Kind string `json:"kind"`
   218  	// API version, fixed value "v3"
   219  	Apiversion string `json:"apiVersion"`
   220  	// Node metadata
   221  	Metadata JobMetadata `json:"metadata"`
   222  	// Node detailed parameters
   223  	Spec JobSpec `json:"spec"`
   224  	// Node status information
   225  	Status JobStatus `json:"status"`
   226  }
   227  
   228  type JobMetadata struct {
   229  	// ID of the job
   230  	ID string `json:"uid"`
   231  }
   232  
   233  type JobSpec struct {
   234  	// Type of job
   235  	Type string `json:"type"`
   236  	// ID of the cluster where the job is located
   237  	ClusterID string `json:"clusterUID"`
   238  	// ID of the IaaS resource for the job operation
   239  	ResourceID string `json:"resourceID"`
   240  	// The name of the IaaS resource for the job operation
   241  	ResourceName string `json:"resourceName"`
   242  	// List of child jobs
   243  	SubJobs []Job `json:"subJobs"`
   244  	// ID of the parent job
   245  	OwnerJob string `json:"ownerJob"`
   246  }
   247  
   248  type JobStatus struct {
   249  	// Job status
   250  	Phase string `json:"phase"`
   251  	// The reason why the job becomes the current state
   252  	Reason string `json:"reason"`
   253  	// The job becomes the current state details
   254  	Message string `json:"message"`
   255  }
   256  
   257  type commonResult struct {
   258  	golangsdk.Result
   259  }
   260  
   261  // Extract is a function that accepts a result and extracts a node.
   262  func (r commonResult) Extract() (*Nodes, error) {
   263  	var s Nodes
   264  	err := r.ExtractInto(&s)
   265  	return &s, err
   266  }
   267  
   268  // ExtractNode is a function that accepts a ListOpts struct, which allows you to filter and sort
   269  // the returned collection for greater efficiency.
   270  func (r commonResult) ExtractNode() ([]Nodes, error) {
   271  	var s ListNode
   272  	err := r.ExtractInto(&s)
   273  	if err != nil {
   274  		return nil, err
   275  	}
   276  	return s.Nodes, nil
   277  }
   278  
   279  // ExtractJob is a function that accepts a result and extracts a job.
   280  func (r commonResult) ExtractJob() (*Job, error) {
   281  	var s Job
   282  	err := r.ExtractInto(&s)
   283  	return &s, err
   284  }
   285  
   286  // ListResult represents the result of a list operation. Call its ExtractNode
   287  // method to interpret it as a Nodes.
   288  type ListResult struct {
   289  	commonResult
   290  }
   291  
   292  // CreateResult represents the result of a create operation. Call its Extract
   293  // method to interpret it as a Node.
   294  type CreateResult struct {
   295  	commonResult
   296  }
   297  
   298  // GetResult represents the result of a get operation. Call its Extract
   299  // method to interpret it as a Node.
   300  type GetResult struct {
   301  	commonResult
   302  }
   303  
   304  // UpdateResult represents the result of an update operation. Call its Extract
   305  // method to interpret it as a Node.
   306  type UpdateResult struct {
   307  	commonResult
   308  }
   309  
   310  // DeleteResult represents the result of a delete operation. Call its ExtractErr
   311  // method to determine if the request succeeded or failed.
   312  type DeleteResult struct {
   313  	golangsdk.ErrResult
   314  }