From c51fb79bf370cefc513cbcb81861145202eda1e0 Mon Sep 17 00:00:00 2001 From: Jake Champlin Date: Thu, 6 Apr 2017 13:05:52 -0400 Subject: [PATCH] provider/opc: Remove 'model' from instance networking Removes `model` as a configurable attribute in instance networking. Also adds missing `name` attribute from `ip_reservation` docs ``` $ make testacc TEST=./builtin/providers/opc TESTARGS="-run=TestAccOPCInstance_ipNetwork" ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/04/06 12:53:13 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/opc -v -run=TestAccOPCInstance_ipNetwork -timeout 120m === RUN TestAccOPCInstance_ipNetwork --- PASS: TestAccOPCInstance_ipNetwork (258.69s) PASS ok github.com/hashicorp/terraform/builtin/providers/opc 258.721s ``` ``` $ make testacc TEST=./builtin/providers/opc TESTARGS="-run=TestAccOPCInstance_sharedNetworking" ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/04/06 12:58:43 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/opc -v -run=TestAccOPCInstance_sharedNetworking -timeout 120m === RUN TestAccOPCInstance_sharedNetworking --- PASS: TestAccOPCInstance_sharedNetworking (253.15s) PASS ok github.com/hashicorp/terraform/builtin/providers/opc 253.180s ``` --- builtin/providers/opc/resource_instance.go | 29 ++----------------- .../providers/opc/resource_instance_test.go | 2 -- .../opc_compute_ip_reservation.html.markdown | 2 ++ 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/builtin/providers/opc/resource_instance.go b/builtin/providers/opc/resource_instance.go index 8157835ad..a2840829e 100644 --- a/builtin/providers/opc/resource_instance.go +++ b/builtin/providers/opc/resource_instance.go @@ -128,20 +128,6 @@ func resourceInstance() *schema.Resource { Optional: true, }, - "model": { - // Required, Shared Network only. - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { - value := v.(string) - if value != "e1000" { - errors = append(errors, fmt.Errorf("Model needs to be set to 'e1000', got: %s", value)) - } - return - }, - }, - "name_servers": { // Optional, IP Network + Shared Network Type: schema.TypeList, @@ -205,7 +191,6 @@ func resourceInstance() *schema.Resource { buf.WriteString(fmt.Sprintf("%d-", m["index"].(int))) buf.WriteString(fmt.Sprintf("%s-", m["vnic"].(string))) buf.WriteString(fmt.Sprintf("%s-", m["nat"])) - buf.WriteString(fmt.Sprintf("%s-", m["model"].(string))) return hashcode.String(buf.String()) }, }, @@ -618,6 +603,8 @@ func readNetworkInterfacesFromConfig(d *schema.ResourceData) (map[string]compute if ni["shared_network"].(bool) { // Populate shared network parameters info, err = readSharedNetworkFromConfig(ni) + // Set 'model' since we're configuring a shared network interface + info.Model = compute.NICDefaultModel } else { // Populate IP Network Parameters info, err = readIPNetworkFromConfig(ni) @@ -703,7 +690,6 @@ func readSharedNetworkFromConfig(ni map[string]interface{}) (compute.NetworkingI // function based off of multiple fields in the supplied schema. func validateSharedNetwork(ni map[string]interface{}) error { // A Shared Networking Interface MUST have the following attributes set: - // - "model" // - "nat" // The following attributes _cannot_ be set for a shared network: // - "ip_address" @@ -711,9 +697,6 @@ func validateSharedNetwork(ni map[string]interface{}) error { // - "mac_address" // - "vnic" // - "vnic_sets" - if d, ok := ni["model"]; !ok || d.(string) == "" { - return fmt.Errorf("'model' field needs to be set for a Shared Networking Interface") - } if _, ok := ni["nat"]; !ok { return fmt.Errorf("'nat' field needs to be set for a Shared Networking Interface") @@ -820,19 +803,12 @@ func readIPNetworkFromConfig(ni map[string]interface{}) (compute.NetworkingInfo, func validateIPNetwork(ni map[string]interface{}) error { // An IP Networking Interface MUST have the following attributes set: // - "ip_network" - // The following attributes _cannot_ be set for an IP Network: - // - "model" // Required to be set if d, ok := ni["ip_network"]; !ok || d.(string) == "" { return fmt.Errorf("'ip_network' field is required for an IP Network interface") } - // Requird to be unset - if d, ok := ni["model"]; ok && d.(string) != "" { - return fmt.Errorf("'model' cannot be set in an IP Network Interface") - } - return nil } @@ -872,7 +848,6 @@ func readNetworkInterfaces(d *schema.ResourceData, ifaces map[string]compute.Net res["mac_address"] = iface.MACAddress } if iface.Model != "" { - res["model"] = iface.Model // Model can only be set on Shared networks res["shared_network"] = true } diff --git a/builtin/providers/opc/resource_instance_test.go b/builtin/providers/opc/resource_instance_test.go index 36b214db4..3c4e0ffe6 100644 --- a/builtin/providers/opc/resource_instance_test.go +++ b/builtin/providers/opc/resource_instance_test.go @@ -67,7 +67,6 @@ func TestAccOPCInstance_sharedNetworking(t *testing.T) { // Check Data Source to validate networking attributes resource.TestCheckResourceAttr(dataName, "shared_network", "true"), resource.TestCheckResourceAttr(dataName, "nat.#", "1"), - resource.TestCheckResourceAttr(dataName, "model", "e1000"), resource.TestCheckResourceAttr(dataName, "sec_lists.#", "1"), resource.TestCheckResourceAttr(dataName, "name_servers.#", "0"), resource.TestCheckResourceAttr(dataName, "vnic_sets.#", "0"), @@ -205,7 +204,6 @@ resource "opc_compute_instance" "test" { tags = ["tag1", "tag2"] networking_info { index = 0 - model = "e1000" nat = ["ippool:/oracle/public/ippool"] shared_network = true } diff --git a/website/source/docs/providers/opc/r/opc_compute_ip_reservation.html.markdown b/website/source/docs/providers/opc/r/opc_compute_ip_reservation.html.markdown index 1201fe9cc..faf2184aa 100644 --- a/website/source/docs/providers/opc/r/opc_compute_ip_reservation.html.markdown +++ b/website/source/docs/providers/opc/r/opc_compute_ip_reservation.html.markdown @@ -30,6 +30,8 @@ The following arguments are supported: (if true), or may be returned to the pool and replaced with a different IP address when an instance is restarted, or deleted and recreated (if false). +* `name` - (Optional) Name of the IP Reservation. Will be generated if unspecified. + * `tags` - (Optional) List of tags that may be applied to the IP reservation. ## Import