Skip to content

Commit

Permalink
Use new grid restartservices function from fanatic/go-infoblox librar…
Browse files Browse the repository at this point in the history
…y for host record creation/deletion.
  • Loading branch information
dn1s committed Mar 27, 2019
1 parent 2e19698 commit 0c0d784
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions infoblox/resource_infoblox_record_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ func resourceInfobloxHostRecordCreate(d *schema.ResourceData, meta interface{})
return fmt.Errorf("error creating infoblox Host record: %s", err.Error())
}

grids, err := client.GetGrids()
if err != nil {
return fmt.Errorf("error getting grids: %s", err.Error())
}

for _, grid := range grids {
gridObject := client.GridObject(grid.Ref)
err = gridObject.RestartServicesForGrid("SIMULTANEOUSLY", "RESTART_IF_NEEDED", "ALL")
if err != nil {
return fmt.Errorf("error restarting services after deletion: %s", err.Error())
}
}

d.SetId(recordID)
log.Printf("[INFO] Infoblox Host record created with ID: %s", d.Id())

Expand Down Expand Up @@ -294,5 +307,18 @@ func resourceInfobloxHostRecordDelete(d *schema.ResourceData, meta interface{})
return fmt.Errorf("error deleting Infoblox Host record: %s", err.Error())
}

grids, err := client.GetGrids()
if err != nil {
return fmt.Errorf("error getting grid: %s", err.Error())
}

for _, grid := range grids {
gridObject := client.GridObject(grid.Ref)
err = gridObject.RestartServicesForGrid("SIMULTANEOUSLY", "RESTART_IF_NEEDED", "ALL")
if err != nil {
return fmt.Errorf("error restarting services after deletion: %s", err.Error())
}
}

return nil
}

0 comments on commit 0c0d784

Please sign in to comment.