Changeset 274 for trunk/DNSDB.pm
- Timestamp:
- 03/14/12 18:01:42 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r273 r274 39 39 &changeGroup 40 40 &loadConfig &connectDB &finish 41 &addDomain &del Domain&domainName &revName &domainID &addRDNS41 &addDomain &delZone &domainName &revName &domainID &addRDNS 42 42 &getZoneCount &getZoneList 43 43 &addGroup &delGroup &getChildren &groupName … … 61 61 &changeGroup 62 62 &loadConfig &connectDB &finish 63 &addDomain &del Domain&domainName &revName &domainID &addRDNS63 &addDomain &delZone &domainName &revName &domainID &addRDNS 64 64 &getZoneCount &getZoneList 65 65 &addGroup &delGroup &getChildren &groupName … … 1266 1266 1267 1267 1268 ## DNSDB::delDomain() 1269 # Delete a domain. 1268 ## DNSDB::delZone() 1269 # Delete a forward or reverse zone. 1270 # Takes a database handle, zone ID, and forward/reverse flag. 1270 1271 # for now, just delete the records, then the domain. 1271 1272 # later we may want to archive it in some way instead (status code 2, for example?) 1272 sub delDomain { 1273 my $dbh = shift; 1274 my $domid = shift; 1273 sub delZone { 1274 my $dbh = shift; 1275 my $zoneid = shift; 1276 my $revrec = shift; 1275 1277 1276 1278 # Allow transactions, and raise an exception on errors so we can catch it later. … … 1283 1285 # Wrap all the SQL in a transaction 1284 1286 eval { 1285 my $sth = $dbh->prepare("delete from records where domain_id=?"); 1286 $failmsg = "Failure removing domain records"; 1287 $sth->execute($domid); 1288 $sth = $dbh->prepare("delete from domains where domain_id=?"); 1289 $failmsg = "Failure removing domain"; 1290 $sth->execute($domid); 1287 # Disentangle custom record types before removing the 1288 # ones that are only in the zone to be deleted 1289 if ($revrec eq 'n') { 1290 my $sth = $dbh->prepare("UPDATE records SET type=?,domain_id=0 WHERE domain_id=? AND type=?"); 1291 $failmsg = "Failure converting multizone types to single-zone"; 1292 $sth->execute($reverse_typemap{PTR}, $zoneid, 65280); 1293 $sth->execute($reverse_typemap{PTR}, $zoneid, 65281); 1294 $sth->execute(65282, $zoneid, 65283); 1295 $sth->execute(65282, $zoneid, 65284); 1296 $failmsg = "Failure removing domain records"; 1297 $dbh->do("DELETE FROM records WHERE domain_id=?", undef, ($zoneid)); 1298 $failmsg = "Failure removing domain"; 1299 $dbh->do("DELETE FROM domains WHERE domain_id=?", undef, ($zoneid)); 1300 } else { 1301 my $sth = $dbh->prepare("UPDATE records SET type=?,rdns_id=0 WHERE rdns_id=? AND type=?"); 1302 $failmsg = "Failure converting multizone types to single-zone"; 1303 $sth->execute($reverse_typemap{A}, $zoneid, 65280); 1304 $sth->execute($reverse_typemap{AAAA}, $zoneid, 65281); 1305 # We don't have an "A template" or "AAAA template" type, although it might be useful for symmetry. 1306 # $sth->execute(65285?, $zoneid, 65283); 1307 # $sth->execute(65285?, $zoneid, 65284); 1308 $failmsg = "Failure removing reverse records"; 1309 $dbh->do("DELETE FROM records WHERE rdns_id=?", undef, ($zoneid)); 1310 $failmsg = "Failure removing reverse zone"; 1311 $dbh->do("DELETE FROM revzones WHERE rdns_id=?", undef, ($zoneid)); 1312 } 1291 1313 1292 1314 # once we get here, we should have suceeded. … … 1302 1324 } 1303 1325 1304 } # end del Domain()1326 } # end delZone() 1305 1327 1306 1328
Note:
See TracChangeset
for help on using the changeset viewer.