provider/openstack: gophercloud migration: Making GatewayIP computed
This commit is contained in:
parent
520b3dda82
commit
ed0fe74d59
|
@ -71,12 +71,12 @@ func resourceNetworkingSubnetV2() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: false,
|
ForceNew: false,
|
||||||
|
Computed: true,
|
||||||
},
|
},
|
||||||
"no_gateway": &schema.Schema{
|
"no_gateway": &schema.Schema{
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: false,
|
ForceNew: false,
|
||||||
Deprecated: "This argument is no longer required. Instead, omit gateway_ip or set it to an empty string",
|
|
||||||
},
|
},
|
||||||
"ip_version": &schema.Schema{
|
"ip_version": &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
|
@ -144,13 +144,14 @@ func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{})
|
||||||
MapValueSpecs(d),
|
MapValueSpecs(d),
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("gateway_ip"); ok {
|
noGateway := d.Get("no_gateway").(bool)
|
||||||
noGateway := d.Get("no_gateway").(bool)
|
gatewayIP := d.Get("gateway_ip").(string)
|
||||||
if noGateway {
|
|
||||||
return fmt.Errorf("Both gateway_ip and no_gateway cannot be set.")
|
|
||||||
}
|
|
||||||
|
|
||||||
gatewayIP := v.(string)
|
if gatewayIP != "" && noGateway {
|
||||||
|
return fmt.Errorf("Both gateway_ip and no_gateway cannot be set")
|
||||||
|
}
|
||||||
|
|
||||||
|
if gatewayIP != "" {
|
||||||
createOpts.GatewayIP = &gatewayIP
|
createOpts.GatewayIP = &gatewayIP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ func resourceNetworkingSubnetV2Read(d *schema.ResourceData, meta interface{}) er
|
||||||
return CheckDeleted(d, err, "subnet")
|
return CheckDeleted(d, err, "subnet")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] Retrieved Subnet %s: %+v", d.Id(), s)
|
log.Printf("[DEBUG] Retrieved Subnet %s: %#v", d.Id(), s)
|
||||||
|
|
||||||
d.Set("network_id", s.NetworkID)
|
d.Set("network_id", s.NetworkID)
|
||||||
d.Set("cidr", s.CIDR)
|
d.Set("cidr", s.CIDR)
|
||||||
|
@ -232,6 +233,13 @@ func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{})
|
||||||
|
|
||||||
var updateOpts subnets.UpdateOpts
|
var updateOpts subnets.UpdateOpts
|
||||||
|
|
||||||
|
noGateway := d.Get("no_gateway").(bool)
|
||||||
|
gatewayIP := d.Get("gateway_ip").(string)
|
||||||
|
|
||||||
|
if gatewayIP != "" && noGateway {
|
||||||
|
return fmt.Errorf("Both gateway_ip and no_gateway cannot be set")
|
||||||
|
}
|
||||||
|
|
||||||
if d.HasChange("name") {
|
if d.HasChange("name") {
|
||||||
updateOpts.Name = d.Get("name").(string)
|
updateOpts.Name = d.Get("name").(string)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue