add db schema, vo and dao classes

This commit is contained in:
Manoj Kumar 2026-02-10 07:24:10 +05:30
parent 7b9fc0e48e
commit b2d597c1bb
No known key found for this signature in database
GPG Key ID: E952B7234D2C6F88
17 changed files with 860 additions and 13 deletions

View File

@ -19,9 +19,10 @@ package org.apache.cloudstack.dns;
import java.util.List;
public interface DnsProvider {
// Returns the provider type string (e.g., "PowerDNS")
String getProviderType();
import com.cloud.utils.component.Adapter;
public interface DnsProvider extends Adapter {
DnsProviderType getProviderType();
// Validates connectivity to the server
boolean validate(DnsServer server);

View File

@ -34,8 +34,10 @@ import org.apache.cloudstack.api.response.DnsZoneResponse;
import org.apache.cloudstack.api.response.ListResponse;
import com.cloud.utils.component.Manager;
import com.cloud.utils.component.PluggableService;
public interface DnsProviderManager extends Manager, PluggableService {
public interface DnsProviderManager extends Manager {
DnsServer addDnsServer(AddDnsServerCmd cmd);
ListResponse<DnsServerResponse> listDnsServers(ListDnsServersCmd cmd);
boolean deleteDnsServer(DeleteDnsServerCmd cmd);

View File

@ -0,0 +1,34 @@
// 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;
public enum DnsProviderType {
PowerDNS;
// Cloudflare
// Helper to validate and return Enum from String safely
public static DnsProviderType fromString(String type) {
if (type == null) return null;
for (DnsProviderType t : DnsProviderType.values()) {
if (t.name().equalsIgnoreCase(type)) {
return t;
}
}
throw new IllegalArgumentException("Invalid DNS Provider type: " + type);
}
}

View File

@ -17,23 +17,29 @@
package org.apache.cloudstack.dns;
import java.util.Date;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
public interface DnsServer extends InternalIdentity, Identity {
enum ProviderType {
PowerDNS
}
enum State {
Enabled, Disabled;
};
String getName();
String getUrl();
ProviderType getProviderType();
DnsProviderType getProviderType();
String getKey();
long getDomainId();
String getAPIKey();
long getAccountId();
boolean isPublic();
Date getCreated();
Date getRemoved();
}

View File

@ -26,6 +26,9 @@ public interface DnsZone extends InternalIdentity, Identity {
enum ZoneType {
Public, Private
}
enum State {
Active, Inactive
}
String getName();
@ -33,8 +36,6 @@ public interface DnsZone extends InternalIdentity, Identity {
long getAccountId();
String getDescription();
ZoneType getType();
List<Long> getAssociatedNetworks();

View File

@ -49,3 +49,54 @@ CREATE TABLE IF NOT EXISTS `cloud`.`webhook_filter` (
INDEX `i_webhook_filter__webhook_id`(`webhook_id`),
CONSTRAINT `fk_webhook_filter__webhook_id` FOREIGN KEY(`webhook_id`) REFERENCES `webhook`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ======================================================================
-- DNS Framework Schema
-- ======================================================================
-- 1. DNS Server Table (Stores DNS Server Configurations)
CREATE TABLE `cloud`.`dns_server` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id of the dns server',
`uuid` varchar(255) COMMENT 'uuid of the dns server',
`name` varchar(255) NOT NULL COMMENT 'display name of the dns server',
`url` varchar(1024) NOT NULL COMMENT 'dns server url',
`port` int(11) DEFAULT NULL COMMENT 'optional dns server port',
`is_public` tinyint(1) NOT NULL DEFAULT '0',
`public_domain_suffix` VARCHAR(255),
`state` ENUM('Enabled', 'Disabled') NOT NULL DEFAULT 'Disabled',
`account_id` bigint(20) unsigned NOT NULL,
`created` datetime NOT NULL COMMENT 'date created',
`removed` datetime DEFAULT NULL COMMENT 'Date removed (soft delete)',
PRIMARY KEY (`id`),
KEY `i_dns_server__account_id` (`account_id`),
CONSTRAINT `fk_dns_server__account_id` FOREIGN KEY (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 2. DNS Zone Table (Stores DNS Zone Metadata)
CREATE TABLE `cloud`.`dns_zone` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id of the dns zone',
`uuid` varchar(255) COMMENT 'uuid of the dns zone',
`name` varchar(255) NOT NULL COMMENT 'dns zone name (e.g. example.com)',
`dns_server_id` bigint unsigned NOT NULL COMMENT 'fk to dns_server.id',
`external_reference` VARCHAR(255) COMMENT 'id of external provider resource',
`state` ENUM('Active', 'Inactive') NOT NULL DEFAULT 'Inactive',
`created` datetime NOT NULL COMMENT 'date created',
`removed` datetime DEFAULT NULL COMMENT 'Date removed (soft delete)',
PRIMARY KEY (`id`),
KEY `i_dns_zone__dns_server` (`dns_server_id`),
CONSTRAINT `fk_dns_zone__dns_server_id` FOREIGN KEY (`dns_server_id`) REFERENCES `dns_server` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 3. DNS Zone Network Map (One-to-Many Link)
CREATE TABLE `cloud`.`dns_zone_network_map` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id of the dns zone to network mapping',
`dns_zone_id` bigint(20) unsigned NOT NULL,
`network_id` bigint(20) unsigned NOT NULL COMMENT 'network to which dns zone is associated to',
`sub_domain` varchar(255) DEFAULT NULL COMMENT 'Subdomain for auto-registration',
PRIMARY KEY (`id`),
KEY `fk_dns_map__zone_id` (`dns_zone_id`),
KEY `fk_dns_map__network_id` (`network_id`),
CONSTRAINT `fk_dns_map__zone_id` FOREIGN KEY (`dns_zone_id`) REFERENCES `dns_zone` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_dns_map__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -0,0 +1,177 @@
// 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;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.api.command.user.dns.AddDnsServerCmd;
import org.apache.cloudstack.api.command.user.dns.CreateDnsRecordCmd;
import org.apache.cloudstack.api.command.user.dns.CreateDnsZoneCmd;
import org.apache.cloudstack.api.command.user.dns.DeleteDnsRecordCmd;
import org.apache.cloudstack.api.command.user.dns.DeleteDnsServerCmd;
import org.apache.cloudstack.api.command.user.dns.DeleteDnsZoneCmd;
import org.apache.cloudstack.api.command.user.dns.ListDnsProvidersCmd;
import org.apache.cloudstack.api.command.user.dns.ListDnsRecordsCmd;
import org.apache.cloudstack.api.command.user.dns.ListDnsServersCmd;
import org.apache.cloudstack.api.command.user.dns.ListDnsZonesCmd;
import org.apache.cloudstack.api.response.DnsRecordResponse;
import org.apache.cloudstack.api.response.DnsServerResponse;
import org.apache.cloudstack.api.response.DnsZoneResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.component.PluggableService;
import com.cloud.utils.exception.CloudRuntimeException;
@Component
public class DnsProviderManagerImpl extends ManagerBase implements DnsProviderManager, PluggableService {
@Autowired(required = false)
List<DnsProvider> dnsProviders;
private DnsProvider getProvider(DnsProviderType type) {
if (type == null) {
throw new CloudRuntimeException("Provider type cannot be null");
}
for (DnsProvider provider : dnsProviders) {
if (provider.getProviderType() == type) {
return provider;
}
}
throw new CloudRuntimeException("No plugin found for DNS Provider type: " + type);
}
@Override
public DnsServer addDnsServer(AddDnsServerCmd cmd) {
return null;
}
@Override
public ListResponse<DnsServerResponse> listDnsServers(ListDnsServersCmd cmd) {
return null;
}
@Override
public boolean deleteDnsServer(DeleteDnsServerCmd cmd) {
return false;
}
@Override
public DnsServerResponse createDnsServerResponse(DnsServer server) {
return null;
}
@Override
public DnsServer getDnsServer(Long id) {
return null;
}
@Override
public DnsZone createDnsZone(CreateDnsZoneCmd cmd) {
return null;
}
@Override
public boolean deleteDnsZone(DeleteDnsZoneCmd cmd) {
return false;
}
@Override
public ListResponse<DnsZoneResponse> listDnsZones(ListDnsZonesCmd cmd) {
return null;
}
@Override
public DnsZone getDnsZone(long id) {
return null;
}
@Override
public DnsRecordResponse createDnsRecord(CreateDnsRecordCmd cmd) {
return null;
}
@Override
public boolean deleteDnsRecord(DeleteDnsRecordCmd cmd) {
return false;
}
@Override
public ListResponse<DnsRecordResponse> listDnsRecords(ListDnsRecordsCmd cmd) {
return null;
}
@Override
public List<String> listProviderNames() {
List<String> providerNames = new ArrayList<>();
if (dnsProviders != null) {
for (DnsProvider provider : dnsProviders) {
providerNames.add(provider.getProviderType().toString());
}
}
return providerNames;
}
@Override
public DnsZone allocDnsZone(CreateDnsZoneCmd cmd) {
return null;
}
@Override
public DnsZone provisionDnsZone(long zoneId) {
return null;
}
@Override
public DnsZoneResponse createDnsZoneResponse(DnsZone zone) {
return null;
}
@Override
public boolean start() {
if (dnsProviders == null || dnsProviders.isEmpty()) {
logger.warn("DNS Framework started but no provider plugins were found!");
} else {
logger.info("DNS Framework started with: {} providers.", dnsProviders.size());
}
return true;
}
@Override
public List<Class<?>> getCommands() {
List<Class<?>> cmdList = new ArrayList<>();
// DNS Server Commands
cmdList.add(AddDnsServerCmd.class);
cmdList.add(ListDnsServersCmd.class);
cmdList.add(DeleteDnsServerCmd.class);
cmdList.add(ListDnsProvidersCmd.class);
// DNS Zone Commands
cmdList.add(CreateDnsZoneCmd.class);
cmdList.add(ListDnsZonesCmd.class);
cmdList.add(DeleteDnsZoneCmd.class);
// DNS Record Commands
cmdList.add(CreateDnsRecordCmd.class);
cmdList.add(ListDnsRecordsCmd.class);
cmdList.add(DeleteDnsRecordCmd.class);
return cmdList;
}
}

View File

@ -0,0 +1,30 @@
// 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 java.util.List;
import org.apache.cloudstack.dns.vo.DnsServerVO;
import com.cloud.utils.db.GenericDao;
public interface DnsServerDao extends GenericDao<DnsServerVO, Long> {
List<DnsServerVO> listByProviderType(String providerType);
}

View File

@ -0,0 +1,47 @@
// 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 java.util.List;
import org.apache.cloudstack.dns.vo.DnsServerVO;
import org.springframework.stereotype.Component;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
@Component
public class DnsServerDaoImpl extends GenericDaoBase<DnsServerVO, Long> implements DnsServerDao {
static final String PROVIDER_TYPE = "providerType";
SearchBuilder<DnsServerVO> ProviderSearch;
public DnsServerDaoImpl() {
super();
ProviderSearch = createSearchBuilder();
ProviderSearch.and(PROVIDER_TYPE, ProviderSearch.entity().getProviderType(), SearchCriteria.Op.EQ);
ProviderSearch.done();
}
@Override
public List<DnsServerVO> listByProviderType(String providerType) {
SearchCriteria<DnsServerVO> sc = ProviderSearch.create();
sc.setParameters(PROVIDER_TYPE, providerType);
return listBy(sc);
}
}

View File

@ -0,0 +1,28 @@
// 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 java.util.List;
import org.apache.cloudstack.dns.vo.DnsZoneVO;
import com.cloud.utils.db.GenericDao;
public interface DnsZoneDao extends GenericDao<DnsZoneVO, Long> {
List<DnsZoneVO> listByServerId(long serverId);
}

View File

@ -0,0 +1,47 @@
// 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 java.util.List;
import org.apache.cloudstack.dns.vo.DnsZoneVO;
import org.springframework.stereotype.Component;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
@Component
public class DnsZoneDaoImpl extends GenericDaoBase<DnsZoneVO, Long> implements DnsZoneDao {
static final String DNS_SERVER_ID = "dnsServerId";
SearchBuilder<DnsZoneVO> ServerSearch;
public DnsZoneDaoImpl() {
super();
ServerSearch = createSearchBuilder();
ServerSearch.and(DNS_SERVER_ID, ServerSearch.entity().getDnsServerId(), SearchCriteria.Op.EQ);
ServerSearch.done();
}
@Override
public List<DnsZoneVO> listByServerId(long serverId) {
SearchCriteria<DnsZoneVO> sc = ServerSearch.create();
sc.setParameters(DNS_SERVER_ID, serverId);
return listBy(sc);
}
}

View File

@ -0,0 +1,11 @@
package org.apache.cloudstack.dns.dao;
import java.util.List;
import org.apache.cloudstack.dns.vo.DnsZoneNetworkMapVO;
import com.cloud.utils.db.GenericDao;
public interface DnsZoneNetworkMapDao extends GenericDao<DnsZoneNetworkMapVO, Long> {
List<DnsZoneNetworkMapVO> listByDnsZoneId(long dnsZoneId);
}

View File

@ -0,0 +1,28 @@
package org.apache.cloudstack.dns.dao;
import java.util.List;
import org.apache.cloudstack.dns.vo.DnsZoneNetworkMapVO;
import org.springframework.stereotype.Component;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
@Component
public class DnsZoneNetworkMapDaoImpl extends GenericDaoBase<DnsZoneNetworkMapVO, Long> implements DnsZoneNetworkMapDao {
final SearchBuilder<DnsZoneNetworkMapVO> ZoneSearch;
public DnsZoneNetworkMapDaoImpl() {
super();
ZoneSearch = createSearchBuilder();
ZoneSearch.and("dnsZoneId", ZoneSearch.entity().getDnsZoneId(), SearchCriteria.Op.EQ);
ZoneSearch.done();
}
@Override
public List<DnsZoneNetworkMapVO> listByDnsZoneId(long dnsZoneId) {
SearchCriteria<DnsZoneNetworkMapVO> sc = ZoneSearch.create();
sc.setParameters("dnsZoneId", dnsZoneId);
return listBy(sc);
}
}

View File

@ -0,0 +1,157 @@
// 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.Date;
import java.util.UUID;
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 javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.cloudstack.dns.DnsProviderType;
import org.apache.cloudstack.dns.DnsServer;
import com.cloud.utils.db.Encrypt;
import com.cloud.utils.db.GenericDao;
@Entity
@Table(name = "dns_server")
public class DnsServerVO implements DnsServer {
@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 = "url")
private String url;
@Column(name = "provider_type")
@Enumerated(EnumType.STRING)
private DnsProviderType providerType;
@Encrypt
@Column(name = "api_key")
private String apiKey;
@Column(name = "is_public")
private boolean isPublic;
@Column(name = "public_domain_suffix")
private String publicDomainSuffix;
@Column(name = "state")
@Enumerated(EnumType.STRING)
private State state;
@Column(name = "account_id")
private long accountId;
@Column(name = GenericDao.CREATED_COLUMN)
@Temporal(value = TemporalType.TIMESTAMP)
private Date created = null;
@Column(name = GenericDao.REMOVED_COLUMN)
@Temporal(value = TemporalType.TIMESTAMP)
private Date removed = null;
public DnsServerVO() {
this.uuid = UUID.randomUUID().toString();
this.created = new Date();
}
public DnsServerVO(String name, String url, DnsProviderType providerType, String apiKey, long accountId, boolean isPublic) {
this();
this.name = name;
this.url = url;
this.providerType = providerType;
this.apiKey = apiKey;
this.accountId = accountId;
this.isPublic = isPublic;
}
@Override
public long getId() {
return id;
}
@Override
public String getName() {
return name;
}
@Override
public String getUrl() {
return url;
}
@Override
public DnsProviderType getProviderType() {
return providerType;
}
@Override
public String getAPIKey() {
return apiKey;
}
@Override
public long getAccountId() {
return accountId;
}
@Override
public Date getCreated() {
return created;
}
@Override
public Date getRemoved() {
return removed;
}
@Override
public String getUuid() {
return uuid;
}
public boolean isPublic() {
return isPublic;
}
public State getState() {
return state;
}
public void setState(State state) {
this.state = state;
}
}

View File

@ -0,0 +1,96 @@
// 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.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.utils.db.GenericDao;
@Entity
@Table(name = "dns_zone_network_map")
public class DnsZoneNetworkMapVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private long id;
@Column(name = "dns_zone_id")
private long dnsZoneId;
@Column(name = "network_id")
private long networkId;
@Column(name = "sub_domain")
private String subDomain;
@Column(name = GenericDao.CREATED_COLUMN)
@Temporal(value = TemporalType.TIMESTAMP)
private Date created = null;
@Column(name = GenericDao.REMOVED_COLUMN)
@Temporal(value = TemporalType.TIMESTAMP)
private Date removed = null;
public DnsZoneNetworkMapVO() {
this.created = new Date();
}
public DnsZoneNetworkMapVO(long dnsZoneId, long networkId, String subDomain) {
this();
this.dnsZoneId = dnsZoneId;
this.networkId = networkId;
this.subDomain = subDomain;
}
@Override
public long getId() {
return id;
}
public long getDnsZoneId() {
return dnsZoneId;
}
public long getNetworkId() {
return networkId;
}
public String getSubDomain() {
return subDomain;
}
public Date getCreated() {
return created;
}
public Date getRemoved() {
return removed;
}
}

View File

@ -0,0 +1,125 @@
// 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.Date;
import java.util.List;
import java.util.UUID;
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 javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.cloudstack.dns.DnsZone;
import com.cloud.utils.db.GenericDao;
@Entity
@Table(name = "dns_zone")
public class DnsZoneVO implements DnsZone {
@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 = "dns_server_id")
private long dnsServerId;
@Column(name = "external_reference")
private String externalReference;
@Column(name = "type")
@Enumerated(EnumType.STRING)
private ZoneType type;
@Column(name = "state")
@Enumerated(EnumType.STRING)
private State state;
@Column(name = "account_id")
private long accountId;
@Column(name = GenericDao.CREATED_COLUMN)
@Temporal(value = TemporalType.TIMESTAMP)
private Date created = null;
@Column(name = GenericDao.REMOVED_COLUMN)
@Temporal(value = TemporalType.TIMESTAMP)
private Date removed = null;
public DnsZoneVO() {
this.uuid = UUID.randomUUID().toString();
this.created = new Date();
}
public DnsZoneVO(String name, long dnsServerId, long accountId) {
this();
this.name = name;
this.dnsServerId = dnsServerId;
this.accountId = accountId;
this.type = ZoneType.Public;
}
@Override
public String getName() {
return name;
}
@Override
public long getDnsServerId() {
return dnsServerId;
}
@Override
public long getAccountId() {
return accountId;
}
@Override
public ZoneType getType() {
return type;
}
@Override
public List<Long> getAssociatedNetworks() {
return List.of();
}
@Override
public String getUuid() {
return uuid;
}
@Override
public long getId() {
return id;
}
}

View File

@ -398,4 +398,10 @@
<bean id="ExternalOrchestratorDetailDaoImpl" class="org.apache.cloudstack.hypervisor.external.provisioner.dao.ExternalOrchestratorDetailDaoImpl" />
<bean id="ExtensionResourceMapDaoImpl" class="org.apache.cloudstack.hypervisor.external.provisioner.dao.ExtensionResourceMapDaoImpl" />
<bean id="ExtensionResourceMapDetailsDaoImpl" class="org.apache.cloudstack.hypervisor.external.provisioner.dao.ExtensionResourceMapDetailsDaoImpl" />
<bean id="dnsServerDao" class="org.apache.cloudstack.dns.dao.DnsServerDaoImpl" />
<bean id="dnsZoneDao" class="org.apache.cloudstack.dns.dao.DnsZoneDaoImpl" />
<bean id="dnsZoneNetworkMapDao" class="org.apache.cloudstack.dns.dao.DnsZoneNetworkMapDaoImpl" />
<bean id="dnsProviderManager" class="org.apache.cloudstack.dns.DnsProviderManagerImpl" />
</beans>