Exemplo n.º 1
0
        public static void ValidateIpv6Networks(IAmCluster cluster, string[] ipv6Networks)
        {
            for (int i = 0; i < ipv6Networks.Length - 1; i++)
            {
                for (int j = i + 1; j < ipv6Networks.Length; j++)
                {
                    if (SharedHelper.StringIEquals(ipv6Networks[i], ipv6Networks[j]))
                    {
                        throw new IPv6NetworksHasDuplicateEntries(ipv6Networks[i]);
                    }
                }
            }
            Dictionary <string, AmClusterNetwork> ipv6AutoCfgNetworkMap = AmClusterResourceHelper.GetIpv6AutoCfgNetworkMap(cluster, ipv6Networks);

            if (ipv6AutoCfgNetworkMap != null)
            {
                SharedHelper.DisposeObjectList <AmClusterNetwork>(ipv6AutoCfgNetworkMap.Values);
            }
        }
Exemplo n.º 2
0
        public static List <AmClusterResource> ConfigureIPv6AutoCfgResources(ILogTraceHelper logger, AmClusterGroup group, string[] ipv6Networks)
        {
            bool flag = false;
            Dictionary <string, AmClusterResource> dictionary  = new Dictionary <string, AmClusterResource>(8);
            Dictionary <string, AmClusterNetwork>  dictionary2 = null;

            AmClusterResource[]      array = null;
            List <AmClusterResource> list  = new List <AmClusterResource>(10);
            List <AmClusterResource> list2 = null;

            try
            {
                logger      = (logger ?? NullLogTraceHelper.GetNullLogger());
                dictionary2 = AmClusterResourceHelper.GetIpv6AutoCfgNetworkMap(group.OwningCluster, ipv6Networks);
                IEnumerable <AmClusterResource> source = group.EnumerateResourcesOfType("IPv6 Address");
                if (source.Count <AmClusterResource>() > 0)
                {
                    array = source.ToArray <AmClusterResource>();
                }
                if (array != null)
                {
                    foreach (string key in ipv6Networks)
                    {
                        for (int j = 0; j < array.Length; j++)
                        {
                            AmClusterResource amClusterResource = array[j];
                            string            privateProperty   = amClusterResource.GetPrivateProperty <string>("Network");
                            AmClusterNetwork  amClusterNetwork  = dictionary2[key];
                            if (SharedHelper.StringIEquals(amClusterNetwork.Name, privateProperty))
                            {
                                logger.AppendLogMessage("Reusing ipv6 resource because its network is matching. (resource:{0}, network:{1}/{2}", new object[]
                                {
                                    amClusterResource.Name,
                                    privateProperty,
                                    amClusterNetwork.Name
                                });
                                dictionary[key] = amClusterResource;
                                array[j]        = null;
                                break;
                            }
                        }
                    }
                }
                if (dictionary.Count < ipv6Networks.Length)
                {
                    int num = 1;
                    foreach (string text in ipv6Networks)
                    {
                        if (!dictionary.ContainsKey(text))
                        {
                            AmClusterResource amClusterResource = (AmClusterResource)group.CreateUniqueResource(logger, "IPv6 Auto Config Address", "IPv6 Address", ref num);
                            list.Add(amClusterResource);
                            logger.AppendLogMessage("Created new ipv6 resource. (resource:{0}, network:{1})", new object[]
                            {
                                amClusterResource.Name,
                                text
                            });
                            dictionary[text] = amClusterResource;
                        }
                    }
                }
                list2 = new List <AmClusterResource>(ipv6Networks.Length);
                foreach (string key2 in ipv6Networks)
                {
                    AmClusterResource amClusterResource = dictionary[key2];
                    AmClusterNetwork  amClusterNetwork  = dictionary2[key2];
                    logger.AppendLogMessage("ConfigureIPv6AutoCfgResources: Setting resource '{0}' to be on network '{1}' (role={2}).", new object[]
                    {
                        amClusterResource.Name,
                        amClusterNetwork.Name,
                        amClusterNetwork.GetNativeRole()
                    });
                    amClusterResource.SetPrivateProperty <string>("Network", amClusterNetwork.Name);
                    AmClusterResourceHelper.SetPossibleOwnersForIpResource(logger, amClusterResource);
                    list2.Add(amClusterResource);
                }
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    SharedHelper.DisposeObjectList <AmClusterResource>(list);
                }
                SharedHelper.DisposeObjectList <AmClusterResource>(array);
                if (dictionary2 != null)
                {
                    SharedHelper.DisposeObjectList <AmClusterNetwork>(dictionary2.Values);
                }
            }
            return(list2);
        }