Changing how security groups are read for compute instances

This commit is contained in:
Joe Topjian 2015-02-12 20:58:12 +00:00 committed by Jon Perritt
parent 64d53009a0
commit 4df32aebed
1 changed files with 3 additions and 11 deletions

View File

@ -366,17 +366,9 @@ func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) err
d.Set("metadata", server.Metadata)
secGrpNames := []string{}
err = secgroups.ListByServer(computeClient, d.Id()).EachPage(func(page pagination.Page) (bool, error) {
secGrpList, err := secgroups.ExtractSecurityGroups(page)
if err != nil {
return false, fmt.Errorf("Error getting security groups for OpenStack server: %s", err)
}
log.Printf("[DEBUG] secGrpList: %+v\n\n", secGrpList)
for _, sg := range secGrpList {
secGrpNames = append(secGrpNames, sg.Name)
}
return true, nil
})
for _, sg := range server.SecurityGroups {
secGrpNames = append(secGrpNames, sg["name"].(string))
}
d.Set("security_groups", secGrpNames)
flavorId, ok := server.Flavor["id"].(string)