]> granicus.if.org Git - pdns/commitdiff
pdnsutil: Added change-slave-zone-master for changing slave zone master(s)
authorHannu Ylitalo <hnsk@hnsk.net>
Sat, 27 Aug 2016 08:09:58 +0000 (11:09 +0300)
committerHannu Ylitalo <hnsk@hnsk.net>
Sat, 27 Aug 2016 08:09:58 +0000 (11:09 +0300)
contrib/pdnsutil.bash_completion.d
pdns/pdnsutil.cc

index 4837f602b22c71b4e84119224029b7f27bcfb342..747de2d66ec299e578ee15649c1e59ae49c588cb 100644 (file)
@@ -15,7 +15,7 @@ have pdnsutil && {
   _pdnsutil_helper_local_() {
     local cur prev cmd
 
-    local _PDNSUTIL_ALL_CMDS="activate-tsig-key activate-zone-key add-record add-zone-key backend-cmd b2b-migrate bench-db check-zone check-all-zones clear-zone
+    local _PDNSUTIL_ALL_CMDS="activate-tsig-key activate-zone-key add-record add-zone-key backend-cmd b2b-migrate bench-db change-slave-zone-master check-zone check-all-zones clear-zone
                               create-bind-db create-slave-zone create-zone deactivate-tsig-key deactivate-zone-key delete-rrset delete-tsig-key delete-zone disable-dnssec
                               edit-zone export-zone-dnskey export-zone-key generate-tsig-key generate-zone-key get-meta hash-zone-record increase-serial import-tsig-key
                               import-zone-key load-zone list-algorithms list-keys list-zone list-all-zones list-tsig-keys rectify-zone rectify-all-zones remove-zone-key
index c2d72f86a1a6d072808a239085485c2386d5dac8..51d34326e4813179040dab17ba19a0ea927c3593 100644 (file)
@@ -1197,6 +1197,24 @@ int createSlaveZone(const vector<string>& cmds) {
   return EXIT_SUCCESS;
 }
 
+int changeSlaveZoneMaster(const vector<string>& cmds) {
+  UeberBackend B;
+  DomainInfo di;
+  DNSName zone(cmds[1]);
+  if (!B.getDomainInfo(zone, di)) {
+    cerr<<"Domain '"<<zone<<"' doesn't exist"<<endl;
+    return EXIT_FAILURE;
+  }
+  vector<string> masters;
+  for (unsigned i=2; i < cmds.size(); i++) {
+    ComboAddress master(cmds[i], 53);
+    masters.push_back(master.toStringWithPort());
+  }
+  cerr<<"Updating slave zone '"<<zone<<"', master(s) to '"<<boost::join(masters, ",")<<"'"<<endl;
+  di.backend->setMaster(zone, boost::join(masters, ","));
+  return EXIT_SUCCESS;
+}
+
 // add-record ZONE name type [ttl] "content" ["content"]
 int addOrReplaceRecord(bool addOrReplace, const vector<string>& cmds) {
   DNSResourceRecord rr;
@@ -1920,6 +1938,8 @@ try
     cout<<"create-bind-db FNAME               Create DNSSEC db for BIND backend (bind-dnssec-db)"<<endl;
     cout<<"create-slave-zone ZONE master-ip [master-ip..]"<<endl;
     cout<<"                                   Create slave zone ZONE with master IP address master-ip"<<endl;
+    cout<<"change-slave-zone-master ZONE master-ip [master-ip..]"<<endl;
+    cout<<"                                   Change slave zone ZONE master IP address to master-ip"<<endl;
     cout<<"create-zone ZONE [nsname]          Create empty zone ZONE"<<endl;
     cout<<"deactivate-tsig-key ZONE NAME {master|slave}"<<endl;
     cout<<"                                   Disable TSIG key for a zone"<<endl;
@@ -2268,6 +2288,13 @@ loadMainConfig(g_vm["config-dir"].as<string>());
     }
     exit(createSlaveZone(cmds));
   }
+  else if(cmds[0] == "change-slave-zone-master") {
+    if(cmds.size() < 3 ) {
+      cerr<<"Syntax: pdnsutil change-slave-zone-master ZONE master-ip [master-ip..]"<<endl;
+      return 0;
+    }
+    exit(changeSlaveZoneMaster(cmds));
+  }
   else if(cmds[0] == "add-record") {
     if(cmds.size() < 5) {
       cerr<<"Syntax: pdnsutil add-record ZONE name type [ttl] \"content\" [\"content\"...]"<<endl;