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

128 views Asked by At

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("[email protected]", "test", ""));

        DnsDomainConfiguration dnsd = new DnsDomainConfiguration("testdomain.com", TimeSpan.FromMinutes(20), "[email protected]", "", 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.

1

There are 1 answers

0
Sam Harwell On

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();