Search Engine: Elastic

Article ID: 118999, created on Dec 4, 2013, last review on Oct 4, 2016

  • Applies to:
  • Plesk Automation 11.1
  • Plesk Automation 11.5

Symptoms

For a DNS zone in Plesk Automation (PA), there is the option Switch DNS Hosting to External/Switch DNS Hosting to Internal. This action needs to be automated for several domains.

Resolution

To switch DNS Hosting to external and back for all DNS zones, you should perform the following steps on the Management Node:

  1. Create a list of the relevant domain IDs and subscription IDs using the following command:

     psql -h`hostname` -Uplesk plesk --no-align --field-separator ' ' -t -c "select d.domain_id, s.sub_id from domains d left join subs_resources s on d.hosting_res=s.rt_instance_id where s.sub_id is not null;" > sub_id 
    
  2. Create XML files to use in API requests (pem.removeDNSHosting.xml and pem.addDNSHosting.xml):

    pem.removeDNSHosting.xml

    <methodCall>
    <methodName>pem.removeDNSHosting</methodName>
    <params>
    <param>
    <value>
    <struct>
    <member>
    <name>domain_id</name>
    <value>
    <int>abc</int>
    </value>
    </member>
    </struct>
    </value>
    </param>
    </params>
    </methodCall>
    

    pem.addDNSHosting.xml

    <methodCall>
    <methodName>pem.addDNSHosting</methodName>
    <params>
    <param>
    <value>
    <struct>
    <member>
    <name>domain_id</name>
    <value>
    <int>abc</int>
    </value>
    </member>
    <member>
    <name>subscription_id</name>
    <value>
    <int>qaz</int>
    </value>
    </member>
    </struct>
    </value>
    </param>
    </params>
    </methodCall>
    
  3. Change the DNS service to external for all domains using the following API request, where abc is a placeholder of the domain ID value :

    cat sub_id | while read i z; do cat pem.removeDNSHosting.xml | sed 's/abc/'$i'/g' | curl -k -uadmin:<PASSWORD> -d@- 'https://<IP_ADDRESS>:8440/RPC2'; done
    

    where:

    PASSWORD - The PA administrator's password.

    IP_ADDRESS - The IP address of the PA management node.

  4. Change the DNS service to internal for all domains using the following API request, where 'abc' is the domain_id and 'qaz' is subscription_id:

    cat sub_id | while read i z; do cat pem.addDNSHosting.xml | sed 's/abc/'$i'/g' | sed 's/qaz/'$z'/g' | curl -k -uadmin:<PASSWORD> -d@- 'https://<IP_ADDRESS>:8440/RPC2'; done
    

c1ecc6010feff26cb42d1d14a7881dd6 e0aff7830fa22f92062ee4db78133079 33a70544d00d562bbc5b17762c4ed2b3 caea8340e2d186a540518d08602aa065

Email subscription for changes to this article
Save as PDF