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
```
This commit is contained in:
Jake Champlin 2017-04-06 13:05:52 -04:00
parent 273a925ead
commit c51fb79bf3
No known key found for this signature in database
GPG Key ID: DC31F41958EF4AC2
3 changed files with 4 additions and 29 deletions

View File

@ -128,20 +128,6 @@ func resourceInstance() *schema.Resource {
Optional: true, 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": { "name_servers": {
// Optional, IP Network + Shared Network // Optional, IP Network + Shared Network
Type: schema.TypeList, Type: schema.TypeList,
@ -205,7 +191,6 @@ func resourceInstance() *schema.Resource {
buf.WriteString(fmt.Sprintf("%d-", m["index"].(int))) buf.WriteString(fmt.Sprintf("%d-", m["index"].(int)))
buf.WriteString(fmt.Sprintf("%s-", m["vnic"].(string))) buf.WriteString(fmt.Sprintf("%s-", m["vnic"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["nat"])) buf.WriteString(fmt.Sprintf("%s-", m["nat"]))
buf.WriteString(fmt.Sprintf("%s-", m["model"].(string)))
return hashcode.String(buf.String()) return hashcode.String(buf.String())
}, },
}, },
@ -618,6 +603,8 @@ func readNetworkInterfacesFromConfig(d *schema.ResourceData) (map[string]compute
if ni["shared_network"].(bool) { if ni["shared_network"].(bool) {
// Populate shared network parameters // Populate shared network parameters
info, err = readSharedNetworkFromConfig(ni) info, err = readSharedNetworkFromConfig(ni)
// Set 'model' since we're configuring a shared network interface
info.Model = compute.NICDefaultModel
} else { } else {
// Populate IP Network Parameters // Populate IP Network Parameters
info, err = readIPNetworkFromConfig(ni) 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. // function based off of multiple fields in the supplied schema.
func validateSharedNetwork(ni map[string]interface{}) error { func validateSharedNetwork(ni map[string]interface{}) error {
// A Shared Networking Interface MUST have the following attributes set: // A Shared Networking Interface MUST have the following attributes set:
// - "model"
// - "nat" // - "nat"
// The following attributes _cannot_ be set for a shared network: // The following attributes _cannot_ be set for a shared network:
// - "ip_address" // - "ip_address"
@ -711,9 +697,6 @@ func validateSharedNetwork(ni map[string]interface{}) error {
// - "mac_address" // - "mac_address"
// - "vnic" // - "vnic"
// - "vnic_sets" // - "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 { if _, ok := ni["nat"]; !ok {
return fmt.Errorf("'nat' field needs to be set for a Shared Networking Interface") 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 { func validateIPNetwork(ni map[string]interface{}) error {
// An IP Networking Interface MUST have the following attributes set: // An IP Networking Interface MUST have the following attributes set:
// - "ip_network" // - "ip_network"
// The following attributes _cannot_ be set for an IP Network:
// - "model"
// Required to be set // Required to be set
if d, ok := ni["ip_network"]; !ok || d.(string) == "" { if d, ok := ni["ip_network"]; !ok || d.(string) == "" {
return fmt.Errorf("'ip_network' field is required for an IP Network interface") 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 return nil
} }
@ -872,7 +848,6 @@ func readNetworkInterfaces(d *schema.ResourceData, ifaces map[string]compute.Net
res["mac_address"] = iface.MACAddress res["mac_address"] = iface.MACAddress
} }
if iface.Model != "" { if iface.Model != "" {
res["model"] = iface.Model
// Model can only be set on Shared networks // Model can only be set on Shared networks
res["shared_network"] = true res["shared_network"] = true
} }

View File

@ -67,7 +67,6 @@ func TestAccOPCInstance_sharedNetworking(t *testing.T) {
// Check Data Source to validate networking attributes // Check Data Source to validate networking attributes
resource.TestCheckResourceAttr(dataName, "shared_network", "true"), resource.TestCheckResourceAttr(dataName, "shared_network", "true"),
resource.TestCheckResourceAttr(dataName, "nat.#", "1"), resource.TestCheckResourceAttr(dataName, "nat.#", "1"),
resource.TestCheckResourceAttr(dataName, "model", "e1000"),
resource.TestCheckResourceAttr(dataName, "sec_lists.#", "1"), resource.TestCheckResourceAttr(dataName, "sec_lists.#", "1"),
resource.TestCheckResourceAttr(dataName, "name_servers.#", "0"), resource.TestCheckResourceAttr(dataName, "name_servers.#", "0"),
resource.TestCheckResourceAttr(dataName, "vnic_sets.#", "0"), resource.TestCheckResourceAttr(dataName, "vnic_sets.#", "0"),
@ -205,7 +204,6 @@ resource "opc_compute_instance" "test" {
tags = ["tag1", "tag2"] tags = ["tag1", "tag2"]
networking_info { networking_info {
index = 0 index = 0
model = "e1000"
nat = ["ippool:/oracle/public/ippool"] nat = ["ippool:/oracle/public/ippool"]
shared_network = true shared_network = true
} }

View File

@ -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 (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). 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. * `tags` - (Optional) List of tags that may be applied to the IP reservation.
## Import ## Import