/// <summary>
/// Load key pairs to view model with AWS data based on region selected and EC2 classic/vpc
/// </summary>
private void LoadKeyPairs(AmazonEC2Client ec2Client)
{
try
{
DescribeKeyPairsRequest keyreq = new DescribeKeyPairsRequest();
DescribeKeyPairsResponse keyresp = ec2Client.DescribeKeyPairs(keyreq);
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
{
vm.KeyPairs.Clear();
}));
foreach (KeyPair kp in keyresp.DescribeKeyPairsResult.KeyPair)
{
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
{
vm.KeyPairs.Add(kp.KeyName);
}));
}
}
catch (Exception ex)
{
LogManager.LogEntry(ex.Message);
LogManager.LogEntry(ex.StackTrace);
throw new DataLoadingException("Error occurred loading key pairs for region and environment type");
}
}