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{
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": &schema.Schema{
@ -369,19 +368,18 @@ func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) err
d.Set("metadata", server.Metadata)
secGrpNum := 0
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)
}
for _, sg := range secGrpList {
d.Set(fmt.Sprintf("security_groups.%d", secGrpNum), sg.Name)
secGrpNum++
secGrpNames = append(secGrpNames, sg.Name)
}
return true, nil
})
d.Set("security_groups.#", secGrpNum)
d.Set("security_groups", secGrpNames)
flavorId, ok := server.Flavor["id"].(string)
if !ok {