예제 #1
0
        public async Task <string> NewDnsHostRecordWithNextAvailableIP(string hostName, string network, bool addToDns = true, bool enableDhcp = false, bool setHostName = false, string mac = "")
        {
            string FormattedMAC  = String.Empty;
            string FormattedFQDN = String.Empty;

            if (NetworkAddressTest.IsMAC(mac, out FormattedMAC, true, true) && NetworkAddressTest.IsFqdn(hostName, "hostname", out FormattedFQDN, false, true))
            {
                string Data = "{\"name\":\"" + FormattedFQDN + "\",\"ipv4addrs\":[{\"ipv4addr\":\"func:nextavailableip:" + network + "\"" +
                              ((!String.IsNullOrEmpty(FormattedMAC)) ? ",\"mac\":\"" + FormattedMAC + "\"" : "") +
                              ",\"configure_for_dhcp\":" + ((enableDhcp) ? "true" : "false") +
                              ((setHostName) ? ",\"options\":[{\"name\":\"host-name\",\"num\":12,\"value\":\"" + FormattedFQDN + "\"}]" : "") + "}]" +
                              ",\"configure_for_dns\":" + addToDns.ToString().ToLower() + "}";

                return(await base.NewIbxObject(typeof(host), Data));
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public async Task <string> NewDnsHostRecord(string hostName, string ipAddress, bool addToDns = true, bool enableDhcp = false, bool setHostName = false, string mac = "")
        {
            IPAddress IP;
            string    FQDN       = String.Empty;
            string    MACAddress = String.Empty;

            if (NetworkAddressTest.IsIPv4Address(ipAddress, out IP, false, true) && NetworkAddressTest.IsMAC(mac, out MACAddress, true, true) &&
                NetworkAddressTest.IsFqdn(hostName, "hostname", out FQDN, false, true))
            {
                string Data = "{\"name\":\"" + hostName + "\",\"ipv4addrs\":[{\"ipv4addr\":\"" + IP.ToString() + "\"" +
                              ((!String.IsNullOrEmpty(MACAddress)) ? ",\"mac\":\"" + MACAddress + "\"" : "") +
                              ",\"configure_for_dhcp\":" + ((enableDhcp) ? "true" : "false") +
                              ((setHostName) ? ",\"options\":[{\"name\":\"host-name\",\"num\":12,\"value\":\"" + FQDN + "\"}]" : "") +
                              "}],\"configure_for_dns\":" + addToDns.ToString().ToLower() + "}";

                return(await base.NewIbxObject(typeof(host), Data));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        public async Task <string> SetDnsHostRecordName(string reference, string hostName)
        {
            if (!String.IsNullOrEmpty(reference))
            {
                string FQDN = String.Empty;

                if (NetworkAddressTest.IsFqdn(hostName, "hostname", out FQDN, false, true))
                {
                    string Data = $"{{\"name\":\"{FQDN}\"}}";

                    return(await base.UpdateIbxObject <host>(reference, Data));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                throw new ArgumentNullException("reference", "Reference data cannot be null or empty.");
            }
        }