mirror of https://github.com/apache/cloudstack.git
rename dnsrecordurl -> nicdnsname, DnsNicJoinView -> nicDnsJoinVo
This commit is contained in:
parent
001a197689
commit
172ac67732
|
|
@ -1372,7 +1372,7 @@ public class ApiConstants {
|
|||
public static final String DISABLED = "disabled";
|
||||
public static final String CONTENT_TYPE = "Content-Type";
|
||||
public static final String NATIVE_ZONE = "Native";
|
||||
public static final String NIC_DNS_RECORD = "nicdnsrecord";
|
||||
public static final String NIC_DNS_NAME = "nicdnsname";
|
||||
public static final String TIME_STAMP = "timestamp";
|
||||
public static final String INSTANCE_ID = "instanceId";
|
||||
public static final String OLD_STATE = "oldState";
|
||||
|
|
|
|||
|
|
@ -150,9 +150,9 @@ public class NicResponse extends BaseResponse {
|
|||
@Param(description = "whether the NIC is enabled or not")
|
||||
private Boolean isEnabled;
|
||||
|
||||
@SerializedName("dnsrecordurl")
|
||||
@SerializedName(ApiConstants.NIC_DNS_NAME)
|
||||
@Param(description = "Public IP address associated with this NIC via Static NAT rule")
|
||||
private String dnsRecordUrl;
|
||||
private String nicDnsName;
|
||||
|
||||
public void setVmId(String vmId) {
|
||||
this.vmId = vmId;
|
||||
|
|
@ -433,7 +433,7 @@ public class NicResponse extends BaseResponse {
|
|||
isEnabled = enabled;
|
||||
}
|
||||
|
||||
public void setDnsRecordUrl(String dnsRecordUrl) {
|
||||
this.dnsRecordUrl = dnsRecordUrl;
|
||||
public void setNicDnsName(String nicDnsName) {
|
||||
this.nicDnsName = nicDnsName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -317,6 +317,6 @@
|
|||
<bean id="dnsZoneNetworkMapDao" class="org.apache.cloudstack.dns.dao.DnsZoneNetworkMapDaoImpl" />
|
||||
<bean id="dnsServerJoinDao" class="org.apache.cloudstack.dns.dao.DnsServerJoinDaoImpl" />
|
||||
<bean id="dnsZoneJoinDao" class="org.apache.cloudstack.dns.dao.DnsZoneJoinDaoImpl" />
|
||||
<bean id="dnsNicJoinDao" class="org.apache.cloudstack.dns.dao.DnsNicJoinDaoImpl" />
|
||||
<bean id="dnsNicJoinDao" class="org.apache.cloudstack.dns.dao.NicDnsJoinDaoImpl" />
|
||||
|
||||
</beans>
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ SELECT
|
|||
`nics`.`broadcast_uri` AS `broadcast_uri`,
|
||||
`nics`.`isolation_uri` AS `isolation_uri`,
|
||||
`nics`.`enabled` AS `is_nic_enabled`,
|
||||
`nic_details`.`value` AS `dns_record_url`,
|
||||
`nic_details`.`value` AS `nic_dns_name`,
|
||||
`vpc`.`id` AS `vpc_id`,
|
||||
`vpc`.`uuid` AS `vpc_uuid`,
|
||||
`networks`.`uuid` AS `network_uuid`,
|
||||
|
|
@ -215,7 +215,7 @@ FROM
|
|||
LEFT JOIN `user_data` ON ((`user_data`.`id` = `user_vm`.`user_data_id`)))
|
||||
LEFT JOIN `nics` ON (((`vm_instance`.`id` = `nics`.`instance_id`)
|
||||
AND ISNULL(`nics`.`removed`))))
|
||||
LEFT JOIN `nic_details` ON ((`nic_details`.`nic_id` = `nics`.`id`) AND (`nic_details`.`name` = 'nicdnsrecord')))
|
||||
LEFT JOIN `nic_details` ON ((`nic_details`.`nic_id` = `nics`.`id`) AND (`nic_details`.`name` = 'nicdnsname')))
|
||||
LEFT JOIN `networks` ON ((`nics`.`network_id` = `networks`.`id`)))
|
||||
LEFT JOIN `vpc` ON (((`networks`.`vpc_id` = `vpc`.`id`)
|
||||
AND ISNULL(`vpc`.`removed`))))
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@
|
|||
-- specific language governing permissions and limitations
|
||||
-- under the License.
|
||||
|
||||
-- VIEW `cloud`.`dns_nic_view`;
|
||||
-- VIEW `cloud`.`nic_dns_view`;
|
||||
|
||||
DROP VIEW IF EXISTS `cloud`.`dns_nic_view`;
|
||||
CREATE VIEW `cloud`.`dns_nic_view` AS
|
||||
DROP VIEW IF EXISTS `cloud`.`nic_dns_view`;
|
||||
CREATE VIEW `cloud`.`nic_dns_view` AS
|
||||
SELECT
|
||||
n.id AS id,
|
||||
n.uuid AS uuid,
|
||||
|
|
@ -27,7 +27,7 @@ SELECT
|
|||
n.ip4_address AS ip4_address,
|
||||
n.ip6_address AS ip6_address,
|
||||
n.removed AS removed,
|
||||
nd.value AS nic_dns_url,
|
||||
nd.value AS nic_dns_name,
|
||||
map.dns_zone_id AS dns_zone_id,
|
||||
map.sub_domain AS sub_domain
|
||||
FROM
|
||||
|
|
@ -35,6 +35,6 @@ FROM
|
|||
INNER JOIN
|
||||
`cloud`.`dns_zone_network_map` map ON n.network_id = map.network_id
|
||||
LEFT JOIN
|
||||
`cloud`.`nic_details` nd ON n.id = nd.nic_id AND nd.name = 'nicdnsrecord'
|
||||
`cloud`.`nic_details` nd ON n.id = nd.nic_id AND nd.name = 'nicdnsname'
|
||||
WHERE
|
||||
map.removed IS NULL;
|
||||
|
|
@ -360,7 +360,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
|
|||
nicResponse.setIp6Gateway(userVm.getIp6Gateway());
|
||||
nicResponse.setIp6Cidr(userVm.getIp6Cidr());
|
||||
nicResponse.setEnabled(userVm.isNicEnabled());
|
||||
nicResponse.setDnsRecordUrl(userVm.getDnsRecordUrl());
|
||||
nicResponse.setNicDnsName(userVm.getNicDnsName());
|
||||
if (userVm.getBroadcastUri() != null) {
|
||||
nicResponse.setBroadcastUri(userVm.getBroadcastUri().toString());
|
||||
}
|
||||
|
|
@ -623,7 +623,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
|
|||
/*13: IPv6Cidr*/
|
||||
nicResponse.setIp6Cidr(uvo.getIp6Cidr());
|
||||
/* dnsRecordUrl */
|
||||
nicResponse.setDnsRecordUrl(uvo.getDnsRecordUrl());
|
||||
nicResponse.setNicDnsName(uvo.getNicDnsName());
|
||||
|
||||
/*14: deviceId*/
|
||||
// where do we find nicResponse.setDeviceId(
|
||||
|
|
|
|||
|
|
@ -405,8 +405,8 @@ public class UserVmJoinVO extends BaseViewWithTagInformationVO implements Contro
|
|||
@Column(name = "public_ip_address")
|
||||
private String publicIpAddress;
|
||||
|
||||
@Column(name = "dns_record_url")
|
||||
private String dnsRecordUrl;
|
||||
@Column(name = "nic_dns_name")
|
||||
private String nicDnsName;
|
||||
|
||||
@Column(name = "user_data", updatable = true, nullable = true, length = 2048)
|
||||
private String userData;
|
||||
|
|
@ -1108,7 +1108,7 @@ public class UserVmJoinVO extends BaseViewWithTagInformationVO implements Contro
|
|||
return isNicEnabled;
|
||||
}
|
||||
|
||||
public String getDnsRecordUrl() {
|
||||
return dnsRecordUrl;
|
||||
public String getNicDnsName() {
|
||||
return nicDnsName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ import org.apache.cloudstack.api.response.DnsZoneNetworkMapResponse;
|
|||
import org.apache.cloudstack.api.response.DnsZoneResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.dns.dao.DnsNicJoinDao;
|
||||
import org.apache.cloudstack.dns.dao.NicDnsJoinDao;
|
||||
import org.apache.cloudstack.dns.dao.DnsServerDao;
|
||||
import org.apache.cloudstack.dns.dao.DnsServerJoinDao;
|
||||
import org.apache.cloudstack.dns.dao.DnsZoneDao;
|
||||
|
|
@ -65,7 +65,7 @@ import org.apache.cloudstack.dns.exception.DnsConflictException;
|
|||
import org.apache.cloudstack.dns.exception.DnsNotFoundException;
|
||||
import org.apache.cloudstack.dns.exception.DnsProviderException;
|
||||
import org.apache.cloudstack.dns.exception.DnsTransportException;
|
||||
import org.apache.cloudstack.dns.vo.DnsNicJoinVO;
|
||||
import org.apache.cloudstack.dns.vo.NicDnsJoinVO;
|
||||
import org.apache.cloudstack.dns.vo.DnsServerJoinVO;
|
||||
import org.apache.cloudstack.dns.vo.DnsServerVO;
|
||||
import org.apache.cloudstack.dns.vo.DnsZoneJoinVO;
|
||||
|
|
@ -139,7 +139,7 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
@Inject
|
||||
VMInstanceDao vmInstanceDao;
|
||||
@Inject
|
||||
DnsNicJoinDao dnsNicJoinDao;
|
||||
NicDnsJoinDao nicDnsJoinDao;
|
||||
|
||||
private DnsProvider getProviderByType(DnsProviderType type) {
|
||||
if (type == null) {
|
||||
|
|
@ -342,7 +342,7 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
List<String> dnsRecordNames = records.stream().map(DnsRecord::getName).filter(Objects::nonNull)
|
||||
.map(name -> name.replaceAll("\\.+$", ""))
|
||||
.collect(Collectors.toList());
|
||||
nicDetailsDao.removeDetailsForValuesIn(ApiConstants.NIC_DNS_RECORD, dnsRecordNames);
|
||||
nicDetailsDao.removeDetailsForValuesIn(ApiConstants.NIC_DNS_NAME, dnsRecordNames);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.warn("Failed to fetch DNS records for dnsZone: {}, perform manual cleanup.", dnsZoneName, ex);
|
||||
|
|
@ -882,13 +882,13 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
logger.debug("Instance is not found for the given ID: {}", instanceId);
|
||||
return;
|
||||
}
|
||||
List<DnsNicJoinVO> mappedNics = dnsNicJoinDao.listActiveByVmId(instanceId);
|
||||
List<NicDnsJoinVO> mappedNics = nicDnsJoinDao.listActiveByVmId(instanceId);
|
||||
if (CollectionUtils.isEmpty(mappedNics)) {
|
||||
logger.debug("No active DNS zone associated to NICs");
|
||||
return;
|
||||
}
|
||||
Map<Long, Map<String, List<DnsNicJoinVO>>> dnsZoneRecordNicMap = new HashMap<>();
|
||||
for (DnsNicJoinVO nic : mappedNics) {
|
||||
Map<Long, Map<String, List<NicDnsJoinVO>>> dnsZoneRecordNicMap = new HashMap<>();
|
||||
for (NicDnsJoinVO nic : mappedNics) {
|
||||
DnsZoneVO targetZone = dnsZoneDao.findById(nic.getDnsZoneId());
|
||||
if (targetZone == null) {
|
||||
continue;
|
||||
|
|
@ -899,11 +899,11 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
.add(nic);
|
||||
}
|
||||
|
||||
for (Map.Entry<Long, Map<String, List<DnsNicJoinVO>>> zoneEntry : dnsZoneRecordNicMap.entrySet()) {
|
||||
for (Map.Entry<Long, Map<String, List<NicDnsJoinVO>>> zoneEntry : dnsZoneRecordNicMap.entrySet()) {
|
||||
long targetZoneId = zoneEntry.getKey();
|
||||
for (Map.Entry<String, List<DnsNicJoinVO>> dnsUrlEntry : zoneEntry.getValue().entrySet()) {
|
||||
for (Map.Entry<String, List<NicDnsJoinVO>> dnsUrlEntry : zoneEntry.getValue().entrySet()) {
|
||||
String dnsRecordUrl = dnsUrlEntry.getKey();
|
||||
List<DnsNicJoinVO> nicsForThisFqdn = dnsUrlEntry.getValue();
|
||||
List<NicDnsJoinVO> nicsForThisFqdn = dnsUrlEntry.getValue();
|
||||
try {
|
||||
Transaction.execute(new TransactionCallbackWithExceptionNoReturn<DnsProviderException>() {
|
||||
@Override
|
||||
|
|
@ -911,8 +911,8 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
if (isDnsCollision(dnsRecordUrl, targetZoneId, instanceId)) {
|
||||
return;
|
||||
}
|
||||
for (DnsNicJoinVO nic : nicsForThisFqdn) {
|
||||
nicDetailsDao.addDetail(nic.getId(), ApiConstants.NIC_DNS_RECORD, dnsRecordUrl, true);
|
||||
for (NicDnsJoinVO nic : nicsForThisFqdn) {
|
||||
nicDetailsDao.addDetail(nic.getId(), ApiConstants.NIC_DNS_NAME, dnsRecordUrl, true);
|
||||
}
|
||||
syncDnsRecordsState(instanceId, dnsRecordUrl, targetZoneId);
|
||||
}
|
||||
|
|
@ -927,34 +927,34 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
}
|
||||
|
||||
void handleVmStopAndDestroy(long instanceId) {
|
||||
List<DnsNicJoinVO> historicalNics = dnsNicJoinDao.listIncludingRemovedByVmId(instanceId);
|
||||
List<NicDnsJoinVO> historicalNics = nicDnsJoinDao.listIncludingRemovedByVmId(instanceId);
|
||||
if (CollectionUtils.isEmpty(historicalNics)) {
|
||||
return;
|
||||
}
|
||||
Map<Long, Map<String, List<DnsNicJoinVO>>> groupByDnsZone = new HashMap<>();
|
||||
for (DnsNicJoinVO nic : historicalNics) {
|
||||
Map<Long, Map<String, List<NicDnsJoinVO>>> groupByDnsZone = new HashMap<>();
|
||||
for (NicDnsJoinVO nic : historicalNics) {
|
||||
// If the DNS record url is null, it means this NIC was never registered in nic_details
|
||||
if (nic.getNicDnsUrl() == null) {
|
||||
if (nic.getNicDnsName() == null) {
|
||||
continue;
|
||||
}
|
||||
groupByDnsZone
|
||||
.computeIfAbsent(nic.getDnsZoneId(), k -> new HashMap<>())
|
||||
.computeIfAbsent(nic.getNicDnsUrl(), k -> new ArrayList<>())
|
||||
.computeIfAbsent(nic.getNicDnsName(), k -> new ArrayList<>())
|
||||
.add(nic);
|
||||
}
|
||||
|
||||
for (Map.Entry<Long, Map<String, List<DnsNicJoinVO>>> zoneEntry : groupByDnsZone.entrySet()) {
|
||||
for (Map.Entry<Long, Map<String, List<NicDnsJoinVO>>> zoneEntry : groupByDnsZone.entrySet()) {
|
||||
long targetZoneId = zoneEntry.getKey();
|
||||
for (Map.Entry<String, List<DnsNicJoinVO>> dnsRecordEntry : zoneEntry.getValue().entrySet()) {
|
||||
for (Map.Entry<String, List<NicDnsJoinVO>> dnsRecordEntry : zoneEntry.getValue().entrySet()) {
|
||||
String dnsRecordUrl = dnsRecordEntry.getKey();
|
||||
List<DnsNicJoinVO> nicsForDnsUrl = dnsRecordEntry.getValue();
|
||||
List<NicDnsJoinVO> nicsForDnsUrl = dnsRecordEntry.getValue();
|
||||
|
||||
try {
|
||||
Transaction.execute(new TransactionCallbackWithExceptionNoReturn<DnsProviderException>() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) throws DnsProviderException {
|
||||
for (DnsNicJoinVO nic : nicsForDnsUrl) {
|
||||
nicDetailsDao.removeDetail(nic.getId(), ApiConstants.NIC_DNS_RECORD);
|
||||
for (NicDnsJoinVO nic : nicsForDnsUrl) {
|
||||
nicDetailsDao.removeDetail(nic.getId(), ApiConstants.NIC_DNS_NAME);
|
||||
}
|
||||
// Because we just deleted the nic_details, the sync method will naturally
|
||||
// find 0 active IPs for this VM/FQDN combo and issue a clean DELETE to PowerDNS.
|
||||
|
|
@ -978,19 +978,19 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
return;
|
||||
}
|
||||
|
||||
List<DnsNicJoinVO> mappedNics = dnsNicJoinDao.listActiveByVmId(instanceId);
|
||||
List<NicDnsJoinVO> mappedNics = nicDnsJoinDao.listActiveByVmId(instanceId);
|
||||
if (CollectionUtils.isEmpty(mappedNics)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Long, Map<String, List<DnsNicJoinVO>>> dnsZoneNewRecordNicMap = new HashMap<>();
|
||||
for (DnsNicJoinVO nic : mappedNics) {
|
||||
Map<Long, Map<String, List<NicDnsJoinVO>>> dnsZoneNewRecordNicMap = new HashMap<>();
|
||||
for (NicDnsJoinVO nic : mappedNics) {
|
||||
DnsZoneVO targetZone = dnsZoneDao.findById(nic.getDnsZoneId());
|
||||
if (targetZone == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String oldDnsRecordUrl = nic.getNicDnsUrl();
|
||||
String oldDnsRecordUrl = nic.getNicDnsName();
|
||||
String newDnsRecordUrl = prepareDnsRecordUrl(newHostName, nic.getSubDomain(), targetZone.getName());
|
||||
if (newDnsRecordUrl.equals(oldDnsRecordUrl)) {
|
||||
continue;
|
||||
|
|
@ -1001,22 +1001,22 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
.add(nic);
|
||||
}
|
||||
|
||||
for (Map.Entry<Long, Map<String, List<DnsNicJoinVO>>> zoneEntry : dnsZoneNewRecordNicMap.entrySet()) {
|
||||
for (Map.Entry<Long, Map<String, List<NicDnsJoinVO>>> zoneEntry : dnsZoneNewRecordNicMap.entrySet()) {
|
||||
long targetZoneId = zoneEntry.getKey();
|
||||
|
||||
for (Map.Entry<String, List<DnsNicJoinVO>> newUrlEntry : zoneEntry.getValue().entrySet()) {
|
||||
for (Map.Entry<String, List<NicDnsJoinVO>> newUrlEntry : zoneEntry.getValue().entrySet()) {
|
||||
String newDnsRecordUrl = newUrlEntry.getKey();
|
||||
List<DnsNicJoinVO> nicsForThisFqdn = newUrlEntry.getValue();
|
||||
List<NicDnsJoinVO> nicsForThisFqdn = newUrlEntry.getValue();
|
||||
|
||||
try {
|
||||
Set<String> oldDnsRecordUrls = new HashSet<>();
|
||||
Transaction.execute(new TransactionCallbackWithExceptionNoReturn<DnsProviderException>() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) throws DnsProviderException {
|
||||
for (DnsNicJoinVO nic : nicsForThisFqdn) {
|
||||
if (nic.getNicDnsUrl() != null) {
|
||||
oldDnsRecordUrls.add(nic.getNicDnsUrl());
|
||||
nicDetailsDao.removeDetail(nic.getId(), ApiConstants.NIC_DNS_RECORD);
|
||||
for (NicDnsJoinVO nic : nicsForThisFqdn) {
|
||||
if (nic.getNicDnsName() != null) {
|
||||
oldDnsRecordUrls.add(nic.getNicDnsName());
|
||||
nicDetailsDao.removeDetail(nic.getId(), ApiConstants.NIC_DNS_NAME);
|
||||
}
|
||||
}
|
||||
for (String oldUrl : oldDnsRecordUrls) {
|
||||
|
|
@ -1031,8 +1031,8 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
if (isDnsCollision(newDnsRecordUrl, targetZoneId, instanceId)) {
|
||||
return;
|
||||
}
|
||||
for (DnsNicJoinVO nic : nicsForThisFqdn) {
|
||||
nicDetailsDao.addDetail(nic.getId(), ApiConstants.NIC_DNS_RECORD, newDnsRecordUrl, true);
|
||||
for (NicDnsJoinVO nic : nicsForThisFqdn) {
|
||||
nicDetailsDao.addDetail(nic.getId(), ApiConstants.NIC_DNS_NAME, newDnsRecordUrl, true);
|
||||
}
|
||||
// This sync call finds the newly written intent and sends an ADD/REPLACE call.
|
||||
syncDnsRecordsState(instanceId, newDnsRecordUrl, targetZoneId);
|
||||
|
|
@ -1053,7 +1053,7 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
if (instance == null || instance.getState() != VirtualMachine.State.Running) {
|
||||
return;
|
||||
}
|
||||
DnsNicJoinVO nic = dnsNicJoinDao.findById(nicId);
|
||||
NicDnsJoinVO nic = nicDnsJoinDao.findById(nicId);
|
||||
if (nic == null) {
|
||||
logger.debug("NIC with ID: {} doesn't have DNS zone associated", nicId);
|
||||
return;
|
||||
|
|
@ -1073,7 +1073,7 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
if (isDnsCollision(dnsRecordUrl, targetZone.getId(), instanceId)) {
|
||||
return;
|
||||
}
|
||||
nicDetailsDao.addDetail(nicId, ApiConstants.NIC_DNS_RECORD, dnsRecordUrl, true);
|
||||
nicDetailsDao.addDetail(nicId, ApiConstants.NIC_DNS_NAME, dnsRecordUrl, true);
|
||||
syncDnsRecordsState(instanceId, dnsRecordUrl, targetZone.getId());
|
||||
logger.debug("Successfully synced DNS on NIC Plug for: {}", dnsRecordUrl);
|
||||
}
|
||||
|
|
@ -1086,18 +1086,18 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
}
|
||||
|
||||
void handleNicUnplug(long instanceId, long nicId) {
|
||||
DnsNicJoinVO nic = dnsNicJoinDao.findByIdIncludingRemoved(nicId);
|
||||
if (nic == null || nic.getNicDnsUrl() == null) {
|
||||
NicDnsJoinVO nic = nicDnsJoinDao.findByIdIncludingRemoved(nicId);
|
||||
if (nic == null || nic.getNicDnsName() == null) {
|
||||
return;
|
||||
}
|
||||
String dnsRecordUrl = nic.getNicDnsUrl();
|
||||
String dnsRecordUrl = nic.getNicDnsName();
|
||||
long dnsZoneId = nic.getDnsZoneId();
|
||||
|
||||
try {
|
||||
Transaction.execute(new TransactionCallbackWithExceptionNoReturn<DnsProviderException>() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) throws DnsProviderException {
|
||||
nicDetailsDao.removeDetail(nicId, ApiConstants.NIC_DNS_RECORD);
|
||||
nicDetailsDao.removeDetail(nicId, ApiConstants.NIC_DNS_NAME);
|
||||
syncDnsRecordsState(instanceId, dnsRecordUrl, dnsZoneId);
|
||||
logger.debug("Successfully synced DNS record: {} on NIC unplug", dnsRecordUrl);
|
||||
}
|
||||
|
|
@ -1120,7 +1120,7 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
}
|
||||
|
||||
private boolean isDnsCollision(String dnsRecordUrl, long targetZoneId, long instanceId) {
|
||||
DnsNicJoinVO existing = dnsNicJoinDao.findActiveByDnsRecordAndZone(dnsRecordUrl, targetZoneId);
|
||||
NicDnsJoinVO existing = nicDnsJoinDao.findActiveByDnsRecordAndZone(dnsRecordUrl, targetZoneId);
|
||||
if (existing != null && existing.getInstanceId() != instanceId) {
|
||||
logger.error("DNS collision: cannot register DNS record: {}. Already owned by Instance: {}.",
|
||||
dnsRecordUrl, existing.getInstanceId());
|
||||
|
|
@ -1141,11 +1141,11 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa
|
|||
return;
|
||||
}
|
||||
DnsServerVO dnsServer = dnsServerDao.findById(dnsZone.getDnsServerId());
|
||||
List<DnsNicJoinVO> activeNics = dnsNicJoinDao.listActiveByVmIdZoneAndDnsRecord(instanceId, dnsZoneId, dnsRecordUrl);
|
||||
List<NicDnsJoinVO> activeNics = nicDnsJoinDao.listActiveByVmIdZoneAndDnsRecord(instanceId, dnsZoneId, dnsRecordUrl);
|
||||
|
||||
List<String> ipv4s = new ArrayList<>();
|
||||
List<String> ipv6s = new ArrayList<>();
|
||||
for (DnsNicJoinVO nic : activeNics) {
|
||||
for (NicDnsJoinVO nic : activeNics) {
|
||||
if (nic.getIp4Address() != null && !nic.getIp4Address().isEmpty()) {
|
||||
ipv4s.add(nic.getIp4Address());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ package org.apache.cloudstack.dns.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.dns.vo.DnsNicJoinVO;
|
||||
import org.apache.cloudstack.dns.vo.NicDnsJoinVO;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface DnsNicJoinDao extends GenericDao<DnsNicJoinVO, Long> {
|
||||
public interface NicDnsJoinDao extends GenericDao<NicDnsJoinVO, Long> {
|
||||
|
||||
/**
|
||||
* Used for Collision Checks.
|
||||
|
|
@ -31,7 +31,7 @@ public interface DnsNicJoinDao extends GenericDao<DnsNicJoinVO, Long> {
|
|||
* @param dnsZoneId
|
||||
* @return active records to see who currently owns the dnsRecordUrl.
|
||||
*/
|
||||
DnsNicJoinVO findActiveByDnsRecordAndZone(String dnsRecordUrl, long dnsZoneId);
|
||||
NicDnsJoinVO findActiveByDnsRecordAndZone(String dnsRecordUrl, long dnsZoneId);
|
||||
|
||||
/**
|
||||
* Used to sync DNS record url based on available ips for vmId in the dnsZone
|
||||
|
|
@ -40,19 +40,19 @@ public interface DnsNicJoinDao extends GenericDao<DnsNicJoinVO, Long> {
|
|||
* @param dnsRecordUrl
|
||||
* @return list of active nics using the dnsRecordUrl, supports null vmId for dnsZone wide query
|
||||
*/
|
||||
List<DnsNicJoinVO> listActiveByVmIdZoneAndDnsRecord(Long vmId, long dnsZoneId, String dnsRecordUrl);
|
||||
List<NicDnsJoinVO> listActiveByVmIdZoneAndDnsRecord(Long vmId, long dnsZoneId, String dnsRecordUrl);
|
||||
|
||||
/**
|
||||
* Used for VM Start/Running
|
||||
* @param vmId
|
||||
* @return records associated to vmId
|
||||
*/
|
||||
List<DnsNicJoinVO> listActiveByVmId(long vmId);
|
||||
List<NicDnsJoinVO> listActiveByVmId(long vmId);
|
||||
|
||||
/**
|
||||
* Used by Instance Destroy/Stop or NIC delete
|
||||
* @param vmId
|
||||
* @return records with soft-delete
|
||||
*/
|
||||
List<DnsNicJoinVO> listIncludingRemovedByVmId(long vmId);
|
||||
List<NicDnsJoinVO> listIncludingRemovedByVmId(long vmId);
|
||||
}
|
||||
|
|
@ -20,28 +20,28 @@ package org.apache.cloudstack.dns.dao;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.dns.vo.DnsNicJoinVO;
|
||||
import org.apache.cloudstack.dns.vo.NicDnsJoinVO;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
public class DnsNicJoinDaoImpl extends GenericDaoBase<DnsNicJoinVO, Long> implements DnsNicJoinDao {
|
||||
private final SearchBuilder<DnsNicJoinVO> activeDnsRecordZoneSearch;
|
||||
private final SearchBuilder<DnsNicJoinVO> activeVmZoneDnsRecordSearch; // Route for null vmId
|
||||
private final SearchBuilder<DnsNicJoinVO> activeVmSearch;
|
||||
public class NicDnsJoinDaoImpl extends GenericDaoBase<NicDnsJoinVO, Long> implements NicDnsJoinDao {
|
||||
private final SearchBuilder<NicDnsJoinVO> activeDnsRecordZoneSearch;
|
||||
private final SearchBuilder<NicDnsJoinVO> activeVmZoneDnsRecordSearch; // Route for null vmId
|
||||
private final SearchBuilder<NicDnsJoinVO> activeVmSearch;
|
||||
|
||||
public DnsNicJoinDaoImpl() {
|
||||
public NicDnsJoinDaoImpl() {
|
||||
|
||||
activeDnsRecordZoneSearch = createSearchBuilder();
|
||||
activeDnsRecordZoneSearch.and(ApiConstants.NIC_DNS_RECORD, activeDnsRecordZoneSearch.entity().getNicDnsUrl(), SearchCriteria.Op.EQ);
|
||||
activeDnsRecordZoneSearch.and(ApiConstants.NIC_DNS_NAME, activeDnsRecordZoneSearch.entity().getNicDnsName(), SearchCriteria.Op.EQ);
|
||||
activeDnsRecordZoneSearch.and(ApiConstants.DNS_ZONE_ID, activeDnsRecordZoneSearch.entity().getDnsZoneId(), SearchCriteria.Op.EQ);
|
||||
activeDnsRecordZoneSearch.and(ApiConstants.REMOVED, activeDnsRecordZoneSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
activeDnsRecordZoneSearch.done();
|
||||
|
||||
activeVmZoneDnsRecordSearch = createSearchBuilder();
|
||||
activeVmZoneDnsRecordSearch.and(ApiConstants.INSTANCE_ID, activeVmZoneDnsRecordSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
|
||||
activeVmZoneDnsRecordSearch.and(ApiConstants.NIC_DNS_RECORD, activeVmZoneDnsRecordSearch.entity().getNicDnsUrl(), SearchCriteria.Op.EQ);
|
||||
activeVmZoneDnsRecordSearch.and(ApiConstants.NIC_DNS_NAME, activeVmZoneDnsRecordSearch.entity().getNicDnsName(), SearchCriteria.Op.EQ);
|
||||
activeVmZoneDnsRecordSearch.and(ApiConstants.DNS_ZONE_ID, activeVmZoneDnsRecordSearch.entity().getDnsZoneId(), SearchCriteria.Op.EQ);
|
||||
activeVmZoneDnsRecordSearch.and(ApiConstants.REMOVED, activeVmZoneDnsRecordSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
activeVmZoneDnsRecordSearch.done();
|
||||
|
|
@ -52,39 +52,39 @@ public class DnsNicJoinDaoImpl extends GenericDaoBase<DnsNicJoinVO, Long> implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public DnsNicJoinVO findActiveByDnsRecordAndZone(String dnsRecordUrl, long dnsZoneId) {
|
||||
SearchCriteria<DnsNicJoinVO> sc = activeDnsRecordZoneSearch.create();
|
||||
sc.setParameters(ApiConstants.NIC_DNS_RECORD, dnsRecordUrl);
|
||||
public NicDnsJoinVO findActiveByDnsRecordAndZone(String dnsRecordUrl, long dnsZoneId) {
|
||||
SearchCriteria<NicDnsJoinVO> sc = activeDnsRecordZoneSearch.create();
|
||||
sc.setParameters(ApiConstants.NIC_DNS_NAME, dnsRecordUrl);
|
||||
sc.setParameters(ApiConstants.DNS_ZONE_ID, dnsZoneId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DnsNicJoinVO> listActiveByVmIdZoneAndDnsRecord(Long vmId, long dnsZoneId, String dnsRecordUrl) {
|
||||
public List<NicDnsJoinVO> listActiveByVmIdZoneAndDnsRecord(Long vmId, long dnsZoneId, String dnsRecordUrl) {
|
||||
if (vmId != null) {
|
||||
SearchCriteria<DnsNicJoinVO> sc = activeDnsRecordZoneSearch.create();
|
||||
SearchCriteria<NicDnsJoinVO> sc = activeDnsRecordZoneSearch.create();
|
||||
sc.setParameters(ApiConstants.INSTANCE_ID, vmId);
|
||||
sc.setParameters(ApiConstants.DNS_ZONE_ID, dnsZoneId);
|
||||
sc.setParameters(ApiConstants.NIC_DNS_RECORD, dnsRecordUrl);
|
||||
sc.setParameters(ApiConstants.NIC_DNS_NAME, dnsRecordUrl);
|
||||
return listBy(sc);
|
||||
} else {
|
||||
SearchCriteria<DnsNicJoinVO> sc = activeDnsRecordZoneSearch.create();
|
||||
sc.setParameters(ApiConstants.NIC_DNS_RECORD, dnsRecordUrl);
|
||||
SearchCriteria<NicDnsJoinVO> sc = activeDnsRecordZoneSearch.create();
|
||||
sc.setParameters(ApiConstants.NIC_DNS_NAME, dnsRecordUrl);
|
||||
sc.setParameters(ApiConstants.DNS_ZONE_ID, dnsZoneId);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DnsNicJoinVO> listActiveByVmId(long vmId) {
|
||||
SearchCriteria<DnsNicJoinVO> sc = activeVmSearch.create();
|
||||
public List<NicDnsJoinVO> listActiveByVmId(long vmId) {
|
||||
SearchCriteria<NicDnsJoinVO> sc = activeVmSearch.create();
|
||||
sc.setParameters(ApiConstants.INSTANCE_ID, vmId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DnsNicJoinVO> listIncludingRemovedByVmId(long vmId) {
|
||||
SearchCriteria<DnsNicJoinVO> sc = activeVmSearch.create();
|
||||
public List<NicDnsJoinVO> listIncludingRemovedByVmId(long vmId) {
|
||||
SearchCriteria<NicDnsJoinVO> sc = activeVmSearch.create();
|
||||
sc.setParameters(ApiConstants.INSTANCE_ID, vmId);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
|
@ -34,8 +34,8 @@ import org.apache.cloudstack.api.InternalIdentity;
|
|||
import com.cloud.api.query.vo.BaseViewVO;
|
||||
|
||||
@Entity
|
||||
@Table(name = "dns_nic_view")
|
||||
public class DnsNicJoinVO extends BaseViewVO implements InternalIdentity, Identity {
|
||||
@Table(name = "nic_dns_view")
|
||||
public class NicDnsJoinVO extends BaseViewVO implements InternalIdentity, Identity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
|
|
@ -56,8 +56,8 @@ public class DnsNicJoinVO extends BaseViewVO implements InternalIdentity, Identi
|
|||
@Column(name = "ip6_address")
|
||||
private String ip6Address;
|
||||
|
||||
@Column(name = "nic_dns_url")
|
||||
private String nicDnsUrl;
|
||||
@Column(name = "nic_dns_name")
|
||||
private String nicDnsName;
|
||||
|
||||
@Column(name = "dns_zone_id")
|
||||
private long dnsZoneId;
|
||||
|
|
@ -68,7 +68,7 @@ public class DnsNicJoinVO extends BaseViewVO implements InternalIdentity, Identi
|
|||
@Column(name = "removed")
|
||||
private Date removed;
|
||||
|
||||
public DnsNicJoinVO() {
|
||||
public NicDnsJoinVO() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -97,8 +97,8 @@ public class DnsNicJoinVO extends BaseViewVO implements InternalIdentity, Identi
|
|||
return subDomain;
|
||||
}
|
||||
|
||||
public String getNicDnsUrl() {
|
||||
return nicDnsUrl;
|
||||
public String getNicDnsName() {
|
||||
return nicDnsName;
|
||||
}
|
||||
|
||||
public String getIp4Address() {
|
||||
|
|
@ -52,7 +52,7 @@ import org.apache.cloudstack.api.response.DnsZoneNetworkMapResponse;
|
|||
import org.apache.cloudstack.api.response.DnsZoneResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.dns.dao.DnsNicJoinDao;
|
||||
import org.apache.cloudstack.dns.dao.NicDnsJoinDao;
|
||||
import org.apache.cloudstack.dns.dao.DnsServerDao;
|
||||
import org.apache.cloudstack.dns.dao.DnsServerJoinDao;
|
||||
import org.apache.cloudstack.dns.dao.DnsZoneDao;
|
||||
|
|
@ -67,6 +67,7 @@ import org.apache.cloudstack.dns.vo.DnsServerVO;
|
|||
import org.apache.cloudstack.dns.vo.DnsZoneJoinVO;
|
||||
import org.apache.cloudstack.dns.vo.DnsZoneNetworkMapVO;
|
||||
import org.apache.cloudstack.dns.vo.DnsZoneVO;
|
||||
import org.apache.cloudstack.dns.vo.NicDnsJoinVO;
|
||||
import org.apache.cloudstack.framework.messagebus.MessageBus;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
|
@ -127,7 +128,7 @@ public class DnsProviderManagerImplTest {
|
|||
@Mock
|
||||
NicDetailsDao nicDetailsDao;
|
||||
@Mock
|
||||
DnsNicJoinDao dnsNicJoinDao;
|
||||
NicDnsJoinDao nicDnsJoinDao;
|
||||
@Mock
|
||||
MessageBus messageBus;
|
||||
@Mock
|
||||
|
|
@ -896,9 +897,9 @@ public class DnsProviderManagerImplTest {
|
|||
event.put(org.apache.cloudstack.api.ApiConstants.OLD_STATE, com.cloud.vm.VirtualMachine.State.Running);
|
||||
event.put(org.apache.cloudstack.api.ApiConstants.NEW_STATE, com.cloud.vm.VirtualMachine.State.Stopped);
|
||||
event.put(org.apache.cloudstack.api.ApiConstants.INSTANCE_ID, 15L);
|
||||
when(dnsNicJoinDao.listIncludingRemovedByVmId(15L)).thenReturn(null);
|
||||
when(nicDnsJoinDao.listIncludingRemovedByVmId(15L)).thenReturn(null);
|
||||
subscriber.onPublishMessage("sender", "subject", event);
|
||||
verify(dnsNicJoinDao, times(1)).listIncludingRemovedByVmId(15L);
|
||||
verify(nicDnsJoinDao, times(1)).listIncludingRemovedByVmId(15L);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -943,9 +944,9 @@ public class DnsProviderManagerImplTest {
|
|||
event.put(org.apache.cloudstack.api.ApiConstants.EVENT_TYPE, com.cloud.event.EventTypes.EVENT_NIC_DELETE);
|
||||
event.put(org.apache.cloudstack.api.ApiConstants.NIC_ID, 101L);
|
||||
event.put(org.apache.cloudstack.api.ApiConstants.INSTANCE_ID, 201L);
|
||||
when(dnsNicJoinDao.findByIdIncludingRemoved(101L)).thenReturn(null);
|
||||
when(nicDnsJoinDao.findByIdIncludingRemoved(101L)).thenReturn(null);
|
||||
subscriber.onPublishMessage("sender", "subject", event);
|
||||
verify(dnsNicJoinDao, times(1)).findByIdIncludingRemoved(101L);
|
||||
verify(nicDnsJoinDao, times(1)).findByIdIncludingRemoved(101L);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1035,7 +1036,7 @@ public class DnsProviderManagerImplTest {
|
|||
public void testSyncDnsRecordsStateNoIpv4AndNoIpv6DeletesBothRecords() throws Exception {
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
|
||||
when(dnsServerDao.findById(SERVER_ID)).thenReturn(serverVO);
|
||||
when(dnsNicJoinDao.listActiveByVmIdZoneAndDnsRecord(anyLong(), anyLong(), anyString()))
|
||||
when(nicDnsJoinDao.listActiveByVmIdZoneAndDnsRecord(anyLong(), anyLong(), anyString()))
|
||||
.thenReturn(Collections.emptyList());
|
||||
|
||||
manager.syncDnsRecordsState(1L, "myvm.example.com", ZONE_ID);
|
||||
|
|
@ -1049,10 +1050,10 @@ public class DnsProviderManagerImplTest {
|
|||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
|
||||
when(dnsServerDao.findById(SERVER_ID)).thenReturn(serverVO);
|
||||
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nic = mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO nic = mock(NicDnsJoinVO.class);
|
||||
when(nic.getIp4Address()).thenReturn("10.0.0.1");
|
||||
when(nic.getIp6Address()).thenReturn(null);
|
||||
when(dnsNicJoinDao.listActiveByVmIdZoneAndDnsRecord(anyLong(), anyLong(), anyString()))
|
||||
when(nicDnsJoinDao.listActiveByVmIdZoneAndDnsRecord(anyLong(), anyLong(), anyString()))
|
||||
.thenReturn(Collections.singletonList(nic));
|
||||
|
||||
manager.syncDnsRecordsState(1L, "myvm.example.com", ZONE_ID);
|
||||
|
|
@ -1067,7 +1068,7 @@ public class DnsProviderManagerImplTest {
|
|||
public void testHandleVmRunningStateFoundButNoActiveNics() throws DnsProviderException {
|
||||
com.cloud.vm.VMInstanceVO instanceMock = mock(com.cloud.vm.VMInstanceVO.class);
|
||||
when(vmInstanceDao.findById(30L)).thenReturn(instanceMock);
|
||||
when(dnsNicJoinDao.listActiveByVmId(30L)).thenReturn(Collections.emptyList());
|
||||
when(nicDnsJoinDao.listActiveByVmId(30L)).thenReturn(Collections.emptyList());
|
||||
|
||||
manager.handleVmRunningState(30L);
|
||||
|
||||
|
|
@ -1077,10 +1078,10 @@ public class DnsProviderManagerImplTest {
|
|||
|
||||
@Test
|
||||
public void testHandleVmStopAndDestroyNicWithNullDnsUrlIsSkipped() throws DnsProviderException {
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
when(nicMock.getNicDnsUrl()).thenReturn(null);
|
||||
when(dnsNicJoinDao.listIncludingRemovedByVmId(31L))
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getNicDnsName()).thenReturn(null);
|
||||
when(nicDnsJoinDao.listIncludingRemovedByVmId(31L))
|
||||
.thenReturn(Collections.singletonList(nicMock));
|
||||
|
||||
manager.handleVmStopAndDestroy(31L);
|
||||
|
|
@ -1090,16 +1091,16 @@ public class DnsProviderManagerImplTest {
|
|||
|
||||
@Test
|
||||
public void testHandleVmStopAndDestroyWithValidDnsUrlTriggersCleanup() throws Exception {
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
when(nicMock.getNicDnsUrl()).thenReturn("myvm.example.com");
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getNicDnsName()).thenReturn("myvm.example.com");
|
||||
when(nicMock.getDnsZoneId()).thenReturn(ZONE_ID);
|
||||
when(dnsNicJoinDao.listIncludingRemovedByVmId(32L))
|
||||
when(nicDnsJoinDao.listIncludingRemovedByVmId(32L))
|
||||
.thenReturn(Collections.singletonList(nicMock));
|
||||
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
|
||||
when(dnsServerDao.findById(SERVER_ID)).thenReturn(serverVO);
|
||||
when(dnsNicJoinDao.listActiveByVmIdZoneAndDnsRecord(eq(32L), eq(ZONE_ID), anyString()))
|
||||
when(nicDnsJoinDao.listActiveByVmIdZoneAndDnsRecord(eq(32L), eq(ZONE_ID), anyString()))
|
||||
.thenReturn(Collections.emptyList());
|
||||
|
||||
try (MockedStatic<com.cloud.utils.db.Transaction> txMock =
|
||||
|
|
@ -1119,7 +1120,7 @@ public class DnsProviderManagerImplTest {
|
|||
|
||||
manager.handleVmStopAndDestroy(32L);
|
||||
|
||||
verify(nicDetailsDao).removeDetail(nicMock.getId(), org.apache.cloudstack.api.ApiConstants.NIC_DNS_RECORD);
|
||||
verify(nicDetailsDao).removeDetail(nicMock.getId(), org.apache.cloudstack.api.ApiConstants.NIC_DNS_NAME);
|
||||
verify(dnsProviderMock, times(2)).deleteRecord(eq(serverVO), eq(zoneVO), any(DnsRecord.class));
|
||||
}
|
||||
}
|
||||
|
|
@ -1132,21 +1133,21 @@ public class DnsProviderManagerImplTest {
|
|||
|
||||
manager.handleNicPlug(33L, 500L);
|
||||
|
||||
verify(dnsNicJoinDao, never()).findById(anyLong());
|
||||
verify(nicDnsJoinDao, never()).findById(anyLong());
|
||||
verify(dnsProviderMock, never()).addRecord(any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleNicUnplugNicHasValidDnsUrlTriggersSyncCleanup() throws Exception {
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
when(nicMock.getNicDnsUrl()).thenReturn("myvm.example.com");
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getNicDnsName()).thenReturn("myvm.example.com");
|
||||
when(nicMock.getDnsZoneId()).thenReturn(ZONE_ID);
|
||||
when(dnsNicJoinDao.findByIdIncludingRemoved(600L)).thenReturn(nicMock);
|
||||
when(nicDnsJoinDao.findByIdIncludingRemoved(600L)).thenReturn(nicMock);
|
||||
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
|
||||
when(dnsServerDao.findById(SERVER_ID)).thenReturn(serverVO);
|
||||
when(dnsNicJoinDao.listActiveByVmIdZoneAndDnsRecord(eq(34L), eq(ZONE_ID), anyString()))
|
||||
when(nicDnsJoinDao.listActiveByVmIdZoneAndDnsRecord(eq(34L), eq(ZONE_ID), anyString()))
|
||||
.thenReturn(Collections.emptyList());
|
||||
|
||||
try (MockedStatic<com.cloud.utils.db.Transaction> txMock =
|
||||
|
|
@ -1166,7 +1167,7 @@ public class DnsProviderManagerImplTest {
|
|||
|
||||
manager.handleNicUnplug(34L, 600L);
|
||||
|
||||
verify(nicDetailsDao).removeDetail(600L, org.apache.cloudstack.api.ApiConstants.NIC_DNS_RECORD);
|
||||
verify(nicDetailsDao).removeDetail(600L, org.apache.cloudstack.api.ApiConstants.NIC_DNS_NAME);
|
||||
verify(dnsProviderMock, times(2)).deleteRecord(eq(serverVO), eq(zoneVO), any(DnsRecord.class));
|
||||
}
|
||||
}
|
||||
|
|
@ -1175,7 +1176,7 @@ public class DnsProviderManagerImplTest {
|
|||
public void testHandleVmHostnameChangedVmFoundButNoActiveNicsExitsEarly() throws DnsProviderException {
|
||||
com.cloud.vm.VMInstanceVO instanceMock = mock(com.cloud.vm.VMInstanceVO.class);
|
||||
when(vmInstanceDao.findById(35L)).thenReturn(instanceMock);
|
||||
when(dnsNicJoinDao.listActiveByVmId(35L)).thenReturn(Collections.emptyList());
|
||||
when(nicDnsJoinDao.listActiveByVmId(35L)).thenReturn(Collections.emptyList());
|
||||
|
||||
manager.handleVmHostnameChanged(35L, "newname");
|
||||
|
||||
|
|
@ -1185,10 +1186,10 @@ public class DnsProviderManagerImplTest {
|
|||
|
||||
@Test
|
||||
public void testIsDnsCollisionReturnsTrueForDifferentInstance() {
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO existing =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO existing =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(existing.getInstanceId()).thenReturn(99L);
|
||||
when(dnsNicJoinDao.findActiveByDnsRecordAndZone("vm.example.com", ZONE_ID)).thenReturn(existing);
|
||||
when(nicDnsJoinDao.findActiveByDnsRecordAndZone("vm.example.com", ZONE_ID)).thenReturn(existing);
|
||||
|
||||
try (MockedStatic<com.cloud.event.ActionEventUtils> aeMock =
|
||||
Mockito.mockStatic(com.cloud.event.ActionEventUtils.class)) {
|
||||
|
|
@ -1203,7 +1204,7 @@ public class DnsProviderManagerImplTest {
|
|||
|
||||
@Test
|
||||
public void testIsDnsCollisionReturnsFalseWhenNoExistingRecord() {
|
||||
when(dnsNicJoinDao.findActiveByDnsRecordAndZone("vm.example.com", ZONE_ID)).thenReturn(null);
|
||||
when(nicDnsJoinDao.findActiveByDnsRecordAndZone("vm.example.com", ZONE_ID)).thenReturn(null);
|
||||
boolean result = (boolean) ReflectionTestUtils.invokeMethod(
|
||||
manager, "isDnsCollision", "vm.example.com", ZONE_ID, 42L);
|
||||
assertFalse(result);
|
||||
|
|
@ -1211,10 +1212,10 @@ public class DnsProviderManagerImplTest {
|
|||
|
||||
@Test
|
||||
public void testIsDnsCollisionReturnsFalseWhenSameInstance() {
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO existing =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO existing =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(existing.getInstanceId()).thenReturn(42L);
|
||||
when(dnsNicJoinDao.findActiveByDnsRecordAndZone("vm.example.com", ZONE_ID)).thenReturn(existing);
|
||||
when(nicDnsJoinDao.findActiveByDnsRecordAndZone("vm.example.com", ZONE_ID)).thenReturn(existing);
|
||||
boolean result = (boolean) ReflectionTestUtils.invokeMethod(
|
||||
manager, "isDnsCollision", "vm.example.com", ZONE_ID, 42L);
|
||||
assertFalse(result);
|
||||
|
|
@ -1226,15 +1227,15 @@ public class DnsProviderManagerImplTest {
|
|||
when(instanceMock.getState()).thenReturn(com.cloud.vm.VirtualMachine.State.Running);
|
||||
when(vmInstanceDao.findById(40L)).thenReturn(instanceMock);
|
||||
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getDnsZoneId()).thenReturn(ZONE_ID);
|
||||
when(dnsNicJoinDao.findById(700L)).thenReturn(nicMock);
|
||||
when(nicDnsJoinDao.findById(700L)).thenReturn(nicMock);
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(null); // zone missing → exit after NIC lookup
|
||||
|
||||
manager.handleNicPlug(40L, 700L);
|
||||
|
||||
verify(dnsNicJoinDao, times(1)).findById(700L);
|
||||
verify(nicDnsJoinDao, times(1)).findById(700L);
|
||||
verify(dnsProviderMock, never()).addRecord(any(), any(), any());
|
||||
}
|
||||
|
||||
|
|
@ -1244,10 +1245,10 @@ public class DnsProviderManagerImplTest {
|
|||
com.cloud.vm.VMInstanceVO instanceMock = mock(com.cloud.vm.VMInstanceVO.class);
|
||||
when(vmInstanceDao.findById(41L)).thenReturn(instanceMock);
|
||||
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getDnsZoneId()).thenReturn(ZONE_ID);
|
||||
when(dnsNicJoinDao.listActiveByVmId(41L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(nicDnsJoinDao.listActiveByVmId(41L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(null); // zone null → NIC skipped → empty map
|
||||
|
||||
manager.handleVmHostnameChanged(41L, "newname");
|
||||
|
|
@ -1261,10 +1262,10 @@ public class DnsProviderManagerImplTest {
|
|||
com.cloud.vm.VMInstanceVO instanceMock = mock(com.cloud.vm.VMInstanceVO.class);
|
||||
when(vmInstanceDao.findById(42L)).thenReturn(instanceMock);
|
||||
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getDnsZoneId()).thenReturn(ZONE_ID);
|
||||
when(dnsNicJoinDao.listActiveByVmId(42L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(nicDnsJoinDao.listActiveByVmId(42L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(null); // zone null → NIC skipped → empty outer map
|
||||
|
||||
manager.handleVmRunningState(42L);
|
||||
|
|
@ -1301,7 +1302,7 @@ public class DnsProviderManagerImplTest {
|
|||
public void testHandleVmRunningStateInstanceNullExitsEarly() throws DnsProviderException {
|
||||
when(vmInstanceDao.findById(50L)).thenReturn(null);
|
||||
manager.handleVmRunningState(50L);
|
||||
verify(dnsNicJoinDao, never()).listActiveByVmId(anyLong());
|
||||
verify(nicDnsJoinDao, never()).listActiveByVmId(anyLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1310,18 +1311,18 @@ public class DnsProviderManagerImplTest {
|
|||
when(instanceMock.getHostName()).thenReturn("myvm");
|
||||
when(vmInstanceDao.findById(51L)).thenReturn(instanceMock);
|
||||
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getDnsZoneId()).thenReturn(ZONE_ID);
|
||||
when(nicMock.getSubDomain()).thenReturn(null);
|
||||
when(dnsNicJoinDao.listActiveByVmId(51L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(nicDnsJoinDao.listActiveByVmId(51L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
|
||||
when(dnsServerDao.findById(SERVER_ID)).thenReturn(serverVO);
|
||||
|
||||
// no collision
|
||||
when(dnsNicJoinDao.findActiveByDnsRecordAndZone(anyString(), eq(ZONE_ID))).thenReturn(null);
|
||||
when(nicDnsJoinDao.findActiveByDnsRecordAndZone(anyString(), eq(ZONE_ID))).thenReturn(null);
|
||||
// sync: no IPs → delete both
|
||||
when(dnsNicJoinDao.listActiveByVmIdZoneAndDnsRecord(eq(51L), eq(ZONE_ID), anyString()))
|
||||
when(nicDnsJoinDao.listActiveByVmIdZoneAndDnsRecord(eq(51L), eq(ZONE_ID), anyString()))
|
||||
.thenReturn(Collections.emptyList());
|
||||
|
||||
try (MockedStatic<com.cloud.utils.db.Transaction> txMock =
|
||||
|
|
@ -1339,7 +1340,7 @@ public class DnsProviderManagerImplTest {
|
|||
manager.handleVmRunningState(51L);
|
||||
|
||||
verify(nicDetailsDao).addDetail(anyLong(),
|
||||
eq(org.apache.cloudstack.api.ApiConstants.NIC_DNS_RECORD), anyString(), eq(true));
|
||||
eq(org.apache.cloudstack.api.ApiConstants.NIC_DNS_NAME), anyString(), eq(true));
|
||||
verify(dnsProviderMock, times(2)).deleteRecord(eq(serverVO), eq(zoneVO), any(DnsRecord.class));
|
||||
}
|
||||
}
|
||||
|
|
@ -1350,18 +1351,18 @@ public class DnsProviderManagerImplTest {
|
|||
when(instanceMock.getHostName()).thenReturn("myvm");
|
||||
when(vmInstanceDao.findById(52L)).thenReturn(instanceMock);
|
||||
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getDnsZoneId()).thenReturn(ZONE_ID);
|
||||
when(nicMock.getSubDomain()).thenReturn(null);
|
||||
when(dnsNicJoinDao.listActiveByVmId(52L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(nicDnsJoinDao.listActiveByVmId(52L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
|
||||
|
||||
// collision: different instance owns the record
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO colliding =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO colliding =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(colliding.getInstanceId()).thenReturn(999L);
|
||||
when(dnsNicJoinDao.findActiveByDnsRecordAndZone(anyString(), eq(ZONE_ID))).thenReturn(colliding);
|
||||
when(nicDnsJoinDao.findActiveByDnsRecordAndZone(anyString(), eq(ZONE_ID))).thenReturn(colliding);
|
||||
|
||||
try (MockedStatic<com.cloud.utils.db.Transaction> txMock =
|
||||
Mockito.mockStatic(com.cloud.utils.db.Transaction.class);
|
||||
|
|
@ -1393,7 +1394,7 @@ public class DnsProviderManagerImplTest {
|
|||
public void testHandleVmHostnameChangedInstanceNullExitsEarly() throws DnsProviderException {
|
||||
when(vmInstanceDao.findById(60L)).thenReturn(null);
|
||||
manager.handleVmHostnameChanged(60L, "newname");
|
||||
verify(dnsNicJoinDao, never()).listActiveByVmId(anyLong());
|
||||
verify(nicDnsJoinDao, never()).listActiveByVmId(anyLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1401,13 +1402,13 @@ public class DnsProviderManagerImplTest {
|
|||
com.cloud.vm.VMInstanceVO instanceMock = mock(com.cloud.vm.VMInstanceVO.class);
|
||||
when(vmInstanceDao.findById(61L)).thenReturn(instanceMock);
|
||||
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getDnsZoneId()).thenReturn(ZONE_ID);
|
||||
when(nicMock.getSubDomain()).thenReturn(null);
|
||||
// old URL already equals the new computed URL → continue (skip)
|
||||
when(nicMock.getNicDnsUrl()).thenReturn("newname.example.com");
|
||||
when(dnsNicJoinDao.listActiveByVmId(61L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(nicMock.getNicDnsName()).thenReturn("newname.example.com");
|
||||
when(nicDnsJoinDao.listActiveByVmId(61L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
|
||||
|
||||
manager.handleVmHostnameChanged(61L, "newname");
|
||||
|
|
@ -1422,19 +1423,19 @@ public class DnsProviderManagerImplTest {
|
|||
com.cloud.vm.VMInstanceVO instanceMock = mock(com.cloud.vm.VMInstanceVO.class);
|
||||
when(vmInstanceDao.findById(62L)).thenReturn(instanceMock);
|
||||
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getDnsZoneId()).thenReturn(ZONE_ID);
|
||||
when(nicMock.getSubDomain()).thenReturn(null);
|
||||
when(nicMock.getNicDnsUrl()).thenReturn("oldvm.example.com"); // differs from new FQDN
|
||||
when(dnsNicJoinDao.listActiveByVmId(62L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(nicMock.getNicDnsName()).thenReturn("oldvm.example.com"); // differs from new FQDN
|
||||
when(nicDnsJoinDao.listActiveByVmId(62L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
|
||||
when(dnsServerDao.findById(SERVER_ID)).thenReturn(serverVO);
|
||||
|
||||
// no collision for new record
|
||||
when(dnsNicJoinDao.findActiveByDnsRecordAndZone(anyString(), eq(ZONE_ID))).thenReturn(null);
|
||||
when(nicDnsJoinDao.findActiveByDnsRecordAndZone(anyString(), eq(ZONE_ID))).thenReturn(null);
|
||||
// sync always returns empty → deleteRecord called
|
||||
when(dnsNicJoinDao.listActiveByVmIdZoneAndDnsRecord(eq(62L), eq(ZONE_ID), anyString()))
|
||||
when(nicDnsJoinDao.listActiveByVmIdZoneAndDnsRecord(eq(62L), eq(ZONE_ID), anyString()))
|
||||
.thenReturn(Collections.emptyList());
|
||||
|
||||
try (MockedStatic<com.cloud.utils.db.Transaction> txMock =
|
||||
|
|
@ -1453,10 +1454,10 @@ public class DnsProviderManagerImplTest {
|
|||
|
||||
// Tx1: old URL removed from nic_details
|
||||
verify(nicDetailsDao).removeDetail(anyLong(),
|
||||
eq(org.apache.cloudstack.api.ApiConstants.NIC_DNS_RECORD));
|
||||
eq(org.apache.cloudstack.api.ApiConstants.NIC_DNS_NAME));
|
||||
// Tx2: new URL written to nic_details
|
||||
verify(nicDetailsDao).addDetail(anyLong(),
|
||||
eq(org.apache.cloudstack.api.ApiConstants.NIC_DNS_RECORD), anyString(), eq(true));
|
||||
eq(org.apache.cloudstack.api.ApiConstants.NIC_DNS_NAME), anyString(), eq(true));
|
||||
// deleteRecord called for both old-sync (A+AAAA) and new-sync (A+AAAA) = 4 total
|
||||
verify(dnsProviderMock, times(4)).deleteRecord(eq(serverVO), eq(zoneVO), any(DnsRecord.class));
|
||||
}
|
||||
|
|
@ -1467,21 +1468,21 @@ public class DnsProviderManagerImplTest {
|
|||
com.cloud.vm.VMInstanceVO instanceMock = mock(com.cloud.vm.VMInstanceVO.class);
|
||||
when(vmInstanceDao.findById(63L)).thenReturn(instanceMock);
|
||||
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO nicMock =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO nicMock =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(nicMock.getDnsZoneId()).thenReturn(ZONE_ID);
|
||||
when(nicMock.getSubDomain()).thenReturn(null);
|
||||
when(nicMock.getNicDnsUrl()).thenReturn("oldvm.example.com");
|
||||
when(dnsNicJoinDao.listActiveByVmId(63L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(nicMock.getNicDnsName()).thenReturn("oldvm.example.com");
|
||||
when(nicDnsJoinDao.listActiveByVmId(63L)).thenReturn(Collections.singletonList(nicMock));
|
||||
when(dnsZoneDao.findById(ZONE_ID)).thenReturn(zoneVO);
|
||||
when(dnsServerDao.findById(SERVER_ID)).thenReturn(serverVO);
|
||||
|
||||
// collision on the new FQDN
|
||||
org.apache.cloudstack.dns.vo.DnsNicJoinVO colliding =
|
||||
mock(org.apache.cloudstack.dns.vo.DnsNicJoinVO.class);
|
||||
NicDnsJoinVO colliding =
|
||||
mock(NicDnsJoinVO.class);
|
||||
when(colliding.getInstanceId()).thenReturn(999L);
|
||||
when(dnsNicJoinDao.findActiveByDnsRecordAndZone(anyString(), eq(ZONE_ID))).thenReturn(colliding);
|
||||
when(dnsNicJoinDao.listActiveByVmIdZoneAndDnsRecord(eq(63L), eq(ZONE_ID), anyString()))
|
||||
when(nicDnsJoinDao.findActiveByDnsRecordAndZone(anyString(), eq(ZONE_ID))).thenReturn(colliding);
|
||||
when(nicDnsJoinDao.listActiveByVmIdZoneAndDnsRecord(eq(63L), eq(ZONE_ID), anyString()))
|
||||
.thenReturn(Collections.emptyList());
|
||||
|
||||
try (MockedStatic<com.cloud.utils.db.Transaction> txMock =
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||
from marvin.cloudstackAPI import *
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
import subprocess
|
||||
import time
|
||||
|
|
@ -85,7 +86,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
cls.pdns_url = f"http://{cls.marvin_vm_ip}"
|
||||
cls.logger.info(f"PDNS endpoint: {cls.pdns_url}")
|
||||
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_01_list_dns_providers(self):
|
||||
"""
|
||||
List DNS providers, expect PowerDNS provider to be present
|
||||
|
|
@ -96,6 +97,8 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
self.assertIsNotNone(response, "Failed to list DNS providers")
|
||||
self.logger.info(f"DNS Providers found: {[provider.name for provider in response]}")
|
||||
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_02_add_dns_server(self):
|
||||
"""
|
||||
Register PDNS as DNS provider in CloudStack
|
||||
|
|
@ -109,6 +112,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
self.assertIsNotNone(response.id, "DNS server ID should not be None")
|
||||
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_03_list_dns_servers(self):
|
||||
"""
|
||||
List DNS servers and verify the newly added PDNS provider is present
|
||||
|
|
@ -122,6 +126,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
self.assertEqual(response[0].id, self.dns_server_id, "DNS server ID mismatch")
|
||||
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_04_create_dns_zone(self):
|
||||
"""
|
||||
Create a DNS zone in the added PDNS provider
|
||||
|
|
@ -134,6 +139,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
self.logger.info(f"DNS Zone created: {response.id}")
|
||||
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_05_list_dns_zones(self):
|
||||
"""
|
||||
List DNS zones and verify the newly created zone is present
|
||||
|
|
@ -147,6 +153,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
self.assertEqual(response[0].id, self.dns_zone_id, "DNS zone ID mismatch")
|
||||
self.assertEqual(response[0].name, "example.com", "DNS zone name mismatch")
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_06_create_a_dns_record(self):
|
||||
"""
|
||||
Create a DNS record in the previously created zone
|
||||
|
|
@ -162,6 +169,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
self.assertEqual(response.name, "www.example.com", "DNS record name mismatch")
|
||||
self._assert_dns("www.example.com", "A", expected="10.1.1.10")
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_07_create_aaaa_dns_records(self):
|
||||
"""
|
||||
Create AAAA DNS records in the previously created zone
|
||||
|
|
@ -177,7 +185,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
self.assertTrue(response.name is not None, "DNS record name should not be None")
|
||||
self._assert_dns("www.example.com", "AAAA", expected="2001:db8::10")
|
||||
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_08_create_mx_dns_record(self):
|
||||
"""
|
||||
Create an MX DNS record in the previously created zone
|
||||
|
|
@ -194,6 +202,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
self._assert_dns("example.com", "MX", contains=["10", "mail.example.com"])
|
||||
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_09_list_dns_records(self):
|
||||
"""
|
||||
List DNS records in the zone and verify the created records are present
|
||||
|
|
@ -207,7 +216,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
record_types = set(record.type for record in response)
|
||||
self.assertSetEqual(record_types, {"NS", "A", "AAAA", "MX"}, "DNS record types mismatch")
|
||||
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_10_delete_dns_record(self):
|
||||
"""
|
||||
Delete one of the DNS records and verify it's removed
|
||||
|
|
@ -229,6 +238,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
remaining_record_names = set(record.name for record in response_after_deletion)
|
||||
self.assertNotIn(delete_record_cmd.name, remaining_record_names, "Deleted DNS record still present")
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_11_delete_dns_zone(self):
|
||||
"""
|
||||
Delete the DNS zone and verify it's removed
|
||||
|
|
@ -249,6 +259,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
except Exception as e:
|
||||
self.logger.info(f"Expected exception after delete: {str(e)}")
|
||||
|
||||
@attr(tags=["advanced"], required_hardware="true")
|
||||
def test_12_delete_dns_server(self):
|
||||
"""
|
||||
Delete the PDNS DNS server and verify it's removed
|
||||
|
|
@ -324,7 +335,7 @@ class TestCloudStackDNSFramework(cloudstackTestCase):
|
|||
|
||||
def _dig(self, name, rtype):
|
||||
dns_ip = self.__class__.marvin_vm_ip
|
||||
dns_port = 5353
|
||||
dns_port = 53
|
||||
|
||||
cmd = [
|
||||
"dig",
|
||||
|
|
|
|||
|
|
@ -959,13 +959,13 @@
|
|||
"label.dns.delete.zone": "Delete DNS Zone",
|
||||
"label.dns.dnsapikey": "DNS API key",
|
||||
"label.dns.externalserverid": "DNS server ID",
|
||||
"label.dns.name": "DNS Name",
|
||||
"label.dns.publicdomainsuffix": "Public domain suffix",
|
||||
"label.dns.records": "DNS Records",
|
||||
"label.dns.record.name.tooltip": "The hostname or subdomain for this record (e.g. www)",
|
||||
"label.dns.record.type.tooltip": "The DNS record type",
|
||||
"label.dns.record.contents.tooltip": "The content values for this DNS record (type and press Enter to add)",
|
||||
"label.dns.record.ttl.tooltip": "Time to live in seconds",
|
||||
"label.dns.record.url": "Instance URL",
|
||||
"label.dns.server": "DNS Server",
|
||||
"label.dnsserverid": "DNS Server ID",
|
||||
"label.dnsservername": "DNS Server name",
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@
|
|||
{{ record.isolationuri }}
|
||||
</a-descriptions-item>
|
||||
</template>
|
||||
<a-descriptions-item :label="$t('label.dns.record.url')" v-if="record.dnsrecordurl">
|
||||
{{ record.dnsrecordurl }}
|
||||
<a-descriptions-item :label="$t('label.dns.name')" v-if="record.nicdnsname">
|
||||
{{ record.nicdnsname }}
|
||||
</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Reference in New Issue