mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixed the problem with offerings and templates. These two items due to a previous patch all the way back in 2.1.x versions uses the removed column incorrectly. No one fixed since then. Hence, there's a bunch of findbyidincludingremoved calls in the cloudstack code around these two items.
This commit is contained in:
parent
2d05fe40c0
commit
abbae2aa87
@ -255,34 +255,18 @@ public interface ConfigurationService {
|
||||
|
||||
boolean deleteNetworkOffering(DeleteNetworkOfferingCmd cmd);
|
||||
|
||||
NetworkOffering getNetworkOffering(long id);
|
||||
|
||||
Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId);
|
||||
|
||||
Account getVlanAccount(long vlanId);
|
||||
|
||||
List<? extends NetworkOffering> listNetworkOfferings(TrafficType trafficType, boolean systemOnly);
|
||||
|
||||
ServiceOffering getServiceOffering(long serviceOfferingId);
|
||||
|
||||
Long getDefaultPageSize();
|
||||
|
||||
Integer getServiceOfferingNetworkRate(long serviceOfferingId, Long dataCenterId);
|
||||
|
||||
DiskOffering getDiskOffering(long diskOfferingId);
|
||||
|
||||
boolean updateLDAP(LDAPConfigCmd cmd) throws NamingException;
|
||||
|
||||
boolean removeLDAP(LDAPRemoveCmd cmd);
|
||||
|
||||
LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd);
|
||||
|
||||
/**
|
||||
* @param offering
|
||||
* @return
|
||||
*/
|
||||
boolean isOfferingForVpc(NetworkOffering offering);
|
||||
|
||||
PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throws ConcurrentOperationException;
|
||||
|
||||
boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd);
|
||||
|
||||
@ -28,6 +28,12 @@ import org.apache.cloudstack.api.InternalIdentity;
|
||||
*
|
||||
*/
|
||||
public interface DiskOffering extends InfrastructureEntity, Identity, InternalIdentity {
|
||||
enum State {
|
||||
Inactive,
|
||||
Active,
|
||||
}
|
||||
|
||||
State getState();
|
||||
|
||||
String getUniqueName();
|
||||
|
||||
|
||||
@ -28,6 +28,10 @@ import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
|
||||
public interface VirtualMachineTemplate extends ControlledEntity, Identity, InternalIdentity {
|
||||
enum State {
|
||||
Active,
|
||||
Inactive;
|
||||
}
|
||||
|
||||
public static enum BootloaderType {
|
||||
PyGrub, HVM, External, CD
|
||||
@ -44,6 +48,8 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte
|
||||
all // all templates (only usable by admins)
|
||||
}
|
||||
|
||||
State getState();
|
||||
|
||||
boolean isFeatured();
|
||||
|
||||
/**
|
||||
|
||||
@ -16,17 +16,25 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.systemvm;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.*;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.SystemVmResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ManagementServerException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.VirtualMachineMigrationException;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
@ -85,7 +93,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
|
||||
public void execute(){
|
||||
CallContext.current().setEventDetails("SystemVm Id: "+getId());
|
||||
|
||||
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
|
||||
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||
if (serviceOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||
}
|
||||
@ -109,7 +117,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
|
||||
if (result != null) {
|
||||
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade system vm");
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.systemvm;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
@ -27,8 +29,6 @@ import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.SystemVmResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.user.Account;
|
||||
@ -88,7 +88,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
|
||||
public void execute(){
|
||||
CallContext.current().setEventDetails("Vm Id: "+getId());
|
||||
|
||||
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
|
||||
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||
if (serviceOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
|
||||
if (result != null) {
|
||||
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
|
||||
}
|
||||
|
||||
@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.address;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandJobType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
@ -36,8 +38,6 @@ import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.event.EventTypes;
|
||||
@ -216,7 +216,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
||||
throw new InvalidParameterValueException("Unable to find network by network id specified");
|
||||
}
|
||||
|
||||
NetworkOffering offering = _configService.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
|
||||
DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
|
||||
if (zone.getNetworkType() == NetworkType.Basic && offering.getElasticIp() && offering.getElasticLb()) {
|
||||
@ -278,8 +278,8 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
||||
}
|
||||
|
||||
if (ip != null) {
|
||||
this.setEntityId(ip.getId());
|
||||
this.setEntityUuid(ip.getUuid());
|
||||
setEntityId(ip.getId());
|
||||
setEntityUuid(ip.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to allocate ip address");
|
||||
}
|
||||
@ -309,7 +309,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
||||
if (result != null) {
|
||||
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result);
|
||||
ipResponse.setResponseName(getCommandName());
|
||||
this.setResponseObject(ipResponse);
|
||||
setResponseObject(ipResponse);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign ip address");
|
||||
}
|
||||
|
||||
@ -16,17 +16,24 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.network;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.*;
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkACLResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
@ -212,7 +219,7 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||
}
|
||||
|
||||
public Long getPhysicalNetworkId() {
|
||||
NetworkOffering offering = _configService.getNetworkOffering(networkOfferingId);
|
||||
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, networkOfferingId);
|
||||
if (offering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find network offering by id " + networkOfferingId);
|
||||
}
|
||||
@ -288,7 +295,7 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||
if (result != null) {
|
||||
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
setResponseObject(response);
|
||||
}else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network");
|
||||
}
|
||||
|
||||
@ -24,6 +24,8 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.api.ACL;
|
||||
@ -46,8 +48,6 @@ import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.event.EventTypes;
|
||||
@ -443,7 +443,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
||||
if (result != null) {
|
||||
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to deploy vm");
|
||||
}
|
||||
@ -460,7 +460,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
||||
throw new InvalidParameterValueException("Unable to find zone by id=" + zoneId);
|
||||
}
|
||||
|
||||
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
|
||||
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||
if (serviceOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||
}
|
||||
@ -473,7 +473,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
DiskOffering diskOffering = null;
|
||||
if (diskOfferingId != null) {
|
||||
diskOffering = _configService.getDiskOffering(diskOfferingId);
|
||||
diskOffering = _entityMgr.findById(DiskOffering.class, diskOfferingId);
|
||||
if (diskOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find disk offering " + diskOfferingId);
|
||||
}
|
||||
@ -495,19 +495,19 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
||||
throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
|
||||
} else {
|
||||
vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
|
||||
displayName, diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
|
||||
displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
|
||||
}
|
||||
} else {
|
||||
if (zone.isSecurityGroupEnabled()) {
|
||||
vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
|
||||
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
|
||||
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
|
||||
|
||||
} else {
|
||||
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
|
||||
throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
|
||||
}
|
||||
vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
|
||||
diskOfferingId, size, group, getHypervisor(), this.getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
|
||||
diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.vm;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
@ -26,8 +28,6 @@ import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
@ -92,7 +92,7 @@ public class UpgradeVMCmd extends BaseCmd {
|
||||
public void execute() throws ResourceAllocationException{
|
||||
CallContext.current().setEventDetails("Vm Id: "+getId());
|
||||
|
||||
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
|
||||
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||
if (serviceOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||
}
|
||||
@ -101,7 +101,7 @@ public class UpgradeVMCmd extends BaseCmd {
|
||||
if (result != null){
|
||||
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade vm");
|
||||
}
|
||||
|
||||
@ -2754,7 +2754,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
public boolean upgradeVmDb(long vmId, long serviceOfferingId) {
|
||||
VMInstanceVO vmForUpdate = _vmDao.createForUpdate();
|
||||
vmForUpdate.setServiceOfferingId(serviceOfferingId);
|
||||
ServiceOffering newSvcOff = _configMgr.getServiceOffering(serviceOfferingId);
|
||||
ServiceOffering newSvcOff = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||
vmForUpdate.setHaEnabled(newSvcOff.getOfferHA());
|
||||
vmForUpdate.setLimitCpuUse(newSvcOff.getLimitCpuUse());
|
||||
vmForUpdate.setServiceOfferingId(newSvcOff.getId());
|
||||
@ -3267,7 +3267,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
|
||||
|
||||
long newServiceofferingId = vm.getServiceOfferingId();
|
||||
ServiceOffering newServiceOffering = _configMgr.getServiceOffering(newServiceofferingId);
|
||||
ServiceOffering newServiceOffering = _entityMgr.findById(ServiceOffering.class, newServiceofferingId);
|
||||
HostVO hostVo = _hostDao.findById(vm.getHostId());
|
||||
|
||||
Float memoryOvercommitRatio = Float.parseFloat(_configServer.getConfigValue(Config.MemOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(),
|
||||
|
||||
@ -33,6 +33,7 @@ import java.util.Map;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.Spy;
|
||||
|
||||
@ -77,6 +78,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import com.cloud.hypervisor.HypervisorGuruManager;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
@ -96,6 +98,7 @@ import com.cloud.user.UserVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
@ -199,6 +202,8 @@ public class VirtualMachineManagerImplTest {
|
||||
HostVO _destHostMock;
|
||||
@Mock
|
||||
Map<Volume, StoragePool> _volumeToPoolMock;
|
||||
@Mock
|
||||
EntityManager _entityMgr;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@ -227,6 +232,7 @@ public class VirtualMachineManagerImplTest {
|
||||
_vmMgr._vmDao = _vmInstanceDao;
|
||||
_vmMgr._configServer = _configServer;
|
||||
_vmMgr._uservmDetailsDao = _vmDetailsDao;
|
||||
_vmMgr._entityMgr = _entityMgr;
|
||||
|
||||
when(_vmMock.getId()).thenReturn(314l);
|
||||
when(_vmInstance.getId()).thenReturn(1L);
|
||||
@ -236,7 +242,7 @@ public class VirtualMachineManagerImplTest {
|
||||
when(_vmInstance.getType()).thenReturn(VirtualMachine.Type.User);
|
||||
when(_host.getId()).thenReturn(1L);
|
||||
when(_hostDao.findById(anyLong())).thenReturn(null);
|
||||
when(_configMgr.getServiceOffering(anyLong())).thenReturn(getSvcoffering(512));
|
||||
when(_entityMgr.findById(Mockito.eq(ServiceOffering.class), anyLong())).thenReturn(getSvcoffering(512));
|
||||
when(_workDao.persist(_work)).thenReturn(_work);
|
||||
when(_workDao.update("1", _work)).thenReturn(true);
|
||||
when(_work.getId()).thenReturn("1");
|
||||
|
||||
@ -24,6 +24,8 @@ import javax.persistence.Column;
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.DiscriminatorType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
@ -72,7 +74,7 @@ public class DiskOfferingVO implements DiskOffering {
|
||||
@Column(name = "type")
|
||||
Type type;
|
||||
|
||||
@Column(name = GenericDao.REMOVED)
|
||||
@Column(name = GenericDao.REMOVED_COLUMN)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date removed;
|
||||
|
||||
@ -121,8 +123,12 @@ public class DiskOfferingVO implements DiskOffering {
|
||||
@Column(name="display_offering")
|
||||
boolean displayOffering = true;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "state")
|
||||
State state;
|
||||
|
||||
public DiskOfferingVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public DiskOfferingVO(Long domainId, String name, String displayText, long diskSize, String tags, boolean isCustomized,
|
||||
@ -132,20 +138,21 @@ public class DiskOfferingVO implements DiskOffering {
|
||||
this.displayText = displayText;
|
||||
this.diskSize = diskSize;
|
||||
this.tags = tags;
|
||||
this.recreatable = false;
|
||||
this.type = Type.Disk;
|
||||
this.useLocalStorage = false;
|
||||
this.customized = isCustomized;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.customizedIops = isCustomizedIops;
|
||||
recreatable = false;
|
||||
type = Type.Disk;
|
||||
useLocalStorage = false;
|
||||
customized = isCustomized;
|
||||
uuid = UUID.randomUUID().toString();
|
||||
customizedIops = isCustomizedIops;
|
||||
this.minIops = minIops;
|
||||
this.maxIops = maxIops;
|
||||
state = State.Active;
|
||||
}
|
||||
|
||||
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable,
|
||||
boolean useLocalStorage, boolean systemUse, boolean customized) {
|
||||
this.domainId = null;
|
||||
this.type = Type.Service;
|
||||
domainId = null;
|
||||
type = Type.Service;
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.tags = tags;
|
||||
@ -153,14 +160,15 @@ public class DiskOfferingVO implements DiskOffering {
|
||||
this.useLocalStorage = useLocalStorage;
|
||||
this.systemUse = systemUse;
|
||||
this.customized = customized;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
uuid = UUID.randomUUID().toString();
|
||||
state = State.Active;
|
||||
}
|
||||
|
||||
// domain specific offerings constructor (null domainId implies public
|
||||
// offering)
|
||||
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable,
|
||||
boolean useLocalStorage, boolean systemUse, boolean customized, Long domainId) {
|
||||
this.type = Type.Service;
|
||||
type = Type.Service;
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.tags = tags;
|
||||
@ -169,7 +177,17 @@ public class DiskOfferingVO implements DiskOffering {
|
||||
this.systemUse = systemUse;
|
||||
this.customized = customized;
|
||||
this.domainId = domainId;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
uuid = UUID.randomUUID().toString();
|
||||
state = State.Active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -235,6 +253,7 @@ public class DiskOfferingVO implements DiskOffering {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecreatable() {
|
||||
return recreatable;
|
||||
}
|
||||
@ -299,7 +318,7 @@ public class DiskOfferingVO implements DiskOffering {
|
||||
}
|
||||
|
||||
public void setUniqueName(String name) {
|
||||
this.uniqueName = name;
|
||||
uniqueName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -355,7 +374,7 @@ public class DiskOfferingVO implements DiskOffering {
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
@ -382,34 +401,42 @@ public class DiskOfferingVO implements DiskOffering {
|
||||
this.displayOffering = displayOffering;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytesReadRate(Long bytesReadRate) {
|
||||
this.bytesReadRate = bytesReadRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getBytesReadRate() {
|
||||
return bytesReadRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBytesWriteRate(Long bytesWriteRate) {
|
||||
this.bytesWriteRate = bytesWriteRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getBytesWriteRate() {
|
||||
return bytesWriteRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIopsReadRate(Long iopsReadRate) {
|
||||
this.iopsReadRate = iopsReadRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getIopsReadRate() {
|
||||
return iopsReadRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIopsWriteRate(Long iopsWriteRate) {
|
||||
this.iopsWriteRate = iopsWriteRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getIopsWriteRate() {
|
||||
return iopsWriteRate;
|
||||
}
|
||||
|
||||
@ -31,14 +31,11 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
|
||||
@Entity
|
||||
@Table(name = "vm_template")
|
||||
@ -80,7 +77,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
@Column(name = GenericDao.CREATED_COLUMN)
|
||||
private Date created = null;
|
||||
|
||||
@Column(name = GenericDao.REMOVED)
|
||||
@Column(name = GenericDao.REMOVED_COLUMN)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date removed;
|
||||
|
||||
@ -118,6 +115,10 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
@Column(name = "source_template_id")
|
||||
private Long sourceTemplateId;
|
||||
|
||||
@Column(name = "state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private State state;
|
||||
|
||||
@Column(name = "template_tag")
|
||||
private String templateTag;
|
||||
|
||||
@ -141,7 +142,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
Date updated;
|
||||
|
||||
@Transient
|
||||
Map details;
|
||||
Map<String, String> details;
|
||||
|
||||
@Column(name = "dynamically_scalable")
|
||||
protected boolean dynamicallyScalable;
|
||||
@ -156,7 +157,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
}
|
||||
|
||||
public VMTemplateVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,23 +166,24 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured,
|
||||
boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId,
|
||||
String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable,
|
||||
HypervisorType hyperType, Map details) {
|
||||
HypervisorType hyperType, Map<String, String> details) {
|
||||
this(id, generateUniqueName(id, accountId, name), name, format, isPublic, featured, isExtractable, type, url,
|
||||
null, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType,
|
||||
details);
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured,
|
||||
boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId,
|
||||
String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable,
|
||||
HypervisorType hyperType, String templateTag, Map details, boolean sshKeyEnabled, boolean isDynamicallyScalable) {
|
||||
HypervisorType hyperType, String templateTag, Map<String, String> details, boolean sshKeyEnabled, boolean isDynamicallyScalable) {
|
||||
this(id, name, format, isPublic, featured, isExtractable, type, url, requiresHvm, bits, accountId, cksum,
|
||||
displayText, enablePassword, guestOSId, bootable, hyperType, details);
|
||||
this.templateTag = templateTag;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.enableSshKey = sshKeyEnabled;
|
||||
this.dynamicallyScalable = isDynamicallyScalable;
|
||||
uuid = UUID.randomUUID().toString();
|
||||
enableSshKey = sshKeyEnabled;
|
||||
dynamicallyScalable = isDynamicallyScalable;
|
||||
state = State.Active;
|
||||
}
|
||||
|
||||
|
||||
@ -200,14 +202,14 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
HypervisorType hyperType) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.publicTemplate = isPublic;
|
||||
publicTemplate = isPublic;
|
||||
this.featured = featured;
|
||||
this.templateType = type;
|
||||
templateType = type;
|
||||
this.url = url;
|
||||
this.requiresHvm = requiresHvm;
|
||||
this.bits = bits;
|
||||
this.accountId = accountId;
|
||||
this.checksum = cksum;
|
||||
checksum = cksum;
|
||||
this.uniqueName = uniqueName;
|
||||
this.displayText = displayText;
|
||||
this.enablePassword = enablePassword;
|
||||
@ -215,30 +217,33 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
this.created = created;
|
||||
this.guestOSId = guestOSId;
|
||||
this.bootable = bootable;
|
||||
this.hypervisorType = hyperType;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
hypervisorType = hyperType;
|
||||
uuid = UUID.randomUUID().toString();
|
||||
state = State.Active;
|
||||
}
|
||||
|
||||
// Has an extra attribute - isExtractable
|
||||
public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic,
|
||||
boolean featured, boolean isExtractable, TemplateType type, String url, Date created, boolean requiresHvm,
|
||||
int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId,
|
||||
boolean bootable, HypervisorType hyperType, Map details) {
|
||||
boolean bootable, HypervisorType hyperType, Map<String, String> details) {
|
||||
this(id, uniqueName, name, format, isPublic, featured, type, url, created, requiresHvm, bits, accountId, cksum,
|
||||
displayText, enablePassword, guestOSId, bootable, hyperType);
|
||||
this.extractable = isExtractable;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
extractable = isExtractable;
|
||||
uuid = UUID.randomUUID().toString();
|
||||
this.details = details;
|
||||
state = State.Active;
|
||||
}
|
||||
|
||||
public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic,
|
||||
boolean featured, boolean isExtractable, TemplateType type, String url, Date created, boolean requiresHvm,
|
||||
int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId,
|
||||
boolean bootable, HypervisorType hyperType, String templateTag, Map details) {
|
||||
boolean bootable, HypervisorType hyperType, String templateTag, Map<String, String> details) {
|
||||
this(id, uniqueName, name, format, isPublic, featured, isExtractable, type, url, created, requiresHvm, bits,
|
||||
accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType, details);
|
||||
this.templateTag = templateTag;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
uuid = UUID.randomUUID().toString();
|
||||
state = State.Active;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -269,6 +274,15 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
@ -280,7 +294,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
}
|
||||
|
||||
public void setTemplateType(TemplateType type) {
|
||||
this.templateType = type;
|
||||
templateType = type;
|
||||
}
|
||||
|
||||
public boolean requiresHvm() {
|
||||
@ -455,18 +469,19 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public Map getDetails() {
|
||||
return this.details;
|
||||
@Override
|
||||
public Map<String, String> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(Map details) {
|
||||
public void setDetails(Map<String, String> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
@ -480,7 +495,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
}
|
||||
VMTemplateVO other = (VMTemplateVO) that;
|
||||
|
||||
return ((this.getUniqueName().equals(other.getUniqueName())));
|
||||
return ((getUniqueName().equals(other.getUniqueName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -516,8 +531,9 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
this.dynamicallyScalable = dynamicallyScalable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isDynamicallyScalable() {
|
||||
return this.dynamicallyScalable;
|
||||
return dynamicallyScalable;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -534,19 +550,19 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return this.size;
|
||||
return size;
|
||||
}
|
||||
|
||||
public long getUpdatedCount() {
|
||||
return this.updatedCount;
|
||||
return updatedCount;
|
||||
}
|
||||
|
||||
public void incrUpdatedCount() {
|
||||
this.updatedCount++;
|
||||
updatedCount++;
|
||||
}
|
||||
|
||||
public void decrUpdatedCount() {
|
||||
this.updatedCount--;
|
||||
updatedCount--;
|
||||
}
|
||||
|
||||
public Date getUpdated() {
|
||||
|
||||
@ -23,6 +23,8 @@ import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
@ -33,7 +35,6 @@ import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.to.DataObjectType;
|
||||
@ -70,7 +71,7 @@ public class TemplateObject implements TemplateInfo {
|
||||
}
|
||||
|
||||
protected void configure(VMTemplateVO template, DataStore dataStore) {
|
||||
this.imageVO = template;
|
||||
imageVO = template;
|
||||
this.dataStore = dataStore;
|
||||
}
|
||||
|
||||
@ -81,31 +82,36 @@ public class TemplateObject implements TemplateInfo {
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.imageVO.setSize(size);
|
||||
imageVO.setSize(size);
|
||||
}
|
||||
|
||||
public VMTemplateVO getImage() {
|
||||
return this.imageVO;
|
||||
return imageVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStore getDataStore() {
|
||||
return this.dataStore;
|
||||
return dataStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueName() {
|
||||
return this.imageVO.getUniqueName();
|
||||
return imageVO.getUniqueName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return this.imageVO.getId();
|
||||
return imageVO.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return imageVO.getState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.imageVO.getUuid();
|
||||
return imageVO.getUuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -113,7 +119,7 @@ public class TemplateObject implements TemplateInfo {
|
||||
if ( url != null ){
|
||||
return url;
|
||||
}
|
||||
VMTemplateVO image = imageDao.findById(this.imageVO.getId());
|
||||
VMTemplateVO image = imageDao.findById(imageVO.getId());
|
||||
|
||||
return image.getUrl();
|
||||
|
||||
@ -121,8 +127,8 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public Long getSize() {
|
||||
if (this.dataStore == null) {
|
||||
return this.imageVO.getSize();
|
||||
if (dataStore == null) {
|
||||
return imageVO.getSize();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -142,7 +148,7 @@ public class TemplateObject implements TemplateInfo {
|
||||
* templateSize = templateHostVO.getSize(); } totalAllocatedSize +=
|
||||
* (templateSize + _extraBytesPerVolume); }
|
||||
*/
|
||||
VMTemplateVO image = imageDao.findById(this.imageVO.getId());
|
||||
VMTemplateVO image = imageDao.findById(imageVO.getId());
|
||||
return image.getSize();
|
||||
}
|
||||
|
||||
@ -153,7 +159,7 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public ImageFormat getFormat() {
|
||||
return this.imageVO.getFormat();
|
||||
return imageVO.getFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -175,25 +181,24 @@ public class TemplateObject implements TemplateInfo {
|
||||
@Override
|
||||
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
|
||||
try {
|
||||
if (this.getDataStore().getRole() == DataStoreRole.Primary) {
|
||||
if (getDataStore().getRole() == DataStoreRole.Primary) {
|
||||
if (answer instanceof CopyCmdAnswer) {
|
||||
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer) answer;
|
||||
TemplateObjectTO newTemplate = (TemplateObjectTO) cpyAnswer.getNewData();
|
||||
VMTemplateStoragePoolVO templatePoolRef = templatePoolDao.findByPoolTemplate(this.getDataStore()
|
||||
.getId(), this.getId());
|
||||
VMTemplateStoragePoolVO templatePoolRef = templatePoolDao.findByPoolTemplate(getDataStore()
|
||||
.getId(), getId());
|
||||
templatePoolRef.setDownloadPercent(100);
|
||||
templatePoolRef.setDownloadState(Status.DOWNLOADED);
|
||||
templatePoolRef.setLocalDownloadPath(newTemplate.getPath());
|
||||
templatePoolRef.setInstallPath(newTemplate.getPath());
|
||||
templatePoolDao.update(templatePoolRef.getId(), templatePoolRef);
|
||||
}
|
||||
} else if (this.getDataStore().getRole() == DataStoreRole.Image
|
||||
|| this.getDataStore().getRole() == DataStoreRole.ImageCache) {
|
||||
} else if (getDataStore().getRole() == DataStoreRole.Image
|
||||
|| getDataStore().getRole() == DataStoreRole.ImageCache) {
|
||||
if (answer instanceof CopyCmdAnswer) {
|
||||
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer) answer;
|
||||
TemplateObjectTO newTemplate = (TemplateObjectTO) cpyAnswer.getNewData();
|
||||
TemplateDataStoreVO templateStoreRef = this.templateStoreDao.findByStoreTemplate(this
|
||||
.getDataStore().getId(), this.getId());
|
||||
TemplateDataStoreVO templateStoreRef = templateStoreDao.findByStoreTemplate(getDataStore().getId(), getId());
|
||||
templateStoreRef.setInstallPath(newTemplate.getPath());
|
||||
templateStoreRef.setDownloadPercent(100);
|
||||
templateStoreRef.setDownloadState(Status.DOWNLOADED);
|
||||
@ -202,8 +207,8 @@ public class TemplateObject implements TemplateInfo {
|
||||
templateStoreRef.setPhysicalSize(newTemplate.getPhysicalSize());
|
||||
}
|
||||
templateStoreDao.update(templateStoreRef.getId(), templateStoreRef);
|
||||
if (this.getDataStore().getRole() == DataStoreRole.Image) {
|
||||
VMTemplateVO templateVO = this.imageDao.findById(this.getId());
|
||||
if (getDataStore().getRole() == DataStoreRole.Image) {
|
||||
VMTemplateVO templateVO = imageDao.findById(getId());
|
||||
if (newTemplate.getFormat() != null) {
|
||||
templateVO.setFormat(newTemplate.getFormat());
|
||||
}
|
||||
@ -212,7 +217,7 @@ public class TemplateObject implements TemplateInfo {
|
||||
templateVO.setUniqueName(newTemplate.getName());
|
||||
}
|
||||
templateVO.setSize(newTemplate.getSize());
|
||||
this.imageDao.update(templateVO.getId(), templateVO);
|
||||
imageDao.update(templateVO.getId(), templateVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -234,12 +239,12 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public void incRefCount() {
|
||||
if (this.dataStore == null) {
|
||||
if (dataStore == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), this.getId());
|
||||
if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
|
||||
store.incrRefCnt();
|
||||
store.setLastUpdated(new Date());
|
||||
templateStoreDao.update(store.getId(), store);
|
||||
@ -248,11 +253,11 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public void decRefCount() {
|
||||
if (this.dataStore == null) {
|
||||
if (dataStore == null) {
|
||||
return;
|
||||
}
|
||||
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), this.getId());
|
||||
if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
|
||||
store.decrRefCnt();
|
||||
store.setLastUpdated(new Date());
|
||||
templateStoreDao.update(store.getId(), store);
|
||||
@ -261,11 +266,11 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public Long getRefCount() {
|
||||
if (this.dataStore == null) {
|
||||
if (dataStore == null) {
|
||||
return null;
|
||||
}
|
||||
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), this.getId());
|
||||
if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
|
||||
return store.getRefCnt();
|
||||
}
|
||||
return null;
|
||||
@ -274,10 +279,10 @@ public class TemplateObject implements TemplateInfo {
|
||||
@Override
|
||||
public DataTO getTO() {
|
||||
DataTO to = null;
|
||||
if (this.dataStore == null) {
|
||||
if (dataStore == null) {
|
||||
to = new TemplateObjectTO(this);
|
||||
} else {
|
||||
to = this.dataStore.getDriver().getTO(this);
|
||||
to = dataStore.getDriver().getTO(this);
|
||||
if (to == null) {
|
||||
to = new TemplateObjectTO(this);
|
||||
}
|
||||
@ -288,91 +293,91 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public String getInstallPath() {
|
||||
if (this.dataStore == null) {
|
||||
if (dataStore == null) {
|
||||
return null;
|
||||
}
|
||||
DataObjectInStore obj = objectInStoreMgr.findObject(this, this.dataStore);
|
||||
DataObjectInStore obj = objectInStoreMgr.findObject(this, dataStore);
|
||||
return obj.getInstallPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
return this.imageVO.getAccountId();
|
||||
return imageVO.getAccountId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatured() {
|
||||
return this.imageVO.isFeatured();
|
||||
return imageVO.isFeatured();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPublicTemplate() {
|
||||
return this.imageVO.isPublicTemplate();
|
||||
return imageVO.isPublicTemplate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtractable() {
|
||||
return this.imageVO.isExtractable();
|
||||
return imageVO.isExtractable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.imageVO.getName();
|
||||
return imageVO.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequiresHvm() {
|
||||
return this.imageVO.isRequiresHvm();
|
||||
return imageVO.isRequiresHvm();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayText() {
|
||||
return this.imageVO.getDisplayText();
|
||||
return imageVO.getDisplayText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnablePassword() {
|
||||
return this.imageVO.getEnablePassword();
|
||||
return imageVO.getEnablePassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnableSshKey() {
|
||||
return this.imageVO.getEnableSshKey();
|
||||
return imageVO.getEnableSshKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCrossZones() {
|
||||
return this.imageVO.isCrossZones();
|
||||
return imageVO.isCrossZones();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreated() {
|
||||
return this.imageVO.getCreated();
|
||||
return imageVO.getCreated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGuestOSId() {
|
||||
return this.imageVO.getGuestOSId();
|
||||
return imageVO.getGuestOSId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBootable() {
|
||||
return this.imageVO.isBootable();
|
||||
return imageVO.isBootable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateType getTemplateType() {
|
||||
return this.imageVO.getTemplateType();
|
||||
return imageVO.getTemplateType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
return this.imageVO.getHypervisorType();
|
||||
return imageVO.getHypervisorType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBits() {
|
||||
return this.imageVO.getBits();
|
||||
return imageVO.getBits();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -380,7 +385,7 @@ public class TemplateObject implements TemplateInfo {
|
||||
if (url != null ){
|
||||
return url;
|
||||
}
|
||||
return this.imageVO.getUrl();
|
||||
return imageVO.getUrl();
|
||||
}
|
||||
|
||||
public void setUrl(String url){
|
||||
@ -389,22 +394,22 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public String getChecksum() {
|
||||
return this.imageVO.getChecksum();
|
||||
return imageVO.getChecksum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSourceTemplateId() {
|
||||
return this.imageVO.getSourceTemplateId();
|
||||
return imageVO.getSourceTemplateId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateTag() {
|
||||
return this.imageVO.getTemplateTag();
|
||||
return imageVO.getTemplateTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getDetails() {
|
||||
return this.imageVO.getDetails();
|
||||
return imageVO.getDetails();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -414,7 +419,7 @@ public class TemplateObject implements TemplateInfo {
|
||||
|
||||
@Override
|
||||
public long getDomainId() {
|
||||
return this.imageVO.getDomainId();
|
||||
return imageVO.getDomainId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -34,6 +34,11 @@ import com.cloud.storage.Storage.TemplateType;
|
||||
public class TemplateEntityImpl implements TemplateEntity {
|
||||
protected TemplateInfo templateInfo;
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return templateInfo.getState();
|
||||
}
|
||||
|
||||
public TemplateEntityImpl(TemplateInfo templateInfo) {
|
||||
this.templateInfo = templateInfo;
|
||||
}
|
||||
@ -47,17 +52,17 @@ public class TemplateEntityImpl implements TemplateEntity {
|
||||
}
|
||||
|
||||
public TemplateInfo getTemplateInfo() {
|
||||
return this.templateInfo;
|
||||
return templateInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.templateInfo.getUuid();
|
||||
return templateInfo.getUuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return this.templateInfo.getId();
|
||||
return templateInfo.getId();
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
|
||||
@ -31,9 +31,7 @@ public interface GenericDao<T, ID extends Serializable> {
|
||||
|
||||
/**
|
||||
*/
|
||||
static final String REMOVED_COLUMN = "cloud_removed";
|
||||
|
||||
static final String REMOVED = "removed";
|
||||
static final String REMOVED_COLUMN = "removed";
|
||||
|
||||
/**
|
||||
* This column can be used if the table wants to track creation time.
|
||||
|
||||
@ -136,7 +136,6 @@ public class SqlGenerator {
|
||||
Attribute attr = new Attribute(clazz, overrides, field, tableName, embedded, isId);
|
||||
|
||||
if (attr.getColumnName().equals(GenericDao.REMOVED_COLUMN)) {
|
||||
attr.setColumnName(GenericDao.REMOVED);
|
||||
attr.setTrue(Attribute.Flag.DaoGenerated);
|
||||
attr.setFalse(Attribute.Flag.Insertable);
|
||||
attr.setFalse(Attribute.Flag.Updatable);
|
||||
@ -145,7 +144,7 @@ public class SqlGenerator {
|
||||
attr.setFalse(Attribute.Flag.Date);
|
||||
attr.setTrue(Attribute.Flag.Nullable);
|
||||
attr.setTrue(Attribute.Flag.Removed);
|
||||
}
|
||||
}
|
||||
|
||||
if (attr.isId()) {
|
||||
List<Attribute> attrs = _ids.get(tableName);
|
||||
@ -281,7 +280,7 @@ public class SqlGenerator {
|
||||
for (Attribute attr : _attributes) {
|
||||
|
||||
if (attr.columnName.equalsIgnoreCase(name)) {
|
||||
if (attr.columnName.equalsIgnoreCase(GenericDao.REMOVED) && attr.isUpdatable()) {
|
||||
if (attr.columnName.equalsIgnoreCase(GenericDao.REMOVED_COLUMN) && attr.isUpdatable()) {
|
||||
return null;
|
||||
}
|
||||
return attr;
|
||||
@ -385,7 +384,7 @@ public class SqlGenerator {
|
||||
}
|
||||
|
||||
sql.append(") VALUES (");
|
||||
for (Attribute attr : attrs) {
|
||||
for (int i = 0; i < attrs.size(); i++) {
|
||||
sql.append("?, ");
|
||||
}
|
||||
|
||||
@ -435,7 +434,7 @@ public class SqlGenerator {
|
||||
}
|
||||
|
||||
public Pair<String, Attribute[]> buildRemoveSql() {
|
||||
Attribute attribute = findAttribute(GenericDao.REMOVED);
|
||||
Attribute attribute = findAttribute(GenericDao.REMOVED_COLUMN);
|
||||
if (attribute == null) {
|
||||
return null;
|
||||
}
|
||||
@ -518,7 +517,7 @@ public class SqlGenerator {
|
||||
}
|
||||
|
||||
public Pair<String, Attribute> getRemovedAttribute() {
|
||||
Attribute removed = findAttribute(GenericDao.REMOVED);
|
||||
Attribute removed = findAttribute(GenericDao.REMOVED_COLUMN);
|
||||
if (removed == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -106,6 +106,7 @@ import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.ConfigurationService;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.dc.AccountVlanMapVO;
|
||||
@ -203,7 +204,6 @@ import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.network.vpc.dao.VpcGatewayDao;
|
||||
import com.cloud.network.vpc.dao.VpcOfferingDao;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
@ -298,6 +298,7 @@ public class ApiDBUtils {
|
||||
static NetworkModel _networkModel;
|
||||
static NetworkManager _networkMgr;
|
||||
static TemplateManager _templateMgr;
|
||||
static ConfigurationManager _configMgr;
|
||||
|
||||
static StatsCollector _statsCollector;
|
||||
|
||||
@ -340,7 +341,7 @@ public class ApiDBUtils {
|
||||
static NetworkOfferingDao _networkOfferingDao;
|
||||
static NetworkDao _networkDao;
|
||||
static PhysicalNetworkDao _physicalNetworkDao;
|
||||
static ConfigurationService _configMgr;
|
||||
static ConfigurationService _configSvc;
|
||||
static ConfigurationDao _configDao;
|
||||
static ConsoleProxyDao _consoleProxyDao;
|
||||
static FirewallRulesCidrsDao _firewallCidrsDao;
|
||||
@ -452,7 +453,7 @@ public class ApiDBUtils {
|
||||
@Inject private NetworkOfferingDao networkOfferingDao;
|
||||
@Inject private NetworkDao networkDao;
|
||||
@Inject private PhysicalNetworkDao physicalNetworkDao;
|
||||
@Inject private ConfigurationService configMgr;
|
||||
@Inject private ConfigurationService configSvc;
|
||||
@Inject private ConfigurationDao configDao;
|
||||
@Inject private ConsoleProxyDao consoleProxyDao;
|
||||
@Inject private FirewallRulesCidrsDao firewallCidrsDao;
|
||||
@ -511,17 +512,20 @@ public class ApiDBUtils {
|
||||
@Inject private NetworkACLDao networkACLDao;
|
||||
@Inject private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
|
||||
@Inject private AccountService accountService;
|
||||
@Inject
|
||||
private ConfigurationManager configMgr;
|
||||
|
||||
@PostConstruct
|
||||
void init() {
|
||||
_ms = ms;
|
||||
_configMgr = configMgr;
|
||||
_asyncMgr = asyncMgr;
|
||||
_securityGroupMgr = securityGroupMgr;
|
||||
_storageMgr = storageMgr;
|
||||
_userVmMgr = userVmMgr;
|
||||
_networkModel = networkModel;
|
||||
_networkMgr = networkMgr;
|
||||
_configMgr = configMgr;
|
||||
_configSvc = configSvc;
|
||||
_templateMgr = templateMgr;
|
||||
|
||||
_accountDao = accountDao;
|
||||
@ -1026,7 +1030,7 @@ public class ApiDBUtils {
|
||||
}
|
||||
|
||||
public static Account getVlanAccount(long vlanId) {
|
||||
return _configMgr.getVlanAccount(vlanId);
|
||||
return _configSvc.getVlanAccount(vlanId);
|
||||
}
|
||||
|
||||
public static boolean isSecurityGroupEnabledInZone(long zoneId) {
|
||||
@ -1153,11 +1157,6 @@ public class ApiDBUtils {
|
||||
return _taggedResourceService.getUuid(resourceId, resourceType);
|
||||
}
|
||||
|
||||
public static boolean isOfferingForVpc(NetworkOffering offering) {
|
||||
boolean vpcProvider = _configMgr.isOfferingForVpc(offering);
|
||||
return vpcProvider;
|
||||
}
|
||||
|
||||
public static List<? extends ResourceTag> listByResourceTypeAndId(TaggedResourceType type, long resourceId) {
|
||||
return _taggedResourceService.listByResourceTypeAndId(type, resourceId);
|
||||
}
|
||||
|
||||
@ -172,6 +172,7 @@ import com.cloud.api.response.ApiResponseSerializer;
|
||||
import com.cloud.capacity.Capacity;
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.Resource.ResourceOwnerType;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.configuration.ResourceCount;
|
||||
@ -309,6 +310,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
protected AccountManager _accountMgr;
|
||||
@Inject
|
||||
protected AsyncJobManager _jobMgr;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
|
||||
@Override
|
||||
public UserResponse createUserResponse(User user) {
|
||||
@ -2089,7 +2092,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
|
||||
serviceResponses.add(svcRsp);
|
||||
}
|
||||
response.setForVpc(ApiDBUtils.isOfferingForVpc(offering));
|
||||
response.setForVpc(_configMgr.isOfferingForVpc(offering));
|
||||
|
||||
response.setServices(serviceResponses);
|
||||
|
||||
|
||||
@ -43,7 +43,6 @@ import com.cloud.org.Grouping.AllocationState;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
/**
|
||||
@ -51,7 +50,16 @@ import com.cloud.vm.VirtualMachine;
|
||||
* configuration values
|
||||
*
|
||||
*/
|
||||
public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
public interface ConfigurationManager {
|
||||
/**
|
||||
* @param offering
|
||||
* @return
|
||||
*/
|
||||
boolean isOfferingForVpc(NetworkOffering offering);
|
||||
|
||||
Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId);
|
||||
|
||||
Integer getServiceOfferingNetworkRate(long serviceOfferingId, Long dataCenterId);
|
||||
|
||||
/**
|
||||
* Updates a configuration entry with a new value
|
||||
|
||||
@ -207,7 +207,7 @@ import com.cloud.vm.dao.NicSecondaryIpDao;
|
||||
|
||||
@Local(value = { ConfigurationManager.class, ConfigurationService.class })
|
||||
public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService {
|
||||
public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class.getName());
|
||||
public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class);
|
||||
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
@ -2228,7 +2228,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
|
||||
// Verify input parameters
|
||||
ServiceOffering offeringHandle = getServiceOffering(id);
|
||||
ServiceOffering offeringHandle = _entityMgr.findById(ServiceOffering.class, id);
|
||||
|
||||
if (offeringHandle == null) {
|
||||
throw new InvalidParameterValueException("unable to find service offering " + id);
|
||||
@ -2419,7 +2419,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
Integer sortKey = cmd.getSortKey();
|
||||
|
||||
// Check if diskOffering exists
|
||||
DiskOffering diskOfferingHandle = getDiskOffering(diskOfferingId);
|
||||
DiskOffering diskOfferingHandle = _entityMgr.findById(DiskOffering.class, diskOfferingId);
|
||||
|
||||
if (diskOfferingHandle == null) {
|
||||
throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
|
||||
@ -2482,13 +2482,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
public boolean deleteDiskOffering(DeleteDiskOfferingCmd cmd) {
|
||||
Long diskOfferingId = cmd.getId();
|
||||
|
||||
DiskOffering offering = getDiskOffering(diskOfferingId);
|
||||
DiskOfferingVO offering = _diskOfferingDao.findById(diskOfferingId);
|
||||
|
||||
if (offering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
|
||||
}
|
||||
|
||||
if (_diskOfferingDao.remove(diskOfferingId)) {
|
||||
offering.setState(DiskOffering.State.Inactive);
|
||||
if (_diskOfferingDao.update(offering.getId(), offering)) {
|
||||
CallContext.current().setEventDetails("Disk offering id=" + diskOfferingId);
|
||||
return true;
|
||||
} else {
|
||||
@ -2508,7 +2509,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
|
||||
// Verify service offering id
|
||||
ServiceOffering offering = getServiceOffering(offeringId);
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(offeringId);
|
||||
if (offering == null) {
|
||||
throw new InvalidParameterValueException("unable to find service offering " + offeringId);
|
||||
}
|
||||
@ -2517,7 +2518,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
throw new InvalidParameterValueException("Default service offerings cannot be deleted");
|
||||
}
|
||||
|
||||
if (_serviceOfferingDao.remove(offeringId)) {
|
||||
offering.setState(DiskOffering.State.Inactive);
|
||||
if (_serviceOfferingDao.update(offeringId, offering)) {
|
||||
CallContext.current().setEventDetails("Service offering id=" + offeringId);
|
||||
return true;
|
||||
} else {
|
||||
@ -4767,16 +4769,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkOffering getNetworkOffering(long id) {
|
||||
return _networkOfferingDao.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId) {
|
||||
|
||||
// validate network offering information
|
||||
NetworkOffering no = getNetworkOffering(networkOfferingId);
|
||||
NetworkOffering no = _entityMgr.findById(NetworkOffering.class, networkOfferingId);
|
||||
if (no == null) {
|
||||
throw new InvalidParameterValueException("Unable to find network offering by id=" + networkOfferingId);
|
||||
}
|
||||
@ -4888,16 +4885,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ServiceOffering getServiceOffering(long serviceOfferingId) {
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(serviceOfferingId);
|
||||
if (offering != null && offering.getRemoved() == null) {
|
||||
return offering;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getDefaultPageSize() {
|
||||
return _defaultPageSize;
|
||||
@ -4937,16 +4924,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
return networkRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiskOffering getDiskOffering(long diskOfferingId) {
|
||||
DiskOfferingVO offering = _diskOfferingDao.findById(diskOfferingId);
|
||||
if (offering != null && offering.getRemoved() == null) {
|
||||
return offering;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_RANGE_CREATE,
|
||||
|
||||
@ -1768,7 +1768,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
||||
@Override
|
||||
public IpAddress assignSystemIp(long networkId, Account owner, boolean forElasticLb, boolean forElasticIp) throws InsufficientAddressCapacityException {
|
||||
Network guestNetwork = _networksDao.findById(networkId);
|
||||
NetworkOffering off = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
NetworkOffering off = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
|
||||
IpAddress ip = null;
|
||||
if ((off.getElasticLb() && forElasticLb) || (off.getElasticIp() && forElasticIp)) {
|
||||
|
||||
|
||||
@ -1821,7 +1821,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
||||
// If networkDomain is not specified, take it from the global configuration
|
||||
if (_networkModel.areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) {
|
||||
Map<Network.Capability, String> dnsCapabilities = _networkModel.getNetworkOfferingServiceCapabilities
|
||||
(_configMgr.getNetworkOffering(networkOfferingId), Service.Dns);
|
||||
(_entityMgr.findById(NetworkOffering.class, networkOfferingId), Service.Dns);
|
||||
String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification);
|
||||
if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
|
||||
if (networkDomain != null) {
|
||||
@ -2214,7 +2214,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
||||
_networkAccountDao.remove(networkAccount.getId());
|
||||
}
|
||||
|
||||
NetworkOffering ntwkOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering ntwkOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
boolean updateResourceCount = resourceCountNeedsUpdate(ntwkOff, network.getAclType());
|
||||
if (updateResourceCount) {
|
||||
_resourceLimitMgr.decrementResourceCount(owner.getId(), ResourceType.network);
|
||||
@ -3105,7 +3105,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
||||
if (lbElements.size() > 1) {
|
||||
String providerName = null;
|
||||
//get network offering details
|
||||
NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering off = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
if (lbScheme == Scheme.Public) {
|
||||
providerName = _ntwkOffDetailsDao.getDetail(off.getId(), NetworkOffering.Detail.PublicLbProvider);
|
||||
} else {
|
||||
|
||||
@ -32,13 +32,12 @@ import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
@ -104,6 +103,7 @@ import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
@ -121,11 +121,11 @@ import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.NicSecondaryIpDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Component
|
||||
@Local(value = { NetworkModel.class})
|
||||
public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
static final Logger s_logger = Logger.getLogger(NetworkModelImpl.class);
|
||||
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
@Inject
|
||||
DataCenterDao _dcDao = null;
|
||||
@Inject
|
||||
@ -179,7 +179,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
@Inject
|
||||
PhysicalNetworkServiceProviderDao _pNSPDao;
|
||||
@Inject
|
||||
PortForwardingRulesDao _portForwardingRulesDao;
|
||||
PortForwardingRulesDao _portForwardingRulesDao;
|
||||
@Inject
|
||||
PhysicalNetworkTrafficTypeDao _pNTrafficTypeDao;
|
||||
@Inject
|
||||
@ -520,7 +520,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
public List<IPAddressVO> listPublicIpsAssignedToGuestNtwk(long accountId, long associatedNetworkId, Boolean sourceNat) {
|
||||
SearchCriteria<IPAddressVO> sc = IpAddressSearch.create();
|
||||
sc.setParameters("accountId", accountId);
|
||||
sc.setParameters("associatedWithNetworkId", associatedNetworkId);
|
||||
sc.setParameters("associatedWithNetworkId", associatedNetworkId);
|
||||
|
||||
if (sourceNat != null) {
|
||||
sc.addAnd("sourceNat", SearchCriteria.Op.EQ, sourceNat);
|
||||
@ -555,7 +555,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
public String getNextAvailableMacAddressInNetwork(long networkId) throws InsufficientAddressCapacityException {
|
||||
String mac = _networksDao.getNextAvailableMacAddress(networkId);
|
||||
if (mac == null) {
|
||||
throw new InsufficientAddressCapacityException("Unable to create another mac address", Network.class, networkId);
|
||||
throw new InsufficientAddressCapacityException("Unable to create another mac address", Network.class, networkId);
|
||||
}
|
||||
return mac;
|
||||
}
|
||||
@ -672,7 +672,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
public Map<Capability, String> getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service) {
|
||||
|
||||
if (!areServicesSupportedByNetworkOffering(offering.getId(), service)) {
|
||||
// TBD: We should be sending networkOfferingId and not the offering object itself.
|
||||
// TBD: We should be sending networkOfferingId and not the offering object itself.
|
||||
throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the network offering " + offering);
|
||||
}
|
||||
|
||||
@ -724,7 +724,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
|
||||
List<NetworkVO> networks = _networksDao.listBy(Account.ACCOUNT_ID_SYSTEM, networkOfferingId, zoneId);
|
||||
if (networks == null || networks.isEmpty()) {
|
||||
// TBD: send uuid instead of zoneId. Hardcode tablename in call to addProxyObject().
|
||||
// TBD: send uuid instead of zoneId. Hardcode tablename in call to addProxyObject().
|
||||
throw new InvalidParameterValueException("Unable to find network with traffic type " + trafficType + " in zone " + zoneId);
|
||||
}
|
||||
return networks.get(0);
|
||||
@ -935,7 +935,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
vm = _vmDao.findById(vmId);
|
||||
}
|
||||
Network network = getNetwork(networkId);
|
||||
NetworkOffering ntwkOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering ntwkOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
|
||||
// For default userVm Default network and domR guest/public network, get rate information from the service
|
||||
// offering; for other situations get information
|
||||
@ -1107,7 +1107,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
@Override
|
||||
public List<Long> listNetworkOfferingsForUpgrade(long networkId) {
|
||||
List<Long> offeringsToReturn = new ArrayList<Long>();
|
||||
NetworkOffering originalOffering = _configMgr.getNetworkOffering(getNetwork(networkId).getNetworkOfferingId());
|
||||
NetworkOffering originalOffering = _entityMgr.findById(NetworkOffering.class, getNetwork(networkId).getNetworkOfferingId());
|
||||
|
||||
boolean securityGroupSupportedByOriginalOff = areServicesSupportedByNetworkOffering(originalOffering.getId(), Service.SecurityGroup);
|
||||
|
||||
@ -1174,7 +1174,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
if(mgmtTraffic != null){
|
||||
String label = null;
|
||||
switch(hypervisorType){
|
||||
case XenServer : label = mgmtTraffic.getXenNetworkLabel();
|
||||
case XenServer : label = mgmtTraffic.getXenNetworkLabel();
|
||||
break;
|
||||
case KVM : label = mgmtTraffic.getKvmNetworkLabel();
|
||||
break;
|
||||
@ -1199,7 +1199,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
if(storageTraffic != null){
|
||||
String label = null;
|
||||
switch(hypervisorType){
|
||||
case XenServer : label = storageTraffic.getXenNetworkLabel();
|
||||
case XenServer : label = storageTraffic.getXenNetworkLabel();
|
||||
break;
|
||||
case KVM : label = storageTraffic.getKvmNetworkLabel();
|
||||
break;
|
||||
@ -1280,7 +1280,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
if (effectiveTrafficType != TrafficType.Guest) {
|
||||
physicalNetworkId = getNonGuestNetworkPhysicalNetworkId(network, effectiveTrafficType);
|
||||
} else {
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
physicalNetworkId = network.getPhysicalNetworkId();
|
||||
if(physicalNetworkId == null){
|
||||
physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags(), offering.getTrafficType());
|
||||
@ -1328,7 +1328,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
}
|
||||
|
||||
Long physicalNetworkId = network.getPhysicalNetworkId();
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
if (physicalNetworkId == null) {
|
||||
physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags(), offering.getTrafficType());
|
||||
}
|
||||
@ -1372,7 +1372,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
|
||||
if (enabledServices != null && !enabledServices.isEmpty()) {
|
||||
if (!element.canEnableIndividualServices()) {
|
||||
Set<Service> requiredServices = new HashSet<Service>();
|
||||
Set<Service> requiredServices = new HashSet<Service>();
|
||||
requiredServices.addAll(element.getCapabilities().keySet());
|
||||
|
||||
if (requiredServices.contains(Network.Service.Gateway)) {
|
||||
@ -1584,7 +1584,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Failed to retrive the default label for management traffic:" + "zone: " + dcId +
|
||||
s_logger.debug("Failed to retrive the default label for management traffic:" + "zone: " + dcId +
|
||||
" hypervisor: " + hypervisorType + " due to:" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
@ -1694,7 +1694,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
public Set<Long> getAvailableIps(Network network, String requestedIp) {
|
||||
String[] cidr = network.getCidr().split("/");
|
||||
List<String> ips = getUsedIpsInNetwork(network);
|
||||
Set<Long> usedIps = new TreeSet<Long>();
|
||||
Set<Long> usedIps = new TreeSet<Long>();
|
||||
|
||||
for (String ip : ips) {
|
||||
if (requestedIp != null && requestedIp.equals(ip)) {
|
||||
@ -1867,9 +1867,9 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
Integer networkRate = getNetworkRate(network.getId(), vm.getId());
|
||||
|
||||
// NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
|
||||
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
|
||||
networkRate, isSecurityGroupSupportedInNetwork(network), getNetworkTag(vm.getHypervisorType(), network));
|
||||
// guru.updateNicProfile(profile, network);
|
||||
// guru.updateNicProfile(profile, network);
|
||||
|
||||
return profile;
|
||||
}
|
||||
@ -2000,11 +2000,12 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkInlineMode(Network network) {
|
||||
NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
|
||||
return offering.isInline();
|
||||
|
||||
@ -894,7 +894,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
Long networkId = ipVO.getAssociatedWithNetworkId();
|
||||
if (networkId != null) {
|
||||
Network guestNetwork = getNetwork(networkId);
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
|
||||
Long vmId = ipVO.getAssociatedWithVmId();
|
||||
if (offering.getElasticIp() && vmId != null) {
|
||||
_rulesMgr.getSystemIpAndEnableStaticNatForVm(_userVmDao.findById(vmId), true);
|
||||
@ -1991,7 +1991,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
}
|
||||
//can't update from vpc to non-vpc network offering
|
||||
boolean forVpcNew = _configMgr.isOfferingForVpc(networkOffering);
|
||||
boolean vorVpcOriginal = _configMgr.isOfferingForVpc(_configMgr.getNetworkOffering(oldNetworkOfferingId));
|
||||
boolean vorVpcOriginal = _configMgr.isOfferingForVpc(_entityMgr.findById(NetworkOffering.class, oldNetworkOfferingId));
|
||||
if (forVpcNew != vorVpcOriginal) {
|
||||
String errMsg = forVpcNew ? "a vpc offering " : "not a vpc offering";
|
||||
throw new InvalidParameterValueException("Can't update as the new offering is " + errMsg);
|
||||
@ -2024,7 +2024,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
|
||||
Map<String, String> newSvcProviders = new HashMap<String, String>();
|
||||
if (networkOfferingChanged) {
|
||||
newSvcProviders = _networkMgr.finalizeServicesAndProvidersForNetwork(_configMgr.getNetworkOffering(networkOfferingId), network.getPhysicalNetworkId());
|
||||
newSvcProviders = _networkMgr.finalizeServicesAndProvidersForNetwork(_entityMgr.findById(NetworkOffering.class, networkOfferingId), network.getPhysicalNetworkId());
|
||||
}
|
||||
|
||||
// don't allow to modify network domain if the service is not supported
|
||||
@ -2041,7 +2041,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
offeringId = networkOfferingId;
|
||||
}
|
||||
|
||||
Map<Network.Capability, String> dnsCapabilities = getNetworkOfferingServiceCapabilities(_configMgr.getNetworkOffering(offeringId), Service.Dns);
|
||||
Map<Network.Capability, String> dnsCapabilities = getNetworkOfferingServiceCapabilities(_entityMgr.findById(NetworkOffering.class, offeringId), Service.Dns);
|
||||
String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification);
|
||||
if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
|
||||
// TBD: use uuid instead of networkOfferingId. May need to hardcode tablename in call to addProxyObject().
|
||||
@ -2224,7 +2224,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
txn.commit();
|
||||
} else {
|
||||
network.setNetworkOfferingId(networkOfferingId);
|
||||
_networksDao.update(networkId, network, _networkMgr.finalizeServicesAndProvidersForNetwork(_configMgr.getNetworkOffering(networkOfferingId), network.getPhysicalNetworkId()));
|
||||
_networksDao.update(networkId, network, _networkMgr.finalizeServicesAndProvidersForNetwork(_entityMgr.findById(NetworkOffering.class, networkOfferingId), network.getPhysicalNetworkId()));
|
||||
}
|
||||
} else {
|
||||
_networksDao.update(networkId, network);
|
||||
|
||||
@ -320,7 +320,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
|
||||
throw new InvalidParameterValueException("Unable to find zone by id");
|
||||
}
|
||||
|
||||
ServiceOffering serviceOffering = _configMgr.getServiceOffering(serviceOfferingId);
|
||||
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||
if (serviceOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find service offering by id");
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm)
|
||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
if (!canHandle(offering, dc)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1328,7 +1328,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
LoadBalancer result = null;
|
||||
if (result == null) {
|
||||
IpAddress systemIp = null;
|
||||
NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering off = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
if (off.getElasticLb() && ipVO == null && network.getVpcId() == null) {
|
||||
systemIp = _ipAddrMgr.assignSystemIp(networkId, lbOwner, true, false);
|
||||
ipVO = _ipAddressDao.findById(systemIp.getId());
|
||||
@ -2138,7 +2138,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
}
|
||||
|
||||
//2) Check if the Scheme is supported\
|
||||
NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering off = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
if (scheme == Scheme.Public) {
|
||||
if (!off.getPublicLb()) {
|
||||
throw new InvalidParameterValueException("Scheme " + scheme + " is not supported by the network offering " + off);
|
||||
|
||||
@ -42,7 +42,6 @@ import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
@ -222,6 +221,7 @@ import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
@ -259,12 +259,13 @@ import com.cloud.vm.dao.VMInstanceDao;
|
||||
/**
|
||||
* VirtualNetworkApplianceManagerImpl manages the different types of virtual network appliances available in the Cloud Stack.
|
||||
*/
|
||||
@Component
|
||||
@Local(value = { VirtualNetworkApplianceManager.class, VirtualNetworkApplianceService.class })
|
||||
public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements VirtualNetworkApplianceManager, VirtualNetworkApplianceService,
|
||||
VirtualMachineGuru, Listener {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualNetworkApplianceManagerImpl.class);
|
||||
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
@Inject
|
||||
DataCenterDao _dcDao = null;
|
||||
@Inject
|
||||
@ -448,7 +449,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
return _routerDao.findById(routerId);
|
||||
}
|
||||
|
||||
ServiceOffering newServiceOffering = _configMgr.getServiceOffering(serviceOfferingId);
|
||||
ServiceOffering newServiceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||
if (newServiceOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find service offering with id " + serviceOfferingId);
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.firewall.ListPortForwardingRulesCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
@ -71,6 +70,7 @@ import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
@ -92,14 +92,14 @@ import com.cloud.vm.dao.NicSecondaryIpVO;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Component
|
||||
@Local(value = { RulesManager.class, RulesService.class })
|
||||
public class RulesManagerImpl extends ManagerBase implements RulesManager, RulesService {
|
||||
private static final Logger s_logger = Logger.getLogger(RulesManagerImpl.class);
|
||||
|
||||
@Inject
|
||||
IpAddressManager _ipAddrMgr;
|
||||
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
@Inject
|
||||
PortForwardingRulesDao _portForwardingDao;
|
||||
@Inject
|
||||
@ -381,7 +381,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
||||
_networkModel.checkIpForService(ipAddress, Service.StaticNat, null);
|
||||
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering off = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
if (off.getElasticIp()) {
|
||||
throw new InvalidParameterValueException("Can't create ip forwarding rules for the network where elasticIP service is enabled");
|
||||
}
|
||||
@ -646,7 +646,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
||||
boolean reassignStaticNat = false;
|
||||
if (networkId != null) {
|
||||
Network guestNetwork = _networkModel.getNetwork(networkId);
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
reassignStaticNat = true;
|
||||
}
|
||||
@ -1215,7 +1215,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
||||
// if network has elastic IP functionality supported, we first have to disable static nat on old ip in order to
|
||||
// re-enable it on the new one enable static nat takes care of that
|
||||
Network guestNetwork = _networkModel.getNetwork(ipAddress.getAssociatedWithNetworkId());
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
if (offering.getAssociatePublicIP()) {
|
||||
getSystemIpAndEnableStaticNatForVm(_vmDao.findById(vmId), true);
|
||||
@ -1412,7 +1412,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
||||
List<? extends Nic> nics = _nicDao.listByVmId(vm.getId());
|
||||
for (Nic nic : nics) {
|
||||
Network guestNetwork = _networkModel.getNetwork(nic.getNetworkId());
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
boolean isSystemVM = (vm.getType() == Type.ConsoleProxy || vm.getType() == Type.SecondaryStorageVm);
|
||||
// for user VM's associate public IP only if offering is marked to associate a public IP by default on start of VM
|
||||
|
||||
@ -16,6 +16,16 @@
|
||||
// under the License.
|
||||
package com.cloud.network.vpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
@ -33,30 +43,20 @@ import com.cloud.network.vpc.dao.NetworkACLDao;
|
||||
import com.cloud.network.vpc.dao.VpcGatewayDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value = { NetworkACLManager.class})
|
||||
public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLManager{
|
||||
private static final Logger s_logger = Logger.getLogger(NetworkACLManagerImpl.class);
|
||||
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
@ -178,7 +178,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
|
||||
@Override
|
||||
public boolean replaceNetworkACL(NetworkACL acl, NetworkVO network) throws ResourceUnavailableException {
|
||||
|
||||
NetworkOffering guestNtwkOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering guestNtwkOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
|
||||
if (guestNtwkOff == null) {
|
||||
throw new InvalidParameterValueException("Can't find network offering associated with network: "+network.getUuid());
|
||||
@ -247,6 +247,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
|
||||
return _networkACLItemDao.findById(ruleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_ACL_DELETE, eventDescription = "revoking network acl", async = true)
|
||||
public boolean revokeNetworkACLItem(long ruleId) {
|
||||
|
||||
|
||||
@ -1051,7 +1051,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
public void validateNtwkOffForNtwkInVpc(Long networkId, long newNtwkOffId, String newCidr,
|
||||
String newNetworkDomain, Vpc vpc, String gateway, Account networkOwner, Long aclId) {
|
||||
|
||||
NetworkOffering guestNtwkOff = _configMgr.getNetworkOffering(newNtwkOffId);
|
||||
NetworkOffering guestNtwkOff = _entityMgr.findById(NetworkOffering.class, newNtwkOffId);
|
||||
|
||||
if (guestNtwkOff == null) {
|
||||
throw new InvalidParameterValueException("Can't find network offering by id specified");
|
||||
@ -1086,7 +1086,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
//skip my own network
|
||||
continue;
|
||||
} else {
|
||||
NetworkOffering otherOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering otherOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
if (_ntwkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb) && otherOff.getPublicLb()) {
|
||||
throw new InvalidParameterValueException("Public LB service is already supported " +
|
||||
"by network " + network + " in VPC " + vpc);
|
||||
|
||||
@ -360,7 +360,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
if (storeUuid != null) {
|
||||
imageStore = _dataStoreMgr.getDataStore(storeUuid, DataStoreRole.Image);
|
||||
} else {
|
||||
imageStore = this._dataStoreMgr.getImageStore(zoneId);
|
||||
imageStore = _dataStoreMgr.getImageStore(zoneId);
|
||||
if (imageStore == null) {
|
||||
throw new CloudRuntimeException("cannot find an image store for zone " + zoneId);
|
||||
}
|
||||
@ -1040,7 +1040,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
Long templateId = cmd.getId();
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
|
||||
VirtualMachineTemplate template = getTemplate(templateId);
|
||||
VMTemplateVO template = _tmpltDao.findById(templateId);
|
||||
if (template == null) {
|
||||
throw new InvalidParameterValueException("unable to find template with id " + templateId);
|
||||
}
|
||||
@ -1051,6 +1051,9 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
throw new InvalidParameterValueException("Please specify a valid template.");
|
||||
}
|
||||
|
||||
template.setState(VirtualMachineTemplate.State.Inactive);
|
||||
_tmpltDao.update(template.getId(), template);
|
||||
|
||||
TemplateAdapter adapter = getAdapter(template.getHypervisorType());
|
||||
TemplateProfile profile = adapter.prepareDelete(cmd);
|
||||
return adapter.delete(profile);
|
||||
@ -1063,8 +1066,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
|
||||
VirtualMachineTemplate template = getTemplate(templateId);
|
||||
;
|
||||
VMTemplateVO template = _tmpltDao.findById(templateId);
|
||||
if (template == null) {
|
||||
throw new InvalidParameterValueException("unable to find iso with id " + templateId);
|
||||
}
|
||||
@ -1075,14 +1077,19 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
throw new InvalidParameterValueException("Please specify a valid iso.");
|
||||
}
|
||||
|
||||
|
||||
// check if there is any VM using this ISO.
|
||||
if (!templateIsDeleteable(templateId)) {
|
||||
throw new InvalidParameterValueException("Unable to delete iso, as it's used by other vms");
|
||||
}
|
||||
|
||||
|
||||
if (zoneId != null && (_dataStoreMgr.getImageStore(zoneId) == null)) {
|
||||
throw new InvalidParameterValueException("Failed to find a secondary storage store in the specified zone.");
|
||||
}
|
||||
|
||||
template.setState(VirtualMachineTemplate.State.Inactive);
|
||||
_tmpltDao.update(template.getId(), template);
|
||||
|
||||
TemplateAdapter adapter = getAdapter(template.getHypervisorType());
|
||||
TemplateProfile profile = adapter.prepareDelete(cmd);
|
||||
boolean result = adapter.delete(profile);
|
||||
@ -1524,7 +1531,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
throw new InvalidParameterValueException("Failed to create private template record, unable to find snapshot " + snapshotId);
|
||||
}
|
||||
|
||||
volume = this._volumeDao.findById(snapshot.getVolumeId());
|
||||
volume = _volumeDao.findById(snapshot.getVolumeId());
|
||||
|
||||
// check permissions
|
||||
_accountMgr.checkAccess(caller, null, true, snapshot);
|
||||
|
||||
@ -232,6 +232,7 @@ import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.crypt.RSAHelper;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
@ -269,6 +270,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
linked
|
||||
}
|
||||
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
@Inject
|
||||
protected HostDao _hostDao = null;
|
||||
@Inject
|
||||
@ -1235,7 +1238,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
_itMgr.checkIfCanUpgrade(vmInstance, newServiceOfferingId);
|
||||
|
||||
//Check if its a scale "up"
|
||||
ServiceOffering newServiceOffering = _configMgr.getServiceOffering(newServiceOfferingId);
|
||||
ServiceOffering newServiceOffering = _entityMgr.findById(ServiceOffering.class, newServiceOfferingId);
|
||||
ServiceOffering currentServiceOffering = _offeringDao.findByIdIncludingRemoved(vmInstance.getServiceOfferingId());
|
||||
int newCpu = newServiceOffering.getCpu();
|
||||
int newMemory = newServiceOffering.getRamSize();
|
||||
@ -2453,8 +2456,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
_networkModel.checkNetworkPermissions(owner, network);
|
||||
|
||||
// don't allow to use system networks
|
||||
NetworkOffering networkOffering = _configMgr
|
||||
.getNetworkOffering(network.getNetworkOfferingId());
|
||||
NetworkOffering networkOffering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
if (networkOffering.isSystemOnly()) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Network id="
|
||||
@ -3218,7 +3220,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
try {
|
||||
long networkId = ip.getAssociatedWithNetworkId();
|
||||
Network guestNetwork = _networkDao.findById(networkId);
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
|
||||
assert (offering.getAssociatePublicIP() == true) : "User VM should not have system owned public IP associated with it when offering configured not to associate public IP.";
|
||||
_rulesMgr.disableStaticNat(ip.getId(), ctx.getCallingAccount(), ctx.getCallingUserId(), true);
|
||||
} catch (Exception ex) {
|
||||
@ -4593,9 +4595,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
_networkModel.checkNetworkPermissions(newAccount, network);
|
||||
|
||||
// don't allow to use system networks
|
||||
NetworkOffering networkOffering = _configMgr
|
||||
.getNetworkOffering(network
|
||||
.getNetworkOfferingId());
|
||||
NetworkOffering networkOffering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||
if (networkOffering.isSystemOnly()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException(
|
||||
"Specified Network id is system only and can't be used for vm deployment");
|
||||
|
||||
@ -35,7 +35,6 @@ import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
@ -64,6 +63,7 @@ import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
@ -77,6 +77,7 @@ import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
@ -109,6 +110,9 @@ public class UserVmManagerTest {
|
||||
@Mock List<VolumeVO> _rootVols;
|
||||
@Mock Account _accountMock2;
|
||||
@Mock ServiceOfferingDao _offeringDao;
|
||||
@Mock
|
||||
EntityManager _entityMgr;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
MockitoAnnotations.initMocks(this);
|
||||
@ -127,6 +131,7 @@ public class UserVmManagerTest {
|
||||
_userVmMgr._offeringDao= _offeringDao;
|
||||
_userVmMgr._capacityMgr = _capacityMgr;
|
||||
_userVmMgr._scaleRetry = 2;
|
||||
_userVmMgr._entityMgr = _entityMgr;
|
||||
|
||||
doReturn(3L).when(_account).getId();
|
||||
doReturn(8L).when(_vmMock).getAccountId();
|
||||
@ -358,7 +363,7 @@ public class UserVmManagerTest {
|
||||
ServiceOffering so1 = getSvcoffering(512);
|
||||
ServiceOffering so2 = getSvcoffering(256);
|
||||
|
||||
when(_configMgr.getServiceOffering(anyLong())).thenReturn(so1);
|
||||
when(_entityMgr.findById(eq(ServiceOffering.class), anyLong())).thenReturn(so1);
|
||||
when(_offeringDao.findByIdIncludingRemoved(anyLong())).thenReturn((ServiceOfferingVO) so1);
|
||||
|
||||
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, UUID.randomUUID().toString());
|
||||
@ -395,8 +400,8 @@ public class UserVmManagerTest {
|
||||
ServiceOffering so1 = getSvcoffering(512);
|
||||
ServiceOffering so2 = getSvcoffering(256);
|
||||
|
||||
when(_configMgr.getServiceOffering(anyLong())).thenReturn(so2);
|
||||
when(_configMgr.getServiceOffering(1L)).thenReturn(so1);
|
||||
when(_entityMgr.findById(eq(ServiceOffering.class), anyLong())).thenReturn(so2);
|
||||
when(_entityMgr.findById(ServiceOffering.class, 1L)).thenReturn(so1);
|
||||
|
||||
doReturn(VirtualMachine.State.Stopped).when(_vmInstance).getState();
|
||||
when(_vmDao.findById(anyLong())).thenReturn(null);
|
||||
@ -442,8 +447,8 @@ public class UserVmManagerTest {
|
||||
ServiceOffering so1 = getSvcoffering(512);
|
||||
ServiceOffering so2 = getSvcoffering(256);
|
||||
|
||||
when(_configMgr.getServiceOffering(anyLong())).thenReturn(so2);
|
||||
when(_configMgr.getServiceOffering(1L)).thenReturn(so1);
|
||||
when(_entityMgr.findById(eq(ServiceOffering.class), anyLong())).thenReturn(so2);
|
||||
when(_entityMgr.findById(ServiceOffering.class, 1L)).thenReturn(so1);
|
||||
|
||||
doReturn(VirtualMachine.State.Running).when(_vmInstance).getState();
|
||||
|
||||
|
||||
@ -274,14 +274,6 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.configuration.ConfigurationService#getNetworkOffering(long)
|
||||
*/
|
||||
@Override
|
||||
public NetworkOffering getNetworkOffering(long id) {
|
||||
return _ntwkOffDao.findById(id);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.configuration.ConfigurationService#getNetworkOfferingNetworkRate(long)
|
||||
*/
|
||||
@ -309,15 +301,6 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.configuration.ConfigurationService#getServiceOffering(long)
|
||||
*/
|
||||
@Override
|
||||
public ServiceOffering getServiceOffering(long serviceOfferingId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.configuration.ConfigurationService#getDefaultPageSize()
|
||||
*/
|
||||
@ -335,15 +318,6 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.configuration.ConfigurationService#getDiskOffering(long)
|
||||
*/
|
||||
@Override
|
||||
public DiskOffering getDiskOffering(long diskOfferingId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.configuration.ConfigurationService#updateLDAP(org.apache.cloudstack.api.commands.LDAPConfigCmd)
|
||||
*/
|
||||
|
||||
@ -66,6 +66,7 @@ import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ -87,6 +88,8 @@ public class NetworkACLManagerTest extends TestCase{
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
List<NetworkACLServiceProvider> _networkAclElements;
|
||||
@ -176,6 +179,11 @@ public class NetworkACLManagerTest extends TestCase{
|
||||
return Mockito.mock(VpcManager.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EntityManager entityManager() {
|
||||
return Mockito.mock(EntityManager.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ResourceTagDao resourceTagDao() {
|
||||
return Mockito.mock(ResourceTagDao.class);
|
||||
|
||||
@ -94,3 +94,186 @@ ALTER TABLE `cloud`.`configuration` ADD COLUMN `scope` VARCHAR(255) DEFAULT NULL
|
||||
ALTER TABLE `cloud`.`configuration` ADD COLUMN `is_dynamic` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Can the parameter be change dynamically without restarting the server';
|
||||
|
||||
UPDATE `cloud`.`configuration` SET `default_value` = `value`;
|
||||
|
||||
#Upgrade the offerings and template table to have actual remove and states
|
||||
ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `state` CHAR(40) NOT NULL DEFAULT 'Active' COMMENT 'state for disk offering';
|
||||
|
||||
UPDATE `cloud`.`disk_offering` SET `state`='Inactive' WHERE `removed` IS NOT NULL;
|
||||
UPDATE `cloud`.`disk_offering` SET `removed`=NULL;
|
||||
|
||||
DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
|
||||
CREATE VIEW `cloud`.`disk_offering_view` AS
|
||||
select
|
||||
disk_offering.id,
|
||||
disk_offering.uuid,
|
||||
disk_offering.name,
|
||||
disk_offering.display_text,
|
||||
disk_offering.disk_size,
|
||||
disk_offering.min_iops,
|
||||
disk_offering.max_iops,
|
||||
disk_offering.created,
|
||||
disk_offering.tags,
|
||||
disk_offering.customized,
|
||||
disk_offering.customized_iops,
|
||||
disk_offering.removed,
|
||||
disk_offering.use_local_storage,
|
||||
disk_offering.system_use,
|
||||
disk_offering.bytes_read_rate,
|
||||
disk_offering.bytes_write_rate,
|
||||
disk_offering.iops_read_rate,
|
||||
disk_offering.iops_write_rate,
|
||||
disk_offering.sort_key,
|
||||
disk_offering.type,
|
||||
disk_offering.display_offering,
|
||||
domain.id domain_id,
|
||||
domain.uuid domain_uuid,
|
||||
domain.name domain_name,
|
||||
domain.path domain_path
|
||||
from
|
||||
`cloud`.`disk_offering`
|
||||
left join
|
||||
`cloud`.`domain` ON disk_offering.domain_id = domain.id
|
||||
where
|
||||
disk_offering.state='ACTIVE';
|
||||
|
||||
DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
|
||||
CREATE VIEW `cloud`.`service_offering_view` AS
|
||||
select
|
||||
service_offering.id,
|
||||
disk_offering.uuid,
|
||||
disk_offering.name,
|
||||
disk_offering.display_text,
|
||||
disk_offering.created,
|
||||
disk_offering.tags,
|
||||
disk_offering.removed,
|
||||
disk_offering.use_local_storage,
|
||||
disk_offering.system_use,
|
||||
disk_offering.bytes_read_rate,
|
||||
disk_offering.bytes_write_rate,
|
||||
disk_offering.iops_read_rate,
|
||||
disk_offering.iops_write_rate,
|
||||
service_offering.cpu,
|
||||
service_offering.speed,
|
||||
service_offering.ram_size,
|
||||
service_offering.nw_rate,
|
||||
service_offering.mc_rate,
|
||||
service_offering.ha_enabled,
|
||||
service_offering.limit_cpu_use,
|
||||
service_offering.host_tag,
|
||||
service_offering.default_use,
|
||||
service_offering.vm_type,
|
||||
service_offering.sort_key,
|
||||
service_offering.is_volatile,
|
||||
service_offering.deployment_planner,
|
||||
domain.id domain_id,
|
||||
domain.uuid domain_uuid,
|
||||
domain.name domain_name,
|
||||
domain.path domain_path
|
||||
from
|
||||
`cloud`.`service_offering`
|
||||
inner join
|
||||
`cloud`.`disk_offering` ON service_offering.id = disk_offering.id
|
||||
left join
|
||||
`cloud`.`domain` ON disk_offering.domain_id = domain.id
|
||||
where
|
||||
disk_offering.state='Active';
|
||||
|
||||
DROP VIEW IF EXISTS `cloud`.`template_view`;
|
||||
CREATE VIEW `cloud`.`template_view` AS
|
||||
select
|
||||
vm_template.id,
|
||||
vm_template.uuid,
|
||||
vm_template.unique_name,
|
||||
vm_template.name,
|
||||
vm_template.public,
|
||||
vm_template.featured,
|
||||
vm_template.type,
|
||||
vm_template.hvm,
|
||||
vm_template.bits,
|
||||
vm_template.url,
|
||||
vm_template.format,
|
||||
vm_template.created,
|
||||
vm_template.checksum,
|
||||
vm_template.display_text,
|
||||
vm_template.enable_password,
|
||||
vm_template.dynamically_scalable,
|
||||
vm_template.guest_os_id,
|
||||
guest_os.uuid guest_os_uuid,
|
||||
guest_os.display_name guest_os_name,
|
||||
vm_template.bootable,
|
||||
vm_template.prepopulate,
|
||||
vm_template.cross_zones,
|
||||
vm_template.hypervisor_type,
|
||||
vm_template.extractable,
|
||||
vm_template.template_tag,
|
||||
vm_template.sort_key,
|
||||
vm_template.removed,
|
||||
vm_template.enable_sshkey,
|
||||
source_template.id source_template_id,
|
||||
source_template.uuid source_template_uuid,
|
||||
account.id account_id,
|
||||
account.uuid account_uuid,
|
||||
account.account_name account_name,
|
||||
account.type account_type,
|
||||
domain.id domain_id,
|
||||
domain.uuid domain_uuid,
|
||||
domain.name domain_name,
|
||||
domain.path domain_path,
|
||||
projects.id project_id,
|
||||
projects.uuid project_uuid,
|
||||
projects.name project_name,
|
||||
data_center.id data_center_id,
|
||||
data_center.uuid data_center_uuid,
|
||||
data_center.name data_center_name,
|
||||
launch_permission.account_id lp_account_id,
|
||||
template_store_ref.store_id,
|
||||
image_store.scope as store_scope,
|
||||
template_store_ref.state,
|
||||
template_store_ref.download_state,
|
||||
template_store_ref.download_pct,
|
||||
template_store_ref.error_str,
|
||||
template_store_ref.size,
|
||||
template_store_ref.destroyed,
|
||||
template_store_ref.created created_on_store,
|
||||
vm_template_details.name detail_name,
|
||||
vm_template_details.value detail_value,
|
||||
resource_tags.id tag_id,
|
||||
resource_tags.uuid tag_uuid,
|
||||
resource_tags.key tag_key,
|
||||
resource_tags.value tag_value,
|
||||
resource_tags.domain_id tag_domain_id,
|
||||
resource_tags.account_id tag_account_id,
|
||||
resource_tags.resource_id tag_resource_id,
|
||||
resource_tags.resource_uuid tag_resource_uuid,
|
||||
resource_tags.resource_type tag_resource_type,
|
||||
resource_tags.customer tag_customer,
|
||||
CONCAT(vm_template.id, '_', IFNULL(data_center.id, 0)) as temp_zone_pair
|
||||
from
|
||||
`cloud`.`vm_template`
|
||||
inner join
|
||||
`cloud`.`guest_os` ON guest_os.id = vm_template.guest_os_id
|
||||
inner join
|
||||
`cloud`.`account` ON account.id = vm_template.account_id
|
||||
inner join
|
||||
`cloud`.`domain` ON domain.id = account.domain_id
|
||||
left join
|
||||
`cloud`.`projects` ON projects.project_account_id = account.id
|
||||
left join
|
||||
`cloud`.`vm_template_details` ON vm_template_details.template_id = vm_template.id
|
||||
left join
|
||||
`cloud`.`vm_template` source_template ON source_template.id = vm_template.source_template_id
|
||||
left join
|
||||
`cloud`.`template_store_ref` ON template_store_ref.template_id = vm_template.id and template_store_ref.store_role = 'Image'
|
||||
left join
|
||||
`cloud`.`image_store` ON image_store.removed is NULL AND template_store_ref.store_id is not NULL AND image_store.id = template_store_ref.store_id
|
||||
left join
|
||||
`cloud`.`template_zone_ref` ON template_zone_ref.template_id = vm_template.id AND template_store_ref.store_id is NULL AND template_zone_ref.removed is null
|
||||
left join
|
||||
`cloud`.`data_center` ON (image_store.data_center_id = data_center.id OR template_zone_ref.zone_id = data_center.id)
|
||||
left join
|
||||
`cloud`.`launch_permission` ON launch_permission.template_id = vm_template.id
|
||||
left join
|
||||
`cloud`.`resource_tags` ON resource_tags.resource_id = vm_template.id
|
||||
and (resource_tags.resource_type = 'Template' or resource_tags.resource_type='ISO')
|
||||
where
|
||||
vm_template.state='Active';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user