From 9391ea3fd29e5c8152031df4b1c03ab88b305f1f Mon Sep 17 00:00:00 2001 From: Manoj Kumar Date: Thu, 30 Apr 2026 18:57:37 +0530 Subject: [PATCH] change 'import' to 'existing' for createDnsZone command --- .../org/apache/cloudstack/api/ApiConstants.java | 2 +- .../api/command/user/dns/CreateDnsZoneCmd.java | 10 +++++----- .../cloudstack/dns/DnsProviderManagerImpl.java | 13 ++++++++----- ui/src/views/network/dns/CreateDnsZone.vue | 10 +++++----- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java index c58fba3417d..a87c28636e1 100644 --- a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java @@ -1385,7 +1385,7 @@ public class ApiConstants { public static final String OLD_STATE = "oldState"; public static final String NEW_STATE = "newState"; public static final String OLD_HOST_NAME = "oldHostName"; - public static final String IMPORT = "import"; + public static final String EXISTING = "existing"; public static final String UNMANAGE = "unmanage"; public static final String PARAMETER_DESCRIPTION_ACTIVATION_RULE = "Quota tariff's activation rule. It can receive a JS script that results in either " + diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/dns/CreateDnsZoneCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/dns/CreateDnsZoneCmd.java index 2e81edefe31..76bd8bdc493 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/dns/CreateDnsZoneCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/dns/CreateDnsZoneCmd.java @@ -66,10 +66,10 @@ public class CreateDnsZoneCmd extends BaseAsyncCreateCmd { @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "The description of the DNS zone") private String description; - @Parameter(name = ApiConstants.IMPORT, type = CommandType.BOOLEAN, entityType = DnsZoneResponse.class, + @Parameter(name = ApiConstants.EXISTING, type = CommandType.BOOLEAN, entityType = DnsZoneResponse.class, description = "If true, imports an existing DNS zone from the DNS provider into CloudStack. " + "If false, creates the zone in the DNS provider and registers it in CloudStack.") - private Boolean importDnsZone = false; + private Boolean existing = false; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -120,7 +120,7 @@ public class CreateDnsZoneCmd extends BaseAsyncCreateCmd { @Override public void execute() { try { - DnsZone result = dnsProviderManager.provisionDnsZone(getEntityId(), isImportDnsZone()); + DnsZone result = dnsProviderManager.provisionDnsZone(getEntityId(), isExistingZone()); if (result != null) { DnsZoneResponse response = dnsProviderManager.createDnsZoneResponse(result); response.setResponseName(getCommandName()); @@ -148,7 +148,7 @@ public class CreateDnsZoneCmd extends BaseAsyncCreateCmd { return "creating DNS zone: " + getName(); } - public Boolean isImportDnsZone() { - return Boolean.TRUE.equals(importDnsZone); + public Boolean isExistingZone() { + return Boolean.TRUE.equals(existing); } } 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 209b239963a..93a3d93f87f 100644 --- a/server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java @@ -587,7 +587,7 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa } @Override - public DnsZone provisionDnsZone(long dnsZoneId, boolean isImport) { + public DnsZone provisionDnsZone(long dnsZoneId, boolean isExistingZone) { DnsZoneVO dnsZone = dnsZoneDao.findById(dnsZoneId); if (dnsZone == null) { throw new CloudRuntimeException("DNS zone not found during provisioning"); @@ -595,9 +595,10 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa DnsServerVO server = dnsServerDao.findById(dnsZone.getDnsServerId()); try { DnsProvider provider = getProviderByType(server.getProviderType()); - if (isImport) { + if (isExistingZone) { if (!provider.dnsZoneExists(server, dnsZone)) { - throw new CloudRuntimeException(String.format("DNS zone '%s' cannot be imported because it does not exist in the DNS provider", dnsZone)); + throw new CloudRuntimeException( + String.format("DNS zone '%s' cannot be imported because it does not exist in the DNS provider", dnsZone.getName())); } } else { String externalReferenceId = provider.provisionZone(server, dnsZone); @@ -610,10 +611,12 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa dnsZoneDao.remove(dnsZoneId); logger.error("Failed to provision DNS zone: {} on DNS server: {}", dnsZone.getName(), server.getName(), ex); String errorMsg = ""; - if ( ex instanceof DnsConflictException) { + if (ex instanceof DnsConflictException) { errorMsg = String.format("DNS zone: %s already exists", dnsZone.getName()); - } else if (ex instanceof DnsTransportException){ + } else if (ex instanceof DnsTransportException) { errorMsg = String.format("DNS server: %s not reachable", server.getName()); + } else if (ex instanceof CloudRuntimeException) { + errorMsg = ex.getMessage(); } throw new CloudRuntimeException(errorMsg); } diff --git a/ui/src/views/network/dns/CreateDnsZone.vue b/ui/src/views/network/dns/CreateDnsZone.vue index 145ebe2e633..51d72634890 100644 --- a/ui/src/views/network/dns/CreateDnsZone.vue +++ b/ui/src/views/network/dns/CreateDnsZone.vue @@ -67,11 +67,11 @@ :placeholder="apiParams.description.description"/> - + - +
@@ -107,7 +107,7 @@ export default { name: '', dnsserverid: undefined, description: '', - import: false + existing: false }, rules: {}, fetchingServers: false, @@ -143,7 +143,7 @@ export default { name: this.form.name.trim(), dnsserverid: this.form.dnsserverid, description: this.form.description?.trim(), - import: this.form.import + existing: this.form.existing } const response = await postAPI('createDnsZone', params)