Skip to content

Commit d6bfb40

Browse files
authored
Candidate for release_v3.41.0
Candidate for release_v3.41.0
2 parents e28be80 + 3d97e96 commit d6bfb40

File tree

53 files changed

+3699
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3699
-30
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## 3.40.1 (Unreleased)
1+
## 3.41.0 (Unreleased)
2+
3+
### Added
4+
- Support for Cluster Network in the Compute service
5+
26
## 3.40.0 (August 28, 2019)
37

48
### Added
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
3+
variable "tenancy_ocid" {}
4+
variable "user_ocid" {}
5+
variable "fingerprint" {}
6+
variable "private_key_path" {}
7+
variable "region" {}
8+
variable "compartment_ocid" {}
9+
10+
provider "oci" {
11+
tenancy_ocid = "${var.tenancy_ocid}"
12+
user_ocid = "${var.user_ocid}"
13+
fingerprint = "${var.fingerprint}"
14+
private_key_path = "${var.private_key_path}"
15+
region = "${var.region}"
16+
}
17+
18+
data "oci_identity_availability_domains" "test_availability_domains" {
19+
compartment_id = "${var.tenancy_ocid}"
20+
}
21+
22+
resource "oci_core_vcn" "test_vcn" {
23+
cidr_block = "10.0.0.0/16"
24+
compartment_id = "${var.compartment_ocid}"
25+
display_name = "TestVcn"
26+
dns_label = "dnslabel"
27+
}
28+
29+
resource "oci_core_route_table" "test_route_table" {
30+
compartment_id = "${var.compartment_id}"
31+
vcn_id = "${oci_core_vcn.test_vcn.id}"
32+
display_name = "TestRouteTable"
33+
}
34+
35+
resource "oci_core_subnet" "test_subnet" {
36+
availability_domain = "${lower("${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}")}"
37+
cidr_block = "10.0.2.0/24"
38+
compartment_id = "${var.compartment_id}"
39+
dhcp_options_id = "${oci_core_vcn.test_vcn.default_dhcp_options_id}"
40+
display_name = "TestSubnet"
41+
dns_label = "dnslabel"
42+
route_table_id = "${oci_core_route_table.test_route_table.id}"
43+
security_list_ids = ["${oci_core_vcn.test_vcn.default_security_list_id}"]
44+
vcn_id = "${oci_core_vcn.test_vcn.id}"
45+
}
46+
47+
variable "InstanceImageOCID" {
48+
type = "map"
49+
50+
default = {
51+
// See https://docs.us-phoenix-1.oraclecloud.com/images/
52+
// Oracle-provided image "Oracle-Linux-7.5-2018.10.16-0"
53+
us-phoenix-1 = "ocid1.image.oc1.phx.aaaaaaaadjnj3da72bztpxinmqpih62c2woscbp6l3wjn36by2cvmdhjub6a"
54+
55+
us-ashburn-1 = "ocid1.image.oc1.iad.aaaaaaaawufnve5jxze4xf7orejupw5iq3pms6cuadzjc7klojix6vmk42va"
56+
eu-frankfurt-1 = "ocid1.image.oc1.eu-frankfurt-1.aaaaaaaagbrvhganmn7awcr7plaaf5vhabmzhx763z5afiitswjwmzh7upna"
57+
uk-london-1 = "ocid1.image.oc1.uk-london-1.aaaaaaaajwtut4l7fo3cvyraate6erdkyf2wdk5vpk6fp6ycng3dv2y3ymvq"
58+
}
59+
}
60+
61+
resource "oci_core_network_security_group" "test_network_security_group1" {
62+
compartment_id = "${var.compartment_id}"
63+
vcn_id = "${oci_core_vcn.test_vcn.id}"
64+
}
65+
66+
resource "oci_core_instance_configuration" "test_instance_configuration" {
67+
compartment_id = "${var.compartment_ocid}"
68+
display_name = "TestInstanceConfiguration"
69+
70+
instance_details {
71+
instance_type = "compute"
72+
73+
launch_details {
74+
availability_domain = "${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}"
75+
compartment_id = "${var.compartment_id}"
76+
77+
create_vnic_details {
78+
assign_public_ip = "false"
79+
display_name = "backend-servers"
80+
hostname_label = "hostnameLabel"
81+
nsg_ids = ["${oci_core_network_security_group.test_network_security_group1.id}"]
82+
private_ip = "privateIp"
83+
skip_source_dest_check = "false"
84+
subnet_id = "${oci_core_subnet.test_subnet.id}"
85+
}
86+
87+
display_name = "backend-servers"
88+
89+
extended_metadata = {
90+
"extendedMetadata" = "extendedMetadata"
91+
}
92+
93+
fault_domain = "FAULT-DOMAIN-2"
94+
95+
ipxe_script = "ipxeScript"
96+
97+
metadata = {
98+
"metadata" = "metadata"
99+
}
100+
101+
shape = "BM.HPC2.36"
102+
103+
source_details {
104+
boot_volume_size_in_gbs = "55"
105+
image_id = "${var.InstanceImageOCID[var.region]}"
106+
source_type = "image"
107+
}
108+
}
109+
}
110+
111+
source = "NONE"
112+
}
113+
114+
resource "oci_core_cluster_network" "test_cluster_network" {
115+
compartment_id = "${var.compartment_id}"
116+
display_name = "hpc-cluster-network"
117+
118+
instance_pools {
119+
display_name = "hpc-cluster-network"
120+
instance_configuration_id = "${oci_core_instance_configuration.test_instance_configuration.id}"
121+
size = "1"
122+
}
123+
124+
placement_configuration {
125+
availability_domain = "${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}"
126+
primary_subnet_id = "${oci_core_subnet.test_subnet.id}"
127+
}
128+
}

