private List <AmazonBermudaNode> GetActiveClusterBermudaNodes()
        {
            AmazonEC2 ec2;

            ec2 = AWSClientFactory.CreateAmazonEC2Client();
            var resp      = ec2.DescribeInstances(new DescribeInstancesRequest());
            var addresses = resp.DescribeInstancesResult.Reservation;

            var currentIP             = CurrentIPAddress.ToString();
            var allAmazonBermudaNodes = new List <AmazonBermudaNode>();

            foreach (var a in addresses)
            {
                foreach (var ri in a.RunningInstance.Where(i => !string.IsNullOrWhiteSpace(i.PrivateIpAddress)))
                {
                    var  newNode        = new AmazonBermudaNode();
                    bool hasNodeId      = false;
                    bool hasClusterName = false;
                    foreach (var tag in ri.Tag)
                    {
                        if (tag.Key == BERMUDA_NODE_ID_KEY)
                        {
                            newNode.AmazonInstance    = ri;
                            newNode.IsCurrentInstance = ri.PrivateIpAddress == currentIP;
                            newNode.NodeId            = Int32.Parse(tag.Value);

                            var pi = new PeerInfo();
                            pi.Id            = ri.InstanceId;
                            pi.EndPoint      = new IPEndPoint(IPAddress.Parse(ri.PrivateIpAddress), INTERNAL_PORT);
                            newNode.PeerInfo = pi;

                            hasNodeId = true;
                        }
                        else if (tag.Key == BERMUDA_CLUSTER_NAME_KEY)
                        {
                            newNode.ClusterName = tag.Value;
                            hasClusterName      = true;
                        }
                    }
                    if (hasNodeId && hasClusterName)
                    {
                        allAmazonBermudaNodes.Add(newNode);
                    }
                }
            }

            var activeClusterName         = allAmazonBermudaNodes.Single(abn => abn.IsCurrentInstance).ClusterName;
            var activeClusterBermudaNodes = allAmazonBermudaNodes.Where(abn => abn.ClusterName == activeClusterName);

            return(activeClusterBermudaNodes.ToList());
        }
        private List<AmazonBermudaNode> GetActiveClusterBermudaNodes()
        {
            AmazonEC2 ec2;
            ec2 = AWSClientFactory.CreateAmazonEC2Client();
            var resp = ec2.DescribeInstances(new DescribeInstancesRequest());
            var addresses = resp.DescribeInstancesResult.Reservation;

            var currentIP = CurrentIPAddress.ToString();
            var allAmazonBermudaNodes = new List<AmazonBermudaNode>();
            foreach (var a in addresses)
            {
                foreach (var ri in a.RunningInstance.Where(i => !string.IsNullOrWhiteSpace(i.PrivateIpAddress)))
                {
                    var newNode = new AmazonBermudaNode();
                    bool hasNodeId = false;
                    bool hasClusterName = false;
                    foreach (var tag in ri.Tag)
                    {
                        if (tag.Key == BERMUDA_NODE_ID_KEY)
                        {                      
                            newNode.AmazonInstance = ri;
                            newNode.IsCurrentInstance = ri.PrivateIpAddress == currentIP;
                            newNode.NodeId = Int32.Parse(tag.Value);
                            
                            var pi = new PeerInfo();
                            pi.Id = ri.InstanceId;
                            pi.EndPoint = new IPEndPoint(IPAddress.Parse(ri.PrivateIpAddress), INTERNAL_PORT);
                            newNode.PeerInfo = pi;

                            hasNodeId = true;
                        }
                        else if (tag.Key == BERMUDA_CLUSTER_NAME_KEY)
                        {
                            newNode.ClusterName = tag.Value;
                            hasClusterName = true;
                        }
                    }
                    if (hasNodeId && hasClusterName)
                    {
                        allAmazonBermudaNodes.Add(newNode);
                    }
                }
            }

            var activeClusterName = allAmazonBermudaNodes.Single(abn => abn.IsCurrentInstance).ClusterName;
            var activeClusterBermudaNodes = allAmazonBermudaNodes.Where(abn => abn.ClusterName == activeClusterName);

            return activeClusterBermudaNodes.ToList();    
        }