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,37 +449,39 @@ func resourceProfitBricksServerRead(d *schema.ResourceData, meta interface{}) er
serverId := d.Id()
server := profitbricks.GetServer(dcId, serverId)
primarynic := d.Get("primary_nic").(string)
d.Set("name", server.Properties.Name)
d.Set("cores", server.Properties.Cores)
d.Set("ram", server.Properties.Ram)
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))
if len(nic.Properties.Ips) > 0 {
d.Set("primary_ip", nic.Properties.Ips[0])
}
nic := profitbricks.GetNic(dcId, serverId, primarynic.(string))
if nRaw, ok := d.GetOk("nic"); ok {
log.Printf("[DEBUG] parsing nic")
nicRaw := nRaw.(*schema.Set).List()
for _, raw := range nicRaw {
rawMap := raw.(map[string]interface{})
rawMap["lan"] = nic.Properties.Lan
rawMap["name"] = nic.Properties.Name
rawMap["dhcp"] = nic.Properties.Dhcp
rawMap["nat"] = nic.Properties.Nat
rawMap["firewall_active"] = nic.Properties.FirewallActive
rawMap["ips"] = nic.Properties.Ips
if len(nic.Properties.Ips) > 0 {
d.Set("primary_ip", nic.Properties.Ips[0])
}
if nRaw, ok := d.GetOk("nic"); ok {
log.Printf("[DEBUG] parsing nic")
nicRaw := nRaw.(*schema.Set).List()
for _, raw := range nicRaw {
rawMap := raw.(map[string]interface{})
rawMap["lan"] = nic.Properties.Lan
rawMap["name"] = nic.Properties.Name
rawMap["dhcp"] = nic.Properties.Dhcp
rawMap["nat"] = nic.Properties.Nat
rawMap["firewall_active"] = nic.Properties.FirewallActive
rawMap["ips"] = nic.Properties.Ips
}
d.Set("nic", nicRaw)
}
d.Set("nic", nicRaw)
}
if server.Properties.BootVolume != nil {