Skip to content

Commit 9391ea3

Browse files
committed
change 'import' to 'existing' for createDnsZone command
1 parent ec61f6a commit 9391ea3

4 files changed

Lines changed: 19 additions & 16 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ public class ApiConstants {
13851385
public static final String OLD_STATE = "oldState";
13861386
public static final String NEW_STATE = "newState";
13871387
public static final String OLD_HOST_NAME = "oldHostName";
1388-
public static final String IMPORT = "import";
1388+
public static final String EXISTING = "existing";
13891389
public static final String UNMANAGE = "unmanage";
13901390

13911391
public static final String PARAMETER_DESCRIPTION_ACTIVATION_RULE = "Quota tariff's activation rule. It can receive a JS script that results in either " +

api/src/main/java/org/apache/cloudstack/api/command/user/dns/CreateDnsZoneCmd.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public class CreateDnsZoneCmd extends BaseAsyncCreateCmd {
6666
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "The description of the DNS zone")
6767
private String description;
6868

69-
@Parameter(name = ApiConstants.IMPORT, type = CommandType.BOOLEAN, entityType = DnsZoneResponse.class,
69+
@Parameter(name = ApiConstants.EXISTING, type = CommandType.BOOLEAN, entityType = DnsZoneResponse.class,
7070
description = "If true, imports an existing DNS zone from the DNS provider into CloudStack. " +
7171
"If false, creates the zone in the DNS provider and registers it in CloudStack.")
72-
private Boolean importDnsZone = false;
72+
private Boolean existing = false;
7373

7474
/////////////////////////////////////////////////////
7575
/////////////////// Accessors ///////////////////////
@@ -120,7 +120,7 @@ public void create() throws ResourceAllocationException {
120120
@Override
121121
public void execute() {
122122
try {
123-
DnsZone result = dnsProviderManager.provisionDnsZone(getEntityId(), isImportDnsZone());
123+
DnsZone result = dnsProviderManager.provisionDnsZone(getEntityId(), isExistingZone());
124124
if (result != null) {
125125
DnsZoneResponse response = dnsProviderManager.createDnsZoneResponse(result);
126126
response.setResponseName(getCommandName());
@@ -148,7 +148,7 @@ public String getEventDescription() {
148148
return "creating DNS zone: " + getName();
149149
}
150150

151-
public Boolean isImportDnsZone() {
152-
return Boolean.TRUE.equals(importDnsZone);
151+
public Boolean isExistingZone() {
152+
return Boolean.TRUE.equals(existing);
153153
}
154154
}

server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,17 +587,18 @@ public DnsZone allocateDnsZone(CreateDnsZoneCmd cmd) {
587587
}
588588

589589
@Override
590-
public DnsZone provisionDnsZone(long dnsZoneId, boolean isImport) {
590+
public DnsZone provisionDnsZone(long dnsZoneId, boolean isExistingZone) {
591591
DnsZoneVO dnsZone = dnsZoneDao.findById(dnsZoneId);
592592
if (dnsZone == null) {
593593
throw new CloudRuntimeException("DNS zone not found during provisioning");
594594
}
595595
DnsServerVO server = dnsServerDao.findById(dnsZone.getDnsServerId());
596596
try {
597597
DnsProvider provider = getProviderByType(server.getProviderType());
598-
if (isImport) {
598+
if (isExistingZone) {
599599
if (!provider.dnsZoneExists(server, dnsZone)) {
600-
throw new CloudRuntimeException(String.format("DNS zone '%s' cannot be imported because it does not exist in the DNS provider", dnsZone));
600+
throw new CloudRuntimeException(
601+
String.format("DNS zone '%s' cannot be imported because it does not exist in the DNS provider", dnsZone.getName()));
601602
}
602603
} else {
603604
String externalReferenceId = provider.provisionZone(server, dnsZone);
@@ -610,10 +611,12 @@ public DnsZone provisionDnsZone(long dnsZoneId, boolean isImport) {
610611
dnsZoneDao.remove(dnsZoneId);
611612
logger.error("Failed to provision DNS zone: {} on DNS server: {}", dnsZone.getName(), server.getName(), ex);
612613
String errorMsg = "";
613-
if ( ex instanceof DnsConflictException) {
614+
if (ex instanceof DnsConflictException) {
614615
errorMsg = String.format("DNS zone: %s already exists", dnsZone.getName());
615-
} else if (ex instanceof DnsTransportException){
616+
} else if (ex instanceof DnsTransportException) {
616617
errorMsg = String.format("DNS server: %s not reachable", server.getName());
618+
} else if (ex instanceof CloudRuntimeException) {
619+
errorMsg = ex.getMessage();
617620
}
618621
throw new CloudRuntimeException(errorMsg);
619622
}

ui/src/views/network/dns/CreateDnsZone.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@
6767
:placeholder="apiParams.description.description"/>
6868
</a-form-item>
6969

70-
<a-form-item name="import" ref="import">
70+
<a-form-item name="existing" ref="existing">
7171
<template #label>
72-
<tooltip-label :title="$t('label.import')" :tooltip="apiParams.import?.description" />
72+
<tooltip-label :title="$t('label.existing')" :tooltip="apiParams.existing?.description" />
7373
</template>
74-
<a-switch v-model:checked="form.import" />
74+
<a-switch v-model:checked="form.existing" />
7575
</a-form-item>
7676

7777
<div class="action-button">
@@ -107,7 +107,7 @@ export default {
107107
name: '',
108108
dnsserverid: undefined,
109109
description: '',
110-
import: false
110+
existing: false
111111
},
112112
rules: {},
113113
fetchingServers: false,
@@ -143,7 +143,7 @@ export default {
143143
name: this.form.name.trim(),
144144
dnsserverid: this.form.dnsserverid,
145145
description: this.form.description?.trim(),
146-
import: this.form.import
146+
existing: this.form.existing
147147
}
148148
149149
const response = await postAPI('createDnsZone', params)

0 commit comments

Comments
 (0)