From 6ca9d5ace8fe2d8dc65ce747717e8631528b29f1 Mon Sep 17 00:00:00 2001 From: Manoj Kumar Date: Thu, 26 Feb 2026 13:05:08 +0530 Subject: [PATCH] add views for dns_server and dns_zone --- .../api/response/DnsServerResponse.java | 29 +++- .../api/response/DnsZoneResponse.java | 45 ++++- ...spring-engine-schema-core-daos-context.xml | 6 + .../db/views/cloud.dns_server_view.sql | 44 +++++ .../META-INF/db/views/cloud.dns_zone_view.sql | 45 +++++ .../dns/DnsProviderManagerImpl.java | 102 ++++++++---- .../cloudstack/dns/dao/DnsServerJoinDao.java | 26 +++ .../dns/dao/DnsServerJoinDaoImpl.java | 25 +++ .../cloudstack/dns/dao/DnsZoneJoinDao.java | 26 +++ .../dns/dao/DnsZoneJoinDaoImpl.java | 25 +++ .../cloudstack/dns/vo/DnsServerJoinVO.java | 154 ++++++++++++++++++ .../cloudstack/dns/vo/DnsZoneJoinVO.java | 130 +++++++++++++++ .../spring-server-core-managers-context.xml | 4 - 13 files changed, 618 insertions(+), 43 deletions(-) create mode 100644 engine/schema/src/main/resources/META-INF/db/views/cloud.dns_server_view.sql create mode 100644 engine/schema/src/main/resources/META-INF/db/views/cloud.dns_zone_view.sql create mode 100644 server/src/main/java/org/apache/cloudstack/dns/dao/DnsServerJoinDao.java create mode 100644 server/src/main/java/org/apache/cloudstack/dns/dao/DnsServerJoinDaoImpl.java create mode 100644 server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneJoinDao.java create mode 100644 server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneJoinDaoImpl.java create mode 100644 server/src/main/java/org/apache/cloudstack/dns/vo/DnsServerJoinVO.java create mode 100644 server/src/main/java/org/apache/cloudstack/dns/vo/DnsZoneJoinVO.java diff --git a/api/src/main/java/org/apache/cloudstack/api/response/DnsServerResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/DnsServerResponse.java index f96e05820f4..d67be31504d 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/DnsServerResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/DnsServerResponse.java @@ -22,7 +22,6 @@ import java.util.List; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; -import org.apache.cloudstack.dns.DnsProviderType; import org.apache.cloudstack.dns.DnsServer; import com.cloud.serializer.Param; @@ -49,7 +48,7 @@ public class DnsServerResponse extends BaseResponse { @SerializedName(ApiConstants.PROVIDER) @Param(description = "The provider type of the DNS server") - private DnsProviderType provider; + private String provider; @SerializedName(ApiConstants.IS_PUBLIC) @Param(description = "Is the DNS server publicly available") @@ -63,6 +62,18 @@ public class DnsServerResponse extends BaseResponse { @Param(description = "Name servers entries associated to DNS server") private List nameServers; + @SerializedName(ApiConstants.ACCOUNT) + @Param(description = "the account associated with the DNS server") + private String accountName; + + @SerializedName(ApiConstants.DOMAIN_ID) + @Param(description = "the ID of the domain associated with the DNS server") + private String domainId; + + @SerializedName(ApiConstants.DOMAIN) + @Param(description = "the name of the domain associated with the DNS server") + private String domainName; + public DnsServerResponse() { super(); @@ -80,7 +91,7 @@ public class DnsServerResponse extends BaseResponse { this.url = url; } - public void setProvider(DnsProviderType provider) { + public void setProvider(String provider) { this.provider = provider; } @@ -99,4 +110,16 @@ public class DnsServerResponse extends BaseResponse { public void setNameServers(List nameServers) { this.nameServers = nameServers; } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + public void setDomainName(String domainName) { + this.domainName = domainName; + } } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/DnsZoneResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/DnsZoneResponse.java index 4bad0b513ea..e179d2fd4b1 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/DnsZoneResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/DnsZoneResponse.java @@ -37,7 +37,27 @@ public class DnsZoneResponse extends BaseResponse { @SerializedName("dnsserverid") @Param(description = "ID of the DNS server this zone belongs to") - private Long dnsServerId; + private String dnsServerId; + + @SerializedName("dnsservername") + @Param(description = "the name of the DNS server hosting this zone") + private String dnsServerName; + + @SerializedName("dnsserveraccount") + @Param(description = "the account name of the DNS server owner") + private String dnsServerAccountName; + + @SerializedName(ApiConstants.ACCOUNT) + @Param(description = "the account associated with the DNS zone") + private String accountName; + + @SerializedName(ApiConstants.DOMAIN) + @Param(description = "the name of the domain associated with the DNS zone") + private String domainName; + + @SerializedName(ApiConstants.DOMAIN_ID) + @Param(description = "the ID of the domain associated with the DNS server") + private String domainId; @SerializedName(ApiConstants.NETWORK_ID) @Param(description = "ID of the network this zone is associated with") @@ -68,7 +88,7 @@ public class DnsZoneResponse extends BaseResponse { this.name = name; } - public void setDnsServerId(Long dnsServerId) { + public void setDnsServerId(String dnsServerId) { this.dnsServerId = dnsServerId; } @@ -95,4 +115,25 @@ public class DnsZoneResponse extends BaseResponse { public void setDescription(String description) { this.description = description; } + + public void setDnsServerName(String dnsServerName) { + this.dnsServerName = dnsServerName; + } + + public void setDnsServerAccountName(String dnsServerAccountName) { + this.dnsServerAccountName = dnsServerAccountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public void setDomainName(String domainName) { + this.domainName = domainName; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + } diff --git a/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml b/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml index 0656d5e3c44..191507e0456 100644 --- a/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml +++ b/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml @@ -310,4 +310,10 @@ + + + + + + diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.dns_server_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.dns_server_view.sql new file mode 100644 index 00000000000..a1bc1a1141a --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.dns_server_view.sql @@ -0,0 +1,44 @@ +-- 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. + +-- VIEW `cloud`.`dns_server_view`; + +DROP VIEW IF EXISTS `cloud`.`dns_server_view`; +CREATE VIEW `cloud`.`dns_server_view` AS + SELECT + dns.id, + dns.uuid, + dns.name, + dns.provider_type, + dns.url, + dns.port, + dns.name_servers, + dns.is_public, + dns.public_domain_suffix, + dns.state, + dns.created, + dns.removed, + account.account_name account_name, + domain.name domain_name, + domain.uuid domain_uuid, + domain.path domain_path + FROM + `cloud`.`dns_server` dns + INNER JOIN + `cloud`.`account` account ON dns.account_id = account.id + INNER JOIN + `cloud`.`domain` domain ON dns.domain_id = domain.id; diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.dns_zone_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.dns_zone_view.sql new file mode 100644 index 00000000000..a41e003ae4f --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.dns_zone_view.sql @@ -0,0 +1,45 @@ +-- 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. + +-- VIEW `cloud`.`dns_zone_view`; + +DROP VIEW IF EXISTS `cloud`.`dns_zone_view`; +CREATE VIEW `cloud`.`dns_zone_view` AS + SELECT + zone.id, + zone.uuid, + zone.name, + zone.dns_server_id, + zone.state, + zone.description, + server.uuid dns_server_uuid, + server.name dns_server_name, + server_account.account_name dns_server_account_name, + account.account_name account_name, + domain.name domain_name, + domain.uuid domain_uuid, + domain.path domain_path + FROM + `cloud`.`dns_zone` zone + INNER JOIN + `cloud`.`dns_server` server ON zone.dns_server_id = server.id + INNER JOIN + `cloud`.`account` server_account ON server.account_id = server_account.id + INNER JOIN + `cloud`.`account` account ON zone.account_id = account.id + INNER JOIN + `cloud`.`domain` domain ON zone.domain_id = domain.id; 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 5e70ec3c1f7..0da957cac76 100644 --- a/server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java @@ -47,9 +47,14 @@ 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.DnsServerDao; +import org.apache.cloudstack.dns.dao.DnsServerJoinDao; import org.apache.cloudstack.dns.dao.DnsZoneDao; +import org.apache.cloudstack.dns.dao.DnsZoneJoinDao; import org.apache.cloudstack.dns.dao.DnsZoneNetworkMapDao; +import org.apache.cloudstack.dns.exception.DnsNotFoundException; +import org.apache.cloudstack.dns.vo.DnsServerJoinVO; 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.springframework.stereotype.Component; @@ -95,6 +100,10 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa NicDao nicDao; @Inject DomainDao domainDao; + @Inject + DnsZoneJoinDao dnsZoneJoinDao; + @Inject + DnsServerJoinDao dnsServerJoinDao; private DnsProvider getProviderByType(DnsProviderType type) { if (type == null) { @@ -149,9 +158,14 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa @Override public ListResponse listDnsServers(ListDnsServersCmd cmd) { Pair, Integer> result = searchForDnsServerInternal(cmd); + List serverIds = new ArrayList<>(); + for (DnsServer server : result.first()) { + serverIds.add(server.getUuid()); + } + List joinResult = dnsServerJoinDao.listByUuids(serverIds); ListResponse response = new ListResponse<>(); List serverResponses = new ArrayList<>(); - for (DnsServerVO server : result.first()) { + for (DnsServerJoinVO server : joinResult) { serverResponses.add(createDnsServerResponse(server)); } response.setResponses(serverResponses, result.second()); @@ -186,9 +200,7 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa SearchCriteria sc = sb.create(); accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccountIds, listProjectResourcesCriteria); sc.setParameters(ApiConstants.STATE, DnsServer.State.Enabled); - if (cmd.getProviderType() != null) { - sc.setParameters(ApiConstants.PROVIDER_TYPE, cmd.getProviderType()); - } + sc.setParameters(ApiConstants.PROVIDER_TYPE, cmd.getProviderType()); Pair, Integer> ownServersPair = dnsServerDao.searchAndCount(sc, searchFilter); List dnsServers = new ArrayList<>(ownServersPair.first()); @@ -206,9 +218,7 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa publicSc.setParameters(ApiConstants.IS_PUBLIC, 1); publicSc.setParameters(ApiConstants.DOMAIN_IDS, parentDomainIds.toArray()); publicSc.setParameters(ApiConstants.STATE, DnsServer.State.Enabled); - if (cmd.getProviderType() != null) { - publicSc.setParameters(ApiConstants.PROVIDER_TYPE, cmd.getProviderType()); - } + publicSc.setParameters(ApiConstants.PROVIDER_TYPE, cmd.getProviderType()); List publicServers = dnsServerDao.search(publicSc, null); List ownServerIds = dnsServers.stream().map(DnsServerVO::getId).collect(Collectors.toList()); for (DnsServerVO publicServer : publicServers) { @@ -305,21 +315,6 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa return dnsServerDao.remove(dnsServerId); } - @Override - public DnsServerResponse createDnsServerResponse(DnsServer server) { - DnsServerResponse response = new DnsServerResponse(); - response.setId(server.getUuid()); - response.setName(server.getName()); - response.setUrl(server.getUrl()); - response.setPort(server.getPort()); - response.setProvider(server.getProviderType()); - response.setPublic(server.isPublicServer()); - response.setNameServers(server.getNameServers()); - response.setPublicDomainSuffix(server.getPublicDomainSuffix()); - response.setObjectName("dnsserver"); - return response; - } - @Override public boolean deleteDnsZone(Long zoneId) { DnsZoneVO zone = dnsZoneDao.findById(zoneId); @@ -376,10 +371,14 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa @Override public ListResponse listDnsZones(ListDnsZonesCmd cmd) { Pair, Integer> result = searchForDnsZonesInternal(cmd); - - List zoneResponses = new ArrayList<>(); + List zoneIds = new ArrayList<>(); for (DnsZoneVO zone : result.first()) { - zoneResponses.add(createDnsZoneResponse(zone)); + zoneIds.add(zone.getUuid()); + } + List zoneJoinVos = dnsZoneJoinDao.listByUuids(zoneIds); + List zoneResponses = new ArrayList<>(); + for (DnsZoneJoinVO zoneJoin: zoneJoinVos) { + zoneResponses.add(createDnsZoneResponse(zoneJoin)); } ListResponse response = new ListResponse<>(); response.setResponses(zoneResponses, result.second()); @@ -484,6 +483,9 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa ListResponse listResponse = new ListResponse<>(); listResponse.setResponses(responses, responses.size()); return listResponse; + } catch (DnsNotFoundException ex) { + logger.error("DNS zone is not found", ex); + throw new CloudRuntimeException("DNS zone is not found, please register it first"); } catch (Exception ex) { logger.error("Failed to list DNS records from provider", ex); throw new CloudRuntimeException("Failed to fetch DNS records"); @@ -551,16 +553,48 @@ public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderMa return dnsZone; } + + public DnsServerResponse createDnsServerResponse(DnsServer dnsServer) { + DnsServerJoinVO serverJoin = dnsServerJoinDao.findById(dnsServer.getId()); + return createDnsServerResponse(serverJoin); + } + + DnsServerResponse createDnsServerResponse(DnsServerJoinVO server) { + DnsServerResponse response = new DnsServerResponse(); + response.setId(server.getUuid()); + response.setName(server.getName()); + response.setUrl(server.getUrl()); + response.setPort(server.getPort()); + response.setProvider(server.getProviderType()); + response.setPublic(server.isPublicServer()); + response.setNameServers(server.getNameServers()); + response.setPublicDomainSuffix(server.getPublicDomainSuffix()); + response.setAccountName(server.getAccountName()); + response.setDomainId(server.getDomainUuid()); // Note: APIs always return UUIDs, not internal DB IDs! + response.setDomainName(server.getDomainName()); + response.setObjectName("dnsserver"); + return response; + } + @Override - public DnsZoneResponse createDnsZoneResponse(DnsZone zone) { - DnsZoneResponse res = new DnsZoneResponse(); - res.setName(zone.getName()); - res.setDnsServerId(zone.getDnsServerId()); - res.setType(zone.getType()); - res.setState(zone.getState()); - res.setId(zone.getUuid()); - res.setDescription(zone.getDescription()); - return res; + public DnsZoneResponse createDnsZoneResponse(DnsZone dnsZone) { + DnsZoneJoinVO zoneJoinVO = dnsZoneJoinDao.findById(dnsZone.getId()); + return createDnsZoneResponse(zoneJoinVO); + } + + DnsZoneResponse createDnsZoneResponse(DnsZoneJoinVO zone) { + DnsZoneResponse response = new DnsZoneResponse(); + response.setId(zone.getUuid()); + response.setName(zone.getName()); + response.setDnsServerId(zone.getDnsServerUuid()); + response.setAccountName(zone.getAccountName()); + response.setDomainId(zone.getDomainUuid()); + response.setDomainName(zone.getDomainName()); + response.setDnsServerName(zone.getDnsServerName()); + response.setDnsServerAccountName(zone.getDnsServerAccountName()); + response.setState(zone.getState()); + response.setDescription(zone.getDescription()); + return response; } @Override diff --git a/server/src/main/java/org/apache/cloudstack/dns/dao/DnsServerJoinDao.java b/server/src/main/java/org/apache/cloudstack/dns/dao/DnsServerJoinDao.java new file mode 100644 index 00000000000..b1932d6709c --- /dev/null +++ b/server/src/main/java/org/apache/cloudstack/dns/dao/DnsServerJoinDao.java @@ -0,0 +1,26 @@ +// 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. + +package org.apache.cloudstack.dns.dao; + +import org.apache.cloudstack.dns.vo.DnsServerJoinVO; + +import com.cloud.utils.db.GenericDao; + +public interface DnsServerJoinDao extends GenericDao { + +} diff --git a/server/src/main/java/org/apache/cloudstack/dns/dao/DnsServerJoinDaoImpl.java b/server/src/main/java/org/apache/cloudstack/dns/dao/DnsServerJoinDaoImpl.java new file mode 100644 index 00000000000..28a2e9d6638 --- /dev/null +++ b/server/src/main/java/org/apache/cloudstack/dns/dao/DnsServerJoinDaoImpl.java @@ -0,0 +1,25 @@ +// 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. + +package org.apache.cloudstack.dns.dao; + +import org.apache.cloudstack.dns.vo.DnsServerJoinVO; + +import com.cloud.utils.db.GenericDaoBase; + +public class DnsServerJoinDaoImpl extends GenericDaoBase implements DnsServerJoinDao { +} diff --git a/server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneJoinDao.java b/server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneJoinDao.java new file mode 100644 index 00000000000..ee0bcc5bcae --- /dev/null +++ b/server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneJoinDao.java @@ -0,0 +1,26 @@ +// 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. + +package org.apache.cloudstack.dns.dao; + +import org.apache.cloudstack.dns.vo.DnsZoneJoinVO; + +import com.cloud.utils.db.GenericDao; + +public interface DnsZoneJoinDao extends GenericDao { + +} diff --git a/server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneJoinDaoImpl.java b/server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneJoinDaoImpl.java new file mode 100644 index 00000000000..6be2a3a798e --- /dev/null +++ b/server/src/main/java/org/apache/cloudstack/dns/dao/DnsZoneJoinDaoImpl.java @@ -0,0 +1,25 @@ +// 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. + +package org.apache.cloudstack.dns.dao; + +import org.apache.cloudstack.dns.vo.DnsZoneJoinVO; + +import com.cloud.utils.db.GenericDaoBase; + +public class DnsZoneJoinDaoImpl extends GenericDaoBase implements DnsZoneJoinDao { +} diff --git a/server/src/main/java/org/apache/cloudstack/dns/vo/DnsServerJoinVO.java b/server/src/main/java/org/apache/cloudstack/dns/vo/DnsServerJoinVO.java new file mode 100644 index 00000000000..ae59efc51c2 --- /dev/null +++ b/server/src/main/java/org/apache/cloudstack/dns/vo/DnsServerJoinVO.java @@ -0,0 +1,154 @@ +/* + * 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. + */ + +package org.apache.cloudstack.dns.vo; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.apache.cloudstack.api.Identity; +import org.apache.cloudstack.api.InternalIdentity; +import org.apache.cloudstack.dns.DnsServer; + +import com.cloud.api.query.vo.BaseViewVO; +import com.cloud.utils.StringUtils; + +@Entity +@Table(name = "dns_server_view") +public class DnsServerJoinVO extends BaseViewVO implements InternalIdentity, Identity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; + + @Column(name = "uuid") + private String uuid; + + @Column(name = "name") + private String name; + + @Column(name = "provider_type") + private String providerType; + + @Column(name = "url") + private String url; + + @Column(name = "port") + private Integer port; + + @Column(name = "name_servers") + private String nameServers; + + @Column(name = "is_public") + private boolean isPublic; + + @Column(name = "public_domain_suffix") + private String publicDomainSuffix; + + @Column(name = "state") + @Enumerated(value = EnumType.STRING) + private DnsServer.State state; + + @Column(name = "account_name") + private String accountName; + + @Column(name = "domain_name") + private String domainName; + + @Column(name = "domain_uuid") + private String domainUuid; + + @Column(name = "domain_path") + private String domainPath; + + public DnsServerJoinVO() { + } + + @Override + public long getId() { + return id; + } + + @Override + public String getUuid() { + return uuid; + } + + public String getName() { + return name; + } + + public String getProviderType() { + return providerType; + } + + public String getUrl() { + return url; + } + + public Integer getPort() { + return port; + } + + public List getNameServers() { + if (StringUtils.isBlank(nameServers)) { + return Collections.emptyList(); + } + return Arrays.asList(nameServers.split(",")); + } + + public boolean isPublicServer() { + return isPublic; + } + + public String getPublicDomainSuffix() { + return publicDomainSuffix; + } + + public DnsServer.State getState() { + return state; + } + + public String getAccountName() { + return accountName; + } + + public String getDomainName() { + return domainName; + } + + public String getDomainPath() { + return domainPath; + } + + public String getDomainUuid() { + return domainUuid; + } +} diff --git a/server/src/main/java/org/apache/cloudstack/dns/vo/DnsZoneJoinVO.java b/server/src/main/java/org/apache/cloudstack/dns/vo/DnsZoneJoinVO.java new file mode 100644 index 00000000000..4468a4f64e0 --- /dev/null +++ b/server/src/main/java/org/apache/cloudstack/dns/vo/DnsZoneJoinVO.java @@ -0,0 +1,130 @@ +/* + * 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. + */ + +package org.apache.cloudstack.dns.vo; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.apache.cloudstack.api.Identity; +import org.apache.cloudstack.api.InternalIdentity; +import org.apache.cloudstack.dns.DnsZone; + +import com.cloud.api.query.vo.BaseViewVO; + +@Entity +@Table(name = "dns_zone_view") +public class DnsZoneJoinVO extends BaseViewVO implements InternalIdentity, Identity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; + + @Column(name = "uuid") + private String uuid; + + @Column(name = "name") + private String name; + + @Column(name = "state") + @Enumerated(value = EnumType.STRING) + private DnsZone.State state; + + @Column(name = "dns_server_uuid") + private String dnsServerUuid; + + @Column(name = "dns_server_name") + private String dnsServerName; + + @Column(name = "dns_server_account_name") + private String dnsServerAccountName; + + @Column(name = "account_name") + private String accountName; + + @Column(name = "domain_name") + private String domainName; + + @Column(name = "domain_uuid") + private String domainUuid; + + @Column(name = "domain_path") + private String domainPath; + + @Column(name = "description") + private String description; + + @Override + public long getId() { + return id; + } + + @Override + public String getUuid() { + return uuid; + } + + public DnsZone.State getState() { + return state; + } + + public String getDnsServerUuid() { + return dnsServerUuid; + } + + public String getDnsServerName() { + return dnsServerName; + } + + public String getAccountName() { + return accountName; + } + + public String getDomainName() { + return domainName; + } + + public String getDomainPath() { + return domainPath; + } + + public String getName() { + return name; + } + + public String getDnsServerAccountName() { + return dnsServerAccountName; + } + + public String getDomainUuid() { + return domainUuid; + } + + public String getDescription() { + return description; + } + +} diff --git a/server/src/main/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml b/server/src/main/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml index 02b38e38634..1869a4862af 100644 --- a/server/src/main/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml +++ b/server/src/main/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml @@ -399,10 +399,6 @@ - - - -