diff --git a/go.mod b/go.mod index 81567e3de0..89cd7969ff 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-20201204095247-2438ba26b2d9 + github.com/huaweicloud/golangsdk v0.0.0-20201208095655-46b6c076ba1b 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 6bf137213b..6156d6e3c1 100644 --- a/go.sum +++ b/go.sum @@ -131,6 +131,8 @@ github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1 github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/huaweicloud/golangsdk v0.0.0-20201204095247-2438ba26b2d9 h1:IgV5RijwKkFEW3e6p3eTVTDx8PKCgB2u6sE2JkVNb4w= github.com/huaweicloud/golangsdk v0.0.0-20201204095247-2438ba26b2d9/go.mod h1:fcOI5u+0f62JtJd7zkCch/Z57BNC6bhqb32TKuiF4r0= +github.com/huaweicloud/golangsdk v0.0.0-20201208095655-46b6c076ba1b h1:iknqQBENR+tr/hqZRWSmii5KaGODARsUu0WDC8HnlXY= +github.com/huaweicloud/golangsdk v0.0.0-20201208095655-46b6c076ba1b/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_compute_instance.go b/huaweicloud/resource_huaweicloud_compute_instance.go index 7804173660..3a03a11851 100644 --- a/huaweicloud/resource_huaweicloud_compute_instance.go +++ b/huaweicloud/resource_huaweicloud_compute_instance.go @@ -277,6 +277,11 @@ func ResourceComputeInstanceV2() *schema.Resource { Optional: true, ForceNew: true, }, + "fault_domain": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, "tenancy": { Type: schema.TypeString, Optional: true, @@ -1197,6 +1202,7 @@ func resourceInstanceBlockDevicesV2(d *schema.ResourceData, bds []interface{}) ( func resourceInstanceSchedulerHintsV1(d *schema.ResourceData, schedulerHintsRaw map[string]interface{}) cloudservers.SchedulerHints { schedulerHints := cloudservers.SchedulerHints{ Group: schedulerHintsRaw["group"].(string), + FaultDomain: schedulerHintsRaw["fault_domain"].(string), Tenancy: schedulerHintsRaw["tenancy"].(string), DedicatedHostID: schedulerHintsRaw["deh_id"].(string), } diff --git a/huaweicloud/resource_huaweicloud_compute_servergroup.go b/huaweicloud/resource_huaweicloud_compute_servergroup.go index d392d66586..0179e6131d 100644 --- a/huaweicloud/resource_huaweicloud_compute_servergroup.go +++ b/huaweicloud/resource_huaweicloud_compute_servergroup.go @@ -42,6 +42,11 @@ func ResourceComputeServerGroupV2() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, + "fault_domains": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "value_specs": { Type: schema.TypeMap, Optional: true, @@ -102,12 +107,9 @@ func resourceComputeServerGroupV2Read(d *schema.ResourceData, meta interface{}) } d.Set("policies", policies) - // Set the members - members := []string{} - for _, m := range sg.Members { - members = append(members, m) - } - d.Set("members", members) + // Set the members & fault_domains + d.Set("members", sg.Members) + d.Set("fault_domains", sg.FaultDomain.Names) d.Set("region", GetRegion(d, config)) diff --git a/vendor/github.com/huaweicloud/golangsdk/openstack/compute/v2/extensions/servergroups/results.go b/vendor/github.com/huaweicloud/golangsdk/openstack/compute/v2/extensions/servergroups/results.go index 992fd756d9..ec4fcf3fc5 100644 --- a/vendor/github.com/huaweicloud/golangsdk/openstack/compute/v2/extensions/servergroups/results.go +++ b/vendor/github.com/huaweicloud/golangsdk/openstack/compute/v2/extensions/servergroups/results.go @@ -5,6 +5,11 @@ import ( "github.com/huaweicloud/golangsdk/pagination" ) +// FaultDomainInfo represents the response of `fault_domain` +type FaultDomainInfo struct { + Names []string `json:"fault_domain_names"` +} + // A ServerGroup creates a policy for instance placement in the cloud. type ServerGroup struct { // ID is the unique ID of the Server Group. @@ -27,6 +32,9 @@ type ServerGroup struct { // Members are the members of the server group. Members []string `json:"members"` + // FaultDomain is valid when policy is "fault_domain" + FaultDomain FaultDomainInfo `json:"fault_domain"` + // Metadata includes a list of all user-specified key-value pairs attached // to the Server Group. Metadata map[string]interface{} diff --git a/vendor/github.com/huaweicloud/golangsdk/openstack/ecs/v1/cloudservers/requests.go b/vendor/github.com/huaweicloud/golangsdk/openstack/ecs/v1/cloudservers/requests.go index 4e8742f6f4..7a1cf2b21f 100644 --- a/vendor/github.com/huaweicloud/golangsdk/openstack/ecs/v1/cloudservers/requests.go +++ b/vendor/github.com/huaweicloud/golangsdk/openstack/ecs/v1/cloudservers/requests.go @@ -163,7 +163,8 @@ type SecurityGroup struct { } type SchedulerHints struct { - Group string `json:"group,omitempty"` + Group string `json:"group,omitempty"` + FaultDomain string `json:"fault_domain,omitempty"` // Specifies whether the ECS is created on a Dedicated Host (DeH) or in a shared pool. Tenancy string `json:"tenancy,omitempty"` diff --git a/vendor/github.com/huaweicloud/golangsdk/openstack/ecs/v1/cloudservers/results.go b/vendor/github.com/huaweicloud/golangsdk/openstack/ecs/v1/cloudservers/results.go index 5b8755e24d..7b84d72422 100644 --- a/vendor/github.com/huaweicloud/golangsdk/openstack/ecs/v1/cloudservers/results.go +++ b/vendor/github.com/huaweicloud/golangsdk/openstack/ecs/v1/cloudservers/results.go @@ -29,7 +29,8 @@ type SysTags struct { } type OsSchedulerHints struct { - Group []string `json:"group"` + Group []string `json:"group"` + FaultDomain string `json:"fault_domain,omitempty"` } // Metadata is only used for method that requests details on a single server, by ID. diff --git a/vendor/modules.txt b/vendor/modules.txt index 8e54182156..626368217a 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-20201204095247-2438ba26b2d9 +# github.com/huaweicloud/golangsdk v0.0.0-20201208095655-46b6c076ba1b ## explicit github.com/huaweicloud/golangsdk github.com/huaweicloud/golangsdk/internal