简体   繁体   中英

cannot creat a domain using Rackspace Cloud DNS with openstack.net

I'm currently trying to create a domain on Rackspace Cloud DNS service using openstack.net sdk, but nothings happening.

i got my rackspace account, its activated and i got my API key as well.

I wrote a console app to test my code but the results are always "WaitingForActivation" and i cant find any documentation for cloudsDNS using openstack.net sdk.

Would anyone be able to take a look at my code and tell me what im doing wrong please.

private static string RackSpaceUserName { get { return "username"; } }

    private static string RackSpaceUserApiKey
    {
        get { return "apikey"; }
    }

    private UserAccess RackSpaceUser
    {
        get
        {

            IIdentityProvider identityProvider = new CloudIdentityProvider();

            var userAccess = identityProvider.Authenticate(Cloudidentity);

            return userAccess;
        }

    }

    private static CloudIdentity Cloudidentity
    {
        get
        {
            var ci = new CloudIdentity
            {
                APIKey = RackSpaceUserApiKey,
                Username = RackSpaceUserName
            };

            return ci;
        }
    }


    static void Main(string[] args)
    {
        var ParkedDomain = new CloudDnsProvider(Cloudidentity, null, true, null);

        List<DnsDomainRecordConfiguration> dnsrecords = new List<DnsDomainRecordConfiguration>();

        dnsrecords.Add(new DnsDomainRecordConfiguration(DnsRecordType.Ns, "testdomain.com", "dns1.stabletransit.com", TimeSpan.FromMinutes(20), null, null));

        dnsrecords.Add(new DnsDomainRecordConfiguration(DnsRecordType.Ns, "testdomain.com", "dns2.stabletransit.com", TimeSpan.FromMinutes(20), null, null));

        List<DnsSubdomainConfiguration> subdomains = new List<DnsSubdomainConfiguration>();

        subdomains.Add(new DnsSubdomainConfiguration("info@testdomain.com", "test", ""));

        DnsDomainConfiguration dnsd = new DnsDomainConfiguration("testdomain.com", TimeSpan.FromMinutes(20), "info@testdomain.com", "", dnsrecords, subdomains);

        DnsConfiguration dnsconfig = new DnsConfiguration(dnsd);

        var result = ParkedDomain.CreateDomainsAsync(dnsconfig, AsyncCompletionOption.RequestCompleted, CancellationToken.None, null);

        Console.Write(result.Status);

        Console.ReadLine();
    }

the value for result.Status always returns "WaitingForActivation", and when i check my rackspace cloud dns dashboard, no domains are created.

Any help would be greatly appreciated.

The DNS service uses asynchronous methods. The object returned by CreateDomainsAsync is a Task which represents the asynchronous operation, but that operation may not complete prior to the call returning. You can wait for the request to be complete in your code by any of the following methods:

  1. Await the result (only allowed in an async method, which Main cannot be).

     await result; 
  2. Access the Task<TResult>.Result property.

     var completedResult = result.Result; 
  3. Call the Task.Wait method.

     result.Wait(); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM