Merge pull request #4851 from Sheile/b-openstack-convert-fixedips

provider/openstack Convert FixedIPS from struct to map for ResourceData
This commit is contained in:
Joe Topjian 2016-01-31 14:59:41 -07:00
commit 2e2ea033c5
2 changed files with 13 additions and 1 deletions

View File

@ -81,6 +81,7 @@ func resourceNetworkingPortV2() *schema.Resource {
Type: schema.TypeList, Type: schema.TypeList,
Optional: true, Optional: true,
ForceNew: false, ForceNew: false,
Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"subnet_id": &schema.Schema{ "subnet_id": &schema.Schema{
@ -90,6 +91,7 @@ func resourceNetworkingPortV2() *schema.Resource {
"ip_address": &schema.Schema{ "ip_address": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
Computed: true,
}, },
}, },
}, },
@ -163,7 +165,16 @@ func resourceNetworkingPortV2Read(d *schema.ResourceData, meta interface{}) erro
d.Set("device_owner", p.DeviceOwner) d.Set("device_owner", p.DeviceOwner)
d.Set("security_group_ids", p.SecurityGroups) d.Set("security_group_ids", p.SecurityGroups)
d.Set("device_id", p.DeviceID) d.Set("device_id", p.DeviceID)
d.Set("fixed_ip", p.FixedIPs)
// Convert FixedIPs to list of map
var ips []map[string]interface{}
for _, ipObject := range p.FixedIPs {
ip := make(map[string]interface{})
ip["subnet_id"] = ipObject.SubnetID
ip["ip_address"] = ipObject.IPAddress
ips = append(ips, ip)
}
d.Set("fixed_ip", ips)
return nil return nil
} }

View File

@ -84,3 +84,4 @@ The following attributes are exported:
* `device_owner` - See Argument Reference above. * `device_owner` - See Argument Reference above.
* `security_groups` - See Argument Reference above. * `security_groups` - See Argument Reference above.
* `device_id` - See Argument Reference above. * `device_id` - See Argument Reference above.
* `fixed_ip/ip_address` - See Argument Reference above.