panic_prevention (#12819)

This commit is contained in:
Jasmin Gacic 2017-03-17 19:27:21 +01:00 committed by Paul Stack
parent 23bc24bfcc
commit bbded01863
1 changed files with 24 additions and 22 deletions

View File

@ -449,15 +449,16 @@ func resourceProfitBricksServerRead(d *schema.ResourceData, meta interface{}) er
serverId := d.Id() serverId := d.Id()
server := profitbricks.GetServer(dcId, serverId) server := profitbricks.GetServer(dcId, serverId)
primarynic := d.Get("primary_nic").(string)
d.Set("name", server.Properties.Name) d.Set("name", server.Properties.Name)
d.Set("cores", server.Properties.Cores) d.Set("cores", server.Properties.Cores)
d.Set("ram", server.Properties.Ram) d.Set("ram", server.Properties.Ram)
d.Set("availability_zone", server.Properties.AvailabilityZone) d.Set("availability_zone", server.Properties.AvailabilityZone)
d.Set("primary_nic", primarynic)
nic := profitbricks.GetNic(dcId, serverId, primarynic) if primarynic, ok := d.GetOk("primary_nic"); ok {
d.Set("primary_nic", primarynic.(string))
nic := profitbricks.GetNic(dcId, serverId, primarynic.(string))
if len(nic.Properties.Ips) > 0 { if len(nic.Properties.Ips) > 0 {
d.Set("primary_ip", nic.Properties.Ips[0]) d.Set("primary_ip", nic.Properties.Ips[0])
@ -481,6 +482,7 @@ func resourceProfitBricksServerRead(d *schema.ResourceData, meta interface{}) er
} }
d.Set("nic", nicRaw) d.Set("nic", nicRaw)
} }
}
if server.Properties.BootVolume != nil { if server.Properties.BootVolume != nil {
d.Set("boot_volume", server.Properties.BootVolume.Id) d.Set("boot_volume", server.Properties.BootVolume.Id)