diff --git a/docs/resources/cce_node.md b/docs/resources/cce_node.md index 1b710a0836c..1e1a2f48c1a 100644 --- a/docs/resources/cce_node.md +++ b/docs/resources/cce_node.md @@ -132,6 +132,8 @@ The following arguments are supported: * `subnet_id` - (Optional, String, ForceNew) The ID of the subnet to which the NIC belongs. Changing this parameter will create a new resource. +* `fixed_ip` - (Optional, String, ForceNew) The fixed IP of the NIC. Changing this parameter will create a new resource. + * `eip_id` - (Optional, String, ForceNew) The ID of the EIP. Changing this parameter will create a new resource. @@ -157,6 +159,18 @@ The following arguments are supported: * `postinstall` - (Optional, String, ForceNew) Script required after installation. The input value can be a Base64 encoded string or not. Changing this parameter will create a new resource. +* `extend_param` - (Optional, Map, ForceNew) Extended parameter. Changing this parameter will create a new resource. Availiable keys : + + * `alpha.cce/NodeImageID` - This parameter is required when a custom image is used to create a BMS node. + * `dockerBaseSize` - The available disk space of a single docker container on the node in device mapper mode. + * `DockerLVMConfigOverride` - Docker data disk configurations. The following is an example default configuration: + + ```hcl + extend_param = { + DockerLVMConfigOverride = "dockerThinpool=vgpaas/90%VG;kubernetesLV=vgpaas/10%VG;diskType=evs;lvType=linear" + } + ``` + * `labels` - (Optional, Map, ForceNew) Tags of a Kubernetes node, key/value pair format. Changing this parameter will create a new resource. * `tags` - (Optional, Map) Tags of a VM node, key/value pair format. diff --git a/go.mod b/go.mod index 9eef7da21b5..36d3a14587a 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/hashicorp/errwrap v1.0.0 github.com/hashicorp/go-cleanhttp v0.5.1 github.com/hashicorp/terraform-plugin-sdk v1.13.0 - github.com/huaweicloud/golangsdk v0.0.0-20210223120349-95b96c64969c + github.com/huaweicloud/golangsdk v0.0.0-20210226030432-bcda8c57eb97 github.com/jen20/awspolicyequivalence v0.0.0-20170831201602-3d48364a137a github.com/mitchellh/go-homedir v1.1.0 github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa // indirect diff --git a/go.sum b/go.sum index 6b9587524a6..d7b3504b824 100644 --- a/go.sum +++ b/go.sum @@ -129,12 +129,8 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/huaweicloud/golangsdk v0.0.0-20210205071117-066cac2eec52 h1:+fuguE3AQsM8HRuT1dvcr1uO3eK0jXi3OXiUsb/kAF4= -github.com/huaweicloud/golangsdk v0.0.0-20210205071117-066cac2eec52/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0= -github.com/huaweicloud/golangsdk v0.0.0-20210218092317-09c77d0b0be0 h1:n92GyvoN8wTBHZ16vvvEytIPJbQJ6yCkyYYWEVij2Os= -github.com/huaweicloud/golangsdk v0.0.0-20210218092317-09c77d0b0be0/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0= -github.com/huaweicloud/golangsdk v0.0.0-20210223120349-95b96c64969c h1:OLgbcIr+6i9Qhex7ISLhDcssUPOXARq52Pye8LhBAPA= -github.com/huaweicloud/golangsdk v0.0.0-20210223120349-95b96c64969c/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0= +github.com/huaweicloud/golangsdk v0.0.0-20210226030432-bcda8c57eb97 h1:r4e2CDPxWUvowRs0UgKIeQylw4Rwk6NsF55OqclN2LE= +github.com/huaweicloud/golangsdk v0.0.0-20210226030432-bcda8c57eb97/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0= github.com/jen20/awspolicyequivalence v0.0.0-20170831201602-3d48364a137a h1:FyS/ubzBR5xJlnJGRTwe7GUHpJOR4ukYK3y+LFNffuA= github.com/jen20/awspolicyequivalence v0.0.0-20170831201602-3d48364a137a/go.mod h1:uoIMjNxUfXi48Ci40IXkPRbghZ1vbti6v9LCbNqRgHY= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= diff --git a/huaweicloud/resource_huaweicloud_cce_node_pool.go b/huaweicloud/resource_huaweicloud_cce_node_pool.go index 3a490f991aa..d0623b41f32 100644 --- a/huaweicloud/resource_huaweicloud_cce_node_pool.go +++ b/huaweicloud/resource_huaweicloud_cce_node_pool.go @@ -76,6 +76,10 @@ func ResourceCCENodePool() *schema.Resource { Type: schema.TypeString, Required: true, }, + "hw_passthrough": { + Type: schema.TypeBool, + Optional: true, + }, "extend_param": { Type: schema.TypeMap, Optional: true, @@ -97,6 +101,10 @@ func ResourceCCENodePool() *schema.Resource { Type: schema.TypeString, Required: true, }, + "hw_passthrough": { + Type: schema.TypeBool, + Optional: true, + }, "extend_param": { Type: schema.TypeMap, Optional: true, @@ -230,14 +238,6 @@ func resourceCCENodePoolCreate(d *schema.ResourceData, meta interface{}) error { } } - var base64PreInstall, base64PostInstall string - if v, ok := d.GetOk("preinstall"); ok { - base64PreInstall = installScriptEncode(v.(string)) - } - if v, ok := d.GetOk("postinstall"); ok { - base64PostInstall = installScriptEncode(v.(string)) - } - initialNodeCount := d.Get("initial_node_count").(int) createOpts := nodepools.CreateOpts{ @@ -263,11 +263,8 @@ func resourceCCENodePoolCreate(d *schema.ResourceData, meta interface{}) error { SubnetId: d.Get("subnet_id").(string), }, }, - ExtendParam: nodes.ExtendParam{ - PreInstall: base64PreInstall, - PostInstall: base64PostInstall, - }, - Taints: resourceCCETaint(d), + ExtendParam: resourceCCEExtendParam(d), + Taints: resourceCCETaint(d), }, Autoscaling: nodepools.AutoscalingSpec{ Enable: d.Get("scall_enable").(bool), @@ -372,6 +369,7 @@ func resourceCCENodePoolRead(d *schema.ResourceData, meta interface{}) error { volume := make(map[string]interface{}) volume["size"] = pairObject.Size volume["volumetype"] = pairObject.VolumeType + volume["hw_passthrough"] = pairObject.HwPassthrough volume["extend_param"] = pairObject.ExtendParam volumes = append(volumes, volume) } @@ -381,9 +379,10 @@ func resourceCCENodePoolRead(d *schema.ResourceData, meta interface{}) error { rootVolume := []map[string]interface{}{ { - "size": s.Spec.NodeTemplate.RootVolume.Size, - "volumetype": s.Spec.NodeTemplate.RootVolume.VolumeType, - "extend_param": s.Spec.NodeTemplate.RootVolume.ExtendParam, + "size": s.Spec.NodeTemplate.RootVolume.Size, + "volumetype": s.Spec.NodeTemplate.RootVolume.VolumeType, + "hw_passthrough": s.Spec.NodeTemplate.RootVolume.HwPassthrough, + "extend_param": s.Spec.NodeTemplate.RootVolume.ExtendParam, }, } if err := d.Set("root_volume", rootVolume); err != nil { diff --git a/huaweicloud/resource_huaweicloud_cce_node_v3.go b/huaweicloud/resource_huaweicloud_cce_node_v3.go index 2d103801eab..9721af99e8d 100644 --- a/huaweicloud/resource_huaweicloud_cce_node_v3.go +++ b/huaweicloud/resource_huaweicloud_cce_node_v3.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "fmt" "log" + "strconv" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -101,6 +102,10 @@ func ResourceCCENodeV3() *schema.Resource { Type: schema.TypeString, Required: true, }, + "hw_passthrough": { + Type: schema.TypeBool, + Optional: true, + }, "extend_param": { Type: schema.TypeMap, Optional: true, @@ -122,6 +127,10 @@ func ResourceCCENodeV3() *schema.Resource { Type: schema.TypeString, Required: true, }, + "hw_passthrough": { + Type: schema.TypeBool, + Optional: true, + }, "extend_param": { Type: schema.TypeMap, Optional: true, @@ -265,12 +274,23 @@ func ResourceCCENodeV3() *schema.Resource { } }, }, + "extend_param": { + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "subnet_id": { Type: schema.TypeString, Optional: true, ForceNew: true, Computed: true, }, + "fixed_ip": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, "tags": { Type: schema.TypeMap, Optional: true, @@ -323,9 +343,10 @@ func resourceCCEDataVolume(d *schema.ResourceData) []nodes.VolumeSpec { for i, raw := range volumeRaw { rawMap := raw.(map[string]interface{}) volumes[i] = nodes.VolumeSpec{ - Size: rawMap["size"].(int), - VolumeType: rawMap["volumetype"].(string), - ExtendParam: rawMap["extend_param"].(map[string]interface{}), + Size: rawMap["size"].(int), + VolumeType: rawMap["volumetype"].(string), + HwPassthrough: rawMap["hw_passthrough"].(bool), + ExtendParam: rawMap["extend_param"].(map[string]interface{}), } } return volumes @@ -351,6 +372,7 @@ func resourceCCERootVolume(d *schema.ResourceData) nodes.VolumeSpec { if len(nicsRaw) == 1 { nics.Size = nicsRaw[0].(map[string]interface{})["size"].(int) nics.VolumeType = nicsRaw[0].(map[string]interface{})["volumetype"].(string) + nics.HwPassthrough = nicsRaw[0].(map[string]interface{})["hw_passthrough"].(bool) nics.ExtendParam = nicsRaw[0].(map[string]interface{})["extend_param"].(map[string]interface{}) } return nics @@ -368,6 +390,48 @@ func resourceCCEEipIDs(d *schema.ResourceData) []string { return id } +func resourceCCEExtendParam(d *schema.ResourceData) map[string]interface{} { + extendParam := make(map[string]interface{}) + if v, ok := d.GetOk("extend_param"); ok { + for key, val := range v.(map[string]interface{}) { + extendParam[key] = val.(string) + } + if v, ok := extendParam["periodNum"]; ok { + periodNum, err := strconv.Atoi(v.(string)) + if err != nil { + log.Printf("[WARNING] PeriodNum %s invalid, Type conversion error: %s", v.(string), err) + } + extendParam["periodNum"] = periodNum + } + } + if v, ok := d.GetOk("extend_param_charging_mode"); ok { + extendParam["chargingMode"] = v.(int) + } + if v, ok := d.GetOk("ecs_performance_type"); ok { + extendParam["ecs:performancetype"] = v.(string) + } + if v, ok := d.GetOk("max_pods"); ok { + extendParam["maxPods"] = v.(int) + } + if v, ok := d.GetOk("order_id"); ok { + extendParam["orderID"] = v.(string) + } + if v, ok := d.GetOk("product_id"); ok { + extendParam["productID"] = v.(string) + } + if v, ok := d.GetOk("public_key"); ok { + extendParam["publicKey"] = v.(string) + } + if v, ok := d.GetOk("preinstall"); ok { + extendParam["alpha.cce/preInstall"] = installScriptEncode(v.(string)) + } + if v, ok := d.GetOk("postinstall"); ok { + extendParam["alpha.cce/postInstall"] = installScriptEncode(v.(string)) + } + + return extendParam +} + func resourceCCENodeV3Create(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) nodeClient, err := config.CceV3Client(GetRegion(d, config)) @@ -387,14 +451,6 @@ func resourceCCENodeV3Create(d *schema.ResourceData, meta interface{}) error { } } - var base64PreInstall, base64PostInstall string - if v, ok := d.GetOk("preinstall"); ok { - base64PreInstall = installScriptEncode(v.(string)) - } - if v, ok := d.GetOk("postinstall"); ok { - base64PostInstall = installScriptEncode(v.(string)) - } - // eipCount must be specified when bandwidth_size parameters was set eipCount := 0 if _, ok := d.GetOk("bandwidth_size"); ok { @@ -434,23 +490,18 @@ func resourceCCENodeV3Create(d *schema.ResourceData, meta interface{}) error { SubnetId: d.Get("subnet_id").(string), }, }, - EcsGroupID: d.Get("ecs_group_id").(string), - ExtendParam: nodes.ExtendParam{ - ChargingMode: d.Get("extend_param_charging_mode").(int), - EcsPerformanceType: d.Get("ecs_performance_type").(string), - MaxPods: d.Get("max_pods").(int), - OrderID: d.Get("order_id").(string), - ProductID: d.Get("product_id").(string), - PublicKey: d.Get("public_key").(string), - PreInstall: base64PreInstall, - PostInstall: base64PostInstall, - }, - Taints: resourceCCETaint(d), - K8sTags: resourceCCENodeK8sTags(d), - UserTags: resourceCCENodeTags(d), + EcsGroupID: d.Get("ecs_group_id").(string), + ExtendParam: resourceCCEExtendParam(d), + Taints: resourceCCETaint(d), + K8sTags: resourceCCENodeK8sTags(d), + UserTags: resourceCCENodeTags(d), }, } + if v, ok := d.GetOk("fixed_ip"); ok { + createOpts.Spec.NodeNicSpec.PrimaryNic.FixedIps = []string{v.(string)} + } + clusterid := d.Get("cluster_id").(string) stateCluster := &resource.StateChangeConf{ Target: []string{"Available"}, @@ -548,6 +599,7 @@ func resourceCCENodeV3Read(d *schema.ResourceData, meta interface{}) error { volume := make(map[string]interface{}) volume["size"] = pairObject.Size volume["volumetype"] = pairObject.VolumeType + volume["hw_passthrough"] = pairObject.HwPassthrough volume["extend_param"] = pairObject.ExtendParam volumes = append(volumes, volume) } @@ -557,9 +609,10 @@ func resourceCCENodeV3Read(d *schema.ResourceData, meta interface{}) error { rootVolume := []map[string]interface{}{ { - "size": s.Spec.RootVolume.Size, - "volumetype": s.Spec.RootVolume.VolumeType, - "extend_param": s.Spec.RootVolume.ExtendParam, + "size": s.Spec.RootVolume.Size, + "volumetype": s.Spec.RootVolume.VolumeType, + "hw_passthrough": s.Spec.RootVolume.HwPassthrough, + "extend_param": s.Spec.RootVolume.ExtendParam, }, } if err := d.Set("root_volume", rootVolume); err != nil { diff --git a/vendor/github.com/huaweicloud/golangsdk/openstack/cce/v3/nodes/results.go b/vendor/github.com/huaweicloud/golangsdk/openstack/cce/v3/nodes/results.go index 4d4a76ec7a8..5a4667a0d54 100644 --- a/vendor/github.com/huaweicloud/golangsdk/openstack/cce/v3/nodes/results.go +++ b/vendor/github.com/huaweicloud/golangsdk/openstack/cce/v3/nodes/results.go @@ -66,7 +66,7 @@ type Spec struct { // The node nic spec NodeNicSpec NodeNicSpec `json:"nodeNicSpec,omitempty"` // Extended parameter - ExtendParam ExtendParam `json:"extendParam,omitempty"` + ExtendParam map[string]interface{} `json:"extendParam,omitempty"` // UUID of an ECS group EcsGroupID string `json:"ecsGroupId,omitempty"` // Tag of a VM, key value pair format @@ -87,6 +87,8 @@ type NodeNicSpec struct { type PrimaryNic struct { // The Subnet ID of the primary Nic SubnetId string `json:"subnetId,omitempty"` + // Fixed ips of the primary Nic + FixedIps []string `json:"fixedIps,omitempty"` } // TaintSpec to created nodes to configure anti-affinity @@ -134,29 +136,12 @@ type VolumeSpec struct { Size int `json:"size" required:"true"` // Disk type VolumeType string `json:"volumetype" required:"true"` + //hw:passthrough + HwPassthrough bool `json:"hw:passthrough,omitempty"` // Disk extension parameter ExtendParam map[string]interface{} `json:"extendParam,omitempty"` } -type ExtendParam struct { - // Node charging mode, 0 is on-demand charging. - ChargingMode int `json:"chargingMode,omitempty"` - // Classification of cloud server specifications. - EcsPerformanceType string `json:"ecs:performancetype,omitempty"` - // Order ID, mandatory when the node payment type is the automatic payment package period type. - OrderID string `json:"orderID,omitempty"` - // The Product ID. - ProductID string `json:"productID,omitempty"` - // The Public Key. - PublicKey string `json:"publicKey,omitempty"` - // The maximum number of instances a node is allowed to create. - MaxPods int `json:"maxPods,omitempty"` - // Script required before the installation. - PreInstall string `json:"alpha.cce/preInstall,omitempty"` - // Script required after the installation. - PostInstall string `json:"alpha.cce/postInstall,omitempty"` -} - type PublicIPSpec struct { // List of existing elastic IP IDs Ids []string `json:"ids,omitempty"` diff --git a/vendor/github.com/huaweicloud/golangsdk/openstack/identity/v3/agency/requests.go b/vendor/github.com/huaweicloud/golangsdk/openstack/identity/v3/agency/requests.go index 8e0b23f32f7..4db6b132b14 100644 --- a/vendor/github.com/huaweicloud/golangsdk/openstack/identity/v3/agency/requests.go +++ b/vendor/github.com/huaweicloud/golangsdk/openstack/identity/v3/agency/requests.go @@ -9,6 +9,7 @@ type CreateOpts struct { DomainID string `json:"domain_id" required:"true"` DelegatedDomain string `json:"trust_domain_name" required:"true"` Description string `json:"description,omitempty"` + Duration string `json:"duration,omitempty"` } type CreateOptsBuilder interface { @@ -33,6 +34,7 @@ func Create(c *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult) type UpdateOpts struct { DelegatedDomain string `json:"trust_domain_name,omitempty"` Description string `json:"description,omitempty"` + Duration string `json:"duration,omitempty"` } type UpdateOptsBuilder interface { diff --git a/vendor/modules.txt b/vendor/modules.txt index d7e3c46b533..788ff271f4f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -186,7 +186,7 @@ github.com/hashicorp/terraform-svchost/auth github.com/hashicorp/terraform-svchost/disco # github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d github.com/hashicorp/yamux -# github.com/huaweicloud/golangsdk v0.0.0-20210223120349-95b96c64969c +# github.com/huaweicloud/golangsdk v0.0.0-20210226030432-bcda8c57eb97 ## explicit github.com/huaweicloud/golangsdk github.com/huaweicloud/golangsdk/internal