|
|
|
|
@ -52,15 +52,15 @@ func resourceCloudStackVPC() *schema.Resource {
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"zone": &schema.Schema{
|
|
|
|
|
"source_nat_ip": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Computed: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"source_nat_ip": &schema.Schema{
|
|
|
|
|
"zone": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
@ -157,19 +157,27 @@ func resourceCloudStackVPCRead(d *schema.ResourceData, meta interface{}) error {
|
|
|
|
|
setValueOrID(d, "project", v.Project, v.Projectid)
|
|
|
|
|
setValueOrID(d, "zone", v.Zonename, v.Zoneid)
|
|
|
|
|
|
|
|
|
|
// Grab the source NAT IP that CloudStack assigned.
|
|
|
|
|
// Create a new parameter struct
|
|
|
|
|
p := cs.Address.NewListPublicIpAddressesParams()
|
|
|
|
|
p.SetVpcid(d.Id())
|
|
|
|
|
p.SetIssourcenat(true)
|
|
|
|
|
|
|
|
|
|
if _, ok := d.GetOk("project"); ok {
|
|
|
|
|
p.SetProjectid(v.Projectid)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
l, e := cs.Address.ListPublicIpAddresses(p)
|
|
|
|
|
if (e == nil) && (l.Count == 1) {
|
|
|
|
|
d.Set("source_nat_ip", l.PublicIpAddresses[0].Ipaddress)
|
|
|
|
|
// Get the source NAT IP assigned to the VPC
|
|
|
|
|
l, err := cs.Address.ListPublicIpAddresses(p)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if l.Count != 1 {
|
|
|
|
|
return fmt.Errorf("Unexpected number (%d) of source NAT IPs returned", l.Count)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d.Set("source_nat_ip", l.PublicIpAddresses[0].Ipaddress)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|