The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

AddonDomain operation and API result codes

Discussion in 'cPanel Developers' started by odmink0, Apr 4, 2012.

  1. odmink0

    odmink0 Member

    Joined:
    Feb 29, 2012
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Russia
    cPanel Access Level:
    Reseller Owner
    Hello.

    I'm trying to create addon domains via API2 AddonDomain module. But it looks like the result codes of 'addaddondomain' function are not always represent the actual results of the operation.
    For example when I'm trying to add an addon domain whose DNS-servers are not the cPanel server's NS-es and not listed in the /etc/ips.remotedns, it returns something like this (this is a Perl hash returned by cPanel::PublicAPI):

    Code:
    Result: {
      cpanelresult => {
        apiversion => 2,
        func => "addaddondomain",
        data => [
          {
            reason => "Deleted domain: best.cool.com\nBind reloading on cpaneltest using rndc zone: [cool.com]\nThe subdomain, best.cool.com has been removed.",
            result => 1
          }
        ],
        event => {
          result => 1
        },
        module => "AddonDomain"
      }
    }
    
    I.e. all "result" values are 1, which should mean that the operation was successful.

    But when I'm trying to do the same via web interface, I get the error like:
    Code:
    Error from park wrapper: Using nameservers with the following IPs: 194.85.61.20,194.226.96.8 Sorry, the domain is already pointed to an IP address that does not appear to use DNS servers associated with this server. Please transfer the domain to this servers nameservers or have your administrator add one of its nameservers to /etc/ips.remotedns and make the proper A entries on that remote nameserver.
    
    Why the same error is not displayed when I'm trying to add addon domain via API?

    After some tries I started to get the error:
    Code:
    Error from park wrapper: best.ru is already configured. Sorry, that domain is already setup (remove it from httpd.conf)
    
    But this error also is not reported via API.

    So the questions are:
    • How to reliably identify a successfull creation of the addon domain?
    • How to get a proper error message via API?
    • Is there some official method of recovering from the last error ("the domain is already setup")? I didn't find any entries in the httpd.conf. There is an instruction that is found via Google, but it doesn't work.
     
  2. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    I've been calling Api2::AddonDomain::listaddondomains and then matching the newly added addon domain against that list. If it is in there, it was created.

    You cannot. There is a bug report open for this addon domain issue though. The main problem is that cPanel is reporting the result of the last action. In this case, the subdomain was removed successfully and the API is confirming that, even though it is not relevant to what information you would want to know. I 'm guessing that it will require a major API rewrite to get this functioning properly.

    No methods to recover from errors, you will just need to identify them and proceed accordingly in your code.
     
  3. odmink0

    odmink0 Member

    Joined:
    Feb 29, 2012
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Russia
    cPanel Access Level:
    Reseller Owner
    Thank you, that's an option and I thought about it too, but hoped that some "more clever" method also exists.

    I also thought about checking domain's nameservers manually before trying to create an addon domain, but after discussing it with our tech stuff, we've decided to just allow remote and unregistered domain in the WHM configuration. And I'll be checking them after addition with the above method or by parsing a status message.

    Too bad that cPanel developers did not synchronize the API and the web interface functionality, but hope that they'll fix it soon.

    I meant that I need to remove this domain and corresponding subdomain somehow to be able to add it again, e.g. after nameservers will be fixed. This question is probably not very consistent with the topic, but it's also a good thing to know.
     
  4. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    I take it you are talking about removing it from the existing server that it is on? That could be automated by logging into the current server the domain is on and using a WHM removeacct or api2 Park::unpark call. That is, provided that you have access to the server that the domain exists on and can determine which server that is.
     
Loading...

Share This Page