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.

AddonDomains module help

Discussion in 'cPanel Developers' started by hron84, Feb 5, 2011.

  1. hron84

    hron84 Member

    Joined:
    Feb 5, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hi!

    I trying migrate our hosting to CPanel, and I ran into a small understanding problems.

    1)
    In AddonDomain::addaddondomain call has 3 parameter:
    - newdomain
    - subdomain
    - dir

    Say, user have somedomain.com as its 'main' domain, but it want add simpledomain.com as 'addon domain', then i fill these parameters with:
    - newdomain: simpledomain.com
    - subdomain: simpledomain
    - dir: public_html/simpledomain.com

    Is this correct? Or I understand something wrong?

    2)
    I tried add another domain, and I got following:
    Code:
    Removed somedomain.somedomain.com Server at line: 435.
    Removed Entry from httpd.conf
    Bind reloading on cloudlinux using rndc zone: [somedomain.com]
    The subdomain,somedomain.somedomain.com has been removed.
    
    The parameters was:
    - dir: public_html/wtf.com
    - newdomain: wtf.com
    - subdomain: somedomain

    And the new domain didn't appeared on Cpanel interface (server:2083). But the return values says it was a successful transaction (result: 1)... or I misunderstand something? :confused:

    Please help me...
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello hron84,

    Could you provide the full API call you used for adding the domain? Also, the example you noted for adding the domain shows a removal rather than adding a domain here:

    Are you certain you provided the correct output from when you ran the API call?

    Thanks.
     
  3. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi hron84,

    1) yes, your parameters are correct.

    2) yes, it's possible to receive that error message from the AddonDomain::addaddondomain call
    2.a) yes it's possible to receive a '1' in the result (indicating success) on an "error" event such as this.


    Now for a little more detail about item #2 above.

    Firstly, I'm not sure what level of access you have to your cPanel box, but if you have privileged access, such as root, you can look at the cPanel error log (/usr/local/cpanel/logs/error_log) and sometime get more info. In this case, the issue becomes very clear because there IS info in the log.

    I'll step through the whole scenario, just to be clear. I use the PHP XML-API class to make my API calls, but you can essentially do all the same function calls in other methods.

    1) So I make this script
    PHP:
    include("xmlapi.php");

    $ip "10.0.0.1";
    $root_pass "root_secret!";
    $user='dave';
    $upass='dave_secret!';
    $url 'where.com';
    $sub 'where';

    $xmlapi = new xmlapi($ip);

    // setup authentication as root
    $xmlapi->password_auth("root"$root_pass);
    $xmlapi->set_port('2087');

    // or as user
    //$xmlapi->password_auth($user, $upass);
    //$xmlapi->set_port('2083');

    // for debugging
    $xmlapi->set_debug(1);

    $args = array(
            
    'newdomain'    =>$url,
            
    'dir'        =>"'public_html/$url",
            
    'subdomain' =>$sub,
            );
    $xmlapi->api2_query($user'AddonDomain''addaddondomain'$args);
    2) the the call and response
    Code:
    [David-N:~/xmlapi] $ php -f addondomain_test.php 
    URL: https://10.0.0.1:2087/xml-api/cpanel
    DATA: newdomain=where.com&dir=%27public_html%2Fwhere.com&subdomain=where&cpanel_xmlapi_user=dave&cpanel_xmlapi_module=AddonDomain&cpanel_xmlapi_func=addaddondomain&cpanel_xmlapi_apiversion=2&api.version=1
    
    
    RESPONSE:
     <?xml version="1.0" ?>
      <cpanelresult>
        <apiversion>2</apiversion>
        <data>
          <reason>Deleted domain: where.dave.test
    Bind reloading on david using rndc zone: [dave.test]
    The subdomain, where.dave.test has been removed.</reason>
          <result>1</result>
        </data>
        <event>
          <result>1</result>
        </event>
        <func>addaddondomain</func>
        <module>AddonDomain</module>
      </cpanelresult>
    
    3) Okay, so I obviously got the same result as you...essential it's this data:
    Code:
    $VAR1 = [
              {
                'reason' => 'Deleted domain: where.dave.test
    Bind reloading on david using rndc zone: [dave.test]
    The subdomain, where.dave.test has been removed.',
                'result' => 1
              }
            ];
    
    A)The reason is totally not related to what we are expecting...it's talking about deleting domains
    B) the result is "1" though we can check the cPanel interface and it's obviously not there


    4) So let's look at error log
    Code:
    [2011-02-07 08:20:52 -0600] warn [addondomain::addaddondomain] Encountered error in addondomain::addaddondomain: Error from park wrapper: Using nameservers with the following IPs: 204.13.248.76,203.62.195.76,208.78.69.76,91.198.22.76,204.13.249.76
    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.
    
    PERFECT! The internals for the "addaddondomain" function are complaining! ....something about where the current DNS record for the new domain is pointed. That kind makes some sense, since I didn't ensure that "where.com" was pointed to my cPanel DNS

    5) So if we look at the "reason" again, it's talking about removing/altering DNS records. So, what must be happening is that cPanel is updating it's DNS first, then trying to validate it with a lookup.

    6) The lookup fails the code has to undo what it just did: it internally makes a DNS record deletion API call, whose returned data is considered (by the code) as the proper response to aggregate back to the client.

    7) So, the "1" result is related to the reason, which is related to the clean-up of the actual "addaddondomain" request.

    kinda of lack-luster. However, I don't think this is a change in behavior with new versions of cPanel. I think that this has been the way that AddDomain::addaddondomain has worked for a long time. I will do some more investigation just to double check.

    Now, if I where to make the same call with a domain name that DID point correctly, or just a domain that did exist
    PHP:
    $url 'jlaoiaouweenrw.test';
    I should see a success message
    Code:
        <data>
          <reason>jlaoiaouweenrw.test was successfully parked on top of where.dave.test</reason>
          <result>1</result>
        </data>
    
    Best Regards,
    -DavidN
     
Loading...

Share This Page