change 'import' to 'existing' for createDnsZone command

This commit is contained in:
Manoj Kumar 2026-04-30 18:57:37 +05:30
parent ec61f6a289
commit 9391ea3fd2
No known key found for this signature in database
GPG Key ID: E952B7234D2C6F88
4 changed files with 19 additions and 16 deletions

View File

@ -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 " +

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -67,11 +67,11 @@
:placeholder="apiParams.description.description"/>
</a-form-item>
<a-form-item name="import" ref="import">
<a-form-item name="existing" ref="existing">
<template #label>
<tooltip-label :title="$t('label.import')" :tooltip="apiParams.import?.description" />
<tooltip-label :title="$t('label.existing')" :tooltip="apiParams.existing?.description" />
</template>
<a-switch v-model:checked="form.import" />
<a-switch v-model:checked="form.existing" />
</a-form-item>
<div class="action-button">
@ -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)