mirror of https://github.com/apache/cloudstack.git
Don't create default pod/zone
Create untagged network as a part of createZone command
This commit is contained in:
parent
eaf4fc3d8b
commit
fb4c448762
|
|
@ -9,7 +9,7 @@ import com.cloud.org.Grouping;
|
|||
*
|
||||
*/
|
||||
public interface DataCenter extends Grouping {
|
||||
public enum DataCenterNetworkType {
|
||||
public enum NetworkType {
|
||||
Basic,
|
||||
Advanced
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ public interface DataCenter extends Grouping {
|
|||
String getDomain();
|
||||
String getVnet();
|
||||
|
||||
DataCenterNetworkType getNetworkType();
|
||||
NetworkType getNetworkType();
|
||||
String getInternalDns1();
|
||||
String getInternalDns2();
|
||||
String getDnsProvider();
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ public interface NetworkOffering {
|
|||
|
||||
public final String DefaultVirtualizedNetworkOffering = "DefaultVirtualizedNetworkOffering";
|
||||
public final String DefaultDirectNetworkOffering = "DefaultDirectNetworkOffering";
|
||||
public final String DefaultDirectPodBasedNetworkOffering = "DefaultDirectPodBasedNetworkOffering";
|
||||
public final String DefaultDirectChooseVlanNetworkOffering = "DefaultDirectChooseVlanNetworkOffering";
|
||||
|
||||
long getId();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import com.cloud.exception.DiscoveryException;
|
|||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.HostStats;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
|||
|
||||
import com.cloud.api.commands.CreateVlanIpRangeCmd;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.DataCenterNetworkType;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.Vlan;
|
||||
|
|
@ -111,7 +111,7 @@ public interface ConfigurationManager extends Manager {
|
|||
* @throws
|
||||
* @throws
|
||||
*/
|
||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId, DataCenterNetworkType zoneType);
|
||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId, NetworkType zoneType);
|
||||
|
||||
/**
|
||||
* Associates an ip address list to an account. The list of ip addresses are all addresses associated with the given vlan id.
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ import com.cloud.configuration.ResourceCount.ResourceType;
|
|||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.AccountVlanMapVO;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.DataCenterNetworkType;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterIpAddressVO;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
|
|
@ -71,6 +71,7 @@ import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl;
|
|||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.PodVlanMapDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
|
|
@ -84,6 +85,8 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
|
|
@ -897,7 +900,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
//if zone is of Basic type, don't allow to add vnet range
|
||||
if (vnetRange != null && zone.getNetworkType() == DataCenterNetworkType.Basic) {
|
||||
if (vnetRange != null && zone.getNetworkType() == NetworkType.Basic) {
|
||||
throw new InvalidParameterValueException("Can't add vnet range for the zone that supports Basic network");
|
||||
}
|
||||
|
||||
|
|
@ -1021,7 +1024,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
@Override @DB
|
||||
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId, DataCenterNetworkType zoneType) {
|
||||
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId, NetworkType zoneType) {
|
||||
int vnetStart = 0;
|
||||
int vnetEnd = 0;
|
||||
if (vnetRange != null) {
|
||||
|
|
@ -1046,21 +1049,55 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
|
||||
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, true, domainId);
|
||||
|
||||
// Create the new zone in the database
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr, domain, domainId, zoneType);
|
||||
zone = _zoneDao.persist(zone);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
// Create the new zone in the database
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr, domain, domainId, zoneType);
|
||||
zone = _zoneDao.persist(zone);
|
||||
|
||||
// Add vnet entries for the new zone if zone type is Advanced
|
||||
if (vnetRange != null) {
|
||||
_zoneDao.addVnet(zone.getId(), vnetStart, vnetEnd);
|
||||
// Add vnet entries for the new zone if zone type is Advanced
|
||||
if (vnetRange != null) {
|
||||
_zoneDao.addVnet(zone.getId(), vnetStart, vnetEnd);
|
||||
}
|
||||
|
||||
//if zone is basic, create a untagged network
|
||||
if (zone != null && zone.getNetworkType() == NetworkType.Basic) {
|
||||
//Create network
|
||||
DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, null);
|
||||
NetworkVO userNetwork = new NetworkVO();
|
||||
userNetwork.setBroadcastDomainType(BroadcastDomainType.Native);
|
||||
|
||||
Account systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
|
||||
|
||||
List<NetworkOfferingVO> networkOffering = _networkOfferingDao.findByType(GuestIpType.DirectPodBased);
|
||||
if (networkOffering == null || networkOffering.isEmpty()) {
|
||||
throw new CloudRuntimeException("No default DirectPodBased network offering is found");
|
||||
}
|
||||
|
||||
List<NetworkVO> networks = _networkMgr.setupNetworkConfiguration(systemAccount, networkOffering.get(0), userNetwork, plan, null, null, true);
|
||||
|
||||
if (networks == null || networks.isEmpty()) {
|
||||
txn.rollback();
|
||||
throw new CloudRuntimeException("Fail to create a network");
|
||||
}
|
||||
}
|
||||
|
||||
if (vnetRange != null) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_CREATE, "Successfully created new zone with name: " + zoneName + ".", "dcId=" + zone.getId(), "dns1=" + dns1, "dns2=" + dns2, "internalDns1=" + internalDns1, "internalDns2=" + internalDns2, "vnetRange=" + vnetRange, "guestCidr=" + guestCidr);
|
||||
} else {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_CREATE, "Successfully created new zone with name: " + zoneName + ".", "dcId=" + zone.getId(), "dns1=" + dns1, "dns2=" + dns2, "internalDns1=" + internalDns1, "internalDns2=" + internalDns2, "guestCidr=" + guestCidr);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
return zone;
|
||||
} catch (Exception ex) {
|
||||
txn.rollback();
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new CloudRuntimeException("Fail to create a network");
|
||||
}finally {
|
||||
txn.close();
|
||||
}
|
||||
|
||||
if (vnetRange != null) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_CREATE, "Successfully created new zone with name: " + zoneName + ".", "dcId=" + zone.getId(), "dns1=" + dns1, "dns2=" + dns2, "internalDns1=" + internalDns1, "internalDns2=" + internalDns2, "vnetRange=" + vnetRange, "guestCidr=" + guestCidr);
|
||||
} else {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_CREATE, "Successfully created new zone with name: " + zoneName + ".", "dcId=" + zone.getId(), "dns1=" + dns1, "dns2=" + dns2, "internalDns1=" + internalDns1, "internalDns2=" + internalDns2, "guestCidr=" + guestCidr);
|
||||
}
|
||||
return zone;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1079,13 +1116,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
Boolean isBasic = false;
|
||||
|
||||
|
||||
if (!(type.equalsIgnoreCase(DataCenterNetworkType.Basic.toString())) && !(type.equalsIgnoreCase(DataCenterNetworkType.Advanced.toString()))) {
|
||||
if (!(type.equalsIgnoreCase(NetworkType.Basic.toString())) && !(type.equalsIgnoreCase(NetworkType.Advanced.toString()))) {
|
||||
throw new InvalidParameterValueException("Invalid zone type; only Advanced and Basic values are supported");
|
||||
} else if (type.endsWith(DataCenterNetworkType.Basic.toString())) {
|
||||
} else if (type.endsWith(NetworkType.Basic.toString())) {
|
||||
isBasic = true;
|
||||
}
|
||||
|
||||
DataCenterNetworkType zoneType = isBasic ? DataCenterNetworkType.Basic : DataCenterNetworkType.Advanced;
|
||||
NetworkType zoneType = isBasic ? NetworkType.Basic : NetworkType.Advanced;
|
||||
DomainVO domainVO = null;
|
||||
|
||||
if (userId == null) {
|
||||
|
|
@ -1097,10 +1134,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
//Verify zone type
|
||||
if (zoneType == DataCenterNetworkType.Basic && vnetRange != null) {
|
||||
if (zoneType == NetworkType.Basic && vnetRange != null) {
|
||||
vnetRange = null;
|
||||
}
|
||||
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr, domainVO != null ? domainVO.getName() : null, domainId, zoneType);
|
||||
|
||||
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr, domainVO != null ? domainVO.getName() : null, domainId, zoneType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1483,9 +1521,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
//Allow adding untagged direct vlan only for Basic zone
|
||||
if (zone.getNetworkType() == DataCenterNetworkType.Advanced && vlanId.equals(Vlan.UNTAGGED) && !forVirtualNetwork) {
|
||||
if (zone.getNetworkType() == NetworkType.Advanced && vlanId.equals(Vlan.UNTAGGED) && !forVirtualNetwork) {
|
||||
throw new InvalidParameterValueException("Direct untagged network is not supported for the zone " + zone.getId() + " of type " + zone.getNetworkType());
|
||||
} else if (zone.getNetworkType() == DataCenterNetworkType.Basic && !(vlanId.equals(Vlan.UNTAGGED) && !forVirtualNetwork)) {
|
||||
} else if (zone.getNetworkType() == NetworkType.Basic && !(vlanId.equals(Vlan.UNTAGGED) && !forVirtualNetwork)) {
|
||||
throw new InvalidParameterValueException("Only direct untagged network is supported in the zone " + zone.getId() + " of type " + zone.getNetworkType());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class DataCenterVO implements DataCenter {
|
|||
|
||||
@Column(name="networktype")
|
||||
@Enumerated(EnumType.STRING)
|
||||
DataCenterNetworkType networkType;
|
||||
NetworkType networkType;
|
||||
|
||||
@Column(name="dns_provider")
|
||||
private String dnsProvider = "VirtualRouter";
|
||||
|
|
@ -146,12 +146,12 @@ public class DataCenterVO implements DataCenter {
|
|||
this.firewallProvider = firewallProvider;
|
||||
}
|
||||
|
||||
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId, DataCenterNetworkType zoneType) {
|
||||
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId, NetworkType zoneType) {
|
||||
this(name, description, dns1, dns2, dns3, dns4, vnet, guestCidr, domain, domainId, zoneType);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId, DataCenterNetworkType zoneType) {
|
||||
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId, NetworkType zoneType) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.dns1 = dns1;
|
||||
|
|
@ -294,12 +294,12 @@ public class DataCenterVO implements DataCenter {
|
|||
this.domain = domain;
|
||||
}
|
||||
|
||||
public void setNetworkType(DataCenterNetworkType zoneNetworkType) {
|
||||
public void setNetworkType(NetworkType zoneNetworkType) {
|
||||
this.networkType = zoneNetworkType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataCenterNetworkType getNetworkType() {
|
||||
public NetworkType getNetworkType() {
|
||||
return networkType;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ import com.cloud.dc.dao.VlanDao;
|
|||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
|
|
@ -756,8 +755,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtual, false, false, rateMbps, multicastRateMbps, null, true);
|
||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering);
|
||||
NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, GuestIpType.Direct, false, true, rateMbps, multicastRateMbps, null, true);
|
||||
NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, GuestIpType.Direct, false, false, rateMbps, multicastRateMbps, null, true);
|
||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering);
|
||||
NetworkOfferingVO defaultGuestDirectPodBasedNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectPodBasedNetworkOffering, "DirectPodBased", TrafficType.Guest, GuestIpType.DirectPodBased, true, false, rateMbps, multicastRateMbps, null, true);
|
||||
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectPodBasedNetworkOffering);
|
||||
|
||||
|
||||
AccountsUsingNetworkConfigurationSearch = _accountDao.createSearchBuilder();
|
||||
SearchBuilder<NetworkAccountVO> networkAccountSearch = _networkConfigDao.createSearchBuilderForAccount();
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
|
||||
@Override
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
||||
if (offering.getTrafficType() != TrafficType.Guest) {
|
||||
if (offering.getTrafficType() != TrafficType.Guest || offering.getGuestIpType() != GuestIpType.Virtual) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package com.cloud.offerings.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
|
@ -35,4 +36,6 @@ public interface NetworkOfferingDao extends GenericDao<NetworkOfferingVO, Long>
|
|||
NetworkOfferingVO findByServiceOffering(ServiceOfferingVO offering);
|
||||
|
||||
List<NetworkOfferingVO> listNonSystemNetworkOfferings();
|
||||
|
||||
List<NetworkOfferingVO> findByType(GuestIpType type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import javax.persistence.EntityExistsException;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
|
|
@ -27,6 +28,7 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
|||
final SearchBuilder<NetworkOfferingVO> NameSearch;
|
||||
final SearchBuilder<NetworkOfferingVO> ServiceOfferingSearch;
|
||||
final SearchBuilder<NetworkOfferingVO> SystemOfferingSearch;
|
||||
final SearchBuilder<NetworkOfferingVO> TypeSearch;
|
||||
|
||||
protected NetworkOfferingDaoImpl() {
|
||||
super();
|
||||
|
|
@ -35,6 +37,10 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
|||
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
NameSearch.done();
|
||||
|
||||
TypeSearch = createSearchBuilder();
|
||||
TypeSearch.and("guestIpType", TypeSearch.entity().getGuestIpType(), SearchCriteria.Op.EQ);
|
||||
TypeSearch.done();
|
||||
|
||||
ServiceOfferingSearch = createSearchBuilder();
|
||||
ServiceOfferingSearch.and("serviceoffering", ServiceOfferingSearch.entity().getGuestIpType(), SearchCriteria.Op.EQ);
|
||||
ServiceOfferingSearch.done();
|
||||
|
|
@ -100,4 +106,10 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
|||
sc.setParameters("system", false);
|
||||
return this.listIncludingRemovedBy(sc, null);
|
||||
}
|
||||
|
||||
public List<NetworkOfferingVO> findByType(GuestIpType type) {
|
||||
SearchCriteria<NetworkOfferingVO> sc = TypeSearch.create();
|
||||
sc.setParameters("guestIpType", type);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ import org.apache.log4j.Logger;
|
|||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationVO;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.DataCenter.DataCenterNetworkType;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.domain.DomainVO;
|
||||
|
|
@ -78,6 +78,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
private final DiskOfferingDao _diskOfferingDao;
|
||||
private final ServiceOfferingDao _serviceOfferingDao;
|
||||
private final DomainDao _domainDao;
|
||||
|
||||
|
||||
public ConfigurationServerImpl() {
|
||||
ComponentLocator locator = ComponentLocator.getLocator(Name);
|
||||
|
|
@ -182,32 +183,44 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
s_logger.debug("ConfigurationServer saved \"" + hostIpAdr + "\" as host.");
|
||||
}
|
||||
|
||||
// Get the gateway and netmask of this machine
|
||||
String[] gatewayAndNetmask = getGatewayAndNetmask();
|
||||
|
||||
if (gatewayAndNetmask != null) {
|
||||
String gateway = gatewayAndNetmask[0];
|
||||
String netmask = gatewayAndNetmask[1];
|
||||
long cidrSize = NetUtils.getCidrSize(netmask);
|
||||
|
||||
// Create a default zone
|
||||
String dns = getDNS();
|
||||
if (dns == null) {
|
||||
dns = "4.2.2.2";
|
||||
}
|
||||
DataCenterVO zone = createZone(User.UID_SYSTEM, "Default", dns, null, dns, null, null,"10.1.1.0/24", null, null, DataCenterNetworkType.Basic);
|
||||
|
||||
// Create a default pod
|
||||
String networkType = _configDao.getValue("network.type");
|
||||
if (networkType != null && networkType.equals("vnet")) {
|
||||
createPod(User.UID_SYSTEM, "Default", zone.getId(), "169.254.1.1", "169.254.1.0/24", "169.254.1.2", "169.254.1.254");
|
||||
} else {
|
||||
createPod(User.UID_SYSTEM, "Default", zone.getId(), gateway, gateway + "/" + cidrSize, null, null);
|
||||
}
|
||||
s_logger.debug("ConfigurationServer saved a default pod and zone, with gateway: " + gateway + " and netmask: " + netmask);
|
||||
} else {
|
||||
s_logger.debug("ConfigurationServer could not detect the gateway and netmask of the management server.");
|
||||
}
|
||||
// // Get the gateway and netmask of this machine
|
||||
// String[] gatewayAndNetmask = getGatewayAndNetmask();
|
||||
//
|
||||
// if (gatewayAndNetmask != null) {
|
||||
// String gateway = gatewayAndNetmask[0];
|
||||
// String netmask = gatewayAndNetmask[1];
|
||||
// long cidrSize = NetUtils.getCidrSize(netmask);
|
||||
//
|
||||
// // Create a default zone
|
||||
// String dns = getDNS();
|
||||
// if (dns == null) {
|
||||
// dns = "4.2.2.2";
|
||||
// }
|
||||
// DataCenterVO zone = createZone(User.UID_SYSTEM, "Default", dns, null, dns, null, null,"10.1.1.0/24", null, null, NetworkType.Basic);
|
||||
//
|
||||
// //Create untagged network
|
||||
// DataCenterDeployment plan = new DataCenterDeployment(zone.getId(), null, null, null);
|
||||
// NetworkVO userNetwork = new NetworkVO();
|
||||
// userNetwork.setBroadcastDomainType(BroadcastDomainType.Native);
|
||||
//
|
||||
// Account systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
|
||||
// List<NetworkOfferingVO> networkOffering = _networkOfferingDao.findByType(GuestIpType.DirectPodBased);
|
||||
// if (networkOffering == null || networkOffering.isEmpty()) {
|
||||
// throw new CloudRuntimeException("No default DirectPodBased network offering is found");
|
||||
// }
|
||||
// _networkMgr.setupNetworkConfiguration(systemAccount, networkOffering.get(0), userNetwork, plan, null, null, true);
|
||||
//
|
||||
// // Create a default pod
|
||||
// String networkType = _configDao.getValue("network.type");
|
||||
// if (networkType != null && networkType.equals("vnet")) {
|
||||
// createPod(User.UID_SYSTEM, "Default", zone.getId(), "169.254.1.1", "169.254.1.0/24", "169.254.1.2", "169.254.1.254");
|
||||
// } else {
|
||||
// createPod(User.UID_SYSTEM, "Default", zone.getId(), gateway, gateway + "/" + cidrSize, null, null);
|
||||
// }
|
||||
// s_logger.debug("ConfigurationServer saved a default pod and zone, with gateway: " + gateway + " and netmask: " + netmask);
|
||||
// } else {
|
||||
// s_logger.debug("ConfigurationServer could not detect the gateway and netmask of the management server.");
|
||||
// }
|
||||
|
||||
// generate a single sign-on key
|
||||
updateSSOKey();
|
||||
|
|
@ -531,7 +544,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, String domain, Long domainId, DataCenterNetworkType zoneType) throws InvalidParameterValueException, InternalErrorException {
|
||||
private DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId, NetworkType zoneType) throws InvalidParameterValueException, InternalErrorException {
|
||||
int vnetStart = 0;
|
||||
int vnetEnd = 0;
|
||||
if (vnetRange != null) {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ import com.cloud.configuration.ConfigurationManager;
|
|||
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.configuration.dao.ResourceLimitDao;
|
||||
import com.cloud.dc.DataCenter.DataCenterNetworkType;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
|
|
@ -3704,7 +3704,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
|
||||
s_logger.debug("Allocating in the DB for vm");
|
||||
|
||||
if (dc.getNetworkType() == DataCenterNetworkType.Basic && networkList == null) {
|
||||
if (dc.getNetworkType() == NetworkType.Basic && networkList == null) {
|
||||
Long singleNetworkId = null;
|
||||
SearchBuilder<NetworkVO> sb = _networkDao.createSearchBuilder();
|
||||
sb.and("broadcastDomainType", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
|
|
|
|||
Loading…
Reference in New Issue