examples/networking/network_security_group/network_security_group.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ resource "oci_core_network_security_group_security_rule" "test_network_security_
101101
network_security_group_id = "${oci_core_network_security_group.test_network_security_group.id}"
102102
destination = "0.0.0.0/0"
103103
direction = "EGRESS"
104-
protocol = "1"
104+
protocol = "17"
105105
stateless = false
106106

107107
udp_options {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/terraform-providers/terraform-provider-oci
33
require (
44
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce // indirect
55
github.com/hashicorp/terraform v0.12.4-0.20190628193153-a74738cd35fc
6-
github.com/oracle/oci-go-sdk v8.0.0+incompatible
6+
github.com/oracle/oci-go-sdk v8.1.0+incompatible
77
github.com/stretchr/objx v0.1.1 // indirect
88
github.com/stretchr/testify v1.3.0
99
gopkg.in/yaml.v2 v2.2.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ github.com/oracle/oci-go-sdk v7.1.0+incompatible h1:ul/J6rOlLTuVgAB9oSBMwse0U9q8
286286
github.com/oracle/oci-go-sdk v7.1.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
287287
github.com/oracle/oci-go-sdk v8.0.0+incompatible h1:NWNIJkMFgtFUabPOL6xGk/ZhH+G9qJan4f0/UL75AvI=
288288
github.com/oracle/oci-go-sdk v8.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
289+
github.com/oracle/oci-go-sdk v8.1.0+incompatible h1:4xcTgxetS9E7P7LHh9tUsmqqqJE/XGwOqeBFXPSiZAE=
290+
github.com/oracle/oci-go-sdk v8.1.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
289291
github.com/packer-community/winrmcp v0.0.0-20180102160824-81144009af58/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk=
290292
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
291293
github.com/pkg/errors v0.0.0-20170505043639-c605e284fe17/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
3+
package provider
4+
5+
import (
6+
"context"
7+
8+
"github.com/hashicorp/terraform/helper/schema"
9+
oci_core "github.com/oracle/oci-go-sdk/core"
10+
)
11+
12+
func CoreClusterNetworkDataSource() *schema.Resource {
13+
fieldMap := make(map[string]*schema.Schema)
14+
fieldMap["cluster_network_id"] = &schema.Schema{
15+
Type: schema.TypeString,
16+
Required: true,
17+
}
18+
return GetSingularDataSourceItemSchema(CoreClusterNetworkResource(), fieldMap, readSingularCoreClusterNetwork)
19+
}
20+
21+
func readSingularCoreClusterNetwork(d *schema.ResourceData, m interface{}) error {
22+
sync := &CoreClusterNetworkDataSourceCrud{}
23+
sync.D = d
24+
sync.Client = m.(*OracleClients).computeManagementClient
25+
26+
return ReadResource(sync)
27+
}
28+
29+
type CoreClusterNetworkDataSourceCrud struct {
30+
D *schema.ResourceData
31+
Client *oci_core.ComputeManagementClient
32+
Res *oci_core.GetClusterNetworkResponse
33+
}
34+
35+
func (s *CoreClusterNetworkDataSourceCrud) VoidState() {
36+
s.D.SetId("")
37+
}
38+
39+
func (s *CoreClusterNetworkDataSourceCrud) Get() error {
40+
request := oci_core.GetClusterNetworkRequest{}
41+
42+
if clusterNetworkId, ok := s.D.GetOkExists("cluster_network_id"); ok {
43+
tmp := clusterNetworkId.(string)
44+
request.ClusterNetworkId = &tmp
45+
}
46+
47+
request.RequestMetadata.RetryPolicy = getRetryPolicy(false, "core")
48+
49+
response, err := s.Client.GetClusterNetwork(context.Background(), request)
50+
if err != nil {
51+
return err
52+
}
53+
54+
s.Res = &response
55+
return nil
56+
}
57+
58+
func (s *CoreClusterNetworkDataSourceCrud) SetData() error {
59+
if s.Res == nil {
60+
return nil
61+
}
62+
63+
s.D.SetId(*s.Res.Id)
64+
65+
if s.Res.CompartmentId != nil {
66+
s.D.Set("compartment_id", *s.Res.CompartmentId)
67+
}
68+
69+
if s.Res.DefinedTags != nil {
70+
s.D.Set("defined_tags", definedTagsToMap(s.Res.DefinedTags))
71+
}
72+
73+
if s.Res.DisplayName != nil {
74+
s.D.Set("display_name", *s.Res.DisplayName)
75+
}
76+
77+
s.D.Set("freeform_tags", s.Res.FreeformTags)
78+
79+
instancePools := []interface{}{}
80+
for _, item := range s.Res.InstancePools {
81+
instancePools = append(instancePools, InstancePoolToMap(item))
82+
}
83+
s.D.Set("instance_pools", instancePools)
84+
85+
if s.Res.PlacementConfiguration != nil {
86+
s.D.Set("placement_configuration", []interface{}{ClusterNetworkPlacementConfigurationDetailsToMap(s.Res.PlacementConfiguration, true)})
87+
} else {
88+
s.D.Set("placement_configuration", nil)
89+
}
90+
91+
s.D.Set("state", s.Res.LifecycleState)
92+
93+
if s.Res.TimeCreated != nil {
94+
s.D.Set("time_created", s.Res.TimeCreated.String())
95+
}
96+
97+
if s.Res.TimeUpdated != nil {
98+
s.D.Set("time_updated", s.Res.TimeUpdated.String())
99+
}
100+
101+
return nil
102+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
3+
package provider
4+
5+
import (
6+
"fmt"
7+
"strings"
8+
"testing"
9+
10+
"github.com/hashicorp/terraform/helper/resource"
11+
"github.com/hashicorp/terraform/terraform"
12+
13+
"github.com/terraform-providers/terraform-provider-oci/httpreplay"
14+
)
15+
16+
var (
17+
clusterNetworkInstanceDataSourceRepresentation = map[string]interface{}{
18+
"cluster_network_id": Representation{repType: Required, create: `${oci_core_cluster_network.test_cluster_network.id}`},
19+
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
20+
}
21+
22+
ClusterNetworkInstanceResourceConfig = ClusterNetworkResourceConfig
23+
)
24+
25+
func TestCoreClusterNetworkInstanceResource_basic(t *testing.T) {
26+
httpreplay.SetScenario("TestCoreClusterNetworkInstanceResource_basic")
27+
defer httpreplay.SaveScenario()
28+
if !strings.Contains(getEnvSettingWithBlankDefault("enabled_tests"), "ClusterNetwork") {
29+
t.Skip("ClusterNetwork test not supported due to limited host capacity")
30+
}
31+
provider := testAccProvider
32+
config := testProviderConfig()
33+
34+
compartmentId := getEnvSettingWithBlankDefault("compartment_ocid")
35+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
36+
37+
datasourceName := "data.oci_core_cluster_network_instances.test_cluster_network_instances"
38+
39+
resource.Test(t, resource.TestCase{
40+
PreCheck: func() { testAccPreCheck(t) },
41+
Providers: map[string]terraform.ResourceProvider{
42+
"oci": provider,
43+
},
44+
Steps: []resource.TestStep{
45+
// verify datasource
46+
{
47+
Config: config +
48+
generateDataSourceFromRepresentationMap("oci_core_cluster_network_instances", "test_cluster_network_instances", Required, Create, clusterNetworkInstanceDataSourceRepresentation) +
49+
compartmentIdVariableStr + ClusterNetworkInstanceResourceConfig,
50+
Check: resource.ComposeAggregateTestCheckFunc(
51+
resource.TestCheckResourceAttrSet(datasourceName, "cluster_network_id"),
52+
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
53+
54+
resource.TestCheckResourceAttrSet(datasourceName, "instances.#"),
55+
resource.TestCheckResourceAttrSet(datasourceName, "instances.0.availability_domain"),
56+
resource.TestCheckResourceAttrSet(datasourceName, "instances.0.compartment_id"),
57+
resource.TestCheckResourceAttrSet(datasourceName, "instances.0.display_name"),
58+
resource.TestCheckResourceAttrSet(datasourceName, "instances.0.fault_domain"),
59+
resource.TestCheckResourceAttrSet(datasourceName, "instances.0.id"),
60+
resource.TestCheckResourceAttrSet(datasourceName, "instances.0.instance_configuration_id"),
61+
resource.TestCheckResourceAttr(datasourceName, "instances.0.load_balancer_backends.#", "1"),
62+
resource.TestCheckResourceAttrSet(datasourceName, "instances.0.region"),
63+
resource.TestCheckResourceAttrSet(datasourceName, "instances.0.shape"),
64+
resource.TestCheckResourceAttrSet(datasourceName, "instances.0.state"),
65+
resource.TestCheckResourceAttrSet(datasourceName, "instances.0.time_created"),
66+
),
67+
},
68+
},
69+
})
70+
}

0 commit comments

Comments
 (0)