Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss

This commit is contained in:
Jessica Wang 2010-10-26 17:55:04 -07:00
commit ae8bdeb0f4
26 changed files with 189 additions and 90 deletions

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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());
}

View File

@ -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();

View File

@ -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,

View File

@ -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

View File

@ -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 "

View File

@ -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) {

View File

@ -231,6 +231,8 @@ public class ApiDispatcher {
throw new ServerApiException(BaseCmd.PARAM_ERROR, cause.getMessage());
} else if (cause instanceof PermissionDeniedException) {
throw new ServerApiException(BaseCmd.ACCOUNT_ERROR, cause.getMessage());
} else if (cause instanceof ServerApiException) {
throw (ServerApiException)cause;
}
s_logger.warn("Exception executing method " + methodName + " for command " + cmd.getClass().getSimpleName(), ite);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Unable to execute method " + methodName + " for command " + cmd.getClass().getSimpleName() + ", internal error in the implementation.");

View File

@ -20,14 +20,18 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseAsyncCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.response.SuccessResponse;
import com.cloud.api.response.SystemVmResponse;
import com.cloud.event.EventTypes;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import com.cloud.vm.ConsoleProxyVO;
import com.cloud.vm.SecondaryStorageVmVO;
import com.cloud.vm.VMInstanceVO;
@Implementation(method="rebootSystemVM", manager=Manager.ManagementServer, description="Reboots a system VM.")
public class RebootSystemVmCmd extends BaseAsyncCmd {
@ -80,10 +84,50 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
Boolean success = (Boolean)getResponseObject();
SuccessResponse response = new SuccessResponse();
response.setSuccess(success);
public SystemVmResponse getResponse() {
VMInstanceVO instance = (VMInstanceVO)getResponseObject();
SystemVmResponse response = new SystemVmResponse();
response.setId(instance.getId());
response.setName(instance.getName());
response.setZoneId(instance.getDataCenterId());
response.setZoneName(ApiDBUtils.findZoneById(instance.getDataCenterId()).getName());
response.setPodId(instance.getPodId());
response.setHostId(instance.getHostId());
if (response.getHostId() != null) {
response.setHostName(ApiDBUtils.findHostById(instance.getHostId()).getName());
}
response.setPrivateIp(instance.getPrivateIpAddress());
response.setPrivateMacAddress(instance.getPrivateMacAddress());
response.setPrivateNetmask(instance.getPrivateNetmask());
response.setTemplateId(instance.getTemplateId());
response.setCreated(instance.getCreated());
response.setState(instance.getState().toString());
if (instance instanceof SecondaryStorageVmVO) {
SecondaryStorageVmVO ssVm = (SecondaryStorageVmVO) instance;
response.setDns1(ssVm.getDns1());
response.setDns2(ssVm.getDns2());
response.setNetworkDomain(ssVm.getDomain());
response.setGateway(ssVm.getGateway());
response.setPublicIp(ssVm.getPublicIpAddress());
response.setPublicMacAddress(ssVm.getPublicMacAddress());
response.setPublicNetmask(ssVm.getPublicNetmask());
} else if (instance instanceof ConsoleProxyVO) {
ConsoleProxyVO proxy = (ConsoleProxyVO)instance;
response.setDns1(proxy.getDns1());
response.setDns2(proxy.getDns2());
response.setNetworkDomain(proxy.getDomain());
response.setGateway(proxy.getGateway());
response.setPublicIp(proxy.getPublicIpAddress());
response.setPublicMacAddress(proxy.getPublicMacAddress());
response.setPublicNetmask(proxy.getPublicNetmask());
response.setActiveViewerSessions(proxy.getActiveSession());
}
response.setResponseName(getName());
return response;
}

View File

@ -39,7 +39,7 @@ public class RebootConsoleProxyExecutor extends VMOperationExecutor {
AsyncJobVO job = getJob();
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
/*
if(getSyncSource() == null) {
asyncMgr.syncAsyncJobExecution(job, "ConsoleProxy", param.getVmId());
return true;
@ -58,7 +58,9 @@ public class RebootConsoleProxyExecutor extends VMOperationExecutor {
e.getMessage());
}
return true;
}
}
*/
return true;
}
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {

View File

@ -39,7 +39,7 @@ public class StopConsoleProxyExecutor extends VMOperationExecutor {
AsyncJobVO job = getJob();
ManagementServer managementServer = asyncMgr.getExecutorContext().getManagementServer();
VMOperationParam param = gson.fromJson(job.getCmdInfo(), VMOperationParam.class);
/*
if(getSyncSource() == null) {
asyncMgr.syncAsyncJobExecution(job, "ConsoleProxy", param.getVmId());
return true;
@ -58,7 +58,9 @@ public class StopConsoleProxyExecutor extends VMOperationExecutor {
e.getMessage());
}
return true;
}
}
*/
return true;
}
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {

View File

@ -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);

View File

@ -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();

View File

@ -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;
}

View File

@ -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 {
@ -2130,7 +2130,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
Long loadBalancerId = cmd.getId();
String privatePort = cmd.getPrivatePort();
String algorithm = cmd.getAlgorithm();
String name = cmd.getName();
String name = cmd.getLoadBalancerName();
String description = cmd.getDescription();
Account account = UserContext.current().getAccount();
@ -2148,7 +2148,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
}
}
Account lbOwner = _accountDao.findById(loadBalancer.getId());
Account lbOwner = _accountDao.findById(loadBalancer.getAccountId());
if (lbOwner == null) {
throw new InvalidParameterValueException("Unable to update load balancer rule, cannot find owning account");
}

View File

@ -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();

View File

@ -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;

View File

@ -787,14 +787,14 @@ public interface ManagementServer {
ConsoleProxyInfo getConsoleProxy(long dataCenterId, long userVmId);
ConsoleProxyVO startConsoleProxy(long instanceId, long startEventId) throws InternalErrorException;
boolean stopConsoleProxy(long instanceId, long startEventId);
boolean rebootConsoleProxy(long instanceId, long startEventId);
ConsoleProxyVO stopConsoleProxy(long instanceId, long startEventId);
ConsoleProxyVO rebootConsoleProxy(long instanceId, long startEventId);
String getConsoleAccessUrlRoot(long vmId);
ConsoleProxyVO findConsoleProxyById(long instanceId);
VMInstanceVO findSystemVMById(long instanceId);
VMInstanceVO stopSystemVM(StopSystemVmCmd cmd);
VMInstanceVO startSystemVM(StartSystemVMCmd cmd) throws InternalErrorException;
boolean rebootSystemVM(RebootSystemVmCmd cmd);
VMInstanceVO rebootSystemVM(RebootSystemVmCmd cmd);
/**
* Returns a configuration value with the specified name

View File

@ -26,7 +26,6 @@ import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@ -146,10 +145,8 @@ import com.cloud.async.AsyncJobResult;
import com.cloud.async.AsyncJobVO;
import com.cloud.async.BaseAsyncJobExecutor;
import com.cloud.async.dao.AsyncJobDao;
import com.cloud.async.executor.ExtractJobResultObject;
import com.cloud.capacity.CapacityVO;
import com.cloud.capacity.dao.CapacityDao;
import com.cloud.certificate.CertificateVO;
import com.cloud.certificate.dao.CertificateDao;
import com.cloud.configuration.Config;
import com.cloud.configuration.ConfigurationManager;
@ -228,7 +225,6 @@ import com.cloud.storage.GuestOSCategoryVO;
import com.cloud.storage.GuestOSVO;
import com.cloud.storage.LaunchPermissionVO;
import com.cloud.storage.Snapshot;
import com.cloud.storage.Upload;
import com.cloud.storage.Snapshot.SnapshotType;
import com.cloud.storage.SnapshotPolicyVO;
import com.cloud.storage.SnapshotVO;
@ -238,6 +234,7 @@ import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePoolHostVO;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.StorageStats;
import com.cloud.storage.Upload;
import com.cloud.storage.Upload.Mode;
import com.cloud.storage.Upload.Type;
import com.cloud.storage.UploadVO;
@ -308,7 +305,6 @@ import com.cloud.vm.UserVmManager;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineName;
import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.InstanceGroupDao;
@ -2781,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);
}
@ -4702,13 +4699,15 @@ public class ManagementServerImpl implements ManagementServer {
}
@Override
public boolean stopConsoleProxy(long instanceId, long startEventId) {
return _consoleProxyMgr.stopProxy(instanceId, startEventId);
public ConsoleProxyVO stopConsoleProxy(long instanceId, long startEventId) {
_consoleProxyMgr.stopProxy(instanceId, startEventId);
return _consoleProxyDao.findById(instanceId);
}
@Override
public boolean rebootConsoleProxy(long instanceId, long startEventId) {
return _consoleProxyMgr.rebootProxy(instanceId, startEventId);
public ConsoleProxyVO rebootConsoleProxy(long instanceId, long startEventId) {
_consoleProxyMgr.rebootProxy(instanceId, startEventId);
return _consoleProxyDao.findById(instanceId);
}
@Override
@ -5193,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() + "%");
}
@ -6277,12 +6276,14 @@ public class ManagementServerImpl implements ManagementServer {
return _secStorageVmMgr.startSecStorageVm(instanceId, startEventId);
}
public boolean stopSecondaryStorageVm(long instanceId, long startEventId) {
return _secStorageVmMgr.stopSecStorageVm(instanceId, startEventId);
public SecondaryStorageVmVO stopSecondaryStorageVm(long instanceId, long startEventId) {
_secStorageVmMgr.stopSecStorageVm(instanceId, startEventId);
return _secStorageVmDao.findById(instanceId);
}
public boolean rebootSecondaryStorageVm(long instanceId, long startEventId) {
return _secStorageVmMgr.rebootSecStorageVm(instanceId, startEventId);
public SecondaryStorageVmVO rebootSecondaryStorageVm(long instanceId, long startEventId) {
_secStorageVmMgr.rebootSecStorageVm(instanceId, startEventId);
return _secStorageVmDao.findById(instanceId);
}
public boolean destroySecondaryStorageVm(long instanceId, long startEventId) {
@ -6406,17 +6407,15 @@ public class ManagementServerImpl implements ManagementServer {
// FIXME: We need to return the system VM from this method, so what do we do with the boolean response from stopConsoleProxy and stopSecondaryStorageVm?
if (systemVm.getType().equals(VirtualMachine.Type.ConsoleProxy)){
long eventId = EventUtils.saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_PROXY_STOP, "stopping console proxy with Id: "+id);
stopConsoleProxy(id, eventId);
return stopConsoleProxy(id, eventId);
} else {
long eventId = EventUtils.saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_STOP, "stopping secondary storage Vm Id: "+id);
stopSecondaryStorageVm(id, eventId);
return stopSecondaryStorageVm(id, eventId);
}
return systemVm;
}
@Override
public boolean rebootSystemVM(RebootSystemVmCmd cmd) {
public VMInstanceVO rebootSystemVM(RebootSystemVmCmd cmd) {
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(cmd.getId(), VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
if (systemVm == null) {

View File

@ -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) {

View File

@ -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();

View File

@ -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);

View File

@ -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);
}
}
}
}

View File

@ -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`)

View File

@ -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();