mirror of https://github.com/apache/cloudstack.git
make console proxy work again with the new network configuration
This commit is contained in:
parent
e63d17dd41
commit
4f9f249218
|
|
@ -6,11 +6,10 @@ package com.cloud.network;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.domain.PartOf;
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.network.Network.BroadcastDomainType;
|
||||
import com.cloud.network.Network.Mode;
|
||||
import com.cloud.network.Network.TrafficType;
|
||||
import com.cloud.user.OwnedBy;
|
||||
import com.cloud.utils.fsm.FiniteState;
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
|
||||
|
|
@ -18,7 +17,7 @@ import com.cloud.utils.fsm.StateMachine;
|
|||
* A NetworkProfile defines the specifics of a network
|
||||
* owned by an account.
|
||||
*/
|
||||
public interface NetworkConfiguration extends OwnedBy, PartOf {
|
||||
public interface NetworkConfiguration extends ControlledEntity {
|
||||
enum Event {
|
||||
ImplementNetwork,
|
||||
DestroyNetwork;
|
||||
|
|
@ -73,7 +72,7 @@ public interface NetworkConfiguration extends OwnedBy, PartOf {
|
|||
/**
|
||||
* @return id of the network profile. Null means the network profile is not from the database.
|
||||
*/
|
||||
Long getId();
|
||||
long getId();
|
||||
|
||||
Mode getMode();
|
||||
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
|||
super();
|
||||
}
|
||||
|
||||
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);
|
||||
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, boolean systemUse) {
|
||||
super(name, displayText, false, tags, recreatable, useLocalStorage, systemUse);
|
||||
this.cpu = cpu;
|
||||
this.ramSize = ramSize;
|
||||
this.speed = speed;
|
||||
|
|
@ -124,7 +124,8 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
|||
this.rateMbps = rateMbps;
|
||||
}
|
||||
|
||||
public int getRateMbps() {
|
||||
@Override
|
||||
public int getRateMbps() {
|
||||
return rateMbps;
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +133,8 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
|||
this.multicastRateMbps = multicastRateMbps;
|
||||
}
|
||||
|
||||
public int getMulticastRateMbps() {
|
||||
@Override
|
||||
public int getMulticastRateMbps() {
|
||||
return multicastRateMbps;
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +142,8 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
|||
this.guestIpType = guestIpType;
|
||||
}
|
||||
|
||||
public NetworkOffering.GuestIpType getGuestIpType() {
|
||||
@Override
|
||||
public NetworkOffering.GuestIpType getGuestIpType() {
|
||||
return guestIpType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package com.cloud.service.dao;
|
|||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.persistence.EntityExistsException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -29,7 +30,6 @@ import com.cloud.utils.db.DB;
|
|||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Local(value={ServiceOfferingDao.class}) @DB(txn=false)
|
||||
public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO, Long> implements ServiceOfferingDao {
|
||||
|
|
@ -41,7 +41,7 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO, Lo
|
|||
|
||||
UniqueNameSearch = createSearchBuilder();
|
||||
UniqueNameSearch.and("name", UniqueNameSearch.entity().getUniqueName(), SearchCriteria.Op.EQ);
|
||||
UniqueNameSearch.and("removed", UniqueNameSearch.entity().getRemoved(), SearchCriteria.Op.NNULL);
|
||||
UniqueNameSearch.and("system", UniqueNameSearch.entity().isSystemUse(), SearchCriteria.Op.EQ);
|
||||
UniqueNameSearch.done();
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +49,8 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO, Lo
|
|||
public ServiceOfferingVO findByName(String name) {
|
||||
SearchCriteria<ServiceOfferingVO> sc = UniqueNameSearch.create();
|
||||
sc.setParameters("name", name);
|
||||
List<ServiceOfferingVO> vos = searchIncludingRemoved(sc, null, null, false);
|
||||
sc.setParameters("system", true);
|
||||
List<ServiceOfferingVO> vos = search(sc, null, null, false);
|
||||
if (vos.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -64,14 +65,9 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO, Lo
|
|||
if (vo != null) {
|
||||
return vo;
|
||||
}
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
vo = persist(offering);
|
||||
remove(vo.getId());
|
||||
txn.commit();
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
return persist(offering);
|
||||
} catch (EntityExistsException e) {
|
||||
// Assume it's conflict on unique name
|
||||
return findByName(offering.getUniqueName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
@Column(name="use_local_storage")
|
||||
private boolean useLocalStorage;
|
||||
|
||||
@Column(name="system_use")
|
||||
private boolean systemUse;
|
||||
|
||||
public DiskOfferingVO() {
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +104,7 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
this.useLocalStorage = false;
|
||||
}
|
||||
|
||||
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage) {
|
||||
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage, boolean systemUse) {
|
||||
this.domainId = null;
|
||||
this.type = Type.Service;
|
||||
this.name = name;
|
||||
|
|
@ -110,20 +113,25 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
this.tags = tags;
|
||||
this.recreatable = recreatable;
|
||||
this.useLocalStorage = useLocalStorage;
|
||||
this.systemUse = systemUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueName() {
|
||||
return uniqueName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseLocalStorage() {
|
||||
return useLocalStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
|
@ -140,14 +148,20 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isSystemUse() {
|
||||
return systemUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
|
@ -159,6 +173,7 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
return diskSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDiskSizeInBytes() {
|
||||
return diskSize * 1024 * 1024;
|
||||
}
|
||||
|
|
@ -186,6 +201,7 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
this.tags = tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
|
@ -194,6 +210,7 @@ public class DiskOfferingVO implements DiskOffering {
|
|||
this.uniqueName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transient
|
||||
public String[] getTagsArray() {
|
||||
String tags = getTags();
|
||||
|
|
|
|||
|
|
@ -136,9 +136,9 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
|||
long accountId,
|
||||
long serviceOfferingId,
|
||||
String userData) {
|
||||
super(id, serviceOfferingId, displayName, instanceName, Type.User, templateId, guestOsId, domainId, accountId, haEnabled);
|
||||
super(id, serviceOfferingId, displayName == null ? instanceName : displayName, instanceName, Type.User, templateId, guestOsId, domainId, accountId, haEnabled);
|
||||
this.userData = userData;
|
||||
this.displayName = displayName;
|
||||
this.displayName = displayName != null ? displayName : null;
|
||||
}
|
||||
|
||||
public UserVmVO(long id,
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
|
|||
throw new PermissionDeniedException(account + " does not have permission to operate within " + domain);
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
|
|||
|
||||
|
||||
|
||||
protected AgentAttache handleDirectConnect(ServerResource resource, StartupCommand[] startup, Map<String, String> details, boolean old) {
|
||||
protected AgentAttache handleDirectConnect(ServerResource resource, StartupCommand[] startup, Map<String, String> details, boolean old) throws ConnectionException {
|
||||
if (startup == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -1043,7 +1043,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected AgentAttache notifyMonitorsOfConnection(AgentAttache attache, final StartupCommand[] cmd) {
|
||||
protected AgentAttache notifyMonitorsOfConnection(AgentAttache attache, final StartupCommand[] cmd) throws ConnectionException {
|
||||
long hostId = attache.getId();
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
for (Pair<Integer, Listener> monitor : _hostMonitors) {
|
||||
|
|
@ -1057,11 +1057,12 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
|
|||
if (e.isSetupError()) {
|
||||
s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage());
|
||||
handleDisconnect(attache, Event.AgentDisconnected, false);
|
||||
throw e;
|
||||
} else {
|
||||
s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + " due to " + e.getMessage());
|
||||
handleDisconnect(attache, Event.ShutdownRequested, false);
|
||||
return attache;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1181,12 +1182,11 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
|
|||
}
|
||||
try {
|
||||
attache = handleDirectConnect(resource, cmds, details, old);
|
||||
}catch (IllegalArgumentException ex)
|
||||
} catch (IllegalArgumentException ex)
|
||||
{
|
||||
s_logger.warn("Unable to connect due to ", ex);
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to connect due to ", e);
|
||||
}
|
||||
|
||||
|
|
@ -1788,7 +1788,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
|
|||
return result;
|
||||
}
|
||||
|
||||
public AgentAttache handleConnect(final Link link, final StartupCommand[] startup) throws IllegalArgumentException {
|
||||
public AgentAttache handleConnect(final Link link, final StartupCommand[] startup) throws IllegalArgumentException, ConnectionException {
|
||||
HostVO server = createHost(startup, null, null, false);
|
||||
if ( server == null ) {
|
||||
return null;
|
||||
|
|
@ -2169,6 +2169,12 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
|
|||
+ request.toString() + " because of " + e.getMessage());
|
||||
s_logger.warn("Unable to create attache for agent: " + request.toString(), e);
|
||||
response = new Response(request, new StartupAnswer((StartupCommand) cmd, e.getMessage()), _nodeId, -1);
|
||||
} catch (ConnectionException e) {
|
||||
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, 0, new Long(0), "Agent from " + startup.getPrivateIpAddress()
|
||||
+ " is unable to connect due to " + e.getMessage(), "Agent from " + startup.getPrivateIpAddress() + " is unable to connect with "
|
||||
+ request.toString() + " because of " + e.getMessage());
|
||||
s_logger.warn("Unable to create attache for agent: " + request.toString(), e);
|
||||
response = new Response(request, new StartupAnswer((StartupCommand) cmd, e.getMessage()), _nodeId, -1);
|
||||
} catch (final CloudRuntimeException e) {
|
||||
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, 0, new Long(0), "Agent from " + startup.getPrivateIpAddress()
|
||||
+ " is unable to connect due to " + e.getMessage(), "Agent from " + startup.getPrivateIpAddress() + " is unable to connect with "
|
||||
|
|
|
|||
|
|
@ -244,14 +244,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, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.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, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.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, true);
|
||||
} else {
|
||||
assert(false) : "Unsupported system vm type";
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.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, true);
|
||||
}
|
||||
|
||||
if(capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
saveConfigurationEvent(userId, null, EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, "Successfully edited configuration value.", "name=" + name, "value=" + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateConfiguration(UpdateCfgCmd cmd) throws InvalidParameterValueException, InternalErrorException{
|
||||
Long userId = UserContext.current().getUserId();
|
||||
String name = cmd.getCfgName();
|
||||
|
|
@ -1076,7 +1077,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
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);
|
||||
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags, false);
|
||||
|
||||
if ((offering = _serviceOfferingDao.persist(offering)) != null) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_CREATE, "Successfully created new service offering with name: " + name + ".", "soId=" + offering.getId(), "name=" + name, "numCPUs=" + cpu, "ram=" + ramSize, "cpuSpeed=" + speed,
|
||||
|
|
@ -1087,6 +1088,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceOfferingVO updateServiceOffering(UpdateServiceOfferingCmd cmd) {
|
||||
String displayText = cmd.getDisplayText();
|
||||
Long id = cmd.getId();
|
||||
|
|
@ -1177,6 +1179,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
return createDiskOffering(domainId, name, description, numGibibytes, tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiskOfferingVO updateDiskOffering(UpdateDiskOfferingCmd cmd) throws InvalidParameterValueException{
|
||||
Long diskOfferingId = cmd.getId();
|
||||
String name = cmd.getName();
|
||||
|
|
@ -1222,6 +1225,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDiskOffering(DeleteDiskOfferingCmd cmd) throws InvalidParameterValueException{
|
||||
Long diskOfferingId = cmd.getId();
|
||||
|
||||
|
|
@ -1238,6 +1242,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteServiceOffering(DeleteServiceOfferingCmd cmd) throws InvalidParameterValueException{
|
||||
|
||||
Long offeringId = cmd.getId();
|
||||
|
|
@ -1264,6 +1269,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String changePrivateIPRange(boolean add, long podId, String startIP, String endIP) throws InvalidParameterValueException {
|
||||
checkPrivateIpRangeErrors(podId, startIP, endIP);
|
||||
|
||||
|
|
|
|||
|
|
@ -539,6 +539,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.warn("Exception while trying to start console proxy", e);
|
||||
return null;
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Exception while trying to start console proxy", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1486,6 +1489,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
s_logger.warn("insuffiient capacity", e);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.debug("Concurrent operation: " + e.getMessage());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.debug("Concurrent operation: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2344,8 +2349,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
_networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
_multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
_serviceOffering = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized,
|
||||
useLocalStorage, true, null);
|
||||
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized,
|
||||
useLocalStorage, true, null, true);
|
||||
_serviceOffering.setUniqueName("Cloud.com-ConsoleProxy");
|
||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||
_template = _templateDao.findConsoleProxyTemplate();
|
||||
|
|
|
|||
|
|
@ -111,12 +111,16 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
|||
this.networkOfferingId = networkOfferingId;
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.state = State.Allocated;
|
||||
this.id = -1;
|
||||
}
|
||||
|
||||
public NetworkConfigurationVO(long id, NetworkConfiguration that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related) {
|
||||
this(id, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related);
|
||||
this.guruName = guruName;
|
||||
this.state = that.getState();
|
||||
if (state == null) {
|
||||
state = State.Allocated;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -134,6 +138,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
|||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
this.related = related;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -151,7 +156,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
@ -223,6 +228,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
|||
this.cidr = cidr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBroadcastUri() {
|
||||
return broadcastUri;
|
||||
}
|
||||
|
|
@ -241,6 +247,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
|
|||
return dataCenterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDns() {
|
||||
return dns;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1630,7 +1630,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (config.getId() != null) {
|
||||
if (config.getId() != -1) {
|
||||
if (config instanceof NetworkConfigurationVO) {
|
||||
configs.add((NetworkConfigurationVO)config);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1459,7 +1459,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
_networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
_multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
_offering = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
_offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null, true);
|
||||
_offering.setUniqueName("Cloud.Com-SoftwareRouter");
|
||||
_offering = _serviceOfferingDao.persistSystemServiceOffering(_offering);
|
||||
_template = _templateDao.findRoutingTemplate();
|
||||
|
|
|
|||
|
|
@ -89,7 +89,8 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
_domainDao = locator.getDao(DomainDao.class);
|
||||
}
|
||||
|
||||
public void persistDefaultValues() throws InvalidParameterValueException, InternalErrorException {
|
||||
@Override
|
||||
public void persistDefaultValues() throws InvalidParameterValueException, InternalErrorException {
|
||||
|
||||
// Create system user and admin user
|
||||
saveUser();
|
||||
|
|
@ -653,7 +654,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
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);
|
||||
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags, false);
|
||||
|
||||
if ((offering = _serviceOfferingDao.persist(offering)) != null) {
|
||||
return offering;
|
||||
|
|
|
|||
|
|
@ -2777,6 +2777,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
if (name != null) {
|
||||
sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
|
||||
}
|
||||
sc.addAnd("systemUse", SearchCriteria.Op.EQ, false);
|
||||
|
||||
return _offeringsDao.search(sc, searchFilter);
|
||||
}
|
||||
|
|
@ -5191,7 +5192,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
if (accountId != null) {
|
||||
sc.setParameters("accountId", accountId);
|
||||
} else if (domainId != null) {
|
||||
DomainVO domain = _domainDao.findById((Long)domainId);
|
||||
DomainVO domain = _domainDao.findById(domainId);
|
||||
SearchCriteria<?> joinSearch = sc.getJoin("accountSearch");
|
||||
joinSearch.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,14 +146,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, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.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, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.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, true);
|
||||
} else {
|
||||
assert(false) : "Unsupported system vm type";
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.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, false);
|
||||
}
|
||||
|
||||
long usedMemory = calcHostAllocatedCpuMemoryCapacity(vmOnHost, CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||
|
|
@ -243,14 +243,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, NetworkOffering.GuestIpType.Virtualized, false, true, null);
|
||||
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.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, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.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, true);
|
||||
} else {
|
||||
assert(false) : "Unsupported system vm type";
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.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, false);
|
||||
}
|
||||
|
||||
if(capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {
|
||||
|
|
|
|||
|
|
@ -1390,7 +1390,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
_networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
_multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
_serviceOffering = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
_serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null, true);
|
||||
_serviceOffering.setUniqueName("Cloud.com-SecondaryStorage");
|
||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||
_template = _templateDao.findConsoleProxyTemplate();
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ public class DatabaseConfig {
|
|||
useLocalStorage = false;
|
||||
}
|
||||
|
||||
ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, nwRate, mcRate, ha, displayText, type, useLocalStorage, false, null);
|
||||
ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, nwRate, mcRate, ha, displayText, type, useLocalStorage, false, null, false);
|
||||
ServiceOfferingDaoImpl dao = ComponentLocator.inject(ServiceOfferingDaoImpl.class);
|
||||
try {
|
||||
dao.persist(serviceOffering);
|
||||
|
|
|
|||
|
|
@ -591,16 +591,21 @@ public class AccountManagerImpl implements AccountManager {
|
|||
@Override
|
||||
public void checkAccess(Account caller, ControlledEntity... entities) {
|
||||
for (ControlledEntity entity : entities) {
|
||||
boolean granted = false;
|
||||
for (SecurityChecker checker : _securityCheckers) {
|
||||
if (checker.checkAccess(caller, entity)) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Access to " + entity + " granted to " + caller + " by " + checker.getName());
|
||||
}
|
||||
granted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert false : "How can all of the security checkers pass on checking this check?";
|
||||
throw new PermissionDeniedException("There's no way to confirm " + caller + " has access to " + entity);
|
||||
if (!granted) {
|
||||
assert false : "How can all of the security checkers pass on checking this check: " + entity;
|
||||
throw new PermissionDeniedException("There's no way to confirm " + caller + " has access to " + entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,9 @@ CREATE TABLE `cloud`.`network_configurations` (
|
|||
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center id that this configuration is used in',
|
||||
`guru_name` varchar(255) NOT NULL COMMENT 'who is responsible for this type of network configuration',
|
||||
`state` varchar(32) NOT NULL COMMENT 'what state is this configuration in',
|
||||
`related` bigint unsigned NOT NULL COMMENT 'related to what other network configuration',
|
||||
`domain_id` bigint unsigned NOT NULL COMMENT 'foreign key to domain id',
|
||||
`account_id` bigint unsigned NOT NULL COMMENT 'owner of this network',
|
||||
`mac_address_seq` bigint unsigned DEFAULT 1 COMMENT 'mac address seq number',
|
||||
`dns` varchar(255) COMMENT 'comma separated DNS list',
|
||||
PRIMARY KEY (`id`)
|
||||
|
|
@ -113,6 +116,7 @@ CREATE TABLE `cloud`.`account_network_ref` (
|
|||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`account_id` bigint unsigned NOT NULL COMMENT 'account id',
|
||||
`network_configuration_id` bigint unsigned NOT NULL COMMENT 'network configuration id',
|
||||
`is_owner` smallint(1) NOT NULL COMMENT 'is the owner of the network',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
@ -859,7 +863,7 @@ CREATE TABLE `cloud`.`disk_offering` (
|
|||
`id` bigint unsigned NOT NULL auto_increment,
|
||||
`domain_id` bigint unsigned,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`display_text` varchar(4096) NULL COMMENT 'Description text set by the admin for display purpose only',
|
||||
`display_text` varchar(4096) NULL COMMENT 'Descrianaption text set by the admin for display purpose only',
|
||||
`disk_size` bigint unsigned NOT NULL COMMENT 'disk space in mbs',
|
||||
`mirrored` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT 'Enable mirroring?',
|
||||
`type` varchar(32) COMMENT 'inheritted by who?',
|
||||
|
|
@ -867,6 +871,7 @@ CREATE TABLE `cloud`.`disk_offering` (
|
|||
`recreatable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'The root disk is always recreatable',
|
||||
`use_local_storage` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Indicates whether local storage pools should be used',
|
||||
`unique_name` varchar(32) UNIQUE COMMENT 'unique name',
|
||||
`system_use` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'is this offering for system used only',
|
||||
`removed` datetime COMMENT 'date removed',
|
||||
`created` datetime COMMENT 'date the disk offering was created',
|
||||
PRIMARY KEY (`id`)
|
||||
|
|
|
|||
|
|
@ -693,7 +693,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
ub.clear();
|
||||
return result;
|
||||
} catch (final SQLException e) {
|
||||
if (e.getSQLState().equals("23000")) {
|
||||
if (e.getSQLState().equals("23000") && e.getErrorCode() == 1062) {
|
||||
throw new EntityExistsException("Entity already exists ", e);
|
||||
}
|
||||
final String sqlStr = pstmt.toString();
|
||||
|
|
@ -1129,7 +1129,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
}
|
||||
txn.commit();
|
||||
} catch (final SQLException e) {
|
||||
if (e.getSQLState().equals("23000")) {
|
||||
if (e.getSQLState().equals("23000") && e.getErrorCode() == 1062) {
|
||||
throw new EntityExistsException("Entity already exists: ", e);
|
||||
} else {
|
||||
final String sqlStr = pstmt.toString();
|
||||
|
|
|
|||
Loading…
Reference in New Issue