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);
|
boolean deleteNetworkOffering(DeleteNetworkOfferingCmd cmd);
|
||||||
|
|
||||||
NetworkOffering getNetworkOffering(long id);
|
|
||||||
|
|
||||||
Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId);
|
|
||||||
|
|
||||||
Account getVlanAccount(long vlanId);
|
Account getVlanAccount(long vlanId);
|
||||||
|
|
||||||
List<? extends NetworkOffering> listNetworkOfferings(TrafficType trafficType, boolean systemOnly);
|
List<? extends NetworkOffering> listNetworkOfferings(TrafficType trafficType, boolean systemOnly);
|
||||||
|
|
||||||
ServiceOffering getServiceOffering(long serviceOfferingId);
|
|
||||||
|
|
||||||
Long getDefaultPageSize();
|
Long getDefaultPageSize();
|
||||||
|
|
||||||
Integer getServiceOfferingNetworkRate(long serviceOfferingId, Long dataCenterId);
|
|
||||||
|
|
||||||
DiskOffering getDiskOffering(long diskOfferingId);
|
|
||||||
|
|
||||||
boolean updateLDAP(LDAPConfigCmd cmd) throws NamingException;
|
boolean updateLDAP(LDAPConfigCmd cmd) throws NamingException;
|
||||||
|
|
||||||
boolean removeLDAP(LDAPRemoveCmd cmd);
|
boolean removeLDAP(LDAPRemoveCmd cmd);
|
||||||
|
|
||||||
LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd);
|
LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param offering
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean isOfferingForVpc(NetworkOffering offering);
|
|
||||||
|
|
||||||
PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throws ConcurrentOperationException;
|
PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throws ConcurrentOperationException;
|
||||||
|
|
||||||
boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd);
|
boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd);
|
||||||
|
|||||||
@ -28,6 +28,12 @@ import org.apache.cloudstack.api.InternalIdentity;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface DiskOffering extends InfrastructureEntity, Identity, InternalIdentity {
|
public interface DiskOffering extends InfrastructureEntity, Identity, InternalIdentity {
|
||||||
|
enum State {
|
||||||
|
Inactive,
|
||||||
|
Active,
|
||||||
|
}
|
||||||
|
|
||||||
|
State getState();
|
||||||
|
|
||||||
String getUniqueName();
|
String getUniqueName();
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,10 @@ import com.cloud.storage.Storage.ImageFormat;
|
|||||||
import com.cloud.storage.Storage.TemplateType;
|
import com.cloud.storage.Storage.TemplateType;
|
||||||
|
|
||||||
public interface VirtualMachineTemplate extends ControlledEntity, Identity, InternalIdentity {
|
public interface VirtualMachineTemplate extends ControlledEntity, Identity, InternalIdentity {
|
||||||
|
enum State {
|
||||||
|
Active,
|
||||||
|
Inactive;
|
||||||
|
}
|
||||||
|
|
||||||
public static enum BootloaderType {
|
public static enum BootloaderType {
|
||||||
PyGrub, HVM, External, CD
|
PyGrub, HVM, External, CD
|
||||||
@ -44,6 +48,8 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte
|
|||||||
all // all templates (only usable by admins)
|
all // all templates (only usable by admins)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
State getState();
|
||||||
|
|
||||||
boolean isFeatured();
|
boolean isFeatured();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -16,17 +16,25 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package org.apache.cloudstack.api.command.admin.systemvm;
|
package org.apache.cloudstack.api.command.admin.systemvm;
|
||||||
|
|
||||||
import com.cloud.event.EventTypes;
|
import org.apache.log4j.Logger;
|
||||||
import com.cloud.exception.*;
|
|
||||||
|
|
||||||
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.command.user.vm.UpgradeVMCmd;
|
||||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||||
import org.apache.cloudstack.api.response.SystemVmResponse;
|
import org.apache.cloudstack.api.response.SystemVmResponse;
|
||||||
import org.apache.cloudstack.context.CallContext;
|
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.offering.ServiceOffering;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
@ -85,7 +93,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
|
|||||||
public void execute(){
|
public void execute(){
|
||||||
CallContext.current().setEventDetails("SystemVm Id: "+getId());
|
CallContext.current().setEventDetails("SystemVm Id: "+getId());
|
||||||
|
|
||||||
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
|
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||||
if (serviceOffering == null) {
|
if (serviceOffering == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||||
}
|
}
|
||||||
@ -109,7 +117,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
|
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
|
||||||
response.setResponseName(getCommandName());
|
response.setResponseName(getCommandName());
|
||||||
this.setResponseObject(response);
|
setResponseObject(response);
|
||||||
} else {
|
} else {
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade system vm");
|
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade system vm");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,8 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package org.apache.cloudstack.api.command.admin.systemvm;
|
package org.apache.cloudstack.api.command.admin.systemvm;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
import org.apache.cloudstack.api.APICommand;
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
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.api.response.SystemVmResponse;
|
||||||
import org.apache.cloudstack.context.CallContext;
|
import org.apache.cloudstack.context.CallContext;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
@ -88,7 +88,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
|
|||||||
public void execute(){
|
public void execute(){
|
||||||
CallContext.current().setEventDetails("Vm Id: "+getId());
|
CallContext.current().setEventDetails("Vm Id: "+getId());
|
||||||
|
|
||||||
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
|
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||||
if (serviceOffering == null) {
|
if (serviceOffering == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
|
SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
|
||||||
response.setResponseName(getCommandName());
|
response.setResponseName(getCommandName());
|
||||||
this.setResponseObject(response);
|
setResponseObject(response);
|
||||||
} else {
|
} else {
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
|
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 java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
import org.apache.cloudstack.api.APICommand;
|
||||||
import org.apache.cloudstack.api.ApiCommandJobType;
|
import org.apache.cloudstack.api.ApiCommandJobType;
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
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.api.response.ZoneResponse;
|
||||||
import org.apache.cloudstack.context.CallContext;
|
import org.apache.cloudstack.context.CallContext;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.dc.DataCenter;
|
import com.cloud.dc.DataCenter;
|
||||||
import com.cloud.dc.DataCenter.NetworkType;
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
import com.cloud.event.EventTypes;
|
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");
|
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());
|
DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
|
||||||
if (zone.getNetworkType() == NetworkType.Basic && offering.getElasticIp() && offering.getElasticLb()) {
|
if (zone.getNetworkType() == NetworkType.Basic && offering.getElasticIp() && offering.getElasticLb()) {
|
||||||
@ -278,8 +278,8 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ip != null) {
|
if (ip != null) {
|
||||||
this.setEntityId(ip.getId());
|
setEntityId(ip.getId());
|
||||||
this.setEntityUuid(ip.getUuid());
|
setEntityUuid(ip.getUuid());
|
||||||
} else {
|
} else {
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to allocate ip address");
|
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to allocate ip address");
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result);
|
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result);
|
||||||
ipResponse.setResponseName(getCommandName());
|
ipResponse.setResponseName(getCommandName());
|
||||||
this.setResponseObject(ipResponse);
|
setResponseObject(ipResponse);
|
||||||
} else {
|
} else {
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign ip address");
|
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign ip address");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,17 +16,24 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package org.apache.cloudstack.api.command.user.network;
|
package org.apache.cloudstack.api.command.user.network;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
import org.apache.cloudstack.api.APICommand;
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
import org.apache.cloudstack.api.ApiErrorCode;
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
import org.apache.cloudstack.api.BaseCmd;
|
||||||
import org.apache.cloudstack.api.Parameter;
|
import org.apache.cloudstack.api.Parameter;
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
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.cloudstack.context.CallContext;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
@ -212,7 +219,7 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long getPhysicalNetworkId() {
|
public Long getPhysicalNetworkId() {
|
||||||
NetworkOffering offering = _configService.getNetworkOffering(networkOfferingId);
|
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, networkOfferingId);
|
||||||
if (offering == null) {
|
if (offering == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find network offering by id " + networkOfferingId);
|
throw new InvalidParameterValueException("Unable to find network offering by id " + networkOfferingId);
|
||||||
}
|
}
|
||||||
@ -288,7 +295,7 @@ public class CreateNetworkCmd extends BaseCmd {
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
|
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
|
||||||
response.setResponseName(getCommandName());
|
response.setResponseName(getCommandName());
|
||||||
this.setResponseObject(response);
|
setResponseObject(response);
|
||||||
}else {
|
}else {
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network");
|
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.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||||
import org.apache.cloudstack.api.ACL;
|
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.api.response.ZoneResponse;
|
||||||
import org.apache.cloudstack.context.CallContext;
|
import org.apache.cloudstack.context.CallContext;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.dc.DataCenter;
|
import com.cloud.dc.DataCenter;
|
||||||
import com.cloud.dc.DataCenter.NetworkType;
|
import com.cloud.dc.DataCenter.NetworkType;
|
||||||
import com.cloud.event.EventTypes;
|
import com.cloud.event.EventTypes;
|
||||||
@ -443,7 +443,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
|
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
|
||||||
response.setResponseName(getCommandName());
|
response.setResponseName(getCommandName());
|
||||||
this.setResponseObject(response);
|
setResponseObject(response);
|
||||||
} else {
|
} else {
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to deploy vm");
|
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);
|
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) {
|
if (serviceOffering == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||||
}
|
}
|
||||||
@ -473,7 +473,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
|||||||
|
|
||||||
DiskOffering diskOffering = null;
|
DiskOffering diskOffering = null;
|
||||||
if (diskOfferingId != null) {
|
if (diskOfferingId != null) {
|
||||||
diskOffering = _configService.getDiskOffering(diskOfferingId);
|
diskOffering = _entityMgr.findById(DiskOffering.class, diskOfferingId);
|
||||||
if (diskOffering == null) {
|
if (diskOffering == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find disk offering " + diskOfferingId);
|
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");
|
throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
|
||||||
} else {
|
} else {
|
||||||
vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
|
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 {
|
} else {
|
||||||
if (zone.isSecurityGroupEnabled()) {
|
if (zone.isSecurityGroupEnabled()) {
|
||||||
vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
|
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 {
|
} else {
|
||||||
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
|
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
|
||||||
throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
|
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,
|
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.
|
// under the License.
|
||||||
package org.apache.cloudstack.api.command.user.vm;
|
package org.apache.cloudstack.api.command.user.vm;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
import org.apache.cloudstack.api.APICommand;
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
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.api.response.UserVmResponse;
|
||||||
import org.apache.cloudstack.context.CallContext;
|
import org.apache.cloudstack.context.CallContext;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
import com.cloud.exception.ResourceAllocationException;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
@ -92,7 +92,7 @@ public class UpgradeVMCmd extends BaseCmd {
|
|||||||
public void execute() throws ResourceAllocationException{
|
public void execute() throws ResourceAllocationException{
|
||||||
CallContext.current().setEventDetails("Vm Id: "+getId());
|
CallContext.current().setEventDetails("Vm Id: "+getId());
|
||||||
|
|
||||||
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
|
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||||
if (serviceOffering == null) {
|
if (serviceOffering == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ public class UpgradeVMCmd extends BaseCmd {
|
|||||||
if (result != null){
|
if (result != null){
|
||||||
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
|
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
|
||||||
response.setResponseName(getCommandName());
|
response.setResponseName(getCommandName());
|
||||||
this.setResponseObject(response);
|
setResponseObject(response);
|
||||||
} else {
|
} else {
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade vm");
|
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) {
|
public boolean upgradeVmDb(long vmId, long serviceOfferingId) {
|
||||||
VMInstanceVO vmForUpdate = _vmDao.createForUpdate();
|
VMInstanceVO vmForUpdate = _vmDao.createForUpdate();
|
||||||
vmForUpdate.setServiceOfferingId(serviceOfferingId);
|
vmForUpdate.setServiceOfferingId(serviceOfferingId);
|
||||||
ServiceOffering newSvcOff = _configMgr.getServiceOffering(serviceOfferingId);
|
ServiceOffering newSvcOff = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||||
vmForUpdate.setHaEnabled(newSvcOff.getOfferHA());
|
vmForUpdate.setHaEnabled(newSvcOff.getOfferHA());
|
||||||
vmForUpdate.setLimitCpuUse(newSvcOff.getLimitCpuUse());
|
vmForUpdate.setLimitCpuUse(newSvcOff.getLimitCpuUse());
|
||||||
vmForUpdate.setServiceOfferingId(newSvcOff.getId());
|
vmForUpdate.setServiceOfferingId(newSvcOff.getId());
|
||||||
@ -3267,7 +3267,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
|
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
|
||||||
|
|
||||||
long newServiceofferingId = vm.getServiceOfferingId();
|
long newServiceofferingId = vm.getServiceOfferingId();
|
||||||
ServiceOffering newServiceOffering = _configMgr.getServiceOffering(newServiceofferingId);
|
ServiceOffering newServiceOffering = _entityMgr.findById(ServiceOffering.class, newServiceofferingId);
|
||||||
HostVO hostVo = _hostDao.findById(vm.getHostId());
|
HostVO hostVo = _hostDao.findById(vm.getHostId());
|
||||||
|
|
||||||
Float memoryOvercommitRatio = Float.parseFloat(_configServer.getConfigValue(Config.MemOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(),
|
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.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.mockito.Spy;
|
import org.mockito.Spy;
|
||||||
|
|
||||||
@ -77,6 +78,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|||||||
import com.cloud.hypervisor.HypervisorGuru;
|
import com.cloud.hypervisor.HypervisorGuru;
|
||||||
import com.cloud.hypervisor.HypervisorGuruManager;
|
import com.cloud.hypervisor.HypervisorGuruManager;
|
||||||
import com.cloud.network.NetworkManager;
|
import com.cloud.network.NetworkManager;
|
||||||
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.server.ConfigurationServer;
|
import com.cloud.server.ConfigurationServer;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.storage.DiskOfferingVO;
|
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.AccountDao;
|
||||||
import com.cloud.user.dao.UserDao;
|
import com.cloud.user.dao.UserDao;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
import com.cloud.utils.db.EntityManager;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.VirtualMachine.Event;
|
import com.cloud.vm.VirtualMachine.Event;
|
||||||
import com.cloud.vm.VirtualMachine.State;
|
import com.cloud.vm.VirtualMachine.State;
|
||||||
@ -199,6 +202,8 @@ public class VirtualMachineManagerImplTest {
|
|||||||
HostVO _destHostMock;
|
HostVO _destHostMock;
|
||||||
@Mock
|
@Mock
|
||||||
Map<Volume, StoragePool> _volumeToPoolMock;
|
Map<Volume, StoragePool> _volumeToPoolMock;
|
||||||
|
@Mock
|
||||||
|
EntityManager _entityMgr;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
@ -227,6 +232,7 @@ public class VirtualMachineManagerImplTest {
|
|||||||
_vmMgr._vmDao = _vmInstanceDao;
|
_vmMgr._vmDao = _vmInstanceDao;
|
||||||
_vmMgr._configServer = _configServer;
|
_vmMgr._configServer = _configServer;
|
||||||
_vmMgr._uservmDetailsDao = _vmDetailsDao;
|
_vmMgr._uservmDetailsDao = _vmDetailsDao;
|
||||||
|
_vmMgr._entityMgr = _entityMgr;
|
||||||
|
|
||||||
when(_vmMock.getId()).thenReturn(314l);
|
when(_vmMock.getId()).thenReturn(314l);
|
||||||
when(_vmInstance.getId()).thenReturn(1L);
|
when(_vmInstance.getId()).thenReturn(1L);
|
||||||
@ -236,7 +242,7 @@ public class VirtualMachineManagerImplTest {
|
|||||||
when(_vmInstance.getType()).thenReturn(VirtualMachine.Type.User);
|
when(_vmInstance.getType()).thenReturn(VirtualMachine.Type.User);
|
||||||
when(_host.getId()).thenReturn(1L);
|
when(_host.getId()).thenReturn(1L);
|
||||||
when(_hostDao.findById(anyLong())).thenReturn(null);
|
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.persist(_work)).thenReturn(_work);
|
||||||
when(_workDao.update("1", _work)).thenReturn(true);
|
when(_workDao.update("1", _work)).thenReturn(true);
|
||||||
when(_work.getId()).thenReturn("1");
|
when(_work.getId()).thenReturn("1");
|
||||||
|
|||||||
@ -24,6 +24,8 @@ import javax.persistence.Column;
|
|||||||
import javax.persistence.DiscriminatorColumn;
|
import javax.persistence.DiscriminatorColumn;
|
||||||
import javax.persistence.DiscriminatorType;
|
import javax.persistence.DiscriminatorType;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
@ -72,7 +74,7 @@ public class DiskOfferingVO implements DiskOffering {
|
|||||||
@Column(name = "type")
|
@Column(name = "type")
|
||||||
Type type;
|
Type type;
|
||||||
|
|
||||||
@Column(name = GenericDao.REMOVED)
|
@Column(name = GenericDao.REMOVED_COLUMN)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date removed;
|
private Date removed;
|
||||||
|
|
||||||
@ -121,8 +123,12 @@ public class DiskOfferingVO implements DiskOffering {
|
|||||||
@Column(name="display_offering")
|
@Column(name="display_offering")
|
||||||
boolean displayOffering = true;
|
boolean displayOffering = true;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(name = "state")
|
||||||
|
State state;
|
||||||
|
|
||||||
public DiskOfferingVO() {
|
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,
|
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.displayText = displayText;
|
||||||
this.diskSize = diskSize;
|
this.diskSize = diskSize;
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
this.recreatable = false;
|
recreatable = false;
|
||||||
this.type = Type.Disk;
|
type = Type.Disk;
|
||||||
this.useLocalStorage = false;
|
useLocalStorage = false;
|
||||||
this.customized = isCustomized;
|
customized = isCustomized;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
this.customizedIops = isCustomizedIops;
|
customizedIops = isCustomizedIops;
|
||||||
this.minIops = minIops;
|
this.minIops = minIops;
|
||||||
this.maxIops = maxIops;
|
this.maxIops = maxIops;
|
||||||
|
state = State.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable,
|
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable,
|
||||||
boolean useLocalStorage, boolean systemUse, boolean customized) {
|
boolean useLocalStorage, boolean systemUse, boolean customized) {
|
||||||
this.domainId = null;
|
domainId = null;
|
||||||
this.type = Type.Service;
|
type = Type.Service;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.displayText = displayText;
|
this.displayText = displayText;
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
@ -153,14 +160,15 @@ public class DiskOfferingVO implements DiskOffering {
|
|||||||
this.useLocalStorage = useLocalStorage;
|
this.useLocalStorage = useLocalStorage;
|
||||||
this.systemUse = systemUse;
|
this.systemUse = systemUse;
|
||||||
this.customized = customized;
|
this.customized = customized;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
|
state = State.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
// domain specific offerings constructor (null domainId implies public
|
// domain specific offerings constructor (null domainId implies public
|
||||||
// offering)
|
// offering)
|
||||||
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable,
|
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable,
|
||||||
boolean useLocalStorage, boolean systemUse, boolean customized, Long domainId) {
|
boolean useLocalStorage, boolean systemUse, boolean customized, Long domainId) {
|
||||||
this.type = Type.Service;
|
type = Type.Service;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.displayText = displayText;
|
this.displayText = displayText;
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
@ -169,7 +177,17 @@ public class DiskOfferingVO implements DiskOffering {
|
|||||||
this.systemUse = systemUse;
|
this.systemUse = systemUse;
|
||||||
this.customized = customized;
|
this.customized = customized;
|
||||||
this.domainId = domainId;
|
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
|
@Override
|
||||||
@ -235,6 +253,7 @@ public class DiskOfferingVO implements DiskOffering {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isRecreatable() {
|
public boolean isRecreatable() {
|
||||||
return recreatable;
|
return recreatable;
|
||||||
}
|
}
|
||||||
@ -299,7 +318,7 @@ public class DiskOfferingVO implements DiskOffering {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setUniqueName(String name) {
|
public void setUniqueName(String name) {
|
||||||
this.uniqueName = name;
|
uniqueName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -355,7 +374,7 @@ public class DiskOfferingVO implements DiskOffering {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
return this.uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUuid(String uuid) {
|
public void setUuid(String uuid) {
|
||||||
@ -382,34 +401,42 @@ public class DiskOfferingVO implements DiskOffering {
|
|||||||
this.displayOffering = displayOffering;
|
this.displayOffering = displayOffering;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBytesReadRate(Long bytesReadRate) {
|
public void setBytesReadRate(Long bytesReadRate) {
|
||||||
this.bytesReadRate = bytesReadRate;
|
this.bytesReadRate = bytesReadRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Long getBytesReadRate() {
|
public Long getBytesReadRate() {
|
||||||
return bytesReadRate;
|
return bytesReadRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBytesWriteRate(Long bytesWriteRate) {
|
public void setBytesWriteRate(Long bytesWriteRate) {
|
||||||
this.bytesWriteRate = bytesWriteRate;
|
this.bytesWriteRate = bytesWriteRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Long getBytesWriteRate() {
|
public Long getBytesWriteRate() {
|
||||||
return bytesWriteRate;
|
return bytesWriteRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setIopsReadRate(Long iopsReadRate) {
|
public void setIopsReadRate(Long iopsReadRate) {
|
||||||
this.iopsReadRate = iopsReadRate;
|
this.iopsReadRate = iopsReadRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Long getIopsReadRate() {
|
public Long getIopsReadRate() {
|
||||||
return iopsReadRate;
|
return iopsReadRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setIopsWriteRate(Long iopsWriteRate) {
|
public void setIopsWriteRate(Long iopsWriteRate) {
|
||||||
this.iopsWriteRate = iopsWriteRate;
|
this.iopsWriteRate = iopsWriteRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Long getIopsWriteRate() {
|
public Long getIopsWriteRate() {
|
||||||
return iopsWriteRate;
|
return iopsWriteRate;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,14 +31,11 @@ import javax.persistence.Temporal;
|
|||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.Storage.TemplateType;
|
import com.cloud.storage.Storage.TemplateType;
|
||||||
import com.cloud.template.VirtualMachineTemplate;
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
import com.cloud.utils.fsm.StateObject;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "vm_template")
|
@Table(name = "vm_template")
|
||||||
@ -80,7 +77,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
@Column(name = GenericDao.CREATED_COLUMN)
|
@Column(name = GenericDao.CREATED_COLUMN)
|
||||||
private Date created = null;
|
private Date created = null;
|
||||||
|
|
||||||
@Column(name = GenericDao.REMOVED)
|
@Column(name = GenericDao.REMOVED_COLUMN)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date removed;
|
private Date removed;
|
||||||
|
|
||||||
@ -118,6 +115,10 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
@Column(name = "source_template_id")
|
@Column(name = "source_template_id")
|
||||||
private Long sourceTemplateId;
|
private Long sourceTemplateId;
|
||||||
|
|
||||||
|
@Column(name = "state")
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private State state;
|
||||||
|
|
||||||
@Column(name = "template_tag")
|
@Column(name = "template_tag")
|
||||||
private String templateTag;
|
private String templateTag;
|
||||||
|
|
||||||
@ -141,7 +142,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
Date updated;
|
Date updated;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
Map details;
|
Map<String, String> details;
|
||||||
|
|
||||||
@Column(name = "dynamically_scalable")
|
@Column(name = "dynamically_scalable")
|
||||||
protected boolean dynamicallyScalable;
|
protected boolean dynamicallyScalable;
|
||||||
@ -156,7 +157,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public VMTemplateVO() {
|
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,
|
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured,
|
||||||
boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId,
|
boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId,
|
||||||
String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable,
|
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,
|
this(id, generateUniqueName(id, accountId, name), name, format, isPublic, featured, isExtractable, type, url,
|
||||||
null, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType,
|
null, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType,
|
||||||
details);
|
details);
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured,
|
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured,
|
||||||
boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId,
|
boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId,
|
||||||
String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable,
|
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,
|
this(id, name, format, isPublic, featured, isExtractable, type, url, requiresHvm, bits, accountId, cksum,
|
||||||
displayText, enablePassword, guestOSId, bootable, hyperType, details);
|
displayText, enablePassword, guestOSId, bootable, hyperType, details);
|
||||||
this.templateTag = templateTag;
|
this.templateTag = templateTag;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
this.enableSshKey = sshKeyEnabled;
|
enableSshKey = sshKeyEnabled;
|
||||||
this.dynamicallyScalable = isDynamicallyScalable;
|
dynamicallyScalable = isDynamicallyScalable;
|
||||||
|
state = State.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -200,14 +202,14 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
HypervisorType hyperType) {
|
HypervisorType hyperType) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.publicTemplate = isPublic;
|
publicTemplate = isPublic;
|
||||||
this.featured = featured;
|
this.featured = featured;
|
||||||
this.templateType = type;
|
templateType = type;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.requiresHvm = requiresHvm;
|
this.requiresHvm = requiresHvm;
|
||||||
this.bits = bits;
|
this.bits = bits;
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
this.checksum = cksum;
|
checksum = cksum;
|
||||||
this.uniqueName = uniqueName;
|
this.uniqueName = uniqueName;
|
||||||
this.displayText = displayText;
|
this.displayText = displayText;
|
||||||
this.enablePassword = enablePassword;
|
this.enablePassword = enablePassword;
|
||||||
@ -215,30 +217,33 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
this.created = created;
|
this.created = created;
|
||||||
this.guestOSId = guestOSId;
|
this.guestOSId = guestOSId;
|
||||||
this.bootable = bootable;
|
this.bootable = bootable;
|
||||||
this.hypervisorType = hyperType;
|
hypervisorType = hyperType;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
|
state = State.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has an extra attribute - isExtractable
|
// Has an extra attribute - isExtractable
|
||||||
public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic,
|
public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic,
|
||||||
boolean featured, boolean isExtractable, TemplateType type, String url, Date created, boolean requiresHvm,
|
boolean featured, boolean isExtractable, TemplateType type, String url, Date created, boolean requiresHvm,
|
||||||
int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId,
|
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,
|
this(id, uniqueName, name, format, isPublic, featured, type, url, created, requiresHvm, bits, accountId, cksum,
|
||||||
displayText, enablePassword, guestOSId, bootable, hyperType);
|
displayText, enablePassword, guestOSId, bootable, hyperType);
|
||||||
this.extractable = isExtractable;
|
extractable = isExtractable;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
this.details = details;
|
this.details = details;
|
||||||
|
state = State.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic,
|
public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic,
|
||||||
boolean featured, boolean isExtractable, TemplateType type, String url, Date created, boolean requiresHvm,
|
boolean featured, boolean isExtractable, TemplateType type, String url, Date created, boolean requiresHvm,
|
||||||
int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId,
|
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,
|
this(id, uniqueName, name, format, isPublic, featured, isExtractable, type, url, created, requiresHvm, bits,
|
||||||
accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType, details);
|
accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType, details);
|
||||||
this.templateTag = templateTag;
|
this.templateTag = templateTag;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
|
state = State.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -269,6 +274,15 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
return name.toString();
|
return name.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public State getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(State state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
@ -280,7 +294,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setTemplateType(TemplateType type) {
|
public void setTemplateType(TemplateType type) {
|
||||||
this.templateType = type;
|
templateType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean requiresHvm() {
|
public boolean requiresHvm() {
|
||||||
@ -455,18 +469,19 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
return this.uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUuid(String uuid) {
|
public void setUuid(String uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getDetails() {
|
@Override
|
||||||
return this.details;
|
public Map<String, String> getDetails() {
|
||||||
|
return details;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDetails(Map details) {
|
public void setDetails(Map<String, String> details) {
|
||||||
this.details = details;
|
this.details = details;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +495,7 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
}
|
}
|
||||||
VMTemplateVO other = (VMTemplateVO) that;
|
VMTemplateVO other = (VMTemplateVO) that;
|
||||||
|
|
||||||
return ((this.getUniqueName().equals(other.getUniqueName())));
|
return ((getUniqueName().equals(other.getUniqueName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -516,8 +531,9 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
this.dynamicallyScalable = dynamicallyScalable;
|
this.dynamicallyScalable = dynamicallyScalable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Boolean isDynamicallyScalable() {
|
public Boolean isDynamicallyScalable() {
|
||||||
return this.dynamicallyScalable;
|
return dynamicallyScalable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -534,19 +550,19 @@ public class VMTemplateVO implements VirtualMachineTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long getSize() {
|
public Long getSize() {
|
||||||
return this.size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getUpdatedCount() {
|
public long getUpdatedCount() {
|
||||||
return this.updatedCount;
|
return updatedCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incrUpdatedCount() {
|
public void incrUpdatedCount() {
|
||||||
this.updatedCount++;
|
updatedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decrUpdatedCount() {
|
public void decrUpdatedCount() {
|
||||||
this.updatedCount--;
|
updatedCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getUpdated() {
|
public Date getUpdated() {
|
||||||
|
|||||||
@ -23,6 +23,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
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.DataObjectInStore;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
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.TemplateDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.to.DataObjectType;
|
import com.cloud.agent.api.to.DataObjectType;
|
||||||
@ -70,7 +71,7 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void configure(VMTemplateVO template, DataStore dataStore) {
|
protected void configure(VMTemplateVO template, DataStore dataStore) {
|
||||||
this.imageVO = template;
|
imageVO = template;
|
||||||
this.dataStore = dataStore;
|
this.dataStore = dataStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,31 +82,36 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSize(Long size) {
|
public void setSize(Long size) {
|
||||||
this.imageVO.setSize(size);
|
imageVO.setSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VMTemplateVO getImage() {
|
public VMTemplateVO getImage() {
|
||||||
return this.imageVO;
|
return imageVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataStore getDataStore() {
|
public DataStore getDataStore() {
|
||||||
return this.dataStore;
|
return dataStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUniqueName() {
|
public String getUniqueName() {
|
||||||
return this.imageVO.getUniqueName();
|
return imageVO.getUniqueName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return this.imageVO.getId();
|
return imageVO.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public State getState() {
|
||||||
|
return imageVO.getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
return this.imageVO.getUuid();
|
return imageVO.getUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -113,7 +119,7 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
if ( url != null ){
|
if ( url != null ){
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
VMTemplateVO image = imageDao.findById(this.imageVO.getId());
|
VMTemplateVO image = imageDao.findById(imageVO.getId());
|
||||||
|
|
||||||
return image.getUrl();
|
return image.getUrl();
|
||||||
|
|
||||||
@ -121,8 +127,8 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getSize() {
|
public Long getSize() {
|
||||||
if (this.dataStore == null) {
|
if (dataStore == null) {
|
||||||
return this.imageVO.getSize();
|
return imageVO.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -142,7 +148,7 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
* templateSize = templateHostVO.getSize(); } totalAllocatedSize +=
|
* templateSize = templateHostVO.getSize(); } totalAllocatedSize +=
|
||||||
* (templateSize + _extraBytesPerVolume); }
|
* (templateSize + _extraBytesPerVolume); }
|
||||||
*/
|
*/
|
||||||
VMTemplateVO image = imageDao.findById(this.imageVO.getId());
|
VMTemplateVO image = imageDao.findById(imageVO.getId());
|
||||||
return image.getSize();
|
return image.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +159,7 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImageFormat getFormat() {
|
public ImageFormat getFormat() {
|
||||||
return this.imageVO.getFormat();
|
return imageVO.getFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -175,25 +181,24 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
@Override
|
@Override
|
||||||
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
|
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
|
||||||
try {
|
try {
|
||||||
if (this.getDataStore().getRole() == DataStoreRole.Primary) {
|
if (getDataStore().getRole() == DataStoreRole.Primary) {
|
||||||
if (answer instanceof CopyCmdAnswer) {
|
if (answer instanceof CopyCmdAnswer) {
|
||||||
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer) answer;
|
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer) answer;
|
||||||
TemplateObjectTO newTemplate = (TemplateObjectTO) cpyAnswer.getNewData();
|
TemplateObjectTO newTemplate = (TemplateObjectTO) cpyAnswer.getNewData();
|
||||||
VMTemplateStoragePoolVO templatePoolRef = templatePoolDao.findByPoolTemplate(this.getDataStore()
|
VMTemplateStoragePoolVO templatePoolRef = templatePoolDao.findByPoolTemplate(getDataStore()
|
||||||
.getId(), this.getId());
|
.getId(), getId());
|
||||||
templatePoolRef.setDownloadPercent(100);
|
templatePoolRef.setDownloadPercent(100);
|
||||||
templatePoolRef.setDownloadState(Status.DOWNLOADED);
|
templatePoolRef.setDownloadState(Status.DOWNLOADED);
|
||||||
templatePoolRef.setLocalDownloadPath(newTemplate.getPath());
|
templatePoolRef.setLocalDownloadPath(newTemplate.getPath());
|
||||||
templatePoolRef.setInstallPath(newTemplate.getPath());
|
templatePoolRef.setInstallPath(newTemplate.getPath());
|
||||||
templatePoolDao.update(templatePoolRef.getId(), templatePoolRef);
|
templatePoolDao.update(templatePoolRef.getId(), templatePoolRef);
|
||||||
}
|
}
|
||||||
} else if (this.getDataStore().getRole() == DataStoreRole.Image
|
} else if (getDataStore().getRole() == DataStoreRole.Image
|
||||||
|| this.getDataStore().getRole() == DataStoreRole.ImageCache) {
|
|| getDataStore().getRole() == DataStoreRole.ImageCache) {
|
||||||
if (answer instanceof CopyCmdAnswer) {
|
if (answer instanceof CopyCmdAnswer) {
|
||||||
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer) answer;
|
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer) answer;
|
||||||
TemplateObjectTO newTemplate = (TemplateObjectTO) cpyAnswer.getNewData();
|
TemplateObjectTO newTemplate = (TemplateObjectTO) cpyAnswer.getNewData();
|
||||||
TemplateDataStoreVO templateStoreRef = this.templateStoreDao.findByStoreTemplate(this
|
TemplateDataStoreVO templateStoreRef = templateStoreDao.findByStoreTemplate(getDataStore().getId(), getId());
|
||||||
.getDataStore().getId(), this.getId());
|
|
||||||
templateStoreRef.setInstallPath(newTemplate.getPath());
|
templateStoreRef.setInstallPath(newTemplate.getPath());
|
||||||
templateStoreRef.setDownloadPercent(100);
|
templateStoreRef.setDownloadPercent(100);
|
||||||
templateStoreRef.setDownloadState(Status.DOWNLOADED);
|
templateStoreRef.setDownloadState(Status.DOWNLOADED);
|
||||||
@ -202,8 +207,8 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
templateStoreRef.setPhysicalSize(newTemplate.getPhysicalSize());
|
templateStoreRef.setPhysicalSize(newTemplate.getPhysicalSize());
|
||||||
}
|
}
|
||||||
templateStoreDao.update(templateStoreRef.getId(), templateStoreRef);
|
templateStoreDao.update(templateStoreRef.getId(), templateStoreRef);
|
||||||
if (this.getDataStore().getRole() == DataStoreRole.Image) {
|
if (getDataStore().getRole() == DataStoreRole.Image) {
|
||||||
VMTemplateVO templateVO = this.imageDao.findById(this.getId());
|
VMTemplateVO templateVO = imageDao.findById(getId());
|
||||||
if (newTemplate.getFormat() != null) {
|
if (newTemplate.getFormat() != null) {
|
||||||
templateVO.setFormat(newTemplate.getFormat());
|
templateVO.setFormat(newTemplate.getFormat());
|
||||||
}
|
}
|
||||||
@ -212,7 +217,7 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
templateVO.setUniqueName(newTemplate.getName());
|
templateVO.setUniqueName(newTemplate.getName());
|
||||||
}
|
}
|
||||||
templateVO.setSize(newTemplate.getSize());
|
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
|
@Override
|
||||||
public void incRefCount() {
|
public void incRefCount() {
|
||||||
if (this.dataStore == null) {
|
if (dataStore == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
|
if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||||
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), this.getId());
|
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
|
||||||
store.incrRefCnt();
|
store.incrRefCnt();
|
||||||
store.setLastUpdated(new Date());
|
store.setLastUpdated(new Date());
|
||||||
templateStoreDao.update(store.getId(), store);
|
templateStoreDao.update(store.getId(), store);
|
||||||
@ -248,11 +253,11 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decRefCount() {
|
public void decRefCount() {
|
||||||
if (this.dataStore == null) {
|
if (dataStore == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
|
if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||||
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), this.getId());
|
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
|
||||||
store.decrRefCnt();
|
store.decrRefCnt();
|
||||||
store.setLastUpdated(new Date());
|
store.setLastUpdated(new Date());
|
||||||
templateStoreDao.update(store.getId(), store);
|
templateStoreDao.update(store.getId(), store);
|
||||||
@ -261,11 +266,11 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getRefCount() {
|
public Long getRefCount() {
|
||||||
if (this.dataStore == null) {
|
if (dataStore == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
|
if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||||
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), this.getId());
|
TemplateDataStoreVO store = templateStoreDao.findByStoreTemplate(dataStore.getId(), getId());
|
||||||
return store.getRefCnt();
|
return store.getRefCnt();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -274,10 +279,10 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
@Override
|
@Override
|
||||||
public DataTO getTO() {
|
public DataTO getTO() {
|
||||||
DataTO to = null;
|
DataTO to = null;
|
||||||
if (this.dataStore == null) {
|
if (dataStore == null) {
|
||||||
to = new TemplateObjectTO(this);
|
to = new TemplateObjectTO(this);
|
||||||
} else {
|
} else {
|
||||||
to = this.dataStore.getDriver().getTO(this);
|
to = dataStore.getDriver().getTO(this);
|
||||||
if (to == null) {
|
if (to == null) {
|
||||||
to = new TemplateObjectTO(this);
|
to = new TemplateObjectTO(this);
|
||||||
}
|
}
|
||||||
@ -288,91 +293,91 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInstallPath() {
|
public String getInstallPath() {
|
||||||
if (this.dataStore == null) {
|
if (dataStore == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
DataObjectInStore obj = objectInStoreMgr.findObject(this, this.dataStore);
|
DataObjectInStore obj = objectInStoreMgr.findObject(this, dataStore);
|
||||||
return obj.getInstallPath();
|
return obj.getInstallPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getAccountId() {
|
public long getAccountId() {
|
||||||
return this.imageVO.getAccountId();
|
return imageVO.getAccountId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFeatured() {
|
public boolean isFeatured() {
|
||||||
return this.imageVO.isFeatured();
|
return imageVO.isFeatured();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPublicTemplate() {
|
public boolean isPublicTemplate() {
|
||||||
return this.imageVO.isPublicTemplate();
|
return imageVO.isPublicTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExtractable() {
|
public boolean isExtractable() {
|
||||||
return this.imageVO.isExtractable();
|
return imageVO.isExtractable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.imageVO.getName();
|
return imageVO.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRequiresHvm() {
|
public boolean isRequiresHvm() {
|
||||||
return this.imageVO.isRequiresHvm();
|
return imageVO.isRequiresHvm();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayText() {
|
public String getDisplayText() {
|
||||||
return this.imageVO.getDisplayText();
|
return imageVO.getDisplayText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getEnablePassword() {
|
public boolean getEnablePassword() {
|
||||||
return this.imageVO.getEnablePassword();
|
return imageVO.getEnablePassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getEnableSshKey() {
|
public boolean getEnableSshKey() {
|
||||||
return this.imageVO.getEnableSshKey();
|
return imageVO.getEnableSshKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCrossZones() {
|
public boolean isCrossZones() {
|
||||||
return this.imageVO.isCrossZones();
|
return imageVO.isCrossZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getCreated() {
|
public Date getCreated() {
|
||||||
return this.imageVO.getCreated();
|
return imageVO.getCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getGuestOSId() {
|
public long getGuestOSId() {
|
||||||
return this.imageVO.getGuestOSId();
|
return imageVO.getGuestOSId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBootable() {
|
public boolean isBootable() {
|
||||||
return this.imageVO.isBootable();
|
return imageVO.isBootable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TemplateType getTemplateType() {
|
public TemplateType getTemplateType() {
|
||||||
return this.imageVO.getTemplateType();
|
return imageVO.getTemplateType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HypervisorType getHypervisorType() {
|
public HypervisorType getHypervisorType() {
|
||||||
return this.imageVO.getHypervisorType();
|
return imageVO.getHypervisorType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBits() {
|
public int getBits() {
|
||||||
return this.imageVO.getBits();
|
return imageVO.getBits();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -380,7 +385,7 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
if (url != null ){
|
if (url != null ){
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
return this.imageVO.getUrl();
|
return imageVO.getUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrl(String url){
|
public void setUrl(String url){
|
||||||
@ -389,22 +394,22 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChecksum() {
|
public String getChecksum() {
|
||||||
return this.imageVO.getChecksum();
|
return imageVO.getChecksum();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getSourceTemplateId() {
|
public Long getSourceTemplateId() {
|
||||||
return this.imageVO.getSourceTemplateId();
|
return imageVO.getSourceTemplateId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTemplateTag() {
|
public String getTemplateTag() {
|
||||||
return this.imageVO.getTemplateTag();
|
return imageVO.getTemplateTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map getDetails() {
|
public Map getDetails() {
|
||||||
return this.imageVO.getDetails();
|
return imageVO.getDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -414,7 +419,7 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getDomainId() {
|
public long getDomainId() {
|
||||||
return this.imageVO.getDomainId();
|
return imageVO.getDomainId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -34,6 +34,11 @@ import com.cloud.storage.Storage.TemplateType;
|
|||||||
public class TemplateEntityImpl implements TemplateEntity {
|
public class TemplateEntityImpl implements TemplateEntity {
|
||||||
protected TemplateInfo templateInfo;
|
protected TemplateInfo templateInfo;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public State getState() {
|
||||||
|
return templateInfo.getState();
|
||||||
|
}
|
||||||
|
|
||||||
public TemplateEntityImpl(TemplateInfo templateInfo) {
|
public TemplateEntityImpl(TemplateInfo templateInfo) {
|
||||||
this.templateInfo = templateInfo;
|
this.templateInfo = templateInfo;
|
||||||
}
|
}
|
||||||
@ -47,17 +52,17 @@ public class TemplateEntityImpl implements TemplateEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TemplateInfo getTemplateInfo() {
|
public TemplateInfo getTemplateInfo() {
|
||||||
return this.templateInfo;
|
return templateInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
return this.templateInfo.getUuid();
|
return templateInfo.getUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return this.templateInfo.getId();
|
return templateInfo.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExternalId() {
|
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_COLUMN = "removed";
|
||||||
|
|
||||||
static final String REMOVED = "removed";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This column can be used if the table wants to track creation time.
|
* 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);
|
Attribute attr = new Attribute(clazz, overrides, field, tableName, embedded, isId);
|
||||||
|
|
||||||
if (attr.getColumnName().equals(GenericDao.REMOVED_COLUMN)) {
|
if (attr.getColumnName().equals(GenericDao.REMOVED_COLUMN)) {
|
||||||
attr.setColumnName(GenericDao.REMOVED);
|
|
||||||
attr.setTrue(Attribute.Flag.DaoGenerated);
|
attr.setTrue(Attribute.Flag.DaoGenerated);
|
||||||
attr.setFalse(Attribute.Flag.Insertable);
|
attr.setFalse(Attribute.Flag.Insertable);
|
||||||
attr.setFalse(Attribute.Flag.Updatable);
|
attr.setFalse(Attribute.Flag.Updatable);
|
||||||
@ -281,7 +280,7 @@ public class SqlGenerator {
|
|||||||
for (Attribute attr : _attributes) {
|
for (Attribute attr : _attributes) {
|
||||||
|
|
||||||
if (attr.columnName.equalsIgnoreCase(name)) {
|
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 null;
|
||||||
}
|
}
|
||||||
return attr;
|
return attr;
|
||||||
@ -385,7 +384,7 @@ public class SqlGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sql.append(") VALUES (");
|
sql.append(") VALUES (");
|
||||||
for (Attribute attr : attrs) {
|
for (int i = 0; i < attrs.size(); i++) {
|
||||||
sql.append("?, ");
|
sql.append("?, ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,7 +434,7 @@ public class SqlGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pair<String, Attribute[]> buildRemoveSql() {
|
public Pair<String, Attribute[]> buildRemoveSql() {
|
||||||
Attribute attribute = findAttribute(GenericDao.REMOVED);
|
Attribute attribute = findAttribute(GenericDao.REMOVED_COLUMN);
|
||||||
if (attribute == null) {
|
if (attribute == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -518,7 +517,7 @@ public class SqlGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pair<String, Attribute> getRemovedAttribute() {
|
public Pair<String, Attribute> getRemovedAttribute() {
|
||||||
Attribute removed = findAttribute(GenericDao.REMOVED);
|
Attribute removed = findAttribute(GenericDao.REMOVED_COLUMN);
|
||||||
if (removed == null) {
|
if (removed == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,6 +106,7 @@ import com.cloud.capacity.CapacityVO;
|
|||||||
import com.cloud.capacity.dao.CapacityDao;
|
import com.cloud.capacity.dao.CapacityDao;
|
||||||
import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
|
import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
|
import com.cloud.configuration.ConfigurationManager;
|
||||||
import com.cloud.configuration.ConfigurationService;
|
import com.cloud.configuration.ConfigurationService;
|
||||||
import com.cloud.configuration.Resource.ResourceType;
|
import com.cloud.configuration.Resource.ResourceType;
|
||||||
import com.cloud.dc.AccountVlanMapVO;
|
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.VpcGatewayDao;
|
||||||
import com.cloud.network.vpc.dao.VpcOfferingDao;
|
import com.cloud.network.vpc.dao.VpcOfferingDao;
|
||||||
import com.cloud.offering.DiskOffering;
|
import com.cloud.offering.DiskOffering;
|
||||||
import com.cloud.offering.NetworkOffering;
|
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
import com.cloud.offerings.NetworkOfferingVO;
|
||||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
@ -298,6 +298,7 @@ public class ApiDBUtils {
|
|||||||
static NetworkModel _networkModel;
|
static NetworkModel _networkModel;
|
||||||
static NetworkManager _networkMgr;
|
static NetworkManager _networkMgr;
|
||||||
static TemplateManager _templateMgr;
|
static TemplateManager _templateMgr;
|
||||||
|
static ConfigurationManager _configMgr;
|
||||||
|
|
||||||
static StatsCollector _statsCollector;
|
static StatsCollector _statsCollector;
|
||||||
|
|
||||||
@ -340,7 +341,7 @@ public class ApiDBUtils {
|
|||||||
static NetworkOfferingDao _networkOfferingDao;
|
static NetworkOfferingDao _networkOfferingDao;
|
||||||
static NetworkDao _networkDao;
|
static NetworkDao _networkDao;
|
||||||
static PhysicalNetworkDao _physicalNetworkDao;
|
static PhysicalNetworkDao _physicalNetworkDao;
|
||||||
static ConfigurationService _configMgr;
|
static ConfigurationService _configSvc;
|
||||||
static ConfigurationDao _configDao;
|
static ConfigurationDao _configDao;
|
||||||
static ConsoleProxyDao _consoleProxyDao;
|
static ConsoleProxyDao _consoleProxyDao;
|
||||||
static FirewallRulesCidrsDao _firewallCidrsDao;
|
static FirewallRulesCidrsDao _firewallCidrsDao;
|
||||||
@ -452,7 +453,7 @@ public class ApiDBUtils {
|
|||||||
@Inject private NetworkOfferingDao networkOfferingDao;
|
@Inject private NetworkOfferingDao networkOfferingDao;
|
||||||
@Inject private NetworkDao networkDao;
|
@Inject private NetworkDao networkDao;
|
||||||
@Inject private PhysicalNetworkDao physicalNetworkDao;
|
@Inject private PhysicalNetworkDao physicalNetworkDao;
|
||||||
@Inject private ConfigurationService configMgr;
|
@Inject private ConfigurationService configSvc;
|
||||||
@Inject private ConfigurationDao configDao;
|
@Inject private ConfigurationDao configDao;
|
||||||
@Inject private ConsoleProxyDao consoleProxyDao;
|
@Inject private ConsoleProxyDao consoleProxyDao;
|
||||||
@Inject private FirewallRulesCidrsDao firewallCidrsDao;
|
@Inject private FirewallRulesCidrsDao firewallCidrsDao;
|
||||||
@ -511,17 +512,20 @@ public class ApiDBUtils {
|
|||||||
@Inject private NetworkACLDao networkACLDao;
|
@Inject private NetworkACLDao networkACLDao;
|
||||||
@Inject private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
|
@Inject private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
|
||||||
@Inject private AccountService accountService;
|
@Inject private AccountService accountService;
|
||||||
|
@Inject
|
||||||
|
private ConfigurationManager configMgr;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
void init() {
|
void init() {
|
||||||
_ms = ms;
|
_ms = ms;
|
||||||
|
_configMgr = configMgr;
|
||||||
_asyncMgr = asyncMgr;
|
_asyncMgr = asyncMgr;
|
||||||
_securityGroupMgr = securityGroupMgr;
|
_securityGroupMgr = securityGroupMgr;
|
||||||
_storageMgr = storageMgr;
|
_storageMgr = storageMgr;
|
||||||
_userVmMgr = userVmMgr;
|
_userVmMgr = userVmMgr;
|
||||||
_networkModel = networkModel;
|
_networkModel = networkModel;
|
||||||
_networkMgr = networkMgr;
|
_networkMgr = networkMgr;
|
||||||
_configMgr = configMgr;
|
_configSvc = configSvc;
|
||||||
_templateMgr = templateMgr;
|
_templateMgr = templateMgr;
|
||||||
|
|
||||||
_accountDao = accountDao;
|
_accountDao = accountDao;
|
||||||
@ -1026,7 +1030,7 @@ public class ApiDBUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Account getVlanAccount(long vlanId) {
|
public static Account getVlanAccount(long vlanId) {
|
||||||
return _configMgr.getVlanAccount(vlanId);
|
return _configSvc.getVlanAccount(vlanId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSecurityGroupEnabledInZone(long zoneId) {
|
public static boolean isSecurityGroupEnabledInZone(long zoneId) {
|
||||||
@ -1153,11 +1157,6 @@ public class ApiDBUtils {
|
|||||||
return _taggedResourceService.getUuid(resourceId, resourceType);
|
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) {
|
public static List<? extends ResourceTag> listByResourceTypeAndId(TaggedResourceType type, long resourceId) {
|
||||||
return _taggedResourceService.listByResourceTypeAndId(type, 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.Capacity;
|
||||||
import com.cloud.capacity.CapacityVO;
|
import com.cloud.capacity.CapacityVO;
|
||||||
import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
|
import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
|
||||||
|
import com.cloud.configuration.ConfigurationManager;
|
||||||
import com.cloud.configuration.Resource.ResourceOwnerType;
|
import com.cloud.configuration.Resource.ResourceOwnerType;
|
||||||
import com.cloud.configuration.Resource.ResourceType;
|
import com.cloud.configuration.Resource.ResourceType;
|
||||||
import com.cloud.configuration.ResourceCount;
|
import com.cloud.configuration.ResourceCount;
|
||||||
@ -309,6 +310,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
protected AccountManager _accountMgr;
|
protected AccountManager _accountMgr;
|
||||||
@Inject
|
@Inject
|
||||||
protected AsyncJobManager _jobMgr;
|
protected AsyncJobManager _jobMgr;
|
||||||
|
@Inject
|
||||||
|
ConfigurationManager _configMgr;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserResponse createUserResponse(User user) {
|
public UserResponse createUserResponse(User user) {
|
||||||
@ -2089,7 +2092,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
|
|
||||||
serviceResponses.add(svcRsp);
|
serviceResponses.add(svcRsp);
|
||||||
}
|
}
|
||||||
response.setForVpc(ApiDBUtils.isOfferingForVpc(offering));
|
response.setForVpc(_configMgr.isOfferingForVpc(offering));
|
||||||
|
|
||||||
response.setServices(serviceResponses);
|
response.setServices(serviceResponses);
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,6 @@ import com.cloud.org.Grouping.AllocationState;
|
|||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.storage.DiskOfferingVO;
|
import com.cloud.storage.DiskOfferingVO;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.Manager;
|
|
||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +50,16 @@ import com.cloud.vm.VirtualMachine;
|
|||||||
* configuration values
|
* 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
|
* Updates a configuration entry with a new value
|
||||||
|
|||||||
@ -207,7 +207,7 @@ import com.cloud.vm.dao.NicSecondaryIpDao;
|
|||||||
|
|
||||||
@Local(value = { ConfigurationManager.class, ConfigurationService.class })
|
@Local(value = { ConfigurationManager.class, ConfigurationService.class })
|
||||||
public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService {
|
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
|
@Inject
|
||||||
EntityManager _entityMgr;
|
EntityManager _entityMgr;
|
||||||
@ -2228,7 +2228,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify input parameters
|
// Verify input parameters
|
||||||
ServiceOffering offeringHandle = getServiceOffering(id);
|
ServiceOffering offeringHandle = _entityMgr.findById(ServiceOffering.class, id);
|
||||||
|
|
||||||
if (offeringHandle == null) {
|
if (offeringHandle == null) {
|
||||||
throw new InvalidParameterValueException("unable to find service offering " + id);
|
throw new InvalidParameterValueException("unable to find service offering " + id);
|
||||||
@ -2419,7 +2419,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||||||
Integer sortKey = cmd.getSortKey();
|
Integer sortKey = cmd.getSortKey();
|
||||||
|
|
||||||
// Check if diskOffering exists
|
// Check if diskOffering exists
|
||||||
DiskOffering diskOfferingHandle = getDiskOffering(diskOfferingId);
|
DiskOffering diskOfferingHandle = _entityMgr.findById(DiskOffering.class, diskOfferingId);
|
||||||
|
|
||||||
if (diskOfferingHandle == null) {
|
if (diskOfferingHandle == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
|
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) {
|
public boolean deleteDiskOffering(DeleteDiskOfferingCmd cmd) {
|
||||||
Long diskOfferingId = cmd.getId();
|
Long diskOfferingId = cmd.getId();
|
||||||
|
|
||||||
DiskOffering offering = getDiskOffering(diskOfferingId);
|
DiskOfferingVO offering = _diskOfferingDao.findById(diskOfferingId);
|
||||||
|
|
||||||
if (offering == null) {
|
if (offering == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
|
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);
|
CallContext.current().setEventDetails("Disk offering id=" + diskOfferingId);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -2508,7 +2509,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify service offering id
|
// Verify service offering id
|
||||||
ServiceOffering offering = getServiceOffering(offeringId);
|
ServiceOfferingVO offering = _serviceOfferingDao.findById(offeringId);
|
||||||
if (offering == null) {
|
if (offering == null) {
|
||||||
throw new InvalidParameterValueException("unable to find service offering " + offeringId);
|
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");
|
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);
|
CallContext.current().setEventDetails("Service offering id=" + offeringId);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -4767,16 +4769,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public NetworkOffering getNetworkOffering(long id) {
|
|
||||||
return _networkOfferingDao.findById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId) {
|
public Integer getNetworkOfferingNetworkRate(long networkOfferingId, Long dataCenterId) {
|
||||||
|
|
||||||
// validate network offering information
|
// validate network offering information
|
||||||
NetworkOffering no = getNetworkOffering(networkOfferingId);
|
NetworkOffering no = _entityMgr.findById(NetworkOffering.class, networkOfferingId);
|
||||||
if (no == null) {
|
if (no == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find network offering by id=" + networkOfferingId);
|
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
|
@Override
|
||||||
public Long getDefaultPageSize() {
|
public Long getDefaultPageSize() {
|
||||||
return _defaultPageSize;
|
return _defaultPageSize;
|
||||||
@ -4937,16 +4924,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||||||
return networkRate;
|
return networkRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DiskOffering getDiskOffering(long diskOfferingId) {
|
|
||||||
DiskOfferingVO offering = _diskOfferingDao.findById(diskOfferingId);
|
|
||||||
if (offering != null && offering.getRemoved() == null) {
|
|
||||||
return offering;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
@ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_RANGE_CREATE,
|
@ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_RANGE_CREATE,
|
||||||
|
|||||||
@ -1768,7 +1768,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
@Override
|
@Override
|
||||||
public IpAddress assignSystemIp(long networkId, Account owner, boolean forElasticLb, boolean forElasticIp) throws InsufficientAddressCapacityException {
|
public IpAddress assignSystemIp(long networkId, Account owner, boolean forElasticLb, boolean forElasticIp) throws InsufficientAddressCapacityException {
|
||||||
Network guestNetwork = _networksDao.findById(networkId);
|
Network guestNetwork = _networksDao.findById(networkId);
|
||||||
NetworkOffering off = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
NetworkOffering off = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
|
||||||
IpAddress ip = null;
|
IpAddress ip = null;
|
||||||
if ((off.getElasticLb() && forElasticLb) || (off.getElasticIp() && forElasticIp)) {
|
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 networkDomain is not specified, take it from the global configuration
|
||||||
if (_networkModel.areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) {
|
if (_networkModel.areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) {
|
||||||
Map<Network.Capability, String> dnsCapabilities = _networkModel.getNetworkOfferingServiceCapabilities
|
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);
|
String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification);
|
||||||
if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
|
if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
|
||||||
if (networkDomain != null) {
|
if (networkDomain != null) {
|
||||||
@ -2214,7 +2214,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||||||
_networkAccountDao.remove(networkAccount.getId());
|
_networkAccountDao.remove(networkAccount.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkOffering ntwkOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
NetworkOffering ntwkOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||||
boolean updateResourceCount = resourceCountNeedsUpdate(ntwkOff, network.getAclType());
|
boolean updateResourceCount = resourceCountNeedsUpdate(ntwkOff, network.getAclType());
|
||||||
if (updateResourceCount) {
|
if (updateResourceCount) {
|
||||||
_resourceLimitMgr.decrementResourceCount(owner.getId(), ResourceType.network);
|
_resourceLimitMgr.decrementResourceCount(owner.getId(), ResourceType.network);
|
||||||
@ -3105,7 +3105,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||||||
if (lbElements.size() > 1) {
|
if (lbElements.size() > 1) {
|
||||||
String providerName = null;
|
String providerName = null;
|
||||||
//get network offering details
|
//get network offering details
|
||||||
NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
NetworkOffering off = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||||
if (lbScheme == Scheme.Public) {
|
if (lbScheme == Scheme.Public) {
|
||||||
providerName = _ntwkOffDetailsDao.getDetail(off.getId(), NetworkOffering.Detail.PublicLbProvider);
|
providerName = _ntwkOffDetailsDao.getDetail(off.getId(), NetworkOffering.Detail.PublicLbProvider);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -32,13 +32,12 @@ import javax.ejb.Local;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||||
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
|
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.api.ApiDBUtils;
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.ConfigurationManager;
|
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.AdapterBase;
|
||||||
import com.cloud.utils.component.ManagerBase;
|
import com.cloud.utils.component.ManagerBase;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
import com.cloud.utils.db.EntityManager;
|
||||||
import com.cloud.utils.db.JoinBuilder;
|
import com.cloud.utils.db.JoinBuilder;
|
||||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
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.NicSecondaryIpDao;
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
import com.cloud.vm.dao.VMInstanceDao;
|
||||||
|
|
||||||
@Component
|
|
||||||
@Local(value = { NetworkModel.class})
|
@Local(value = { NetworkModel.class})
|
||||||
public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
||||||
static final Logger s_logger = Logger.getLogger(NetworkModelImpl.class);
|
static final Logger s_logger = Logger.getLogger(NetworkModelImpl.class);
|
||||||
|
@Inject
|
||||||
|
EntityManager _entityMgr;
|
||||||
@Inject
|
@Inject
|
||||||
DataCenterDao _dcDao = null;
|
DataCenterDao _dcDao = null;
|
||||||
@Inject
|
@Inject
|
||||||
@ -935,7 +935,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
|||||||
vm = _vmDao.findById(vmId);
|
vm = _vmDao.findById(vmId);
|
||||||
}
|
}
|
||||||
Network network = getNetwork(networkId);
|
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
|
// For default userVm Default network and domR guest/public network, get rate information from the service
|
||||||
// offering; for other situations get information
|
// offering; for other situations get information
|
||||||
@ -1107,7 +1107,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
|||||||
@Override
|
@Override
|
||||||
public List<Long> listNetworkOfferingsForUpgrade(long networkId) {
|
public List<Long> listNetworkOfferingsForUpgrade(long networkId) {
|
||||||
List<Long> offeringsToReturn = new ArrayList<Long>();
|
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);
|
boolean securityGroupSupportedByOriginalOff = areServicesSupportedByNetworkOffering(originalOffering.getId(), Service.SecurityGroup);
|
||||||
|
|
||||||
@ -1280,7 +1280,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
|||||||
if (effectiveTrafficType != TrafficType.Guest) {
|
if (effectiveTrafficType != TrafficType.Guest) {
|
||||||
physicalNetworkId = getNonGuestNetworkPhysicalNetworkId(network, effectiveTrafficType);
|
physicalNetworkId = getNonGuestNetworkPhysicalNetworkId(network, effectiveTrafficType);
|
||||||
} else {
|
} else {
|
||||||
NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||||
physicalNetworkId = network.getPhysicalNetworkId();
|
physicalNetworkId = network.getPhysicalNetworkId();
|
||||||
if(physicalNetworkId == null){
|
if(physicalNetworkId == null){
|
||||||
physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags(), offering.getTrafficType());
|
physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags(), offering.getTrafficType());
|
||||||
@ -1328,7 +1328,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Long physicalNetworkId = network.getPhysicalNetworkId();
|
Long physicalNetworkId = network.getPhysicalNetworkId();
|
||||||
NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||||
if (physicalNetworkId == null) {
|
if (physicalNetworkId == null) {
|
||||||
physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags(), offering.getTrafficType());
|
physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags(), offering.getTrafficType());
|
||||||
}
|
}
|
||||||
@ -2005,6 +2005,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isNetworkInlineMode(Network network) {
|
public boolean isNetworkInlineMode(Network network) {
|
||||||
NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
|
NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
|
||||||
return offering.isInline();
|
return offering.isInline();
|
||||||
|
|||||||
@ -894,7 +894,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||||||
Long networkId = ipVO.getAssociatedWithNetworkId();
|
Long networkId = ipVO.getAssociatedWithNetworkId();
|
||||||
if (networkId != null) {
|
if (networkId != null) {
|
||||||
Network guestNetwork = getNetwork(networkId);
|
Network guestNetwork = getNetwork(networkId);
|
||||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
|
||||||
Long vmId = ipVO.getAssociatedWithVmId();
|
Long vmId = ipVO.getAssociatedWithVmId();
|
||||||
if (offering.getElasticIp() && vmId != null) {
|
if (offering.getElasticIp() && vmId != null) {
|
||||||
_rulesMgr.getSystemIpAndEnableStaticNatForVm(_userVmDao.findById(vmId), true);
|
_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
|
//can't update from vpc to non-vpc network offering
|
||||||
boolean forVpcNew = _configMgr.isOfferingForVpc(networkOffering);
|
boolean forVpcNew = _configMgr.isOfferingForVpc(networkOffering);
|
||||||
boolean vorVpcOriginal = _configMgr.isOfferingForVpc(_configMgr.getNetworkOffering(oldNetworkOfferingId));
|
boolean vorVpcOriginal = _configMgr.isOfferingForVpc(_entityMgr.findById(NetworkOffering.class, oldNetworkOfferingId));
|
||||||
if (forVpcNew != vorVpcOriginal) {
|
if (forVpcNew != vorVpcOriginal) {
|
||||||
String errMsg = forVpcNew ? "a vpc offering " : "not a vpc offering";
|
String errMsg = forVpcNew ? "a vpc offering " : "not a vpc offering";
|
||||||
throw new InvalidParameterValueException("Can't update as the new offering is " + errMsg);
|
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>();
|
Map<String, String> newSvcProviders = new HashMap<String, String>();
|
||||||
if (networkOfferingChanged) {
|
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
|
// 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;
|
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);
|
String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification);
|
||||||
if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
|
if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
|
||||||
// TBD: use uuid instead of networkOfferingId. May need to hardcode tablename in call to addProxyObject().
|
// 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();
|
txn.commit();
|
||||||
} else {
|
} else {
|
||||||
network.setNetworkOfferingId(networkOfferingId);
|
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 {
|
} else {
|
||||||
_networksDao.update(networkId, network);
|
_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");
|
throw new InvalidParameterValueException("Unable to find zone by id");
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceOffering serviceOffering = _configMgr.getServiceOffering(serviceOfferingId);
|
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||||
if (serviceOffering == null) {
|
if (serviceOffering == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find service offering by id");
|
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)
|
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm)
|
||||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||||
DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
|
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)) {
|
if (!canHandle(offering, dc)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1328,7 +1328,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
|||||||
LoadBalancer result = null;
|
LoadBalancer result = null;
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
IpAddress systemIp = 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) {
|
if (off.getElasticLb() && ipVO == null && network.getVpcId() == null) {
|
||||||
systemIp = _ipAddrMgr.assignSystemIp(networkId, lbOwner, true, false);
|
systemIp = _ipAddrMgr.assignSystemIp(networkId, lbOwner, true, false);
|
||||||
ipVO = _ipAddressDao.findById(systemIp.getId());
|
ipVO = _ipAddressDao.findById(systemIp.getId());
|
||||||
@ -2138,7 +2138,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
//2) Check if the Scheme is supported\
|
//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 (scheme == Scheme.Public) {
|
||||||
if (!off.getPublicLb()) {
|
if (!off.getPublicLb()) {
|
||||||
throw new InvalidParameterValueException("Scheme " + scheme + " is not supported by the network offering " + off);
|
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 javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd;
|
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd;
|
||||||
import org.apache.cloudstack.context.CallContext;
|
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.component.ManagerBase;
|
||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
import com.cloud.utils.db.EntityManager;
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
import com.cloud.utils.db.GlobalLock;
|
import com.cloud.utils.db.GlobalLock;
|
||||||
import com.cloud.utils.db.JoinBuilder;
|
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.
|
* VirtualNetworkApplianceManagerImpl manages the different types of virtual network appliances available in the Cloud Stack.
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Local(value = { VirtualNetworkApplianceManager.class, VirtualNetworkApplianceService.class })
|
@Local(value = { VirtualNetworkApplianceManager.class, VirtualNetworkApplianceService.class })
|
||||||
public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements VirtualNetworkApplianceManager, VirtualNetworkApplianceService,
|
public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements VirtualNetworkApplianceManager, VirtualNetworkApplianceService,
|
||||||
VirtualMachineGuru, Listener {
|
VirtualMachineGuru, Listener {
|
||||||
private static final Logger s_logger = Logger.getLogger(VirtualNetworkApplianceManagerImpl.class);
|
private static final Logger s_logger = Logger.getLogger(VirtualNetworkApplianceManagerImpl.class);
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
EntityManager _entityMgr;
|
||||||
@Inject
|
@Inject
|
||||||
DataCenterDao _dcDao = null;
|
DataCenterDao _dcDao = null;
|
||||||
@Inject
|
@Inject
|
||||||
@ -448,7 +449,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
return _routerDao.findById(routerId);
|
return _routerDao.findById(routerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceOffering newServiceOffering = _configMgr.getServiceOffering(serviceOfferingId);
|
ServiceOffering newServiceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
|
||||||
if (newServiceOffering == null) {
|
if (newServiceOffering == null) {
|
||||||
throw new InvalidParameterValueException("Unable to find service offering with id " + serviceOfferingId);
|
throw new InvalidParameterValueException("Unable to find service offering with id " + serviceOfferingId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,6 @@ import javax.ejb.Local;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.command.user.firewall.ListPortForwardingRulesCmd;
|
import org.apache.cloudstack.api.command.user.firewall.ListPortForwardingRulesCmd;
|
||||||
import org.apache.cloudstack.context.CallContext;
|
import org.apache.cloudstack.context.CallContext;
|
||||||
@ -71,6 +70,7 @@ import com.cloud.utils.Pair;
|
|||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.component.ManagerBase;
|
import com.cloud.utils.component.ManagerBase;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
import com.cloud.utils.db.EntityManager;
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
import com.cloud.utils.db.JoinBuilder;
|
import com.cloud.utils.db.JoinBuilder;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
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.UserVmDao;
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
import com.cloud.vm.dao.VMInstanceDao;
|
||||||
|
|
||||||
@Component
|
|
||||||
@Local(value = { RulesManager.class, RulesService.class })
|
@Local(value = { RulesManager.class, RulesService.class })
|
||||||
public class RulesManagerImpl extends ManagerBase implements RulesManager, RulesService {
|
public class RulesManagerImpl extends ManagerBase implements RulesManager, RulesService {
|
||||||
private static final Logger s_logger = Logger.getLogger(RulesManagerImpl.class);
|
private static final Logger s_logger = Logger.getLogger(RulesManagerImpl.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
IpAddressManager _ipAddrMgr;
|
IpAddressManager _ipAddrMgr;
|
||||||
|
@Inject
|
||||||
|
EntityManager _entityMgr;
|
||||||
@Inject
|
@Inject
|
||||||
PortForwardingRulesDao _portForwardingDao;
|
PortForwardingRulesDao _portForwardingDao;
|
||||||
@Inject
|
@Inject
|
||||||
@ -381,7 +381,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
|||||||
_networkModel.checkIpForService(ipAddress, Service.StaticNat, null);
|
_networkModel.checkIpForService(ipAddress, Service.StaticNat, null);
|
||||||
|
|
||||||
Network network = _networkModel.getNetwork(networkId);
|
Network network = _networkModel.getNetwork(networkId);
|
||||||
NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
NetworkOffering off = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||||
if (off.getElasticIp()) {
|
if (off.getElasticIp()) {
|
||||||
throw new InvalidParameterValueException("Can't create ip forwarding rules for the network where elasticIP service is enabled");
|
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;
|
boolean reassignStaticNat = false;
|
||||||
if (networkId != null) {
|
if (networkId != null) {
|
||||||
Network guestNetwork = _networkModel.getNetwork(networkId);
|
Network guestNetwork = _networkModel.getNetwork(networkId);
|
||||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
|
||||||
if (offering.getElasticIp()) {
|
if (offering.getElasticIp()) {
|
||||||
reassignStaticNat = true;
|
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
|
// 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
|
// re-enable it on the new one enable static nat takes care of that
|
||||||
Network guestNetwork = _networkModel.getNetwork(ipAddress.getAssociatedWithNetworkId());
|
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.getElasticIp()) {
|
||||||
if (offering.getAssociatePublicIP()) {
|
if (offering.getAssociatePublicIP()) {
|
||||||
getSystemIpAndEnableStaticNatForVm(_vmDao.findById(vmId), true);
|
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());
|
List<? extends Nic> nics = _nicDao.listByVmId(vm.getId());
|
||||||
for (Nic nic : nics) {
|
for (Nic nic : nics) {
|
||||||
Network guestNetwork = _networkModel.getNetwork(nic.getNetworkId());
|
Network guestNetwork = _networkModel.getNetwork(nic.getNetworkId());
|
||||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
|
||||||
if (offering.getElasticIp()) {
|
if (offering.getElasticIp()) {
|
||||||
boolean isSystemVM = (vm.getType() == Type.ConsoleProxy || vm.getType() == Type.SecondaryStorageVm);
|
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
|
// 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.
|
// under the License.
|
||||||
package com.cloud.network.vpc;
|
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.configuration.ConfigurationManager;
|
||||||
import com.cloud.event.ActionEvent;
|
import com.cloud.event.ActionEvent;
|
||||||
import com.cloud.event.EventTypes;
|
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.network.vpc.dao.VpcGatewayDao;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.tags.dao.ResourceTagDao;
|
import com.cloud.tags.dao.ResourceTagDao;
|
||||||
import com.cloud.user.Account;
|
|
||||||
import com.cloud.user.AccountManager;
|
import com.cloud.user.AccountManager;
|
||||||
import com.cloud.utils.component.ManagerBase;
|
import com.cloud.utils.component.ManagerBase;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
import com.cloud.utils.db.EntityManager;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
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})
|
@Local(value = { NetworkACLManager.class})
|
||||||
public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLManager{
|
public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLManager{
|
||||||
private static final Logger s_logger = Logger.getLogger(NetworkACLManagerImpl.class);
|
private static final Logger s_logger = Logger.getLogger(NetworkACLManagerImpl.class);
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
EntityManager _entityMgr;
|
||||||
@Inject
|
@Inject
|
||||||
AccountManager _accountMgr;
|
AccountManager _accountMgr;
|
||||||
@Inject
|
@Inject
|
||||||
@ -178,7 +178,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana
|
|||||||
@Override
|
@Override
|
||||||
public boolean replaceNetworkACL(NetworkACL acl, NetworkVO network) throws ResourceUnavailableException {
|
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) {
|
if (guestNtwkOff == null) {
|
||||||
throw new InvalidParameterValueException("Can't find network offering associated with network: "+network.getUuid());
|
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);
|
return _networkACLItemDao.findById(ruleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_ACL_DELETE, eventDescription = "revoking network acl", async = true)
|
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_ACL_DELETE, eventDescription = "revoking network acl", async = true)
|
||||||
public boolean revokeNetworkACLItem(long ruleId) {
|
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,
|
public void validateNtwkOffForNtwkInVpc(Long networkId, long newNtwkOffId, String newCidr,
|
||||||
String newNetworkDomain, Vpc vpc, String gateway, Account networkOwner, Long aclId) {
|
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) {
|
if (guestNtwkOff == null) {
|
||||||
throw new InvalidParameterValueException("Can't find network offering by id specified");
|
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
|
//skip my own network
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
NetworkOffering otherOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
NetworkOffering otherOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||||
if (_ntwkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb) && otherOff.getPublicLb()) {
|
if (_ntwkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb) && otherOff.getPublicLb()) {
|
||||||
throw new InvalidParameterValueException("Public LB service is already supported " +
|
throw new InvalidParameterValueException("Public LB service is already supported " +
|
||||||
"by network " + network + " in VPC " + vpc);
|
"by network " + network + " in VPC " + vpc);
|
||||||
|
|||||||
@ -360,7 +360,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||||||
if (storeUuid != null) {
|
if (storeUuid != null) {
|
||||||
imageStore = _dataStoreMgr.getDataStore(storeUuid, DataStoreRole.Image);
|
imageStore = _dataStoreMgr.getDataStore(storeUuid, DataStoreRole.Image);
|
||||||
} else {
|
} else {
|
||||||
imageStore = this._dataStoreMgr.getImageStore(zoneId);
|
imageStore = _dataStoreMgr.getImageStore(zoneId);
|
||||||
if (imageStore == null) {
|
if (imageStore == null) {
|
||||||
throw new CloudRuntimeException("cannot find an image store for zone " + zoneId);
|
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();
|
Long templateId = cmd.getId();
|
||||||
Account caller = CallContext.current().getCallingAccount();
|
Account caller = CallContext.current().getCallingAccount();
|
||||||
|
|
||||||
VirtualMachineTemplate template = getTemplate(templateId);
|
VMTemplateVO template = _tmpltDao.findById(templateId);
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
throw new InvalidParameterValueException("unable to find template with id " + templateId);
|
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.");
|
throw new InvalidParameterValueException("Please specify a valid template.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template.setState(VirtualMachineTemplate.State.Inactive);
|
||||||
|
_tmpltDao.update(template.getId(), template);
|
||||||
|
|
||||||
TemplateAdapter adapter = getAdapter(template.getHypervisorType());
|
TemplateAdapter adapter = getAdapter(template.getHypervisorType());
|
||||||
TemplateProfile profile = adapter.prepareDelete(cmd);
|
TemplateProfile profile = adapter.prepareDelete(cmd);
|
||||||
return adapter.delete(profile);
|
return adapter.delete(profile);
|
||||||
@ -1063,8 +1066,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||||||
Account caller = CallContext.current().getCallingAccount();
|
Account caller = CallContext.current().getCallingAccount();
|
||||||
Long zoneId = cmd.getZoneId();
|
Long zoneId = cmd.getZoneId();
|
||||||
|
|
||||||
VirtualMachineTemplate template = getTemplate(templateId);
|
VMTemplateVO template = _tmpltDao.findById(templateId);
|
||||||
;
|
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
throw new InvalidParameterValueException("unable to find iso with id " + templateId);
|
throw new InvalidParameterValueException("unable to find iso with id " + templateId);
|
||||||
}
|
}
|
||||||
@ -1075,6 +1077,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||||||
throw new InvalidParameterValueException("Please specify a valid iso.");
|
throw new InvalidParameterValueException("Please specify a valid iso.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// check if there is any VM using this ISO.
|
// check if there is any VM using this ISO.
|
||||||
if (!templateIsDeleteable(templateId)) {
|
if (!templateIsDeleteable(templateId)) {
|
||||||
throw new InvalidParameterValueException("Unable to delete iso, as it's used by other vms");
|
throw new InvalidParameterValueException("Unable to delete iso, as it's used by other vms");
|
||||||
@ -1083,6 +1086,10 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||||||
if (zoneId != null && (_dataStoreMgr.getImageStore(zoneId) == null)) {
|
if (zoneId != null && (_dataStoreMgr.getImageStore(zoneId) == null)) {
|
||||||
throw new InvalidParameterValueException("Failed to find a secondary storage store in the specified zone.");
|
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());
|
TemplateAdapter adapter = getAdapter(template.getHypervisorType());
|
||||||
TemplateProfile profile = adapter.prepareDelete(cmd);
|
TemplateProfile profile = adapter.prepareDelete(cmd);
|
||||||
boolean result = adapter.delete(profile);
|
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);
|
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
|
// check permissions
|
||||||
_accountMgr.checkAccess(caller, null, true, snapshot);
|
_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.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.crypt.RSAHelper;
|
import com.cloud.utils.crypt.RSAHelper;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
import com.cloud.utils.db.EntityManager;
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
import com.cloud.utils.db.GlobalLock;
|
import com.cloud.utils.db.GlobalLock;
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
@ -269,6 +270,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
linked
|
linked
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
EntityManager _entityMgr;
|
||||||
@Inject
|
@Inject
|
||||||
protected HostDao _hostDao = null;
|
protected HostDao _hostDao = null;
|
||||||
@Inject
|
@Inject
|
||||||
@ -1235,7 +1238,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
_itMgr.checkIfCanUpgrade(vmInstance, newServiceOfferingId);
|
_itMgr.checkIfCanUpgrade(vmInstance, newServiceOfferingId);
|
||||||
|
|
||||||
//Check if its a scale "up"
|
//Check if its a scale "up"
|
||||||
ServiceOffering newServiceOffering = _configMgr.getServiceOffering(newServiceOfferingId);
|
ServiceOffering newServiceOffering = _entityMgr.findById(ServiceOffering.class, newServiceOfferingId);
|
||||||
ServiceOffering currentServiceOffering = _offeringDao.findByIdIncludingRemoved(vmInstance.getServiceOfferingId());
|
ServiceOffering currentServiceOffering = _offeringDao.findByIdIncludingRemoved(vmInstance.getServiceOfferingId());
|
||||||
int newCpu = newServiceOffering.getCpu();
|
int newCpu = newServiceOffering.getCpu();
|
||||||
int newMemory = newServiceOffering.getRamSize();
|
int newMemory = newServiceOffering.getRamSize();
|
||||||
@ -2453,8 +2456,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
_networkModel.checkNetworkPermissions(owner, network);
|
_networkModel.checkNetworkPermissions(owner, network);
|
||||||
|
|
||||||
// don't allow to use system networks
|
// don't allow to use system networks
|
||||||
NetworkOffering networkOffering = _configMgr
|
NetworkOffering networkOffering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||||
.getNetworkOffering(network.getNetworkOfferingId());
|
|
||||||
if (networkOffering.isSystemOnly()) {
|
if (networkOffering.isSystemOnly()) {
|
||||||
throw new InvalidParameterValueException(
|
throw new InvalidParameterValueException(
|
||||||
"Network id="
|
"Network id="
|
||||||
@ -3218,7 +3220,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
try {
|
try {
|
||||||
long networkId = ip.getAssociatedWithNetworkId();
|
long networkId = ip.getAssociatedWithNetworkId();
|
||||||
Network guestNetwork = _networkDao.findById(networkId);
|
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.";
|
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);
|
_rulesMgr.disableStaticNat(ip.getId(), ctx.getCallingAccount(), ctx.getCallingUserId(), true);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -4593,9 +4595,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
_networkModel.checkNetworkPermissions(newAccount, network);
|
_networkModel.checkNetworkPermissions(newAccount, network);
|
||||||
|
|
||||||
// don't allow to use system networks
|
// don't allow to use system networks
|
||||||
NetworkOffering networkOffering = _configMgr
|
NetworkOffering networkOffering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
|
||||||
.getNetworkOffering(network
|
|
||||||
.getNetworkOfferingId());
|
|
||||||
if (networkOffering.isSystemOnly()) {
|
if (networkOffering.isSystemOnly()) {
|
||||||
InvalidParameterValueException ex = new InvalidParameterValueException(
|
InvalidParameterValueException ex = new InvalidParameterValueException(
|
||||||
"Specified Network id is system only and can't be used for vm deployment");
|
"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.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.cloud.service.dao.ServiceOfferingDao;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@ -64,6 +63,7 @@ import com.cloud.hypervisor.Hypervisor;
|
|||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
|
import com.cloud.service.dao.ServiceOfferingDao;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.storage.Volume;
|
import com.cloud.storage.Volume;
|
||||||
@ -77,6 +77,7 @@ import com.cloud.user.AccountVO;
|
|||||||
import com.cloud.user.UserVO;
|
import com.cloud.user.UserVO;
|
||||||
import com.cloud.user.dao.AccountDao;
|
import com.cloud.user.dao.AccountDao;
|
||||||
import com.cloud.user.dao.UserDao;
|
import com.cloud.user.dao.UserDao;
|
||||||
|
import com.cloud.utils.db.EntityManager;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.dao.UserVmDao;
|
import com.cloud.vm.dao.UserVmDao;
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
import com.cloud.vm.dao.VMInstanceDao;
|
||||||
@ -109,6 +110,9 @@ public class UserVmManagerTest {
|
|||||||
@Mock List<VolumeVO> _rootVols;
|
@Mock List<VolumeVO> _rootVols;
|
||||||
@Mock Account _accountMock2;
|
@Mock Account _accountMock2;
|
||||||
@Mock ServiceOfferingDao _offeringDao;
|
@Mock ServiceOfferingDao _offeringDao;
|
||||||
|
@Mock
|
||||||
|
EntityManager _entityMgr;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup(){
|
public void setup(){
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
@ -127,6 +131,7 @@ public class UserVmManagerTest {
|
|||||||
_userVmMgr._offeringDao= _offeringDao;
|
_userVmMgr._offeringDao= _offeringDao;
|
||||||
_userVmMgr._capacityMgr = _capacityMgr;
|
_userVmMgr._capacityMgr = _capacityMgr;
|
||||||
_userVmMgr._scaleRetry = 2;
|
_userVmMgr._scaleRetry = 2;
|
||||||
|
_userVmMgr._entityMgr = _entityMgr;
|
||||||
|
|
||||||
doReturn(3L).when(_account).getId();
|
doReturn(3L).when(_account).getId();
|
||||||
doReturn(8L).when(_vmMock).getAccountId();
|
doReturn(8L).when(_vmMock).getAccountId();
|
||||||
@ -358,7 +363,7 @@ public class UserVmManagerTest {
|
|||||||
ServiceOffering so1 = getSvcoffering(512);
|
ServiceOffering so1 = getSvcoffering(512);
|
||||||
ServiceOffering so2 = getSvcoffering(256);
|
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);
|
when(_offeringDao.findByIdIncludingRemoved(anyLong())).thenReturn((ServiceOfferingVO) so1);
|
||||||
|
|
||||||
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, UUID.randomUUID().toString());
|
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, UUID.randomUUID().toString());
|
||||||
@ -395,8 +400,8 @@ public class UserVmManagerTest {
|
|||||||
ServiceOffering so1 = getSvcoffering(512);
|
ServiceOffering so1 = getSvcoffering(512);
|
||||||
ServiceOffering so2 = getSvcoffering(256);
|
ServiceOffering so2 = getSvcoffering(256);
|
||||||
|
|
||||||
when(_configMgr.getServiceOffering(anyLong())).thenReturn(so2);
|
when(_entityMgr.findById(eq(ServiceOffering.class), anyLong())).thenReturn(so2);
|
||||||
when(_configMgr.getServiceOffering(1L)).thenReturn(so1);
|
when(_entityMgr.findById(ServiceOffering.class, 1L)).thenReturn(so1);
|
||||||
|
|
||||||
doReturn(VirtualMachine.State.Stopped).when(_vmInstance).getState();
|
doReturn(VirtualMachine.State.Stopped).when(_vmInstance).getState();
|
||||||
when(_vmDao.findById(anyLong())).thenReturn(null);
|
when(_vmDao.findById(anyLong())).thenReturn(null);
|
||||||
@ -442,8 +447,8 @@ public class UserVmManagerTest {
|
|||||||
ServiceOffering so1 = getSvcoffering(512);
|
ServiceOffering so1 = getSvcoffering(512);
|
||||||
ServiceOffering so2 = getSvcoffering(256);
|
ServiceOffering so2 = getSvcoffering(256);
|
||||||
|
|
||||||
when(_configMgr.getServiceOffering(anyLong())).thenReturn(so2);
|
when(_entityMgr.findById(eq(ServiceOffering.class), anyLong())).thenReturn(so2);
|
||||||
when(_configMgr.getServiceOffering(1L)).thenReturn(so1);
|
when(_entityMgr.findById(ServiceOffering.class, 1L)).thenReturn(so1);
|
||||||
|
|
||||||
doReturn(VirtualMachine.State.Running).when(_vmInstance).getState();
|
doReturn(VirtualMachine.State.Running).when(_vmInstance).getState();
|
||||||
|
|
||||||
|
|||||||
@ -274,14 +274,6 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.cloud.configuration.ConfigurationService#getNetworkOffering(long)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public NetworkOffering getNetworkOffering(long id) {
|
|
||||||
return _ntwkOffDao.findById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.cloud.configuration.ConfigurationService#getNetworkOfferingNetworkRate(long)
|
* @see com.cloud.configuration.ConfigurationService#getNetworkOfferingNetworkRate(long)
|
||||||
*/
|
*/
|
||||||
@ -309,15 +301,6 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
|
|||||||
return null;
|
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)
|
/* (non-Javadoc)
|
||||||
* @see com.cloud.configuration.ConfigurationService#getDefaultPageSize()
|
* @see com.cloud.configuration.ConfigurationService#getDefaultPageSize()
|
||||||
*/
|
*/
|
||||||
@ -335,15 +318,6 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
|
|||||||
return null;
|
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)
|
/* (non-Javadoc)
|
||||||
* @see com.cloud.configuration.ConfigurationService#updateLDAP(org.apache.cloudstack.api.commands.LDAPConfigCmd)
|
* @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.AccountVO;
|
||||||
import com.cloud.user.UserVO;
|
import com.cloud.user.UserVO;
|
||||||
import com.cloud.utils.component.ComponentContext;
|
import com.cloud.utils.component.ComponentContext;
|
||||||
|
import com.cloud.utils.db.EntityManager;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ -87,6 +88,8 @@ public class NetworkACLManagerTest extends TestCase{
|
|||||||
@Inject
|
@Inject
|
||||||
ConfigurationManager _configMgr;
|
ConfigurationManager _configMgr;
|
||||||
@Inject
|
@Inject
|
||||||
|
EntityManager _entityMgr;
|
||||||
|
@Inject
|
||||||
NetworkModel _networkModel;
|
NetworkModel _networkModel;
|
||||||
@Inject
|
@Inject
|
||||||
List<NetworkACLServiceProvider> _networkAclElements;
|
List<NetworkACLServiceProvider> _networkAclElements;
|
||||||
@ -176,6 +179,11 @@ public class NetworkACLManagerTest extends TestCase{
|
|||||||
return Mockito.mock(VpcManager.class);
|
return Mockito.mock(VpcManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public EntityManager entityManager() {
|
||||||
|
return Mockito.mock(EntityManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ResourceTagDao resourceTagDao() {
|
public ResourceTagDao resourceTagDao() {
|
||||||
return Mockito.mock(ResourceTagDao.class);
|
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';
|
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`;
|
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