mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 5592: Added configurable domain for hosts.
status 5592: resolved fixed
This commit is contained in:
parent
656c933891
commit
fa4a16cb68
@ -55,4 +55,6 @@ public interface Account extends PartOf {
|
||||
public void setState(String state);
|
||||
public long getDomainId();
|
||||
public Date getRemoved();
|
||||
public String getNetworkDomain();
|
||||
public void setNetworkDomain(String networkDomain);
|
||||
}
|
||||
|
||||
@ -86,6 +86,9 @@ public class StartRouterCommand extends AbstractStartCommand {
|
||||
} else if (router.getRole() == Role.DHCP_USERDATA) {
|
||||
basic = basic + " type=dhcpsrvr";
|
||||
}
|
||||
if(router.getDomain() != null){
|
||||
basic += " domain="+router.getDomain();
|
||||
}
|
||||
return basic;
|
||||
}
|
||||
|
||||
|
||||
@ -61,17 +61,20 @@ public class DataCenterVO implements DataCenter {
|
||||
|
||||
@Column(name="guest_network_cidr")
|
||||
private String guestNetworkCidr = null;
|
||||
|
||||
@Column(name="domain")
|
||||
private String domain = null;
|
||||
|
||||
@Column(name="mac_address", updatable = false, nullable=false)
|
||||
@TableGenerator(name="mac_address_sq", table="data_center", pkColumnName="id", valueColumnName="mac_address", allocationSize=1)
|
||||
private long macAddress = 1;
|
||||
|
||||
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr) {
|
||||
this(name, description, dns1, dns2, dns3, dns4, vnet, guestCidr);
|
||||
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain) {
|
||||
this(name, description, dns1, dns2, dns3, dns4, vnet, guestCidr, domain);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr) {
|
||||
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.dns1 = dns1;
|
||||
@ -80,6 +83,7 @@ public class DataCenterVO implements DataCenter {
|
||||
this.internalDns2 = dns4;
|
||||
this.vnet = vnet;
|
||||
this.guestNetworkCidr = guestCidr;
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
@ -159,5 +163,13 @@ public class DataCenterVO implements DataCenter {
|
||||
{
|
||||
this.guestNetworkCidr = guestNetworkCidr;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -53,7 +53,11 @@ public class AccountVO implements Account {
|
||||
private Date removed;
|
||||
|
||||
@Column(name="cleanup_needed")
|
||||
private boolean needsCleanup = false;
|
||||
private boolean needsCleanup = false;
|
||||
|
||||
@Column(name="network_domain")
|
||||
private String networkDomain = null;
|
||||
|
||||
|
||||
public AccountVO() {}
|
||||
public AccountVO(long id) {
|
||||
@ -103,5 +107,11 @@ public class AccountVO implements Account {
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
public String getNetworkDomain() {
|
||||
return networkDomain;
|
||||
}
|
||||
public void setNetworkDomain(String networkDomain) {
|
||||
this.networkDomain = networkDomain;
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,6 +63,9 @@ public class CreateUserCmd extends BaseCmd {
|
||||
|
||||
@Parameter(name="username", type=CommandType.STRING, required=true, description="Unique username.")
|
||||
private String username;
|
||||
|
||||
@Parameter(name="networkdomain", type=CommandType.STRING, description="Network domain name of the Vms that belong to the domain")
|
||||
private String networkdomain;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
@ -105,7 +108,9 @@ public class CreateUserCmd extends BaseCmd {
|
||||
return username;
|
||||
}
|
||||
|
||||
|
||||
public String getNetworkdomain() {
|
||||
return networkdomain;
|
||||
}
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -58,6 +58,9 @@ public class CreateZoneCmd extends BaseCmd {
|
||||
//FIXME - this parameter is called "vnet" in updateZone. Have to figure out which one is right
|
||||
@Parameter(name="vlan", type=CommandType.STRING, description="the VNET for the Zone")
|
||||
private String vlan;
|
||||
|
||||
@Parameter(name="domain", type=CommandType.STRING, description="Domain name for the Vms in the zone")
|
||||
private String domain;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
@ -91,6 +94,10 @@ public class CreateZoneCmd extends BaseCmd {
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
@ -114,7 +121,7 @@ public class CreateZoneCmd extends BaseCmd {
|
||||
response.setInternalDns2(zone.getInternalDns2());
|
||||
response.setVlan(zone.getVnet());
|
||||
response.setGuestCidrAddress(zone.getGuestNetworkCidr());
|
||||
|
||||
response.setDomain(zone.getDomain());
|
||||
response.setResponseName(getName());
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ package com.cloud.api.commands;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseCmd.CommandType;
|
||||
import com.cloud.api.BaseCmd.Manager;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
@ -61,6 +62,9 @@ public class UpdateZoneCmd extends BaseCmd {
|
||||
|
||||
@Parameter(name="vnet", type=CommandType.STRING, description="the VNET for the Zone")
|
||||
private String vnet;
|
||||
|
||||
@Parameter(name="domain", type=CommandType.STRING, description="Domain name for the Vms in the zone")
|
||||
private String domain;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -97,6 +101,10 @@ public class UpdateZoneCmd extends BaseCmd {
|
||||
public String getVnet() {
|
||||
return vnet;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
@ -123,6 +131,7 @@ public class UpdateZoneCmd extends BaseCmd {
|
||||
response.setInternalDns2(responseObject.getInternalDns2());
|
||||
response.setName(responseObject.getName());
|
||||
response.setVlan(responseObject.getVnet());
|
||||
response.setDomain(responseObject.getDomain());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update zone; internal error.");
|
||||
}
|
||||
|
||||
@ -55,6 +55,9 @@ public class ZoneResponse extends BaseResponse {
|
||||
|
||||
@SerializedName("displaytext")
|
||||
private String displayText;
|
||||
|
||||
@SerializedName("domain") @Param(description="Domain name for the Vms in the zone")
|
||||
private String domain;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -143,4 +146,12 @@ public class ZoneResponse extends BaseResponse {
|
||||
public void setDisplayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ public interface ConfigurationManager extends Manager {
|
||||
* @throws InvalidParameterValueException
|
||||
* @throws InternalErrorException
|
||||
*/
|
||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr) throws InvalidParameterValueException, InternalErrorException;
|
||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain) throws InvalidParameterValueException, InternalErrorException;
|
||||
|
||||
/**
|
||||
* Edits a zone in the database. Will not allow you to edit DNS values if there are VMs in the specified zone.
|
||||
|
||||
@ -811,6 +811,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
String internalDns2 = cmd.getInternalDns2();
|
||||
String vnetRange = cmd.getVnet();
|
||||
String guestCidr = cmd.getGuestCidrAddress();
|
||||
String domain = cmd.getDomain();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
|
||||
if (userId == null) {
|
||||
@ -862,6 +863,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
if(guestCidr == null)
|
||||
guestCidr = zone.getGuestNetworkCidr();
|
||||
|
||||
if(domain == null)
|
||||
domain = zone.getDomain();
|
||||
|
||||
boolean checkForDuplicates = !zoneName.equals(oldZoneName);
|
||||
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates);
|
||||
|
||||
@ -871,6 +875,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
zone.setInternalDns1(internalDns1);
|
||||
zone.setInternalDns2(internalDns2);
|
||||
zone.setGuestNetworkCidr(guestCidr);
|
||||
zone.setDomain(domain);
|
||||
|
||||
if (vnetRange != null) {
|
||||
zone.setVnet(vnetRange);
|
||||
@ -937,7 +942,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr) throws InvalidParameterValueException, InternalErrorException {
|
||||
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain) throws InvalidParameterValueException, InternalErrorException {
|
||||
int vnetStart, vnetEnd;
|
||||
if (vnetRange != null) {
|
||||
String[] tokens = vnetRange.split("-");
|
||||
@ -971,7 +976,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, true);
|
||||
|
||||
// Create the new zone in the database
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr);
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr, domain);
|
||||
zone = _zoneDao.persist(zone);
|
||||
|
||||
// Add vnet entries for the new zone
|
||||
@ -993,12 +998,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
String internalDns2 = cmd.getInternalDns2();
|
||||
String vnetRange = cmd.getVlan();
|
||||
String guestCidr = cmd.getGuestCidrAddress();
|
||||
String domain = cmd.getDomain();
|
||||
|
||||
if (userId == null) {
|
||||
userId = User.UID_SYSTEM;
|
||||
}
|
||||
|
||||
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr);
|
||||
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr, domain);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -235,6 +235,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
private ServiceOfferingVO _offering;
|
||||
private int _networkRate;
|
||||
private int _multicastRate;
|
||||
String _networkDomain;
|
||||
|
||||
private VMTemplateVO _template;
|
||||
|
||||
@ -925,7 +926,19 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
router.setVnet(vnet);
|
||||
final String name = VirtualMachineName.attachVnet(router.getName(), vnet);
|
||||
router.setInstanceName(name);
|
||||
|
||||
long accountId = router.getAccountId();
|
||||
// Use account level network domain if available
|
||||
String networkDomain = _accountDao.findById(accountId).getNetworkDomain();
|
||||
if(networkDomain == null){
|
||||
// Use zone level network domain, if account level domain is not available
|
||||
networkDomain = dc.getDomain();
|
||||
if(networkDomain == null){
|
||||
// Use system wide default network domain, if zone wide network domain is also not available
|
||||
networkDomain = _networkDomain;
|
||||
}
|
||||
|
||||
}
|
||||
router.setDomain(networkDomain);
|
||||
_routerDao.updateIf(router, Event.OperationRetry, routingHost.getId());
|
||||
|
||||
List<VolumeVO> vols = _storageMgr.prepare(router, routingHost);
|
||||
@ -1425,6 +1438,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
||||
if (_instance == null) {
|
||||
_instance = "DEFAULT";
|
||||
}
|
||||
|
||||
_networkDomain = configs.get("domain.suffix");
|
||||
|
||||
s_logger.info("Router configurations: " + "ramsize=" + _routerRamSize + "; templateId=" + _routerTemplateId);
|
||||
|
||||
|
||||
@ -190,7 +190,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
if (dns == null) {
|
||||
dns = "4.2.2.2";
|
||||
}
|
||||
DataCenterVO zone = createZone(User.UID_SYSTEM, "Default", dns, null, dns, null, "1000-2000","10.1.1.0/24");
|
||||
DataCenterVO zone = createZone(User.UID_SYSTEM, "Default", dns, null, dns, null, "1000-2000","10.1.1.0/24", null);
|
||||
|
||||
// Create a default pod
|
||||
String networkType = _configDao.getValue("network.type");
|
||||
@ -527,7 +527,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
}
|
||||
}
|
||||
|
||||
private DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr) throws InvalidParameterValueException, InternalErrorException {
|
||||
private DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain) throws InvalidParameterValueException, InternalErrorException {
|
||||
int vnetStart, vnetEnd;
|
||||
if (vnetRange != null) {
|
||||
String[] tokens = vnetRange.split("-");
|
||||
@ -559,7 +559,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
}
|
||||
|
||||
// Create the new zone in the database
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr);
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr, domain);
|
||||
zone = _zoneDao.persist(zone);
|
||||
|
||||
// Add vnet entries for the new zone
|
||||
|
||||
@ -576,6 +576,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
String timezone = cmd.getTimezone();
|
||||
String accountName = cmd.getAccountName();
|
||||
short userType = cmd.getAccountType().shortValue();
|
||||
String networkDomain = cmd.getNetworkdomain();
|
||||
try {
|
||||
if (accountName == null) {
|
||||
accountName = username;
|
||||
@ -616,6 +617,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
newAccount.setDomainId(domainId);
|
||||
newAccount.setType(userType);
|
||||
newAccount.setState("enabled");
|
||||
newAccount.setNetworkDomain(networkDomain);
|
||||
newAccount = _accountDao.persist(newAccount);
|
||||
accountId = newAccount.getId();
|
||||
}
|
||||
|
||||
@ -350,6 +350,7 @@ CREATE TABLE `cloud`.`data_center` (
|
||||
`router_mac_address` varchar(17) NOT NULL DEFAULT '02:00:00:00:00:01' COMMENT 'mac address for the router within the domain',
|
||||
`mac_address` bigint unsigned NOT NULL DEFAULT '1' COMMENT 'Next available mac address for the ethernet card interacting with public internet',
|
||||
`guest_network_cidr` varchar(18),
|
||||
`domain` varchar(100) COMMENT 'Network domain name of the Vms of the zone',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
@ -738,6 +739,7 @@ CREATE TABLE `cloud`.`account` (
|
||||
`state` varchar(10) NOT NULL default 'enabled',
|
||||
`removed` datetime COMMENT 'date removed',
|
||||
`cleanup_needed` tinyint(1) NOT NULL default '0',
|
||||
`network_domain` varchar(100) COMMENT 'Network domain name of the Vms of the account',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user