mirror of https://github.com/apache/cloudstack.git
my changes
This commit is contained in:
parent
89cd3131bf
commit
e0165dd2ef
|
|
@ -17,18 +17,20 @@
|
|||
*/
|
||||
package com.cloud.offering;
|
||||
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
|
||||
/**
|
||||
* Describes network offering
|
||||
*
|
||||
*/
|
||||
public interface NetworkOffering {
|
||||
public enum GuestIpType {
|
||||
Virtualized,
|
||||
DirectSingle,
|
||||
DirectDual
|
||||
}
|
||||
|
||||
public enum GuestIpType {
|
||||
Virtualized,
|
||||
DirectSingle,
|
||||
DirectDual
|
||||
}
|
||||
|
||||
long getId();
|
||||
|
||||
/**
|
||||
|
|
@ -60,4 +62,6 @@ public interface NetworkOffering {
|
|||
* @return concurrent connections to be supported.
|
||||
*/
|
||||
Integer getConcurrentConnections();
|
||||
|
||||
TrafficType getTrafficType();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,13 +22,7 @@ package com.cloud.offering;
|
|||
* offered.
|
||||
*/
|
||||
public interface ServiceOffering {
|
||||
public enum GuestIpType {
|
||||
Virtualized,
|
||||
DirectSingle,
|
||||
DirectDual
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return user readable description
|
||||
*/
|
||||
String getName();
|
||||
|
|
@ -66,7 +60,7 @@ public interface ServiceOffering {
|
|||
/**
|
||||
* @return the type of IP address to allocate as the primary ip address to a guest
|
||||
*/
|
||||
GuestIpType getGuestIpType();
|
||||
NetworkOffering.GuestIpType getGuestIpType();
|
||||
|
||||
/**
|
||||
* @return whether or not the service offering requires local storage
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
package com.cloud.offerings;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
|
|
@ -26,7 +28,9 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name="network_offerings")
|
||||
|
|
@ -54,6 +58,19 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
@Column(name="type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
GuestIpType guestIpType;
|
||||
|
||||
@Column(name="traffic_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
TrafficType trafficType;
|
||||
|
||||
@Column(name="system_only")
|
||||
boolean systemOnly;
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
Date removed;
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
Date created;
|
||||
|
||||
@Override
|
||||
public String getDisplayText() {
|
||||
|
|
@ -69,6 +86,11 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrafficType getTrafficType() {
|
||||
return trafficType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMulticastRateMbps() {
|
||||
|
|
@ -85,21 +107,44 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
return rateMbps;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public boolean isSystemOnly() {
|
||||
return systemOnly;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getConcurrentConnections() {
|
||||
return concurrentConnections;
|
||||
}
|
||||
|
||||
public NetworkOfferingVO() {
|
||||
}
|
||||
|
||||
public NetworkOfferingVO(String name, String displayText, GuestIpType type, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections) {
|
||||
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections) {
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.guestIpType = type;
|
||||
this.rateMbps = rateMbps;
|
||||
this.multicastRateMbps = multicastRateMbps;
|
||||
this.concurrentConnections = concurrentConnections;
|
||||
this.trafficType = trafficType;
|
||||
this.systemOnly = systemOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getConcurrentConnections() {
|
||||
return concurrentConnections;
|
||||
|
||||
/**
|
||||
* Network Offering for all system vms.
|
||||
* @param name
|
||||
* @param trafficType
|
||||
* @param type
|
||||
*/
|
||||
public NetworkOfferingVO(String name, TrafficType trafficType, GuestIpType type) {
|
||||
this(name, "System Offering for " + name, trafficType, type, true, null, null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import javax.persistence.PrimaryKeyJoinColumn;
|
|||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
|
||||
|
|
@ -55,13 +56,13 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
|||
|
||||
@Column(name="guest_ip_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private GuestIpType guestIpType;
|
||||
private NetworkOffering.GuestIpType guestIpType;
|
||||
|
||||
protected ServiceOfferingVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags) {
|
||||
public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, NetworkOffering.GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags) {
|
||||
super(name, displayText, false, tags, recreatable, useLocalStorage);
|
||||
this.cpu = cpu;
|
||||
this.ramSize = ramSize;
|
||||
|
|
@ -135,11 +136,11 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
|||
return multicastRateMbps;
|
||||
}
|
||||
|
||||
public void setGuestIpType(GuestIpType guestIpType) {
|
||||
public void setGuestIpType(NetworkOffering.GuestIpType guestIpType) {
|
||||
this.guestIpType = guestIpType;
|
||||
}
|
||||
|
||||
public GuestIpType getGuestIpType() {
|
||||
public NetworkOffering.GuestIpType getGuestIpType() {
|
||||
return guestIpType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import javax.ejb.Local;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
|
|
@ -279,7 +279,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
|||
SearchCriteria<UserVmVO> sc = AccountDataCenterVirtualSearch.create();
|
||||
sc.setParameters("account", accountId);
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setJoinParameters("offeringSearch", "guestIpType", ServiceOffering.GuestIpType.Virtualized);
|
||||
sc.setJoinParameters("offeringSearch", "guestIpType", NetworkOffering.GuestIpType.Virtualized);
|
||||
|
||||
return listActiveBy(sc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,9 @@ import com.cloud.configuration.dao.ConfigurationDao;
|
|||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
|
|
@ -252,14 +253,14 @@ public class UserConcentratedAllocator implements PodAllocator {
|
|||
so = _offeringDao.findById(userVm.getServiceOfferingId());
|
||||
} else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomP", 1,
|
||||
_proxyRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
} else {
|
||||
assert(false) : "Unsupported system vm type";
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
}
|
||||
|
||||
if(capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
|
|
@ -142,7 +143,7 @@ public class CreateServiceOfferingCmd extends BaseCmd{
|
|||
storageType = offering.getUseLocalStorage() ? "local" : "shared";
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.STORAGE_TYPE.getName(), storageType));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.OFFER_HA.getName(), offering.getOfferHA()));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.USE_VIRTUAL_NETWORK.getName(), (offering.getGuestIpType().equals(GuestIpType.Virtualized))));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.USE_VIRTUAL_NETWORK.getName(), (offering.getGuestIpType().equals(NetworkOffering.GuestIpType.Virtualized))));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.TAGS.getName(), offering.getTags()));
|
||||
}
|
||||
return returnValues;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -123,7 +124,7 @@ public class ListServiceOfferingsCmd extends BaseCmd {
|
|||
String storageType = offering.getUseLocalStorage() ? "local" : "shared";
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.STORAGE_TYPE.getName(), storageType));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.OFFER_HA.getName(), offering.getOfferHA()));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.USE_VIRTUAL_NETWORK.getName(), (offering.getGuestIpType().equals(GuestIpType.Virtualized))));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.USE_VIRTUAL_NETWORK.getName(), (offering.getGuestIpType().equals(NetworkOffering.GuestIpType.Virtualized))));
|
||||
offeringData.add(new Pair<String, Object>(BaseCmd.Properties.TAGS.getName(), (offering.getTags())));
|
||||
|
||||
soTag[i++] = offeringData;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
|
|
@ -95,7 +96,7 @@ public class UpdateServiceOfferingCmd extends BaseCmd{
|
|||
String storageType = offering.getUseLocalStorage() ? "local" : "shared";
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.STORAGE_TYPE.getName(), storageType));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.OFFER_HA.getName(), offering.getOfferHA()));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.USE_VIRTUAL_NETWORK.getName(), (offering.getGuestIpType().equals(GuestIpType.Virtualized))));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.USE_VIRTUAL_NETWORK.getName(), (offering.getGuestIpType().equals(NetworkOffering.GuestIpType.Virtualized))));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.TAGS.getName(), offering.getTags()));
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service offering " + offeringId);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ import com.cloud.event.dao.EventDao;
|
|||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
|
|
@ -799,7 +800,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
GuestIpType guestIpType = useVirtualNetwork ? GuestIpType.Virtualized : GuestIpType.DirectSingle;
|
||||
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtualized : NetworkOffering.GuestIpType.DirectSingle;
|
||||
tags = cleanupTags(tags);
|
||||
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags);
|
||||
|
||||
|
|
@ -833,7 +834,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
}
|
||||
|
||||
if (useVirtualNetwork != null) {
|
||||
GuestIpType guestIpType = useVirtualNetwork ? GuestIpType.Virtualized : GuestIpType.DirectSingle;
|
||||
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtualized : NetworkOffering.GuestIpType.DirectSingle;
|
||||
offering.setGuestIpType(guestIpType);
|
||||
}
|
||||
|
||||
|
|
@ -848,7 +849,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
if (_serviceOfferingDao.update(serviceOfferingId, offering)) {
|
||||
offering = _serviceOfferingDao.findById(serviceOfferingId);
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_EDIT, "Successfully updated service offering with name: " + offering.getName() + ".", "soId=" + offering.getId(), "name=" + offering.getName(),
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == GuestIpType.Virtualized), "tags=" + offering.getTags());
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized), "tags=" + offering.getTags());
|
||||
return offering;
|
||||
} else {
|
||||
return null;
|
||||
|
|
@ -891,7 +892,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
|
||||
if (_serviceOfferingDao.remove(serviceOfferingId)) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_EDIT, "Successfully deleted service offering with name: " + offering.getName(), "soId=" + serviceOfferingId, "name=" + offering.getName(),
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == GuestIpType.Virtualized));
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -96,8 +96,9 @@ import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo;
|
|||
import com.cloud.maid.StackMaid;
|
||||
import com.cloud.network.IpAddrAllocator;
|
||||
import com.cloud.network.IpAddrAllocator.networkInfo;
|
||||
import com.cloud.network.NetworkProfileVO;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.StorageManager;
|
||||
|
|
@ -134,6 +135,7 @@ import com.cloud.vm.VirtualMachine;
|
|||
import com.cloud.vm.VirtualMachine.Event;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VmManager;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
import com.google.gson.Gson;
|
||||
|
|
@ -221,7 +223,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
private EventDao _eventDao;
|
||||
@Inject
|
||||
ServiceOfferingDao _offeringDao;
|
||||
@Inject
|
||||
private IpAddrAllocator _IpAllocator;
|
||||
|
||||
private ConsoleProxyListener _listener;
|
||||
|
|
@ -231,6 +232,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
|
||||
@Inject
|
||||
private AsyncJobManager _asyncMgr;
|
||||
|
||||
@Inject
|
||||
private VmManager _vmMgr;
|
||||
|
||||
private final ScheduledExecutorService _capacityScanScheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory("CP-Scan"));
|
||||
private final ExecutorService _requestHandlerScheduler = Executors.newCachedThreadPool(new NamedThreadFactory("Request-handler"));
|
||||
|
|
@ -248,6 +252,10 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
|
||||
private String _domain;
|
||||
private String _instance;
|
||||
private NetworkProfileVO _publicNetworkProfile;
|
||||
private NetworkProfileVO _managementNetworkProfile;
|
||||
private NetworkProfileVO _controlNetworkProfile;
|
||||
|
||||
|
||||
// private String _privateNetmask;
|
||||
private int _proxyCmdPort = DEFAULT_PROXY_CMD_PORT;
|
||||
|
|
@ -989,6 +997,102 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
}
|
||||
}
|
||||
|
||||
@DB
|
||||
protected Map<String, Object> createProxyInstance2(long dataCenterId) {
|
||||
|
||||
Map<String, Object> context = new HashMap<String, Object>();
|
||||
String publicIpAddress = null;
|
||||
|
||||
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
DataCenterVO dc = _dcDao.findById(dataCenterId);
|
||||
assert (dc != null);
|
||||
context.put("dc", dc);
|
||||
|
||||
// this will basically allocate the pod based on data center id as
|
||||
// we use system user id here
|
||||
Set<Long> avoidPods = new HashSet<Long>();
|
||||
Pair<HostPodVO, Long> pod = null;
|
||||
networkInfo publicIpAndVlan = null;
|
||||
|
||||
// About MAC address allocation
|
||||
// MAC address used by User VM is inherited from DomR MAC address,
|
||||
// with the least 16 bits overrided. to avoid
|
||||
// potential conflicts, domP will mask bit 31
|
||||
//
|
||||
String[] macAddresses = _dcDao.getNextAvailableMacAddressPair(dataCenterId, (1L << 31));
|
||||
String privateMacAddress = macAddresses[0];
|
||||
String publicMacAddress = macAddresses[1];
|
||||
macAddresses = _dcDao.getNextAvailableMacAddressPair(dataCenterId, (1L << 31));
|
||||
String guestMacAddress = macAddresses[0];
|
||||
while ((pod = _agentMgr.findPod(_template, _serviceOffering, dc, Account.ACCOUNT_ID_SYSTEM, avoidPods)) != null) {
|
||||
publicIpAndVlan = allocPublicIpAddress(dataCenterId, pod.first().getId(), publicMacAddress);
|
||||
if (publicIpAndVlan == null) {
|
||||
s_logger.warn("Unable to allocate public IP address for console proxy vm in data center : " + dataCenterId + ", pod="
|
||||
+ pod.first().getId());
|
||||
avoidPods.add(pod.first().getId());
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pod == null || publicIpAndVlan == null) {
|
||||
s_logger.warn("Unable to allocate pod for console proxy vm in data center : " + dataCenterId);
|
||||
|
||||
context.put("proxyVmId", (long) 0);
|
||||
return context;
|
||||
}
|
||||
|
||||
long id = _consoleProxyDao.getNextInSequence(Long.class, "id");
|
||||
|
||||
context.put("publicIpAddress", publicIpAndVlan._ipAddr);
|
||||
context.put("pod", pod);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Pod allocated " + pod.first().getName());
|
||||
}
|
||||
|
||||
String cidrNetmask = NetUtils.getCidrNetmask(pod.first().getCidrSize());
|
||||
|
||||
// Find the VLAN ID, VLAN gateway, and VLAN netmask for
|
||||
// publicIpAddress
|
||||
publicIpAddress = publicIpAndVlan._ipAddr;
|
||||
|
||||
String vlanGateway = publicIpAndVlan._gateWay;
|
||||
String vlanNetmask = publicIpAndVlan._netMask;
|
||||
|
||||
txn.start();
|
||||
ConsoleProxyVO proxy;
|
||||
String name = VirtualMachineName.getConsoleProxyName(id, _instance).intern();
|
||||
proxy = new ConsoleProxyVO(id, name, guestMacAddress, null, NetUtils.getLinkLocalNetMask(), privateMacAddress, null, cidrNetmask,
|
||||
_template.getId(), _template.getGuestOSId(), publicMacAddress, publicIpAddress, vlanNetmask, publicIpAndVlan._vlanDbId,
|
||||
publicIpAndVlan._vlanid, pod.first().getId(), dataCenterId, vlanGateway, null, dc.getDns1(), dc.getDns2(), _domain,
|
||||
_proxyRamSize, 0);
|
||||
|
||||
proxy.setLastHostId(pod.second());
|
||||
proxy = _consoleProxyDao.persist(proxy);
|
||||
long proxyVmId = proxy.getId();
|
||||
|
||||
final EventVO event = new EventVO();
|
||||
event.setUserId(User.UID_SYSTEM);
|
||||
event.setAccountId(Account.ACCOUNT_ID_SYSTEM);
|
||||
event.setType(EventTypes.EVENT_PROXY_CREATE);
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
event.setDescription("New console proxy created - " + proxy.getName());
|
||||
_eventDao.persist(event);
|
||||
txn.commit();
|
||||
|
||||
context.put("proxyVmId", proxyVmId);
|
||||
return context;
|
||||
} catch (Throwable e) {
|
||||
s_logger.error("Unexpected exception : ", e);
|
||||
|
||||
context.put("proxyVmId", (long) 0);
|
||||
return context;
|
||||
}
|
||||
}
|
||||
|
||||
@DB
|
||||
protected ConsoleProxyVO allocProxyStorage(long dataCenterId, long proxyVmId) {
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
|
|
@ -2224,7 +2328,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
}
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean((String) params.get(Config.SystemVMUseLocalStorage.key()));
|
||||
_serviceOffering = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized,
|
||||
_serviceOffering = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized,
|
||||
useLocalStorage, true, null);
|
||||
_serviceOffering.setUniqueName("Cloud.com-ConsoleProxy");
|
||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||
|
|
@ -2232,7 +2336,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
if (_template == null) {
|
||||
throw new ConfigurationException("Unable to find the template for console proxy VMs");
|
||||
}
|
||||
|
||||
|
||||
_capacityScanScheduler.scheduleAtFixedRate(getCapacityScanTask(), STARTUP_DELAY, _capacityScanInterval, TimeUnit.MILLISECONDS);
|
||||
|
||||
if (s_logger.isInfoEnabled())
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ import com.cloud.host.Host;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.migration.DiskOffering21VO.Type;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
|
|
@ -305,7 +306,7 @@ public class Db20to21MigrationUtil {
|
|||
_configDao.getValue(Config.ConsoleProxyRamSize.key()),
|
||||
ConsoleProxyManager.DEFAULT_PROXY_VM_RAMSIZE);
|
||||
ServiceOffering21VO soConsoleProxy = new ServiceOffering21VO("Fake Offering For DomP", 1,
|
||||
proxyRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized,
|
||||
proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized,
|
||||
useLocalStorage, true, null);
|
||||
soConsoleProxy.setId(seq++);
|
||||
soConsoleProxy.setUniqueName("Cloud.com-ConsoleProxy");
|
||||
|
|
@ -316,7 +317,7 @@ public class Db20to21MigrationUtil {
|
|||
_configDao.getValue(Config.SecStorageVmRamSize.key()),
|
||||
SecondaryStorageVmManager.DEFAULT_SS_VM_RAMSIZE);
|
||||
ServiceOffering21VO soSecondaryVm = new ServiceOffering21VO("Fake Offering For Secondary Storage VM", 1,
|
||||
secStorageVmRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
soSecondaryVm.setId(seq++);
|
||||
soSecondaryVm.setUniqueName("Cloud.com-SecondaryStorage");
|
||||
soSecondaryVm = _serviceOffering21Dao.persist(soSecondaryVm);
|
||||
|
|
@ -324,7 +325,7 @@ public class Db20to21MigrationUtil {
|
|||
|
||||
int routerRamSize = NumbersUtil.parseInt(_configDao.getValue("router.ram.size"), 128);
|
||||
ServiceOffering21VO soDomainRouter = new ServiceOffering21VO("Fake Offering For DomR", 1,
|
||||
routerRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
soDomainRouter.setId(seq++);
|
||||
soDomainRouter.setUniqueName("Cloud.Com-SoftwareRouter");
|
||||
soDomainRouter = _serviceOffering21Dao.persist(soDomainRouter);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
|
|
@ -51,7 +52,7 @@ public class ServiceOffering20VO {
|
|||
|
||||
@Column(name="guest_ip_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private GuestIpType guestIpType = GuestIpType.Virtualized;
|
||||
private NetworkOffering.GuestIpType guestIpType = NetworkOffering.GuestIpType.Virtualized;
|
||||
|
||||
@Column(name="use_local_storage")
|
||||
private boolean useLocalStorage;
|
||||
|
|
@ -66,10 +67,10 @@ public class ServiceOffering20VO {
|
|||
}
|
||||
|
||||
public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, boolean localStorageRequired) {
|
||||
this(id, name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, GuestIpType.Virtualized, localStorageRequired);
|
||||
this(id, name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, NetworkOffering.GuestIpType.Virtualized, localStorageRequired);
|
||||
}
|
||||
|
||||
public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, GuestIpType guestIpType, boolean useLocalStorage) {
|
||||
public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, NetworkOffering.GuestIpType guestIpType, boolean useLocalStorage) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.cpu = cpu;
|
||||
|
|
@ -167,11 +168,11 @@ public class ServiceOffering20VO {
|
|||
return multicastRateMbps;
|
||||
}
|
||||
|
||||
public void setGuestIpType(GuestIpType guestIpType) {
|
||||
public void setGuestIpType(NetworkOffering.GuestIpType guestIpType) {
|
||||
this.guestIpType = guestIpType;
|
||||
}
|
||||
|
||||
public GuestIpType getGuestIpType() {
|
||||
public NetworkOffering.GuestIpType getGuestIpType() {
|
||||
return guestIpType;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import javax.persistence.PrimaryKeyJoinColumn;
|
|||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
|
||||
@Entity
|
||||
|
|
@ -36,13 +37,13 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
|
|||
|
||||
@Column(name="guest_ip_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private GuestIpType guestIpType;
|
||||
private NetworkOffering.GuestIpType guestIpType;
|
||||
|
||||
protected ServiceOffering21VO() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ServiceOffering21VO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags) {
|
||||
public ServiceOffering21VO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, NetworkOffering.GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags) {
|
||||
super(name, displayText, false, tags, recreatable, useLocalStorage);
|
||||
this.cpu = cpu;
|
||||
this.ramSize = ramSize;
|
||||
|
|
@ -116,11 +117,11 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
|
|||
return multicastRateMbps;
|
||||
}
|
||||
|
||||
public void setGuestIpType(GuestIpType guestIpType) {
|
||||
public void setGuestIpType(NetworkOffering.GuestIpType guestIpType) {
|
||||
this.guestIpType = guestIpType;
|
||||
}
|
||||
|
||||
public GuestIpType getGuestIpType() {
|
||||
public NetworkOffering.GuestIpType getGuestIpType() {
|
||||
return guestIpType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,11 +98,15 @@ import com.cloud.host.Host;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.SecurityGroupVMMapDao;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
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.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.StorageManager;
|
||||
|
|
@ -186,8 +190,8 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
@Inject AsyncJobManager _asyncMgr;
|
||||
@Inject StoragePoolDao _storagePoolDao = null;
|
||||
@Inject ServiceOfferingDao _serviceOfferingDao = null;
|
||||
@Inject
|
||||
private UserStatisticsDao _statsDao;
|
||||
@Inject UserStatisticsDao _statsDao = null;
|
||||
@Inject NetworkOfferingDao _networkOfferingDao = null;
|
||||
|
||||
long _routerTemplateId = -1;
|
||||
int _routerRamSize;
|
||||
|
|
@ -198,6 +202,10 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
int _routerCleanupInterval = 3600;
|
||||
int _routerStatsInterval = 300;
|
||||
private ServiceOfferingVO _offering;
|
||||
private NetworkOfferingVO _managementNetworkOffering;
|
||||
private NetworkOfferingVO _publicNetworkOffering;
|
||||
private NetworkOfferingVO _linkLocalNetworkOffering;
|
||||
private NetworkOfferingVO _guestNetworkOffering;
|
||||
private VMTemplateVO _template;
|
||||
|
||||
ScheduledExecutorService _executor;
|
||||
|
|
@ -207,6 +215,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
return destroyRouter(router.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendSshKeysToHost(Long hostId, String pubKey, String prvKey) {
|
||||
ModifySshKeysCommand cmd = new ModifySshKeysCommand(pubKey, prvKey);
|
||||
final Answer answer = _agentMgr.easySend(hostId, cmd);
|
||||
|
|
@ -219,7 +228,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
|
||||
@Override @DB
|
||||
public String assignSourceNatIpAddress(AccountVO account, final DataCenterVO dc, final String domain, final ServiceOfferingVO serviceOffering, long startEventId) throws ResourceAllocationException {
|
||||
if (serviceOffering.getGuestIpType() == GuestIpType.DirectDual || serviceOffering.getGuestIpType() == GuestIpType.DirectSingle) {
|
||||
if (serviceOffering.getGuestIpType() == NetworkOffering.GuestIpType.DirectDual || serviceOffering.getGuestIpType() == NetworkOffering.GuestIpType.DirectSingle) {
|
||||
return null;
|
||||
}
|
||||
final long dcId = dc.getId();
|
||||
|
|
@ -354,6 +363,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public DomainRouterVO createDhcpServerForDirectlyAttachedGuests(long userId, long accountId, DataCenterVO dc, HostPodVO pod, Long candidateHost, VlanVO guestVlan) throws ConcurrentOperationException{
|
||||
|
||||
|
|
@ -1492,6 +1502,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FirewallRuleVO> updatePortForwardingRules(final List<FirewallRuleVO> fwRules, final DomainRouterVO router, Long hostId ){
|
||||
final List<FirewallRuleVO> fwdRules = new ArrayList<FirewallRuleVO>();
|
||||
final List<FirewallRuleVO> result = new ArrayList<FirewallRuleVO>();
|
||||
|
|
@ -1734,6 +1745,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
return _routerDao.listByHostId(hostId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateLoadBalancerRules(final List<FirewallRuleVO> fwRules, final DomainRouterVO router, Long hostId) {
|
||||
|
||||
for (FirewallRuleVO rule : fwRules) {
|
||||
|
|
@ -1806,7 +1818,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
_haMgr.registerHandler(VirtualMachine.Type.DomainRouter, this);
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean((String)params.get(Config.SystemVMUseLocalStorage.key()));
|
||||
_offering = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
_offering = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
_offering.setUniqueName("Cloud.Com-SoftwareRouter");
|
||||
_offering = _serviceOfferingDao.persistSystemServiceOffering(_offering);
|
||||
_template = _templateDao.findById(_routerTemplateId);
|
||||
|
|
@ -1814,6 +1826,14 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
throw new ConfigurationException("Unable to find the template for the router: " + _routerTemplateId);
|
||||
}
|
||||
|
||||
_publicNetworkOffering = new NetworkOfferingVO("System-VM-Public-Network", TrafficType.Public, null);
|
||||
_publicNetworkOffering = _networkOfferingDao.persistSystemNetworkOffering(_publicNetworkOffering);
|
||||
|
||||
_managementNetworkOffering = new NetworkOfferingVO("System-VM-Management-Network", TrafficType.Management, null);
|
||||
_linkLocalNetworkOffering = new NetworkOfferingVO("System-VM-LinkLocal-Network", TrafficType.LinkLocal, null);
|
||||
_guestNetworkOffering = new NetworkOfferingVO("System-VM-Guest-Network", TrafficType.Guest, GuestIpType.Virtualized);
|
||||
// FIXME: Obviously Virtualized is not the only guest network. How do we determine which one to use?
|
||||
|
||||
s_logger.info("Network Manager is configured.");
|
||||
|
||||
return true;
|
||||
|
|
@ -2133,6 +2153,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
public RouterCleanupTask() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final List<Long> ids = _routerDao.findLonelyRouters();
|
||||
|
|
@ -2298,6 +2319,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
public NetworkUsageTask() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final List<DomainRouterVO> routers = _routerDao.listUpByHostId(null);
|
||||
s_logger.debug("Found " + routers.size() + " running routers. ");
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import com.cloud.user.OwnedBy;
|
|||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="network_profile")
|
||||
@Table(name="network_profiles")
|
||||
public class NetworkProfileVO implements OwnedBy {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
|
|
@ -65,15 +65,18 @@ public class NetworkProfileVO implements OwnedBy {
|
|||
|
||||
public NetworkProfileVO() {
|
||||
}
|
||||
|
||||
public NetworkProfileVO(long accountId, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType) {
|
||||
this.accountId = accountId;
|
||||
this.trafficType = trafficType;
|
||||
this.mode = mode;
|
||||
this.broadcastDomainType = broadcastDomainType;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Mode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.offerings.dao;
|
||||
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
/**
|
||||
* NetworkOfferingDao deals with searches and operations done on the
|
||||
* network_offering table.
|
||||
*
|
||||
*/
|
||||
public interface NetworkOfferingDao extends GenericDao<NetworkOfferingVO, Long> {
|
||||
/**
|
||||
* Returns the network offering that matches the name.
|
||||
* @param name name
|
||||
* @return NetworkOfferingVO
|
||||
*/
|
||||
NetworkOfferingVO findByName(String name);
|
||||
|
||||
/**
|
||||
* Persists the system network offering by checking the name. If it
|
||||
* is already there, then it returns the correct one in the database.
|
||||
* If not, then it persists it into the database.
|
||||
*
|
||||
* @param offering network offering to persist if not in the database.
|
||||
* @return NetworkOfferingVO backed by a row in the database
|
||||
*/
|
||||
NetworkOfferingVO persistSystemNetworkOffering(NetworkOfferingVO offering);
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.offerings.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.persistence.EntityExistsException;
|
||||
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Local(value=NetworkOfferingDao.class)
|
||||
public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Long> {
|
||||
SearchBuilder<NetworkOfferingVO> NameSearch;
|
||||
|
||||
protected NetworkOfferingDaoImpl() {
|
||||
super();
|
||||
|
||||
NameSearch = createSearchBuilder();
|
||||
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
NameSearch.done();
|
||||
}
|
||||
|
||||
public NetworkOfferingVO findByName(String name) {
|
||||
SearchCriteria<NetworkOfferingVO> sc = NameSearch.create();
|
||||
|
||||
sc.setParameters("name", name);
|
||||
|
||||
return findOneActiveBy(sc);
|
||||
|
||||
}
|
||||
|
||||
public NetworkOfferingVO persistSystemNetworkOffering(NetworkOfferingVO offering) {
|
||||
assert offering.getName() != null : "how are you going to find this later if you don't set it?";
|
||||
NetworkOfferingVO vo = findByName(offering.getName());
|
||||
if (vo != null) {
|
||||
return vo;
|
||||
}
|
||||
try {
|
||||
vo = persist(offering);
|
||||
return vo;
|
||||
} catch (EntityExistsException e) {
|
||||
// Assume it's conflict on unique name from two different management servers.
|
||||
return findByName(offering.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -174,8 +174,9 @@ import com.cloud.network.security.NetworkGroupManager;
|
|||
import com.cloud.network.security.NetworkGroupRulesVO;
|
||||
import com.cloud.network.security.NetworkGroupVO;
|
||||
import com.cloud.network.security.dao.NetworkGroupDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.auth.UserAuthenticator;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
|
|
@ -2275,7 +2276,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
throw rae;
|
||||
}
|
||||
} else {
|
||||
if (offering.getGuestIpType() == GuestIpType.Virtualized) {
|
||||
if (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized) {
|
||||
try {
|
||||
externalIp = _networkMgr.assignSourceNatIpAddress(account, dc, domain, offering, startEventId);
|
||||
} catch (ResourceAllocationException rae) {
|
||||
|
|
@ -2484,12 +2485,12 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
}
|
||||
if (offering.getGuestIpType() != GuestIpType.Virtualized) {
|
||||
if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtualized) {
|
||||
_networkGroupMgr.createDefaultNetworkGroup(accountId);
|
||||
}
|
||||
|
||||
if (networkGroups != null) {
|
||||
if (offering.getGuestIpType() == GuestIpType.Virtualized) {
|
||||
if (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtualized) {
|
||||
throw new InvalidParameterValueException("Network groups are not compatible with service offering " + offering.getName());
|
||||
}
|
||||
Set<String> nameSet = new HashSet<String>(); //handle duplicate names -- allowed
|
||||
|
|
@ -2502,7 +2503,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
|
||||
} else { //create a default group if necessary
|
||||
if (offering.getGuestIpType() != GuestIpType.Virtualized && _networkGroupsEnabled) {
|
||||
if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtualized && _networkGroupsEnabled) {
|
||||
networkGroups = new String[]{NetworkGroupManager.DEFAULT_GROUP_NAME};
|
||||
}
|
||||
}
|
||||
|
|
@ -2932,7 +2933,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
// sanity check that the vm can be applied to the load balancer
|
||||
ServiceOfferingVO offering = _offeringsDao.findById(userVm.getServiceOfferingId());
|
||||
if ((offering == null) || !GuestIpType.Virtualized.equals(offering.getGuestIpType())) {
|
||||
if ((offering == null) || !NetworkOffering.GuestIpType.Virtualized.equals(offering.getGuestIpType())) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to apply port forwarding service to virtual machine " + userVm.toString() + ", bad network type (" + ((offering == null) ? "null" : offering.getGuestIpType()) + ")");
|
||||
}
|
||||
|
|
@ -3362,7 +3363,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
private FirewallRuleVO createFirewallRule(long userId, String ipAddress, UserVm userVm, String publicPort, String privatePort, String protocol, Long securityGroupId) throws NetworkRuleConflictException {
|
||||
// sanity check that the vm can be applied to the load balancer
|
||||
ServiceOfferingVO offering = _offeringsDao.findById(userVm.getServiceOfferingId());
|
||||
if ((offering == null) || !GuestIpType.Virtualized.equals(offering.getGuestIpType())) {
|
||||
if ((offering == null) || !NetworkOffering.GuestIpType.Virtualized.equals(offering.getGuestIpType())) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to create port forwarding rule (" + protocol + ":" + publicPort + "->" + privatePort+ ") for virtual machine " + userVm.toString() + ", bad network type (" + ((offering == null) ? "null" : offering.getGuestIpType()) + ")");
|
||||
}
|
||||
|
|
@ -7211,7 +7212,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
} else {
|
||||
// sanity check that the vm can be applied to the load balancer
|
||||
ServiceOfferingVO offering = _offeringsDao.findById(userVm.getServiceOfferingId());
|
||||
if ((offering == null) || !GuestIpType.Virtualized.equals(offering.getGuestIpType())) {
|
||||
if ((offering == null) || !NetworkOffering.GuestIpType.Virtualized.equals(offering.getGuestIpType())) {
|
||||
// we previously added these instanceIds to the loadBalancerVMMap, so remove them here as we are rejecting the API request
|
||||
// without actually modifying the load balancer
|
||||
_loadBalancerVMMapDao.remove(loadBalancerId, instanceIds, Boolean.TRUE);
|
||||
|
|
|
|||
|
|
@ -32,8 +32,9 @@ import com.cloud.capacity.dao.CapacityDao;
|
|||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.StoragePool;
|
||||
|
|
@ -146,14 +147,14 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
|
|||
so = _offeringDao.findById(userVm.getServiceOfferingId());
|
||||
} else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomP", 1,
|
||||
_proxyRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
} else {
|
||||
assert(false) : "Unsupported system vm type";
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
}
|
||||
|
||||
long usedMemory = calcHostAllocatedCpuMemoryCapacity(vmOnHost, CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||
|
|
@ -243,14 +244,14 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
|
|||
so = _offeringDao.findById(userVm.getServiceOfferingId());
|
||||
} else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomP", 1,
|
||||
_proxyRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
} else {
|
||||
assert(false) : "Unsupported system vm type";
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, GuestIpType.Virtualized, false, true, null);
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
}
|
||||
|
||||
if(capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ import com.cloud.network.IpAddrAllocator;
|
|||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.IpAddrAllocator.networkInfo;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.StorageManager;
|
||||
|
|
@ -1365,7 +1366,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
}
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean((String)params.get(Config.SystemVMUseLocalStorage.key()));
|
||||
_serviceOffering = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
_serviceOffering = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
_serviceOffering.setUniqueName("Cloud.com-SecondaryStorage");
|
||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||
_template = _templateDao.findConsoleProxyTemplate();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ import org.xml.sax.Attributes;
|
|||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDaoImpl;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
|
|
@ -720,11 +721,11 @@ public class DatabaseConfig {
|
|||
boolean ha = Boolean.parseBoolean(_currentObjectParams.get("enableHA"));
|
||||
boolean mirroring = Boolean.parseBoolean(_currentObjectParams.get("mirrored"));
|
||||
String guestIpType = _currentObjectParams.get("guestIpType");
|
||||
GuestIpType type = null;
|
||||
NetworkOffering.GuestIpType type = null;
|
||||
if (guestIpType == null) {
|
||||
type = GuestIpType.Virtualized;
|
||||
type = NetworkOffering.GuestIpType.Virtualized;
|
||||
} else {
|
||||
type = GuestIpType.valueOf(guestIpType);
|
||||
type = NetworkOffering.GuestIpType.valueOf(guestIpType);
|
||||
}
|
||||
|
||||
boolean useLocalStorage;
|
||||
|
|
|
|||
|
|
@ -33,9 +33,7 @@ import com.cloud.configuration.dao.ResourceLimitDao;
|
|||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
|
|
@ -48,8 +46,6 @@ public class AccountManagerImpl implements AccountManager {
|
|||
private String _name;
|
||||
@Inject private AccountDao _accountDao;
|
||||
@Inject private DomainDao _domainDao;
|
||||
@Inject private UserDao _userDao;
|
||||
@Inject private VMTemplateDao _templateDao;
|
||||
@Inject private ResourceLimitDao _resourceLimitDao;
|
||||
@Inject private ResourceCountDao _resourceCountDao;
|
||||
private final GlobalLock m_resourceCountLock = GlobalLock.getInternLock("resource.count");
|
||||
|
|
|
|||
|
|
@ -120,8 +120,9 @@ import com.cloud.network.dao.SecurityGroupDao;
|
|||
import com.cloud.network.dao.SecurityGroupVMMapDao;
|
||||
import com.cloud.network.security.NetworkGroupManager;
|
||||
import com.cloud.network.security.NetworkGroupVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offering.ServiceOffering.GuestIpType;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
|
|
@ -1176,7 +1177,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
|||
public void releaseGuestIpAddress(UserVmVO userVm) {
|
||||
ServiceOffering offering = _offeringDao.findById(userVm.getServiceOfferingId());
|
||||
|
||||
if (offering.getGuestIpType() != GuestIpType.Virtualized) {
|
||||
if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtualized) {
|
||||
IPAddressVO guestIP = (userVm.getGuestIpAddress() == null) ? null : _ipAddressDao.findById(userVm.getGuestIpAddress());
|
||||
if (guestIP != null && guestIP.getAllocated() != null) {
|
||||
_ipAddressDao.unassignIpAddress(userVm.getGuestIpAddress());
|
||||
|
|
|
|||
|
|
@ -114,12 +114,16 @@ CREATE TABLE `cloud`.`nics` (
|
|||
|
||||
CREATE TABLE `cloud`.`network_offerings` (
|
||||
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
|
||||
`name` varchar(64) NOT NULL COMMENT 'network offering',
|
||||
`name` varchar(64) NOT NULL unique COMMENT 'network offering',
|
||||
`type` varchar(32) NOT NULL COMMENT 'type of network',
|
||||
`display_text` varchar(255) NOT NULL COMMENT 'text to display to users',
|
||||
`nw_rate` smallint unsigned default 200 COMMENT 'network rate throttle mbits/s',
|
||||
`mc_rate` smallint unsigned default 10 COMMENT 'mcast rate throttle mbits/s',
|
||||
`concurrent_connections` smallint unsigned COMMENT 'concurrent connections supported on this network',
|
||||
`nw_rate` smallint unsigned COMMENT 'network rate throttle mbits/s',
|
||||
`mc_rate` smallint unsigned COMMENT 'mcast rate throttle mbits/s',
|
||||
`concurrent_connections` int(10) unsigned COMMENT 'concurrent connections supported on this network',
|
||||
`traffic_type` varchar(32) NOT NULL COMMENT 'traffic type carried on this network',
|
||||
`created` datetime NOT NULL COMMENT 'time the entry was created',
|
||||
`removed` datetime NOT NULL COMMENT 'time the entry was removed',
|
||||
`system_only` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Is this network offering for system use only',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue