azure: support nics with multiple ipconfigs

This commit is contained in:
Cole Mickens 2016-11-15 12:59:40 -08:00
parent 2110f72e4c
commit 6357c391f9

View File

@ -151,9 +151,12 @@ func getPrimaryIPConfig(nic network.Interface) (*network.InterfaceIPConfiguratio
return &((*nic.Properties.IPConfigurations)[0]), nil
}
// we're here because we either have multiple ipconfigs and can't determine the primary:
// https://github.com/Azure/azure-rest-api-specs/issues/305
// or somehow we had zero ipconfigs
for _, ref := range *nic.Properties.IPConfigurations {
if *ref.Properties.Primary {
return &ref, nil
}
}
return nil, fmt.Errorf("failed to determine the determine primary ipconfig. nicname=%q", *nic.Name)
}