Skip to content

Commit 9044a7f

Browse files
Rebecca Shanleyjotruon
authored andcommitted
Added - Support for shielded instance SDDC
1 parent 68c2fc1 commit 9044a7f

13 files changed

+386
-16
lines changed

examples/ocvp/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ resource "oci_ocvp_sddc" "test_sddc" {
370370
// Optional
371371
provisioning_vlan_id = oci_core_vlan.test_provisioning_vlan.id
372372
replication_vlan_id = oci_core_vlan.test_replication_vlan.id
373-
initial_sku = data.oci_ocvp_supported_skus.test_supported_skus.items[0].name
373+
initial_sku = "HOUR"
374+
is_shielded_instance_enabled = false
374375
hcx_action = "upgrade"
375376
refresh_hcx_license_status = true
376377
#reserving_hcx_on_premise_license_keys = var.reserving_hcx_on_premise_license_keys

internal/integrationtest/ocvp_esxi_host_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ var (
6262
}
6363
replacementEsxiHostRepresentation = acctest.RepresentationCopyWithNewProperties(esxiHostRepresentation, map[string]interface{}{
6464
"failed_esxi_host_id": acctest.Representation{RepType: acctest.Optional, Create: `${data.oci_ocvp_esxi_hosts.existing_esxi_hosts.esxi_host_collection[0].id}`},
65+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `replacement`},
6566
})
6667

