/// <summary> /// /// </summary> /// <param name="Credential"></param> /// <param name="wsdlPath"></param> /// <param name="DnsView"></param> /// <param name="IpStack"></param> /// <param name="TTL"></param> /// <param name="Comments"></param> /// <returns></returns> public static long AddHostRecord(NetworkCredential Credential, string wsdlPath, VirtualIPStack IpStack, int TTL, string Comments, string View, string Parent) { try { ProteusAPI proxy = Connect(Credential, wsdlPath); string AbsoluteName = IpStack.hostname + "." + IpStack.suffix; APIEntity DnsView = GetDnsView(proxy, View, Parent); long DnsViewID = DnsView.id; long HostID = proxy.addHostRecord(DnsViewID, AbsoluteName, IpStack.ipaddress, TTL, Comments); proxy.logout(); return HostID; } catch (Exception ex) { if (ex.Message == "Duplicate of another item") { // // Find out who has my information // ProteusAPI proxy = Connect(Credential, wsdlPath); APIEntity[] DupeIps = proxy.searchByObjectTypes(IpStack.ipaddress, ObjectTypes.IP4Address, 0, 10); APIEntity[] DupeNames = proxy.searchByObjectTypes(IpStack.hostname, ObjectTypes.HostRecord, 0, 10); if (DupeIps.Count<APIEntity>() > 0) { Console.WriteLine("Duplicate IP"); } if (DupeNames.Count<APIEntity>() > 0) { Console.WriteLine("Duplicate Name"); } } throw ex; } }
public static VirtualIPStack GetIpStack(NetworkCredential Credential, string wsdlPath, long EntityId, string EntityName) { VirtualIPStack ipStack = new VirtualIPStack(); ProteusAPI proxy = Connect(Credential, wsdlPath); APIEntity ipNetwork = GetIp4Network(proxy, EntityId); IPNetwork vlan = ParseCidr(ipNetwork); string ipAddress = GetNextIp4Address(proxy, ipNetwork.id); if (ipAddress == "") { // // ZOMG network is full // // we need to quit now // } else { ipStack.ipaddress = ipAddress; } ipStack.netmask = vlan.Netmask.ToString(); ipStack.gateway = vlan.LastUsable.ToString(); proxy.logout(); return ipStack; }