diff --git a/server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java b/server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java index 6fb0592ba88..1366290faa5 100644 --- a/server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java @@ -310,10 +310,10 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa boolean dbResult = Transaction.execute((TransactionCallback) status -> { DnsZoneNetworkMapVO networkMapVO = dnsZoneNetworkMapDao.findByZoneId(zoneId); + DnsProvider provider = getProviderByType(server.getProviderType()); + // Remove DNS records from nic_details if there are any if (networkMapVO != null) { - // Remove DNS records from nic_details if there are any try { - DnsProvider provider = getProviderByType(server.getProviderType()); List records = provider.listRecords(server, dnsZone); if (CollectionUtils.isNotEmpty(records)) { List dnsRecordNames = records.stream().map(DnsRecord::getName).filter(Objects::nonNull) @@ -324,19 +324,19 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa } catch (Exception ex) { logger.warn("Failed to fetch DNS records for dnsZone: {}, perform manual cleanup.", dnsZoneName, ex); } - // Remove DNS zone from provider and cleanup DB - try { - DnsProvider provider = getProviderByType(server.getProviderType()); - provider.deleteZone(server, dnsZone); - logger.debug("Deleted DNS zone: {} from provider", dnsZoneName); - } catch (DnsNotFoundException ex) { - logger.warn("DNS zone: {} is not present in the provider, proceeding with cleanup", dnsZoneName); - } catch (Exception ex) { - logger.error("Failed to delete DNS zone from provider", ex); - throw new CloudRuntimeException(String.format("Failed to delete DNS zone: %s.", dnsZoneName)); - } dnsZoneNetworkMapDao.removeNetworkMappingByZoneId(zoneId); } + + // Remove DNS zone from provider and cleanup DB + try { + provider.deleteZone(server, dnsZone); + logger.debug("Deleted DNS zone: {} from provider", dnsZoneName); + } catch (DnsNotFoundException ex) { + logger.warn("DNS zone: {} is not present in the provider, proceeding with cleanup", dnsZoneName); + } catch (Exception ex) { + logger.error("Failed to delete DNS zone from provider", ex); + throw new CloudRuntimeException(String.format("Failed to delete DNS zone: %s.", dnsZoneName)); + } return dnsZoneDao.remove(zoneId); }); diff --git a/ui/src/config/section/network.js b/ui/src/config/section/network.js index a51783a3b4f..ebc98c4f4fb 100644 --- a/ui/src/config/section/network.js +++ b/ui/src/config/section/network.js @@ -1565,6 +1565,7 @@ export default { message: 'message.action.delete.dns.server', dataView: true, popup: true, + component: shallowRef(defineAsyncComponent(() => import('@/views/network/dns/DeleteDnsServer.vue'))), show: (record, store) => { return record.account === store.userInfo.account || isAdminOrDomainAdmin(store.userInfo.roletype) }, groupAction: false, groupMap: (selection) => { return selection.map(x => { return { id: x } }) } @@ -1615,9 +1616,9 @@ export default { message: 'message.action.delete.dns.zone', dataView: true, popup: true, - groupAction: false, + component: shallowRef(defineAsyncComponent(() => import('@/views/network/dns/DeleteDnsZone.vue'))), show: (record, store) => { return record.account === store.userInfo.account || isAdminOrDomainAdmin(store.userInfo.roletype) }, - groupMap: (selection) => { return selection.map(x => { return { id: x } }) } + groupAction: false } ] } diff --git a/ui/src/views/network/dns/DeleteDnsServer.vue b/ui/src/views/network/dns/DeleteDnsServer.vue new file mode 100644 index 00000000000..3f42c784b7f --- /dev/null +++ b/ui/src/views/network/dns/DeleteDnsServer.vue @@ -0,0 +1,187 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + + + + + + diff --git a/ui/src/views/network/dns/DeleteDnsZone.vue b/ui/src/views/network/dns/DeleteDnsZone.vue new file mode 100644 index 00000000000..641c7cc7ee5 --- /dev/null +++ b/ui/src/views/network/dns/DeleteDnsZone.vue @@ -0,0 +1,153 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + + + + + +