Beispiel #1
0
        public override VmDnsRecord GetRecordDataFromUIFields()

        {
            VmDnsRecord addressRecord = null;

            UIErrorHelper.CheckedExec(delegate()

            {
                DoValidateControls();

                var data = new VMDNS_A_DATA();

                data.IpAddress = (UInt32)IPAddress.NetworkToHostOrder(

                    (int)IPAddress.Parse(AddRecordFrm.ARecordHostIPText.Text).Address);

                VMDNS_RECORD_A record = new VMDNS_RECORD_A();

                record.data = data;

                record.common.iClass = 1;

                record.common.pszName = AddRecordFrm.ARecordHostNameText.Text;

                record.common.type = (UInt16)RecordType.VMDNS_RR_TYPE_A;

                addressRecord = new VmDnsRecordA(record);
            });

            return(addressRecord);
        }
Beispiel #2
0
        TestAddARecord()
        {
            using (VmDnsClient client = new VmDnsClient(hostname, username, domain, password))
            {
                var zone = FindZone(client, "vsphere.local");

                var data = new VMDNS_A_DATA();
                data.IpAddress = (UInt32)IPAddress.NetworkToHostOrder(
                    (int)IPAddress.Parse("192.168.1.11").Address);
                VMDNS_RECORD_A record = new VMDNS_RECORD_A();
                record.data           = data;
                record.common.iClass  = 1;
                record.common.pszName = "test1";
                record.common.type    = (UInt16)RecordType.VMDNS_RR_TYPE_A;
                VmDnsRecordA addressRecord = new VmDnsRecordA(record);
                try
                {
                    zone.AddRecord(addressRecord);
                }
                catch (VmDnsException e)
                {
                    if (e.ErrorCode != 183)
                    {
                        throw;
                    }
                }

                IList <VmDnsRecord> records =
                    zone.QueryRecords(
                        "test1",
                        RecordType.VMDNS_RR_TYPE_A,
                        0);
                try
                {
                    foreach (VmDnsRecord entry in records)
                    {
                        Console.WriteLine("Record address {0}", ((VmDnsRecordA)entry).Address);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }