update compute instance security group Read operation

This commit is contained in:
Jon Perritt 2015-02-11 21:56:26 -07:00
parent 2b152f38b2
commit 49b01a4f0a
1 changed files with 3 additions and 5 deletions

View File

@ -175,7 +175,6 @@ func resourceComputeInstanceV2() *schema.Resource {
"volume": &schema.Schema{ "volume": &schema.Schema{
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"id": &schema.Schema{ "id": &schema.Schema{
@ -369,19 +368,18 @@ func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) err
d.Set("metadata", server.Metadata) d.Set("metadata", server.Metadata)
secGrpNum := 0 secGrpNames := []string{}
err = secgroups.ListByServer(computeClient, d.Id()).EachPage(func(page pagination.Page) (bool, error) { err = secgroups.ListByServer(computeClient, d.Id()).EachPage(func(page pagination.Page) (bool, error) {
secGrpList, err := secgroups.ExtractSecurityGroups(page) secGrpList, err := secgroups.ExtractSecurityGroups(page)
if err != nil { if err != nil {
return false, fmt.Errorf("Error getting security groups for OpenStack server: %s", err) return false, fmt.Errorf("Error getting security groups for OpenStack server: %s", err)
} }
for _, sg := range secGrpList { for _, sg := range secGrpList {
d.Set(fmt.Sprintf("security_groups.%d", secGrpNum), sg.Name) secGrpNames = append(secGrpNames, sg.Name)
secGrpNum++
} }
return true, nil return true, nil
}) })
d.Set("security_groups.#", secGrpNum) d.Set("security_groups", secGrpNames)
flavorId, ok := server.Flavor["id"].(string) flavorId, ok := server.Flavor["id"].(string)
if !ok { if !ok {