From d25640571313d0864d910651ca43e96d7b049038 Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Mon, 23 Mar 2020 16:35:37 +0800 Subject: [PATCH] Add subnet_id support to CCE node (#280) --- go.mod | 2 +- go.sum | 4 ++-- .../resource_huaweicloud_cce_node_v3.go | 10 ++++++++++ .../openstack/cce/v3/nodes/results.go | 14 ++++++++++++++ .../huaweicloud/golangsdk/openstack/client.go | 18 ++++++++++++++++++ vendor/modules.txt | 2 +- website/docs/r/cce_nodes_v3.html.md | 2 ++ 7 files changed, 48 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index b800cf6b0b..ecf059abe0 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/errwrap v1.0.0 github.com/hashicorp/go-cleanhttp v0.5.1 github.com/hashicorp/terraform-plugin-sdk v1.0.0 - github.com/huaweicloud/golangsdk v0.0.0-20200229071744-cde13ac05a94 + github.com/huaweicloud/golangsdk v0.0.0-20200323070305-98b64a3f37ba 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 a4fd9bffd8..194eb33432 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKe 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/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huaweicloud/golangsdk v0.0.0-20200229071744-cde13ac05a94 h1:3MKOAqfBneQCxf7+GMMql6n+JIvE+rmdgtjoM1IhDWc= -github.com/huaweicloud/golangsdk v0.0.0-20200229071744-cde13ac05a94/go.mod h1:WQBcHRNX9shz3928lWEvstQJtAtYI7ks6XlgtRT9Tcw= +github.com/huaweicloud/golangsdk v0.0.0-20200323070305-98b64a3f37ba h1:eTQZkCooySmxShTy8boiZ69ueUNNNRxBWjt9T35sp8c= +github.com/huaweicloud/golangsdk v0.0.0-20200323070305-98b64a3f37ba/go.mod h1:WQBcHRNX9shz3928lWEvstQJtAtYI7ks6XlgtRT9Tcw= 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/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= diff --git a/huaweicloud/resource_huaweicloud_cce_node_v3.go b/huaweicloud/resource_huaweicloud_cce_node_v3.go index 355cb10669..9f0562631d 100644 --- a/huaweicloud/resource_huaweicloud_cce_node_v3.go +++ b/huaweicloud/resource_huaweicloud_cce_node_v3.go @@ -230,6 +230,11 @@ func resourceCCENodeV3() *schema.Resource { } }, }, + "subnet_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, "private_ip": { Type: schema.TypeString, Computed: true, @@ -349,6 +354,11 @@ func resourceCCENodeV3Create(d *schema.ResourceData, meta interface{}) error { }, BillingMode: d.Get("billing_mode").(int), Count: 1, + NodeNicSpec: nodes.NodeNicSpec{ + PrimaryNic: nodes.PrimaryNic{ + SubnetId: d.Get("subnet_id").(string), + }, + }, ExtendParam: nodes.ExtendParam{ ChargingMode: d.Get("extend_param_charging_mode").(int), EcsPerformanceType: d.Get("ecs_performance_type").(string), 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 c4dc7e742c..baff4d9b4a 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 @@ -60,10 +60,24 @@ type Spec struct { BillingMode int `json:"billingMode,omitempty"` // Number of nodes when creating in batch Count int `json:"count" required:"true"` + // The node nic spec + NodeNicSpec NodeNicSpec `json:"nodeNicSpec,omitempty"` // Extended parameter ExtendParam ExtendParam `json:"extendParam,omitempty"` } +// Gives the Nic spec of the node +type NodeNicSpec struct { + // The primary Nic of the Node + PrimaryNic PrimaryNic `json:"primaryNic,omitempty"` +} + +// Gives the Primary Nic of the node +type PrimaryNic struct { + // The Subnet ID of the primary Nic + SubnetId string `json:"subnetId,omitempty"` +} + // Gives the current status of the node type Status struct { // The state of the Node diff --git a/vendor/github.com/huaweicloud/golangsdk/openstack/client.go b/vendor/github.com/huaweicloud/golangsdk/openstack/client.go index 45bfc9f516..1ab7f5caeb 100644 --- a/vendor/github.com/huaweicloud/golangsdk/openstack/client.go +++ b/vendor/github.com/huaweicloud/golangsdk/openstack/client.go @@ -829,6 +829,15 @@ func NewMapReduceV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) return sc, err } +// AntiDDoSV1 creates a ServiceClient that may be used with the v1 Anti DDoS service. +func AntiDDoSV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*golangsdk.ServiceClient, error) { + sc, err := initClientOpts(client, eo, "network") + sc.Endpoint = strings.Replace(sc.Endpoint, "vpc", "antiddos", 1) + sc.Endpoint = sc.Endpoint + "v1/" + sc.ResourceBase = sc.Endpoint + client.ProjectID + "/" + return sc, err +} + // NewAntiDDoSV1 creates a ServiceClient that may be used with the v1 Anti DDoS Service // package. func NewAntiDDoSV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*golangsdk.ServiceClient, error) { @@ -1032,6 +1041,15 @@ func SDRSV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*golan return sc, err } +// CCIV1 creates a ServiceClient that may be used with the v1 CCI service. +func CCIV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*golangsdk.ServiceClient, error) { + sc, err := initClientOpts(client, eo, "network") + sc.Endpoint = strings.Replace(sc.Endpoint, "vpc", "cci", 1) + sc.Endpoint = sc.Endpoint + "apis/networking.cci.io/v1beta1/" + sc.ResourceBase = sc.Endpoint + return sc, err +} + // TMSV1 creates a ServiceClient that may be used with the v1 TMS service. func TMSV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*golangsdk.ServiceClient, error) { sc, err := initClientOpts(client, eo, "network") diff --git a/vendor/modules.txt b/vendor/modules.txt index 3e35d36058..44a80ba5f3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -177,7 +177,7 @@ github.com/hashicorp/terraform-plugin-sdk/internal/svchost github.com/hashicorp/terraform-plugin-sdk/internal/svchost/auth # github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d github.com/hashicorp/yamux -# github.com/huaweicloud/golangsdk v0.0.0-20200229071744-cde13ac05a94 +# github.com/huaweicloud/golangsdk v0.0.0-20200323070305-98b64a3f37ba github.com/huaweicloud/golangsdk github.com/huaweicloud/golangsdk/openstack github.com/huaweicloud/golangsdk/openstack/antiddos/v1/antiddos diff --git a/website/docs/r/cce_nodes_v3.html.md b/website/docs/r/cce_nodes_v3.html.md index 1762f0ef27..9b8840904e 100644 --- a/website/docs/r/cce_nodes_v3.html.md +++ b/website/docs/r/cce_nodes_v3.html.md @@ -95,6 +95,8 @@ If the eip_ids parameter is configured, you do not need to configure the eip_cou * `postinstall` - (Optional) Script required after installation. The input value can be a Base64 encoded string or not. Changing this parameter will create a new resource. +* `subnet_id` - (Optional) The ID of the subnet to which the NIC belongs. Changing this parameter will create a new resource. + **root_volume** **- (Required)** It corresponds to the system disk related configuration. Changing this parameter will create a new resource. * `size` - (Required) Disk size in GB.