Merge pull request #1745 from hashicorp/b-openstack-bool

provider/openstack: enable_dhcp should be bool [GH-1741]
This commit is contained in:
Mitchell Hashimoto 2015-04-30 14:27:14 -07:00
commit aaf94e7cec
1 changed files with 7 additions and 18 deletions

View File

@ -3,7 +3,6 @@ package openstack
import (
"fmt"
"log"
"strconv"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
@ -72,7 +71,7 @@ func resourceNetworkingSubnetV2() *schema.Resource {
ForceNew: true,
},
"enable_dhcp": &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeBool,
Optional: true,
ForceNew: false,
},
@ -125,13 +124,9 @@ func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{})
HostRoutes: resourceSubnetHostRoutesV2(d),
}
edRaw := d.Get("enable_dhcp").(string)
if edRaw != "" {
ed, err := strconv.ParseBool(edRaw)
if err != nil {
return fmt.Errorf("enable_dhcp, if provided, must be either 'true' or 'false'")
}
createOpts.EnableDHCP = &ed
if raw, ok := d.GetOk("enable_dhcp"); ok {
value := raw.(bool)
createOpts.EnableDHCP = &value
}
log.Printf("[DEBUG] Create Options: %#v", createOpts)
@ -167,7 +162,7 @@ func resourceNetworkingSubnetV2Read(d *schema.ResourceData, meta interface{}) er
d.Set("tenant_id", s.TenantID)
d.Set("allocation_pools", s.AllocationPools)
d.Set("gateway_ip", s.GatewayIP)
d.Set("enable_dhcp", strconv.FormatBool(s.EnableDHCP))
d.Set("enable_dhcp", s.EnableDHCP)
d.Set("dns_nameservers", s.DNSNameservers)
d.Set("host_routes", s.HostRoutes)
@ -200,14 +195,8 @@ func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{})
}
if d.HasChange("enable_dhcp") {
edRaw := d.Get("enable_dhcp").(string)
if edRaw != "" {
ed, err := strconv.ParseBool(edRaw)
if err != nil {
return fmt.Errorf("enable_dhcp, if provided, must be either 'true' or 'false'")
}
updateOpts.EnableDHCP = &ed
}
v := d.Get("enable_dhcp").(bool)
updateOpts.EnableDHCP = &v
}
log.Printf("[DEBUG] Updating Subnet %s with options: %+v", d.Id(), updateOpts)