github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cce/v3/nodes/results.go (about) 1 package nodes 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 "github.com/chnsz/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 // Disk initialization configuration management parameters 61 // If omit, disk management is performed according to the DockerLVMConfigOverride parameter in extendParam 62 Storage *StorageSpec `json:"storage,omitempty"` 63 // Elastic IP parameters of the node 64 PublicIP PublicIPSpec `json:"publicIP,omitempty"` 65 // The billing mode of the node: the value is 0 (on demand) 66 BillingMode int `json:"billingMode,omitempty"` 67 // Number of nodes when creating in batch 68 Count int `json:"count" required:"true"` 69 // The node nic spec 70 NodeNicSpec NodeNicSpec `json:"nodeNicSpec,omitempty"` 71 // Extended parameter 72 ExtendParam map[string]interface{} `json:"extendParam,omitempty"` 73 // UUID of an ECS group 74 EcsGroupID string `json:"ecsGroupId,omitempty"` 75 // Tag of a VM, key value pair format 76 UserTags []tags.ResourceTag `json:"userTags,omitempty"` 77 // Tag of a Kubernetes node, key value pair format 78 K8sTags map[string]string `json:"k8sTags,omitempty"` 79 // The runtime spec 80 RunTime *RunTimeSpec `json:"runtime,omitempty"` 81 // taints to created nodes to configure anti-affinity 82 Taints []TaintSpec `json:"taints,omitempty"` 83 // The name of the created partition 84 Partition string `json:"partition,omitempty"` 85 // The initialized conditions 86 InitializedConditions []string `json:"initializedConditions,omitempty"` 87 } 88 89 // Gives the Nic spec of the node 90 type NodeNicSpec struct { 91 // The primary Nic of the Node 92 PrimaryNic PrimaryNic `json:"primaryNic,omitempty"` 93 // The extension Nics of the Node 94 ExtNics []ExtNic `json:"extNics,omitempty"` 95 } 96 97 // Gives the Primary Nic of the node 98 type PrimaryNic struct { 99 // The Subnet ID of the primary Nic 100 SubnetId string `json:"subnetId,omitempty"` 101 // Fixed ips of the primary Nic 102 FixedIps []string `json:"fixedIps,omitempty"` 103 } 104 105 type ExtNic struct { 106 // The Subnet ID of the extension Nic 107 SubnetId string `json:"subnetId,omitempty"` 108 // Fixed ips of the extension Nic 109 FixedIps []string `json:"fixedIps,omitempty"` 110 // IP block of the extension Nic 111 IPBlock string `json:"ipBlock,omitempty"` 112 } 113 114 // TaintSpec to created nodes to configure anti-affinity 115 type TaintSpec struct { 116 Key string `json:"key" required:"true"` 117 Value string `json:"value,omitempty"` 118 // Available options are NoSchedule, PreferNoSchedule, and NoExecute 119 Effect string `json:"effect" required:"true"` 120 } 121 122 // Gives the current status of the node 123 type Status struct { 124 // The state of the Node 125 Phase string `json:"phase"` 126 // The virtual machine ID of the node in the ECS 127 ServerID string `json:"ServerID"` 128 // Elastic IP of the node 129 PublicIP string `json:"PublicIP"` 130 //Private IP of the node 131 PrivateIP string `json:"privateIP"` 132 // The ID of the Job that is operating asynchronously in the Node 133 JobID string `json:"jobID"` 134 // Reasons for the Node to become current 135 Reason string `json:"reason"` 136 // Details of the node transitioning to the current state 137 Message string `json:"message"` 138 //The status of each component in the Node 139 Conditions Conditions `json:"conditions"` 140 } 141 142 type LoginSpec struct { 143 // Select the key pair name when logging in by key pair mode 144 SshKey string `json:"sshKey,omitempty"` 145 // Select the user/password when logging in 146 UserPassword UserPassword `json:"userPassword,omitempty"` 147 } 148 149 type UserPassword struct { 150 Username string `json:"username" required:"true"` 151 Password string `json:"password" required:"true"` 152 } 153 154 type VolumeSpec struct { 155 // Disk size in GB 156 Size int `json:"size" required:"true"` 157 // Disk type 158 VolumeType string `json:"volumetype" required:"true"` 159 //hw:passthrough 160 HwPassthrough bool `json:"hw:passthrough,omitempty"` 161 // Disk extension parameter 162 ExtendParam map[string]interface{} `json:"extendParam,omitempty"` 163 // Disk encryption information. 164 Metadata *VolumeMetadata `json:"metadata,omitempty"` 165 // DSS pool ID 166 ClusterID string `json:"cluster_id,omitempty"` 167 // DSS pool type, fixed to dss 168 ClusterType string `json:"cluster_type,omitempty"` 169 } 170 171 type VolumeMetadata struct { 172 // Whether the EVS disk is encrypted. 173 // The value 0 indicates that the EVS disk is not encrypted, 174 // and the value 1 indicates that the EVS disk is encrypted. 175 SystemEncrypted string `json:"__system__encrypted,omitempty"` 176 // CMK ID, which indicates encryption in metadata. 177 SystemCmkid string `json:"__system__cmkid,omitempty"` 178 } 179 180 type PublicIPSpec struct { 181 // List of existing elastic IP IDs 182 Ids []string `json:"ids,omitempty"` 183 // The number of elastic IPs to be dynamically created 184 Count int `json:"count,omitempty"` 185 // Elastic IP parameters 186 Eip EipSpec `json:"eip,omitempty"` 187 } 188 189 type EipSpec struct { 190 // The value of the iptype keyword 191 IpType string `json:"iptype,omitempty"` 192 // Elastic IP bandwidth parameters 193 Bandwidth BandwidthOpts `json:"bandwidth,omitempty"` 194 } 195 196 type RunTimeSpec struct { 197 // the name of runtime: docker or containerd 198 Name string `json:"name,omitempty"` 199 } 200 201 type BandwidthOpts struct { 202 ChargeMode string `json:"chargemode,omitempty"` 203 Size int `json:"size,omitempty"` 204 ShareType string `json:"sharetype,omitempty"` 205 } 206 207 type Conditions struct { 208 //The type of component 209 Type string `json:"type"` 210 //The state of the component 211 Status string `json:"status"` 212 //The reason that the component becomes current 213 Reason string `json:"reason"` 214 } 215 216 type StorageSpec struct { 217 // Disk selection. Matched disks are managed according to matchLabels and storageType 218 StorageSelectors []StorageSelectorsSpec `json:"storageSelectors" required:"true"` 219 // A storage group consists of multiple storage devices. It is used to divide storage space 220 StorageGroups []StorageGroupsSpec `json:"storageGroups" required:"true"` 221 } 222 223 type StorageSelectorsSpec struct { 224 // Selector name, used as the index of selectorNames in storageGroup, the name of each selector must be unique 225 Name string `json:"name" required:"true"` 226 // Specifies the storage type. Currently, only evs and local are supported 227 // The local storage does not support disk selection. All local disks will form a VG 228 // Therefore, only one storageSelector of the local type is allowed 229 StorageType string `json:"storageType" required:"true"` 230 // Matching field of an EVS volume 231 MatchLabels MatchLabelsSpec `json:"matchLabels,omitempty"` 232 } 233 234 type MatchLabelsSpec struct { 235 // Matched disk size if left unspecified, the disk size is not limited 236 Size string `json:"size,omitempty"` 237 // EVS disk type 238 VolumeType string `json:"volumeType,omitempty"` 239 // Disk encryption identifier 240 // 0 indicates that the disk is not encrypted, and 1 indicates that the disk is encrypted 241 MetadataEncrypted string `json:"metadataEncrypted,omitempty"` 242 // Customer master key ID of an encrypted disk 243 MetadataCmkid string `json:"metadataCmkid,omitempty"` 244 // Number of disks to be selected, if left blank, all disks of this type are selected 245 Count string `json:"count,omitempty"` 246 } 247 248 type StorageGroupsSpec struct { 249 // Name of a virtual storage group, each group name must be unique 250 Name string `json:"name" required:"true"` 251 // Storage space for Kubernetes and runtime components 252 // Only one group can be set to true, default value is false 253 CceManaged bool `json:"cceManaged,omitempty"` 254 // This parameter corresponds to name in storageSelectors 255 // A group can match multiple selectors, but a selector can match only one group 256 SelectorNames []string `json:"selectorNames" required:"true"` 257 // Detailed management of space configuration in a group 258 VirtualSpaces []VirtualSpacesSpec `json:"virtualSpaces" required:"true"` 259 } 260 261 type VirtualSpacesSpec struct { 262 // virtualSpace name, currently, only kubernetes, runtime, and user are supported 263 // kubernetes and user require lvmConfig to be configured, runtime requires runtimeConfig to be configured 264 Name string `json:"name" required:"true"` 265 // Size of a virtual space, only an integer percentage is supported, example: 90% 266 // Note that the total percentage of all virtual spaces in a group cannot exceed 100% 267 Size string `json:"size" required:"true"` 268 // LVM configurations, applicable to kubernetes and user spaces 269 // One virtual space supports only one config 270 LVMConfig *LVMConfigSpec `json:"lvmConfig,omitempty"` 271 // runtime configurations, applicable to the runtime space 272 // One virtual space supports only one config 273 RuntimeConfig *RuntimeConfigSpec `json:"runtimeConfig,omitempty"` 274 } 275 276 type LVMConfigSpec struct { 277 // LVM write mode, values can be linear and striped 278 LvType string `json:"lvType" required:"true"` 279 // Path to which the disk is attached, this parameter takes effect only in user configuration 280 // The value is an absolute path 281 Path string `json:"path,omitempty"` 282 } 283 284 type RuntimeConfigSpec struct { 285 // LVM write mode, values can be linear and striped 286 LvType string `json:"lvType" required:"true"` 287 } 288 289 // Describes the Job Structure 290 type Job struct { 291 // API type, fixed value "Job" 292 Kind string `json:"kind"` 293 // API version, fixed value "v3" 294 Apiversion string `json:"apiVersion"` 295 // Node metadata 296 Metadata JobMetadata `json:"metadata"` 297 // Node detailed parameters 298 Spec JobSpec `json:"spec"` 299 //Node status information 300 Status JobStatus `json:"status"` 301 } 302 303 type JobMetadata struct { 304 // ID of the job 305 ID string `json:"uid"` 306 } 307 308 type JobSpec struct { 309 // Type of job 310 Type string `json:"type"` 311 // ID of the cluster where the job is located 312 ClusterID string `json:"clusterUID"` 313 // ID of the IaaS resource for the job operation 314 ResourceID string `json:"resourceID"` 315 // The name of the IaaS resource for the job operation 316 ResourceName string `json:"resourceName"` 317 // List of child jobs 318 SubJobs []Job `json:"subJobs"` 319 // ID of the parent job 320 OwnerJob string `json:"ownerJob"` 321 } 322 323 type JobStatus struct { 324 // Job status 325 Phase string `json:"phase"` 326 // The reason why the job becomes the current state 327 Reason string `json:"reason"` 328 // The job becomes the current state details 329 Message string `json:"message"` 330 } 331 332 type AddNodeResponse struct { 333 JobID string `json:"jobid"` 334 } 335 336 func (r commonResult) ExtractAddNode() (*AddNodeResponse, error) { 337 var s AddNodeResponse 338 err := r.ExtractInto(&s) 339 return &s, err 340 } 341 342 type commonResult struct { 343 golangsdk.Result 344 } 345 346 // Extract is a function that accepts a result and extracts a node. 347 func (r commonResult) Extract() (*Nodes, error) { 348 var s Nodes 349 err := r.ExtractInto(&s) 350 return &s, err 351 } 352 353 // ExtractNode is a function that accepts a ListOpts struct, which allows you to filter and sort 354 // the returned collection for greater efficiency. 355 func (r commonResult) ExtractNode() ([]Nodes, error) { 356 var s ListNode 357 err := r.ExtractInto(&s) 358 if err != nil { 359 return nil, err 360 } 361 return s.Nodes, nil 362 } 363 364 // ExtractJob is a function that accepts a result and extracts a job. 365 func (r commonResult) ExtractJob() (*Job, error) { 366 var s Job 367 err := r.ExtractInto(&s) 368 return &s, err 369 } 370 371 // ListResult represents the result of a list operation. Call its ExtractNode 372 // method to interpret it as a Nodes. 373 type ListResult struct { 374 commonResult 375 } 376 377 // CreateResult represents the result of a create operation. Call its Extract 378 // method to interpret it as a Node. 379 type CreateResult struct { 380 commonResult 381 } 382 383 type AddResult struct { 384 commonResult 385 } 386 387 // GetResult represents the result of a get operation. Call its Extract 388 // method to interpret it as a Node. 389 type GetResult struct { 390 commonResult 391 } 392 393 // UpdateResult represents the result of an update operation. Call its Extract 394 // method to interpret it as a Node. 395 type UpdateResult struct { 396 commonResult 397 } 398 399 // DeleteResult represents the result of a delete operation. Call its ExtractErr 400 // method to determine if the request succeeded or failed. 401 type DeleteResult struct { 402 golangsdk.ErrResult 403 }