// Token: 0x06000231 RID: 561 RVA: 0x0000A320 File Offset: 0x00008520 public void SetPrivateProperty <MyType>(string key, MyType value) { int num = 0; if (typeof(string) == typeof(MyType)) { string value2 = (string)((object)value); using (AmClusterPropListDisposable amClusterPropListDisposable = AmClusPropListMaker.CreatePropListString(key, value2, out num)) { this.SetResourceControlData(AmClusterResourceControlCode.CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES, amClusterPropListDisposable.RawBuffer, amClusterPropListDisposable.BufferSize); return; } } if (typeof(int) == typeof(MyType)) { int value3 = (int)((object)value); using (AmClusterPropListDisposable amClusterPropListDisposable2 = AmClusPropListMaker.CreatePropListInt(key, value3, out num)) { this.SetResourceControlData(AmClusterResourceControlCode.CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES, amClusterPropListDisposable2.RawBuffer, amClusterPropListDisposable2.BufferSize); return; } } if (typeof(string[]) == typeof(MyType)) { string[] value4 = (string[])((object)value); using (AmClusterPropListDisposable amClusterPropListDisposable3 = AmClusPropListMaker.CreatePropListMultiString(key, value4, out num)) { this.SetResourceControlData(AmClusterResourceControlCode.CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES, amClusterPropListDisposable3.RawBuffer, amClusterPropListDisposable3.BufferSize); } } }
private static int WriteStringValue(IntPtr buffer, int offset, int syntax, string data) { int num = 0; Marshal.WriteInt32(buffer, offset + num, syntax); num += 4; int num2 = (data.Length + 1) * 2; Marshal.WriteInt32(buffer, offset + num, num2); num += 4; IntPtr destination = (IntPtr)(buffer.ToInt64() + (long)offset + (long)num); Marshal.Copy(data.ToCharArray(), 0, destination, data.Length); num += data.Length * 2; Marshal.WriteInt16(buffer, offset + num, 0); num += 2; int num3 = AmClusPropListMaker.PaddingSize(num2, 4); for (int i = 0; i < num3; i++) { Marshal.WriteByte(buffer, offset + num, 0); num++; } return(num); }
// Token: 0x060001AF RID: 431 RVA: 0x00007B20 File Offset: 0x00005D20 public void SetCommonProperty <MyType>(string key, MyType value) { int num = 0; if (typeof(string) == typeof(MyType)) { string value2 = (string)((object)value); using (AmClusterPropListDisposable amClusterPropListDisposable = AmClusPropListMaker.CreatePropListString(key, value2, out num)) { this.SetNetworkControlData(AmClusterNetworkControlCode.CLUSCTL_NETWORK_SET_COMMON_PROPERTIES, amClusterPropListDisposable.RawBuffer, amClusterPropListDisposable.BufferSize); return; } } if (typeof(int) == typeof(MyType)) { int value3 = (int)((object)value); using (AmClusterPropListDisposable amClusterPropListDisposable2 = AmClusPropListMaker.CreatePropListInt(key, value3, out num)) { this.SetNetworkControlData(AmClusterNetworkControlCode.CLUSCTL_NETWORK_SET_COMMON_PROPERTIES, amClusterPropListDisposable2.RawBuffer, amClusterPropListDisposable2.BufferSize); return; } } if (typeof(string[]) == typeof(MyType)) { string[] value4 = (string[])((object)value); using (AmClusterPropListDisposable amClusterPropListDisposable3 = AmClusPropListMaker.CreatePropListMultiString(key, value4, out num)) { this.SetNetworkControlData(AmClusterNetworkControlCode.CLUSCTL_NETWORK_SET_COMMON_PROPERTIES, amClusterPropListDisposable3.RawBuffer, amClusterPropListDisposable3.BufferSize); } } }
private static int WriteMultiStringValue(IntPtr buffer, int offset, int syntax, string[] values) { int num = 0; Marshal.WriteInt32(buffer, offset + num, syntax); num += 4; int num2 = 0; foreach (string text in values) { num2 += (text.Length + 1) * 2; } num2 += 2; Marshal.WriteInt32(buffer, offset + num, num2); num += 4; foreach (string text2 in values) { IntPtr destination = (IntPtr)(buffer.ToInt64() + (long)offset + (long)num); Marshal.Copy(text2.ToCharArray(), 0, destination, text2.Length); num += text2.Length * 2; Marshal.WriteInt16(buffer, offset + num, 0); num += 2; } Marshal.WriteInt16(buffer, offset + num, 0); num += 2; int num3 = AmClusPropListMaker.PaddingSize(num2, 4); for (int k = 0; k < num3; k++) { Marshal.WriteByte(buffer, offset + num, 0); num++; } return(num); }
public static AmClusterPropListDisposable CreatePropListString(string name, string value, out int bufferSize) { int num = 4 + AmClusPropListMaker.ClusPropValueSize(name) + AmClusPropListMaker.ClusPropValueSize(value) + 4; int num2 = AmClusPropListMaker.PaddingSize(num, 4); bufferSize = num + num2; IntPtr intPtr = Marshal.AllocHGlobal(bufferSize); string.Format("buffer is alloc'ed 0x{0:x} at 0x{1:x}", bufferSize, intPtr.ToInt64()); int num3 = 0; num3 += AmClusPropListMaker.WriteHeader(intPtr, num3, 1); num3 += AmClusPropListMaker.WriteStringValue(intPtr, num3, 262147, name); num3 += AmClusPropListMaker.WriteStringValue(intPtr, num3, 65539, value); num3 += AmClusPropListMaker.WriteTerminator(intPtr, num3); ClusapiMethods.ResUtilVerifyPrivatePropertyList(intPtr, bufferSize); return(new AmClusterPropListDisposable(new SafeHGlobalHandle(intPtr), (uint)bufferSize)); }
public static AmClusterPropListDisposable CreatePropListMultiString(string name, string[] value, out int bufferSize) { int num = 4 + AmClusPropListMaker.ClusPropValueSize(name) + AmClusPropListMaker.ClusPropValueSize(value) + 4; int num2 = AmClusPropListMaker.PaddingSize(num, 4); bufferSize = num + num2; IntPtr intPtr = Marshal.AllocHGlobal(bufferSize); string.Format("buffer is alloc'ed 0x{0:x} at 0x{1:x}", bufferSize, intPtr.ToInt64()); int num3 = 0; num3 += AmClusPropListMaker.WriteHeader(intPtr, num3, 1); num3 += AmClusPropListMaker.WriteStringValue(intPtr, num3, 262147, name); num3 += AmClusPropListMaker.WriteMultiStringValue(intPtr, num3, 65541, value); num3 += AmClusPropListMaker.WriteTerminator(intPtr, num3); ClusapiMethods.ResUtilVerifyPrivatePropertyList(intPtr, bufferSize); throw new NotImplementedException("CreatePropListMultiString entire function may work, but has not been tested properly."); }
private static IEnumerable <AmClusterResource> AddStaticIpAddressesToStrandedNetworks(ITaskOutputHelper logger, AmClusterGroup group, AmClusterResource netname, IEnumerable <AmClusterNetwork> publicNetworks, IEnumerable <string> networksWithResources, IEnumerable <IPAddress> staticIpAddresses) { logger = (logger ?? NullTaskOutputHelper.GetNullLogger()); if (publicNetworks.Count <AmClusterNetwork>() <= networksWithResources.Count <string>()) { logger.AppendLogMessage("AddStaticIpAddressesToStrandedNetworks: publicNetworks.Count({0}) <= networksWithResources.Count({1}). So we're doing nothing.", new object[] { publicNetworks.Count <AmClusterNetwork>(), networksWithResources.Count <string>() }); return(new List <AmClusterResource>(0)); } List <AmClusterResource> list = new List <AmClusterResource>(publicNetworks.Count <AmClusterNetwork>() - networksWithResources.Count <string>()); IEnumerable <AmClusterNetwork> enumerable = from publicNet in publicNetworks where !networksWithResources.Contains(publicNet.Name) select publicNet; bool flag = false; using (IEnumerator <AmClusterNetwork> enumerator = enumerable.GetEnumerator()) { while (enumerator.MoveNext()) { AmClusterNetwork publicNetwork = enumerator.Current; logger.AppendLogMessage("AddStaticIpAddressesToStrandedNetworks() There doesn't appear to be an IP resource on network '{0}'.", new object[] { publicNetwork.Name }); IEnumerable <IPAddress> enumerable2 = from staticIp in staticIpAddresses where publicNetwork.IsIPInNetwork(staticIp) select staticIp; if (enumerable2.Count <IPAddress>() > 0) { flag = true; } foreach (IPAddress ipaddress in enumerable2) { logger.AppendLogMessage("AddStaticIpAddressesToStrandedNetworks() Adding IP {0} to network '{1}'.", new object[] { ipaddress, publicNetwork.Name }); int num = 1; bool flag2 = false; AmClusterResource amClusterResource = null; try { amClusterResource = (AmClusterResource)group.CreateUniqueResource(logger, "IPv4 Static Address", "IP Address", ref num); logger.AppendLogMessage("Created new ipv4 static resource. (resource:{0}, address:{1})", new object[] { amClusterResource.Name, ipaddress.ToString() }); int num2; using (AmClusterPropListDisposable amClusterPropListDisposable = AmClusPropListMaker.CreatePropListString("Address", ipaddress.ToString(), out num2)) { using (AmClusterPropListDisposable amClusterPropListDisposable2 = AmClusPropListMaker.DupeAndAppendPropListString(amClusterPropListDisposable.RawBuffer, (int)amClusterPropListDisposable.BufferSize, "Network", publicNetwork.Name, out num2)) { using (AmClusterPropListDisposable amClusterPropListDisposable3 = AmClusPropListMaker.DupeAndAppendPropListString(amClusterPropListDisposable2.RawBuffer, (int)amClusterPropListDisposable2.BufferSize, "SubnetMask", publicNetwork.GetAddressMask(), out num2)) { logger.AppendLogMessage("Created new ipv4 resource: name '{0}' to be {1} on network named '{2}' with mask={3}.", new object[] { amClusterResource.Name, ipaddress.ToString(), publicNetwork.Name, publicNetwork.GetAddressMask() }); amClusterResource.SetPrivatePropertyList(amClusterPropListDisposable3); } } } list.Add(amClusterResource); flag2 = true; } finally { if (!flag2 && amClusterResource != null) { logger.AppendLogMessage("There was some error creating and configuring the IP address resource {0}. Making a best-effort attempt to delete it.", new object[] { ipaddress }); try { amClusterResource.OfflineResource(); amClusterResource.DeleteResource(); } catch (ClusterApiException ex) { logger.AppendLogMessage("There was an error deleting the incomplete IP address. Ignoring the error and continuing. The error was {0}", new object[] { ex }); } if (amClusterResource != null) { amClusterResource.Dispose(); amClusterResource = null; } } } } } } if (!flag) { string[] value = (from network in enumerable select network.Name).ToArray <string>(); string[] value2 = (from staticIp in staticIpAddresses select staticIp.ToString()).ToArray <string>(); logger.WriteWarning(Strings.DagTaskNotEnoughStaticIPAddresses(string.Join(",", value), string.Join(",", value2))); } return(list); }
public static List <AmClusterResource> ConfigureIPv4DhcpResources(ILogTraceHelper logger, AmClusterGroup group, string[] ipv4Networks) { 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 = new List <AmClusterResource>(10); List <AmClusterResource> list3 = null; try { logger = (logger ?? NullLogTraceHelper.GetNullLogger()); dictionary2 = AmClusterResourceHelper.GetIpv4DhcpNetworkMap(group.OwningCluster, ipv4Networks); IEnumerable <AmClusterResource> enumerable = group.EnumerateResourcesOfType("IP Address"); if (enumerable != null) { array = enumerable.ToArray <AmClusterResource>(); for (int i = 0; i < array.Length; i++) { AmClusterResource amClusterResource = array[i]; if (amClusterResource.GetPrivateProperty <int>("EnableDhcp") != 0) { list.Add(amClusterResource); array[i] = null; } } } foreach (string key in ipv4Networks) { for (int k = 0; k < list.Count; k++) { AmClusterResource amClusterResource2 = list[k]; string privateProperty = amClusterResource2.GetPrivateProperty <string>("Network"); AmClusterNetwork amClusterNetwork = dictionary2[key]; if (SharedHelper.StringIEquals(amClusterNetwork.Name, privateProperty)) { logger.AppendLogMessage("Reusing ipv4 dhcp resource because its network is matching. (resource:{0}, network:{1}/{2}", new object[] { amClusterResource2.Name, privateProperty, amClusterNetwork.Name }); dictionary[key] = amClusterResource2; list[k] = null; break; } } } if (dictionary.Count < ipv4Networks.Length) { int num = 1; foreach (string text in ipv4Networks) { if (!dictionary.ContainsKey(text)) { AmClusterResource amClusterResource2 = (AmClusterResource)group.CreateUniqueResource(logger, "IPv4 DHCP Address", "IP Address", ref num); list2.Add(amClusterResource2); logger.AppendLogMessage("Created new ipv4 dhcp resource. (resource:{0}, network:{1})", new object[] { amClusterResource2.Name, text }); dictionary[text] = amClusterResource2; } } } list3 = new List <AmClusterResource>(ipv4Networks.Length); foreach (string key2 in ipv4Networks) { AmClusterResource amClusterResource2 = dictionary[key2]; AmClusterNetwork amClusterNetwork = dictionary2[key2]; int num2; using (AmClusterPropListDisposable amClusterPropListDisposable = AmClusPropListMaker.CreatePropListInt("EnableDhcp", 1, out num2)) { using (AmClusterPropListDisposable amClusterPropListDisposable2 = AmClusPropListMaker.DupeAndAppendPropListString(amClusterPropListDisposable.RawBuffer, (int)amClusterPropListDisposable.BufferSize, "Network", amClusterNetwork.Name, out num2)) { logger.AppendLogMessage("ConfigureIPv4DhcpResources: Setting resource '{0}' to be DHCP-enabled on network '{1}' (role={2}).", new object[] { amClusterResource2.Name, amClusterNetwork.Name, amClusterNetwork.GetNativeRole() }); amClusterResource2.SetPrivatePropertyList(amClusterPropListDisposable2); } } AmClusterResourceHelper.SetPossibleOwnersForIpResource(logger, amClusterResource2); list3.Add(amClusterResource2); } flag = true; } finally { if (!flag) { SharedHelper.DisposeObjectList <AmClusterResource>(list2); } SharedHelper.DisposeObjectList <AmClusterResource>(array); SharedHelper.DisposeObjectList <AmClusterResource>(list); if (dictionary2 != null) { SharedHelper.DisposeObjectList <AmClusterNetwork>(dictionary2.Values); } } return(list3); }