mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
1) Create default networks for zones specified in server-setup.xml file
2) Direct pod based netwoks is taken care by DirectNetworkGuru now
This commit is contained in:
parent
84edea9c0f
commit
65f53e3910
@ -94,5 +94,8 @@
|
|||||||
<dao name="host zone configuration server" class="com.cloud.dc.dao.DataCenterDaoImpl" singleton="false"/>
|
<dao name="host zone configuration server" class="com.cloud.dc.dao.DataCenterDaoImpl" singleton="false"/>
|
||||||
<dao name="host pod configuration server" class="com.cloud.dc.dao.HostPodDaoImpl" singleton="false"/>
|
<dao name="host pod configuration server" class="com.cloud.dc.dao.HostPodDaoImpl" singleton="false"/>
|
||||||
<dao name="DomainDao" class="com.cloud.domain.dao.DomainDaoImpl" singleton="false"/>
|
<dao name="DomainDao" class="com.cloud.domain.dao.DomainDaoImpl" singleton="false"/>
|
||||||
|
<dao name="NetworkOfferingDao" class="com.cloud.offerings.dao.NetworkOfferingDaoImpl" singleton="false"/>
|
||||||
|
<dao name="DataCenterDao" class="com.cloud.dc.dao.DataCenterDaoImpl" singleton="false"/>
|
||||||
|
<dao name="NetworkDao" class="com.cloud.network.dao.NetworkDaoImpl" singleton="false"/>
|
||||||
</configuration-server>
|
</configuration-server>
|
||||||
</components.xml>
|
</components.xml>
|
||||||
|
|||||||
@ -46,7 +46,6 @@ import com.cloud.api.commands.AddVpnUserCmd;
|
|||||||
import com.cloud.api.commands.AssociateIPAddrCmd;
|
import com.cloud.api.commands.AssociateIPAddrCmd;
|
||||||
import com.cloud.api.commands.CreateNetworkCmd;
|
import com.cloud.api.commands.CreateNetworkCmd;
|
||||||
import com.cloud.api.commands.CreateRemoteAccessVpnCmd;
|
import com.cloud.api.commands.CreateRemoteAccessVpnCmd;
|
||||||
import com.cloud.api.commands.DeleteNetworkCmd;
|
|
||||||
import com.cloud.api.commands.DeleteRemoteAccessVpnCmd;
|
import com.cloud.api.commands.DeleteRemoteAccessVpnCmd;
|
||||||
import com.cloud.api.commands.DisassociateIPAddrCmd;
|
import com.cloud.api.commands.DisassociateIPAddrCmd;
|
||||||
import com.cloud.api.commands.ListNetworksCmd;
|
import com.cloud.api.commands.ListNetworksCmd;
|
||||||
|
|||||||
@ -51,7 +51,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
||||||
if (!(offering.getTrafficType() == TrafficType.Public && offering.getGuestIpType() == GuestIpType.Direct)) {
|
if (!(offering.getTrafficType() == TrafficType.Public && (offering.getGuestIpType() == GuestIpType.Direct || offering.getGuestIpType() == GuestIpType.DirectPodBased))) {
|
||||||
s_logger.trace("We only take care of public direct network, so this is no ours");
|
s_logger.trace("We only take care of public direct network, so this is no ours");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import java.security.MessageDigest;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -52,7 +53,16 @@ import com.cloud.domain.DomainVO;
|
|||||||
import com.cloud.domain.dao.DomainDao;
|
import com.cloud.domain.dao.DomainDao;
|
||||||
import com.cloud.exception.InternalErrorException;
|
import com.cloud.exception.InternalErrorException;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
|
import com.cloud.network.Network.State;
|
||||||
|
import com.cloud.network.NetworkVO;
|
||||||
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
|
import com.cloud.network.Networks.Mode;
|
||||||
|
import com.cloud.network.Networks.TrafficType;
|
||||||
|
import com.cloud.network.dao.NetworkDao;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
|
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||||
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.service.dao.ServiceOfferingDao;
|
import com.cloud.service.dao.ServiceOfferingDao;
|
||||||
import com.cloud.storage.DiskOfferingVO;
|
import com.cloud.storage.DiskOfferingVO;
|
||||||
@ -78,6 +88,9 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||||||
private final DiskOfferingDao _diskOfferingDao;
|
private final DiskOfferingDao _diskOfferingDao;
|
||||||
private final ServiceOfferingDao _serviceOfferingDao;
|
private final ServiceOfferingDao _serviceOfferingDao;
|
||||||
private final DomainDao _domainDao;
|
private final DomainDao _domainDao;
|
||||||
|
private final NetworkOfferingDao _networkOfferingDao;
|
||||||
|
private final DataCenterDao _dataCenterDao;
|
||||||
|
private final NetworkDao _networkDao;
|
||||||
|
|
||||||
|
|
||||||
public ConfigurationServerImpl() {
|
public ConfigurationServerImpl() {
|
||||||
@ -88,7 +101,10 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||||||
_podDao = locator.getDao(HostPodDao.class);
|
_podDao = locator.getDao(HostPodDao.class);
|
||||||
_diskOfferingDao = locator.getDao(DiskOfferingDao.class);
|
_diskOfferingDao = locator.getDao(DiskOfferingDao.class);
|
||||||
_serviceOfferingDao = locator.getDao(ServiceOfferingDao.class);
|
_serviceOfferingDao = locator.getDao(ServiceOfferingDao.class);
|
||||||
|
_networkOfferingDao = locator.getDao(NetworkOfferingDao.class);
|
||||||
_domainDao = locator.getDao(DomainDao.class);
|
_domainDao = locator.getDao(DomainDao.class);
|
||||||
|
_dataCenterDao = locator.getDao(DataCenterDao.class);
|
||||||
|
_networkDao = locator.getDao(NetworkDao.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -224,6 +240,13 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||||||
|
|
||||||
// generate a single sign-on key
|
// generate a single sign-on key
|
||||||
updateSSOKey();
|
updateSSOKey();
|
||||||
|
|
||||||
|
//Create default network offerings
|
||||||
|
createDefaultNetworkOfferings();
|
||||||
|
|
||||||
|
//Create default networks
|
||||||
|
createDefaultNetworks();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the public and private keys in the database
|
// store the public and private keys in the database
|
||||||
@ -684,4 +707,89 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||||||
|
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createDefaultNetworkOfferings() {
|
||||||
|
Integer rateMbps = getIntegerConfigValue(Config.NetworkThrottlingRate.key(), null);
|
||||||
|
Integer multicastRateMbps = getIntegerConfigValue(Config.MulticastThrottlingRate.key(), null);
|
||||||
|
|
||||||
|
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmPublicNetwork, TrafficType.Public, null);
|
||||||
|
publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
|
||||||
|
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmManagementNetwork, TrafficType.Management, null);
|
||||||
|
managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
|
||||||
|
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmControlNetwork, TrafficType.Control, null);
|
||||||
|
controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
|
||||||
|
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmStorageNetwork, TrafficType.Storage, null);
|
||||||
|
storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
|
||||||
|
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.Public, GuestIpType.Direct, false, false, rateMbps, multicastRateMbps, null, true);
|
||||||
|
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering);
|
||||||
|
NetworkOfferingVO defaultGuestDirectPodBasedNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectPodBasedNetworkOffering, "DirectPodBased", TrafficType.Public, GuestIpType.DirectPodBased, true, false, rateMbps, multicastRateMbps, null, true);
|
||||||
|
defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectPodBasedNetworkOffering);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer getIntegerConfigValue(String configKey, Integer dflt) {
|
||||||
|
String value = _configDao.getValue(configKey);
|
||||||
|
if (value != null) {
|
||||||
|
return Integer.parseInt(value);
|
||||||
|
}
|
||||||
|
return dflt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createDefaultNetworks() {
|
||||||
|
List<DataCenterVO> zones = _dataCenterDao.listAll();
|
||||||
|
long id = 1;
|
||||||
|
|
||||||
|
HashMap<TrafficType, String> guruNames = new HashMap<TrafficType, String>();
|
||||||
|
guruNames.put(TrafficType.Public, "PublicNetworkGuru-com.cloud.network.guru.PublicNetworkGuru");
|
||||||
|
guruNames.put(TrafficType.Management, "PodBasedNetworkGuru-com.cloud.network.guru.PodBasedNetworkGuru");
|
||||||
|
guruNames.put(TrafficType.Control, "ControlNetworkGuru-com.cloud.network.guru.ControlNetworkGuru");
|
||||||
|
guruNames.put(TrafficType.Storage, "PodBasedNetworkGuru-com.cloud.network.guru.PodBasedNetworkGuru");
|
||||||
|
|
||||||
|
for (DataCenterVO zone : zones) {
|
||||||
|
long zoneId = zone.getId();
|
||||||
|
long accountId = 1L;
|
||||||
|
Long domainId = zone.getDomainId();
|
||||||
|
|
||||||
|
if (domainId == null) {
|
||||||
|
domainId = 1L;
|
||||||
|
}
|
||||||
|
//Create default networks - system only
|
||||||
|
List<NetworkOfferingVO> ntwkOff = _networkOfferingDao.listSystemNetworkOfferings();
|
||||||
|
|
||||||
|
for (NetworkOfferingVO offering : ntwkOff) {
|
||||||
|
if (offering.isSystemOnly()) {
|
||||||
|
long related = id;
|
||||||
|
long networkOfferingId = offering.getId();
|
||||||
|
Mode mode = Mode.Static;
|
||||||
|
|
||||||
|
BroadcastDomainType broadcastDomainType = null;
|
||||||
|
TrafficType trafficType= offering.getTrafficType();
|
||||||
|
GuestIpType guestIpType = offering.getGuestIpType();
|
||||||
|
if (offering.getGuestIpType() != GuestIpType.DirectPodBased) {
|
||||||
|
if (trafficType == TrafficType.Management || trafficType == TrafficType.Storage) {
|
||||||
|
broadcastDomainType = BroadcastDomainType.Native;
|
||||||
|
} else if (trafficType == TrafficType.Public) {
|
||||||
|
broadcastDomainType = BroadcastDomainType.Vlan;
|
||||||
|
} else if (trafficType == TrafficType.Control) {
|
||||||
|
broadcastDomainType = BroadcastDomainType.LinkLocal;
|
||||||
|
}
|
||||||
|
} else if (zone.getNetworkType() == NetworkType.Basic && offering.getGuestIpType() == GuestIpType.DirectPodBased){
|
||||||
|
broadcastDomainType = BroadcastDomainType.Vlan;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (broadcastDomainType != null) {
|
||||||
|
NetworkVO network = new NetworkVO(id, trafficType, guestIpType, mode, broadcastDomainType, networkOfferingId, zoneId, domainId, accountId, related, null, null, true);
|
||||||
|
network.setGuruName(guruNames.get(network.getTrafficType()));
|
||||||
|
network.setDns1(zone.getDns1());
|
||||||
|
network.setDns2(zone.getDns2());
|
||||||
|
network.setState(State.Implemented);
|
||||||
|
_networkDao.persist(network, false);
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -296,7 +296,7 @@ INSERT INTO `cloud`.`sequence` (name, value) VALUES ('public_mac_address_seq', 1
|
|||||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('private_mac_address_seq', 1);
|
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('private_mac_address_seq', 1);
|
||||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('storage_pool_seq', 200);
|
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('storage_pool_seq', 200);
|
||||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('volume_seq', 1);
|
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('volume_seq', 1);
|
||||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('networks_seq', 1);
|
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('networks_seq', 200);
|
||||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('snapshots_seq', 1);
|
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('snapshots_seq', 1);
|
||||||
|
|
||||||
CREATE TABLE `cloud`.`volumes` (
|
CREATE TABLE `cloud`.`volumes` (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user