6768
EsxiHostResourceDependencies = SddcRequiredOnlyResource + acctest.GenerateDataSourceFromRepresentationMap("oci_ocvp_esxi_hosts", "existing_esxi_hosts", acctest.Optional, acctest.Create, existingEsxiHostDataSourceRepresentation)
@@ -112,7 +113,7 @@ func TestOcvpEsxiHostResource_basic(t *testing.T) {
112113
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
113114
resource.TestCheckResourceAttrSet(resourceName, "compute_availability_domain"),
114115
resource.TestCheckResourceAttr(resourceName, "current_sku", "MONTH"),
115-
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
116+
resource.TestCheckResourceAttr(resourceName, "display_name", `replacement`),
116117
resource.TestCheckResourceAttrSet(resourceName, "failed_esxi_host_id"),
117118
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
118119
resource.TestCheckResourceAttrSet(resourceName, "id"),
@@ -140,7 +141,7 @@ func TestOcvpEsxiHostResource_basic(t *testing.T) {
140141
resource.TestCheckResourceAttrSet(singularDatasourceName, "compartment_id"),
141142
resource.TestCheckResourceAttrSet(singularDatasourceName, "compute_availability_domain"),
142143
resource.TestCheckResourceAttr(singularDatasourceName, "current_sku", "MONTH"),
143-
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", "displayName"),
144+
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", `replacement`),
144145
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.%", "1"),
145146
resource.TestCheckResourceAttrSet(singularDatasourceName, "grace_period_end_date"),
146147
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),

internal/integrationtest/ocvp_sddc_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ var (
5252

5353
sddcRepresentation = map[string]interface{}{
5454
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
55-
"initial_sku": acctest.Representation{RepType: acctest.Optional, Create: `HOUR`},
5655
"compute_availability_domain": acctest.Representation{RepType: acctest.Required, Create: `${lookup(data.oci_identity_availability_domains.ADs.availability_domains[0],"name")}`},
5756
"esxi_hosts_count": acctest.Representation{RepType: acctest.Required, Create: `3`},
5857
"nsx_edge_uplink1vlan_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_vlan.test_nsx_edge_uplink1_vlan.id}`},
@@ -68,6 +67,8 @@ var (
6867
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
6968
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
7069
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
70+
"initial_sku": acctest.Representation{RepType: acctest.Optional, Create: `HOUR`},
71+
"is_shielded_instance_enabled": acctest.Representation{RepType: acctest.Optional, Create: `true`},
7172
"hcx_action": acctest.Representation{RepType: acctest.Optional, Create: ocvp.UpgradeHcxAction},
7273
"hcx_vlan_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_core_vlan.test_hcx_vlan.id}`},
7374
"instance_display_name_prefix": acctest.Representation{RepType: acctest.Optional, Create: `njki`},
@@ -484,8 +485,9 @@ func TestOcvpSddcResource_basic(t *testing.T) {
484485
resource.TestCheckResourceAttrSet(resourceName, "hcx_vlan_id"),
485486
resource.TestCheckResourceAttrSet(resourceName, "id"),
486487
resource.TestCheckResourceAttr(resourceName, "initial_sku", "HOUR"),
487-
resource.TestCheckResourceAttr(resourceName, "instance_display_name_prefix", "njki"),
488+
resource.TestCheckResourceAttr(resourceName, "is_shielded_instance_enabled", "true"),
488489
resource.TestCheckResourceAttr(resourceName, "is_hcx_enabled", "true"),
490+
resource.TestCheckResourceAttr(resourceName, "instance_display_name_prefix", "njki"),
489491
resource.TestCheckResourceAttrSet(resourceName, "nsx_edge_uplink1vlan_id"),
490492
resource.TestCheckResourceAttrSet(resourceName, "nsx_edge_uplink2vlan_id"),
491493
resource.TestCheckResourceAttrSet(resourceName, "nsx_edge_vtep_vlan_id"),
@@ -539,6 +541,7 @@ func TestOcvpSddcResource_basic(t *testing.T) {
539541
resource.TestCheckResourceAttrSet(resourceName, "hcx_vlan_id"),
540542
resource.TestCheckResourceAttrSet(resourceName, "id"),
541543
resource.TestCheckResourceAttr(resourceName, "initial_sku", "HOUR"),
544+
resource.TestCheckResourceAttr(resourceName, "is_shielded_instance_enabled", "true"),
542545
resource.TestCheckResourceAttr(resourceName, "instance_display_name_prefix", "njki"),
543546
resource.TestCheckResourceAttr(resourceName, "is_hcx_enabled", "true"),
544547
resource.TestCheckResourceAttrSet(resourceName, "nsx_edge_uplink1vlan_id"),
@@ -590,6 +593,7 @@ func TestOcvpSddcResource_basic(t *testing.T) {
590593
resource.TestCheckResourceAttrSet(resourceName, "hcx_vlan_id"),
591594
resource.TestCheckResourceAttrSet(resourceName, "id"),
592595
resource.TestCheckResourceAttr(resourceName, "initial_sku", "HOUR"),
596+
resource.TestCheckResourceAttr(resourceName, "is_shielded_instance_enabled", "true"),
593597
resource.TestCheckResourceAttr(resourceName, "instance_display_name_prefix", "njki"),
594598
resource.TestCheckResourceAttr(resourceName, "is_hcx_enabled", "true"),
595599
resource.TestCheckResourceAttrSet(resourceName, "nsx_edge_uplink1vlan_id"),
@@ -638,6 +642,7 @@ func TestOcvpSddcResource_basic(t *testing.T) {
638642
resource.TestCheckResourceAttrSet(datasourceName, "sddc_collection.0.id"),
639643
resource.TestCheckResourceAttrSet(datasourceName, "sddc_collection.0.compute_availability_domain"),
640644
resource.TestCheckResourceAttr(datasourceName, "sddc_collection.0.display_name", "displayName2"),
645+
resource.TestCheckResourceAttr(datasourceName, "sddc_collection.0.is_shielded_instance_enabled", "true"),
641646
resource.TestCheckResourceAttr(datasourceName, "sddc_collection.0.vmware_software_version", "7.0 update 2"),
642647
resource.TestCheckResourceAttr(datasourceName, "sddc_collection.0.compartment_id", compartmentId),
643648
resource.TestCheckResourceAttr(datasourceName, "sddc_collection.0.esxi_hosts_count", "3"),
@@ -674,6 +679,7 @@ func TestOcvpSddcResource_basic(t *testing.T) {
674679
resource.TestCheckResourceAttr(singularDatasourceName, "is_hcx_enabled", "true"),
675680
resource.TestCheckResourceAttr(singularDatasourceName, "is_hcx_enterprise_enabled", "true"),
676681
resource.TestCheckResourceAttrSet(singularDatasourceName, "is_hcx_pending_downgrade"),
682+
resource.TestCheckResourceAttr(singularDatasourceName, "is_shielded_instance_enabled", "true"),
677683
resource.TestCheckResourceAttrSet(singularDatasourceName, "nsx_edge_uplink_ip_id"),
678684
resource.TestCheckResourceAttrSet(singularDatasourceName, "nsx_manager_fqdn"),
679685
resource.TestCheckResourceAttrSet(singularDatasourceName, "nsx_manager_initial_password"),
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"testing"
9+
10+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
11+
12+
"github.com/terraform-providers/terraform-provider-oci/httpreplay"
13+
"github.com/terraform-providers/terraform-provider-oci/internal/acctest"
14+
15+
"github.com/terraform-providers/terraform-provider-oci/internal/utils"
16+
)
17+
18+
var (
19+
supportedHostShapeDataSourceRepresentation = map[string]interface{}{
20+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
21+
"name": acctest.Representation{RepType: acctest.Optional, Create: `BM.DenseIO.E4.128`},
22+
"sddc_type": acctest.Representation{RepType: acctest.Optional, Create: `PRODUCTION`},
23+
}
24+
25+
SupportedHostShapeResourceConfig = ""
26+
)
27+
28+
// issue-routing-tag: ocvp/default
29+
func TestOcvpSupportedHostShapeResource_basic(t *testing.T) {
30+
httpreplay.SetScenario("TestOcvpSupportedHostShapeResource_basic")
31+
defer httpreplay.SaveScenario()
32+
33+
config := acctest.ProviderTestConfig()
34+
35+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
36+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
37+
38+
datasourceName := "data.oci_ocvp_supported_host_shapes.test_supported_host_shapes"
39+
40+
acctest.SaveConfigContent("", "", "", t)
41+
42+
acctest.ResourceTest(t, nil, []resource.TestStep{
43+
// verify datasource with required params
44+
{
45+
Config: config +
46+
acctest.GenerateDataSourceFromRepresentationMap("oci_ocvp_supported_host_shapes", "test_supported_host_shapes", acctest.Required, acctest.Create, supportedHostShapeDataSourceRepresentation) +
47+
compartmentIdVariableStr + SupportedHostShapeResourceConfig,
48+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
49+
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
50+
resource.TestCheckResourceAttrSet(datasourceName, "items.#"),
51+
resource.TestCheckResourceAttr(datasourceName, "items.#", "2"),
52+
),
53+
},
54+
// verify datasource with optional params
55+
{
56+
Config: config +
57+
acctest.GenerateDataSourceFromRepresentationMap("oci_ocvp_supported_host_shapes", "test_supported_host_shapes", acctest.Optional, acctest.Create, supportedHostShapeDataSourceRepresentation) +
58+
compartmentIdVariableStr + SupportedHostShapeResourceConfig,
59+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
60+
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
61+
resource.TestCheckResourceAttrSet(datasourceName, "items.#"),
62+
resource.TestCheckResourceAttr(datasourceName, "items.#", "1"),
63+
resource.TestCheckResourceAttr(datasourceName, "items.0.default_ocpu_count", "64"),
64+
resource.TestCheckResourceAttr(datasourceName, "items.0.description", "2.55 GHz AMD EPYC™ 7J13 (Milan) processor."),
65+
resource.TestCheckResourceAttr(datasourceName, "items.0.is_support_shielded_instances", "false"),
66+
resource.TestCheckResourceAttr(datasourceName, "items.0.name", "BM.DenseIO.E4.128"),
67+
resource.TestCheckResourceAttr(datasourceName, "items.0.supported_operations.#", "2"),
68+
resource.TestCheckResourceAttr(datasourceName, "items.0.shape_family", "AMD"),
69+
resource.TestCheckResourceAttr(datasourceName, "items.0.supported_ocpu_count.#", "1"),
70+
resource.TestCheckResourceAttr(datasourceName, "items.0.supported_sddc_types.#", "2"),
71+
),
72+
},
73+
})
74+
}

internal/provider/register_datasource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ func init() {
955955
RegisterDatasource("oci_ocvp_esxi_host", tf_ocvp.OcvpEsxiHostDataSource())
956956
RegisterDatasource("oci_ocvp_esxi_hosts", tf_ocvp.OcvpEsxiHostsDataSource())
957957
RegisterDatasource("oci_ocvp_sddc", tf_ocvp.OcvpSddcDataSource())
958+
RegisterDatasource("oci_ocvp_supported_host_shapes", tf_ocvp.OcvpSupportedHostShapesDataSource())
958959
RegisterDatasource("oci_ocvp_sddcs", tf_ocvp.OcvpSddcsDataSource())
959960
RegisterDatasource("oci_ocvp_supported_skus", tf_ocvp.OcvpSupportedSkusDataSource())
960961
RegisterDatasource("oci_ocvp_supported_vmware_software_versions", tf_ocvp.OcvpSupportedVmwareSoftwareVersionsDataSource())

internal/service/ocvp/ocvp_sddc_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ func (s *OcvpSddcDataSourceCrud) SetData() error {
133133
s.D.Set("is_hcx_pending_downgrade", *s.Res.IsHcxPendingDowngrade)
134134
}
135135

136+
if s.Res.IsShieldedInstanceEnabled != nil {
137+
s.D.Set("is_shielded_instance_enabled", *s.Res.IsShieldedInstanceEnabled)
138+
}
139+
136140
if s.Res.NsxEdgeUplink1VlanId != nil {
137141
s.D.Set("nsx_edge_uplink1vlan_id", *s.Res.NsxEdgeUplink1VlanId)
138142
}

internal/service/ocvp/ocvp_sddc_resource.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ func OcvpSddcResource() *schema.Resource {
144144
Computed: true,
145145
ForceNew: true,
146146
},
147+
"is_shielded_instance_enabled": {
148+
Type: schema.TypeBool,
149+
Optional: true,
150+
Computed: true,
151+
ForceNew: true,
152+
},
147153
"provisioning_vlan_id": {
148154
Type: schema.TypeString,
149155
Optional: true,
@@ -422,6 +428,11 @@ func (s *OcvpSddcResourceCrud) Create() error {
422428
request.IsHcxEnabled = &tmp
423429
}
424430

431+
if isShieldedInstanceEnabled, ok := s.D.GetOkExists("is_shielded_instance_enabled"); ok {
432+
tmp := isShieldedInstanceEnabled.(bool)
433+
request.IsShieldedInstanceEnabled = &tmp
434+
}
435+
425436
if nsxEdgeUplink1VlanId, ok := s.D.GetOkExists("nsx_edge_uplink1vlan_id"); ok {
426437
tmp := nsxEdgeUplink1VlanId.(string)
427438
request.NsxEdgeUplink1VlanId = &tmp
@@ -952,6 +963,10 @@ func (s *OcvpSddcResourceCrud) SetData() error {
952963
s.D.Set("is_hcx_pending_downgrade", *s.Res.IsHcxPendingDowngrade)
953964
}
954965

966+
if s.Res.IsShieldedInstanceEnabled != nil {
967+
s.D.Set("is_shielded_instance_enabled", *s.Res.IsShieldedInstanceEnabled)
968+
}
969+
955970
if s.Res.NsxEdgeUplink1VlanId != nil {
956971
s.D.Set("nsx_edge_uplink1vlan_id", *s.Res.NsxEdgeUplink1VlanId)
957972
}
@@ -1119,6 +1134,10 @@ func SddcSummaryToMap(obj oci_ocvp.SddcSummary) map[string]interface{} {
11191134
result["is_hcx_enabled"] = bool(*obj.IsHcxEnabled)
11201135
}
11211136

1137+
if obj.IsShieldedInstanceEnabled != nil {
1138+
result["is_shielded_instance_enabled"] = bool(*obj.IsShieldedInstanceEnabled)
1139+
}
1140+
11221141
if obj.NsxManagerFqdn != nil {
11231142
result["nsx_manager_fqdn"] = string(*obj.NsxManagerFqdn)
11241143
}

0 commit comments

Comments
 (0)