update compute instance security group Read operation
This commit is contained in:
parent
2b152f38b2
commit
49b01a4f0a
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue