mirror of https://github.com/apache/cloudstack.git
AutoScale. Alena's final review comments. 1st Cut.
This commit is contained in:
parent
1c960c0b34
commit
fa9282add1
|
|
@ -40,7 +40,7 @@ public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd {
|
|||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.DURATION, type = CommandType.INTEGER, required = true, description = "the duration for which the conditions have to be true before action is taken")
|
||||
private Integer duration;
|
||||
private int duration;
|
||||
|
||||
@Parameter(name = ApiConstants.QUIETTIME, type = CommandType.INTEGER, description = "the cool down period for which the policy should not be evaluated after the action has been taken")
|
||||
private Integer quietTime;
|
||||
|
|
@ -64,7 +64,7 @@ public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd {
|
|||
return "autoscale_policies";
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@IdentityMapper(entityTableName="firewall_rules")
|
||||
@Parameter(name = ApiConstants.LBID, type = CommandType.LONG, required = true, description = "the ID of the load balancer rule")
|
||||
private Long lbRuleId;
|
||||
private long lbRuleId;
|
||||
|
||||
@Parameter(name=ApiConstants.MIN_MEMBERS, type=CommandType.INTEGER, required=true, description="the minimum number of members in the vmgroup, the number of instances in the vm group will be equal to or more than this number.")
|
||||
private int minMembers;
|
||||
|
|
@ -64,7 +64,7 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@IdentityMapper(entityTableName="autoscale_vmprofiles")
|
||||
@Parameter(name=ApiConstants.VMPROFILE_ID, type=CommandType.LONG, required=true, description="the autoscale profile that contains information about the vms in the vm group.")
|
||||
private Long profileId;
|
||||
private long profileId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -88,7 +88,7 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
|||
return interval;
|
||||
}
|
||||
|
||||
public Long getProfileId() {
|
||||
public long getProfileId() {
|
||||
return profileId;
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
|||
return scaleDownPolicyIds;
|
||||
}
|
||||
|
||||
public Long getLbRuleId() {
|
||||
public long getLbRuleId() {
|
||||
return lbRuleId;
|
||||
}
|
||||
|
||||
|
|
@ -161,9 +161,6 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
|||
AutoScaleVmGroup result = _autoScaleService.createAutoScaleVmGroup(this);
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
AutoScaleVmGroupResponse response = _responseGenerator.createAutoScaleVmGroupResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Autoscale Vm Group");
|
||||
}
|
||||
|
|
@ -176,15 +173,20 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
|||
try
|
||||
{
|
||||
// success = _autoScaleService.configureAutoScaleVmGroup(this);
|
||||
vmGroup = _entityMgr.findById(AutoScaleVmGroup.class, getEntityId());
|
||||
AutoScaleVmGroupResponse responseObject = _responseGenerator.createAutoScaleVmGroupResponse(vmGroup);
|
||||
setResponseObject(responseObject);
|
||||
responseObject.setResponseName(getCommandName());
|
||||
// TODO, this will be removed later, when above line is uncommented
|
||||
success = true;
|
||||
if(success) {
|
||||
vmGroup = _entityMgr.findById(AutoScaleVmGroup.class, getEntityId());
|
||||
AutoScaleVmGroupResponse responseObject = _responseGenerator.createAutoScaleVmGroupResponse(vmGroup);
|
||||
setResponseObject(responseObject);
|
||||
responseObject.setResponseName(getCommandName());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
//TODO what will happen if Resource Layer fails in a step inbetween
|
||||
s_logger.warn("Failed to create autoscale vm group", ex);
|
||||
} finally {
|
||||
if(!success || vmGroup == null) {
|
||||
_autoScaleService.deleteAutoScaleVmGroup(getEntityId());
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Autoscale Vm Group");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,13 +26,10 @@ import com.cloud.api.Parameter;
|
|||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.AutoScaleVmProfileResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.network.as.AutoScaleVmProfile;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserContext;
|
||||
|
|
@ -227,22 +224,6 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
|
||||
DataCenter zone = _configService.getZone(zoneId);
|
||||
if (zone == null) {
|
||||
throw new InvalidParameterValueException("Unable to find zone by id=" + zoneId);
|
||||
}
|
||||
|
||||
ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
|
||||
if (serviceOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||
}
|
||||
|
||||
VirtualMachineTemplate template = _templateService.getTemplate(templateId);
|
||||
// Make sure a valid template ID was specified
|
||||
if (template == null) {
|
||||
throw new InvalidParameterValueException("Unable to use template " + templateId);
|
||||
}
|
||||
|
||||
AutoScaleVmProfile result = _autoScaleService.createAutoScaleVmProfile(this);
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class UpdateAutoScalePolicyCmd extends BaseAsyncCmd {
|
|||
private Long id;
|
||||
|
||||
@Override
|
||||
public void execute() throws ServerApiException {
|
||||
public void execute() {
|
||||
UserContext.current().setEventDetails("AutoScale Policy Id: " + getId());
|
||||
AutoScalePolicy result = _autoScaleService.updateAutoScalePolicy(this);
|
||||
if (result != null) {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd {
|
|||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ServerApiException {
|
||||
public void execute() {
|
||||
UserContext.current().setEventDetails("AutoScale Vm Group Id: " + getId());
|
||||
AutoScaleVmGroup result = _autoScaleService.updateAutoScaleVmGroup(this);
|
||||
if (result != null) {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd {
|
|||
// ///////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() throws ServerApiException {
|
||||
public void execute() {
|
||||
UserContext.current().setEventDetails("AutoScale Policy Id: " + getId());
|
||||
AutoScaleVmProfile result = _autoScaleService.updateAutoScaleVmProfile(this);
|
||||
if (result != null) {
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ public interface AutoScalePolicy extends ControlledEntity {
|
|||
|
||||
long getId();
|
||||
|
||||
public Integer getDuration();
|
||||
public int getDuration();
|
||||
|
||||
public Integer getQuietTime();
|
||||
public int getQuietTime();
|
||||
|
||||
public String getAction();
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api;
|
||||
|
||||
|
|
@ -213,15 +213,15 @@ public class ApiDBUtils {
|
|||
private static HighAvailabilityManager _haMgr;
|
||||
private static TaggedResourceService _taggedResourceService;
|
||||
private static VpcManager _vpcMgr;
|
||||
private static ConditionDao _asConditionDao;
|
||||
private static AutoScalePolicyConditionMapDao _asPolicyConditionMapDao;
|
||||
private static AutoScaleVmGroupPolicyMapDao _asVmGroupPolicyMapDao;
|
||||
private static AutoScalePolicyDao _asPolicyDao;
|
||||
private static CounterDao _counterDao;
|
||||
private static ConditionDao _asConditionDao;
|
||||
private static AutoScalePolicyConditionMapDao _asPolicyConditionMapDao;
|
||||
private static AutoScaleVmGroupPolicyMapDao _asVmGroupPolicyMapDao;
|
||||
private static AutoScalePolicyDao _asPolicyDao;
|
||||
private static CounterDao _counterDao;
|
||||
|
||||
static {
|
||||
_ms = (ManagementServer) ComponentLocator.getComponent(ManagementServer.Name);
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
|
||||
_asyncMgr = locator.getManager(AsyncJobManager.class);
|
||||
_securityGroupMgr = locator.getManager(SecurityGroupManager.class);
|
||||
_storageMgr = locator.getManager(StorageManager.class);
|
||||
|
|
@ -275,16 +275,16 @@ public class ApiDBUtils {
|
|||
_haMgr = locator.getManager(HighAvailabilityManager.class);
|
||||
_taggedResourceService = locator.getManager(TaggedResourceService.class);
|
||||
_vpcMgr = locator.getManager(VpcManager.class);
|
||||
_asConditionDao = locator.getDao(ConditionDao.class);
|
||||
_asPolicyDao = locator.getDao(AutoScalePolicyDao.class);
|
||||
_asPolicyConditionMapDao = locator.getDao(AutoScalePolicyConditionMapDao.class);
|
||||
_counterDao = locator.getDao(CounterDao.class);
|
||||
_asVmGroupPolicyMapDao = locator.getDao(AutoScaleVmGroupPolicyMapDao.class);
|
||||
_asVmGroupPolicyMapDao = locator.getDao(AutoScaleVmGroupPolicyMapDao.class);
|
||||
_counterDao = locator.getDao(CounterDao.class);
|
||||
_asConditionDao = locator.getDao(ConditionDao.class);
|
||||
_asPolicyDao = locator.getDao(AutoScalePolicyDao.class);
|
||||
_asPolicyConditionMapDao = locator.getDao(AutoScalePolicyConditionMapDao.class);
|
||||
_counterDao = locator.getDao(CounterDao.class);
|
||||
_asVmGroupPolicyMapDao = locator.getDao(AutoScaleVmGroupPolicyMapDao.class);
|
||||
_asVmGroupPolicyMapDao = locator.getDao(AutoScaleVmGroupPolicyMapDao.class);
|
||||
_counterDao = locator.getDao(CounterDao.class);
|
||||
|
||||
// Note: stats collector should already have been initialized by this time, otherwise a null instance is
|
||||
// returned
|
||||
// Note: stats collector should already have been initialized by this time, otherwise a null instance is
|
||||
// returned
|
||||
_statsCollector = StatsCollector.getInstance();
|
||||
}
|
||||
|
||||
|
|
@ -311,20 +311,20 @@ public class ApiDBUtils {
|
|||
// into this utils class.
|
||||
return _ms.getMemoryOrCpuCapacityByHost(poolId, capacityType);
|
||||
}
|
||||
|
||||
|
||||
public static List<SummedCapacity> getCapacityByClusterPodZone(Long zoneId, Long podId, Long clusterId){
|
||||
return _capacityDao.findByClusterPodZone(zoneId,podId,clusterId);
|
||||
return _capacityDao.findByClusterPodZone(zoneId,podId,clusterId);
|
||||
}
|
||||
|
||||
|
||||
public static List<SummedCapacity> findNonSharedStorageForClusterPodZone(Long zoneId, Long podId, Long clusterId){
|
||||
return _capacityDao.findNonSharedStorageForClusterPodZone(zoneId,podId,clusterId);
|
||||
return _capacityDao.findNonSharedStorageForClusterPodZone(zoneId,podId,clusterId);
|
||||
}
|
||||
|
||||
|
||||
public static List<CapacityVO> getCapacityByPod(){
|
||||
return null;
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Long getPodIdForVlan(long vlanDbId) {
|
||||
return _networkMgr.getPodIdForVlan(vlanDbId);
|
||||
}
|
||||
|
|
@ -413,15 +413,15 @@ public class ApiDBUtils {
|
|||
public static StorageStats getSecondaryStorageStatistics(long id) {
|
||||
return _statsCollector.getStorageStats(id);
|
||||
}
|
||||
|
||||
|
||||
public static CapacityVO getStoragePoolUsedStats(Long poolId, Long clusterId, Long podId, Long zoneId){
|
||||
return _storageMgr.getStoragePoolUsedStats(poolId, clusterId, podId, zoneId);
|
||||
return _storageMgr.getStoragePoolUsedStats(poolId, clusterId, podId, zoneId);
|
||||
}
|
||||
|
||||
public static CapacityVO getSecondaryStorageUsedStats(Long hostId, Long zoneId){
|
||||
return _storageMgr.getSecondaryStorageUsedStats(hostId, zoneId);
|
||||
return _storageMgr.getSecondaryStorageUsedStats(hostId, zoneId);
|
||||
}
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////////////
|
||||
// Dao methods //
|
||||
// ///////////////////////////////////////////////////////////
|
||||
|
|
@ -465,7 +465,7 @@ public class ApiDBUtils {
|
|||
public static GuestOS findGuestOSByDisplayName(String displayName) {
|
||||
return _guestOSDao.listByDisplayName(displayName);
|
||||
}
|
||||
|
||||
|
||||
public static HostVO findHostById(Long hostId) {
|
||||
return _hostDao.findByIdIncludingRemoved(hostId);
|
||||
}
|
||||
|
|
@ -531,15 +531,15 @@ public class ApiDBUtils {
|
|||
}
|
||||
|
||||
public static VMTemplateVO findTemplateById(Long templateId) {
|
||||
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(templateId);
|
||||
if(template != null) {
|
||||
Map details = _templateDetailsDao.findDetails(templateId);
|
||||
if(details != null && !details.isEmpty())
|
||||
template.setDetails(details);
|
||||
}
|
||||
return template;
|
||||
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(templateId);
|
||||
if(template != null) {
|
||||
Map details = _templateDetailsDao.findDetails(templateId);
|
||||
if(details != null && !details.isEmpty())
|
||||
template.setDetails(details);
|
||||
}
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
public static VMTemplateHostVO findTemplateHostRef(long templateId, long zoneId) {
|
||||
return findTemplateHostRef(templateId, zoneId, false);
|
||||
}
|
||||
|
|
@ -553,11 +553,11 @@ public class ApiDBUtils {
|
|||
return _storageMgr.getTemplateHostRef(zoneId, templateId, readyOnly);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static VolumeHostVO findVolumeHostRef(long volumeId, long zoneId) {
|
||||
return _volumeHostDao.findVolumeByZone(volumeId, zoneId);
|
||||
}
|
||||
|
||||
|
||||
public static VMTemplateSwiftVO findTemplateSwiftRef(long templateId) {
|
||||
return _templateSwiftDao.findOneByTemplateId(templateId);
|
||||
}
|
||||
|
|
@ -585,11 +585,11 @@ public class ApiDBUtils {
|
|||
public static Site2SiteVpnGatewayVO findVpnGatewayById(Long vpnGatewayId) {
|
||||
return _site2SiteVpnGatewayDao.findById(vpnGatewayId);
|
||||
}
|
||||
|
||||
public static Site2SiteCustomerGatewayVO findCustomerGatewayById(Long customerGatewayId) {
|
||||
return _site2SiteCustomerGatewayDao.findById(customerGatewayId);
|
||||
|
||||
public static Site2SiteCustomerGatewayVO findCustomerGatewayById(Long customerGatewayId) {
|
||||
return _site2SiteCustomerGatewayDao.findById(customerGatewayId);
|
||||
}
|
||||
|
||||
|
||||
public static List<UserVO> listUsersByAccount(long accountId) {
|
||||
return _userDao.listByAccount(accountId);
|
||||
}
|
||||
|
|
@ -610,9 +610,9 @@ public class ApiDBUtils {
|
|||
public static HypervisorType getVolumeHyperType(long volumeId) {
|
||||
return _volumeDao.getHypervisorType(volumeId);
|
||||
}
|
||||
|
||||
|
||||
public static HypervisorType getHypervisorTypeFromFormat(ImageFormat format){
|
||||
return _storageMgr.getHypervisorTypeFromFormat(format);
|
||||
return _storageMgr.getHypervisorTypeFromFormat(format);
|
||||
}
|
||||
|
||||
public static List<VMTemplateHostVO> listTemplateHostBy(long templateId, Long zoneId, boolean readyOnly) {
|
||||
|
|
@ -713,13 +713,13 @@ public class ApiDBUtils {
|
|||
float cpuOverprovisioningFactor = NumbersUtil.parseFloat(opFactor, 1);
|
||||
return cpuOverprovisioningFactor;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isExtractionDisabled(){
|
||||
String disableExtractionString = _configDao.getValue(Config.DisableExtraction.toString());
|
||||
String disableExtractionString = _configDao.getValue(Config.DisableExtraction.toString());
|
||||
boolean disableExtraction = (disableExtractionString == null) ? false : Boolean.parseBoolean(disableExtractionString);
|
||||
return disableExtraction;
|
||||
}
|
||||
|
||||
|
||||
public static SecurityGroup getSecurityGroup(String groupName, long ownerId) {
|
||||
return _securityGroupMgr.getSecurityGroup(groupName, ownerId);
|
||||
}
|
||||
|
|
@ -727,77 +727,77 @@ public class ApiDBUtils {
|
|||
public static ConsoleProxyVO findConsoleProxy(long id) {
|
||||
return _consoleProxyDao.findById(id);
|
||||
}
|
||||
|
||||
|
||||
public static List<String> findFirewallSourceCidrs(long id){
|
||||
return _firewallCidrsDao.getSourceCidrs(id);
|
||||
return _firewallCidrsDao.getSourceCidrs(id);
|
||||
}
|
||||
|
||||
|
||||
public static Hashtable<Long, UserVmData> listVmDetails(Hashtable<Long, UserVmData> vmData){
|
||||
return _userVmDao.listVmDetails(vmData);
|
||||
}
|
||||
|
||||
|
||||
public static Account getProjectOwner(long projectId) {
|
||||
return _projectMgr.getProjectOwner(projectId);
|
||||
}
|
||||
|
||||
|
||||
public static Project findProjectByProjectAccountId(long projectAccountId) {
|
||||
return _projectMgr.findByProjectAccountId(projectAccountId);
|
||||
}
|
||||
|
||||
|
||||
public static Project findProjectById(long projectId) {
|
||||
return _projectMgr.getProject(projectId);
|
||||
}
|
||||
|
||||
|
||||
public static long getProjectOwnwerId(long projectId) {
|
||||
return _projectMgr.getProjectOwner(projectId).getId();
|
||||
}
|
||||
|
||||
|
||||
public static Map<String, String> getAccountDetails(long accountId) {
|
||||
Map<String, String> details = _accountDetailsDao.findDetails(accountId);
|
||||
return details.isEmpty() ? null : details;
|
||||
Map<String, String> details = _accountDetailsDao.findDetails(accountId);
|
||||
return details.isEmpty() ? null : details;
|
||||
}
|
||||
|
||||
public static Map<Service, Set<Provider>> listNetworkOfferingServices(long networkOfferingId) {
|
||||
return _networkMgr.getNetworkOfferingServiceProvidersMap(networkOfferingId);
|
||||
}
|
||||
|
||||
|
||||
public static List<Service> getElementServices(Provider provider) {
|
||||
return _networkMgr.getElementServices(provider);
|
||||
return _networkMgr.getElementServices(provider);
|
||||
}
|
||||
|
||||
|
||||
public static List<? extends Provider> getProvidersForService(Service service) {
|
||||
return _networkMgr.listSupportedNetworkServiceProviders(service.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canElementEnableIndividualServices(Provider serviceProvider) {
|
||||
return _networkMgr.canElementEnableIndividualServices(serviceProvider);
|
||||
}
|
||||
|
||||
|
||||
public static Pair<Long, Boolean> getDomainNetworkDetails(long networkId) {
|
||||
NetworkDomainVO map = _networkDomainDao.getDomainNetworkMapByNetworkId(networkId);
|
||||
|
||||
boolean subdomainAccess = (map.isSubdomainAccess() != null) ? map.isSubdomainAccess() : _networkMgr.getAllowSubdomainAccessGlobal();
|
||||
|
||||
return new Pair<Long, Boolean>(map.getDomainId(), subdomainAccess);
|
||||
NetworkDomainVO map = _networkDomainDao.getDomainNetworkMapByNetworkId(networkId);
|
||||
|
||||
boolean subdomainAccess = (map.isSubdomainAccess() != null) ? map.isSubdomainAccess() : _networkMgr.getAllowSubdomainAccessGlobal();
|
||||
|
||||
return new Pair<Long, Boolean>(map.getDomainId(), subdomainAccess);
|
||||
}
|
||||
|
||||
|
||||
public static long countFreePublicIps() {
|
||||
return _ipAddressDao.countFreePublicIPs();
|
||||
return _ipAddressDao.countFreePublicIPs();
|
||||
}
|
||||
|
||||
|
||||
public static long findDefaultRouterServiceOffering() {
|
||||
ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
|
||||
return serviceOffering.getId();
|
||||
}
|
||||
|
||||
|
||||
public static IpAddress findIpByAssociatedVmId(long vmId) {
|
||||
return _ipAddressDao.findByAssociatedVmId(vmId);
|
||||
}
|
||||
|
||||
|
||||
public static String getHaTag() {
|
||||
return _haMgr.getHaTag();
|
||||
}
|
||||
|
||||
|
||||
public static String getUuid(String resourceId, TaggedResourceType resourceType) {
|
||||
return _taggedResourceService.getUuid(resourceId, resourceType);
|
||||
}
|
||||
|
|
@ -805,48 +805,60 @@ public class ApiDBUtils {
|
|||
public static Map<Service, Set<Provider>> listVpcOffServices(long vpcOffId) {
|
||||
return _vpcMgr.getVpcOffSvcProvidersMap(vpcOffId);
|
||||
}
|
||||
|
||||
|
||||
public static List<? extends Network> listVpcNetworks(long vpcId) {
|
||||
return _networkMgr.listNetworksByVpc(vpcId);
|
||||
}
|
||||
|
||||
|
||||
public static boolean canUseForDeploy(Network network) {
|
||||
return _networkMgr.canUseForDeploy(network);
|
||||
}
|
||||
|
||||
public static List<ConditionVO> getAutoScalePolicyConditions(long policyId)
|
||||
{
|
||||
List<AutoScalePolicyConditionMapVO> vos = _asPolicyConditionMapDao.listByAll(policyId, null);
|
||||
ArrayList<ConditionVO> conditions = new ArrayList<ConditionVO>(vos.size());
|
||||
for (AutoScalePolicyConditionMapVO vo : vos) {
|
||||
conditions.add(_asConditionDao.findById(vo.getConditionId()));
|
||||
}
|
||||
|
||||
return conditions;
|
||||
}
|
||||
public static List<ConditionVO> getAutoScalePolicyConditions(long policyId)
|
||||
{
|
||||
List<AutoScalePolicyConditionMapVO> vos = _asPolicyConditionMapDao.listByAll(policyId, null);
|
||||
ArrayList<ConditionVO> conditions = new ArrayList<ConditionVO>(vos.size());
|
||||
for (AutoScalePolicyConditionMapVO vo : vos) {
|
||||
conditions.add(_asConditionDao.findById(vo.getConditionId()));
|
||||
}
|
||||
|
||||
return conditions;
|
||||
}
|
||||
|
||||
public static List<? extends ResourceTag> listByResourceTypeAndId(TaggedResourceType type, long resourceId) {
|
||||
return _taggedResourceService.listByResourceTypeAndId(type, resourceId);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isOfferingForVpc(NetworkOffering offering) {
|
||||
boolean vpcProvider = _configMgr.isOfferingForVpc(offering);
|
||||
return vpcProvider;
|
||||
}
|
||||
|
||||
public static void getAutoScaleVmGroupPolicies(long vmGroupId, List<AutoScalePolicy> scaleUpPolicies, List<AutoScalePolicy> scaleDownPolicies)
|
||||
{
|
||||
List<AutoScaleVmGroupPolicyMapVO> vos = _asVmGroupPolicyMapDao.listByVmGroupId(vmGroupId);
|
||||
for (AutoScaleVmGroupPolicyMapVO vo : vos) {
|
||||
AutoScalePolicy autoScalePolicy = _asPolicyDao.findById(vo.getPolicyId());
|
||||
if(autoScalePolicy.getAction().equals("scaleup"))
|
||||
scaleUpPolicies.add(autoScalePolicy);
|
||||
else
|
||||
scaleDownPolicies.add(autoScalePolicy);
|
||||
}
|
||||
}
|
||||
public static void getAutoScaleVmGroupPolicyIds(long vmGroupId, List<Long> scaleUpPolicyIds, List<Long> scaleDownPolicyIds)
|
||||
{
|
||||
List<AutoScaleVmGroupPolicyMapVO> vos = _asVmGroupPolicyMapDao.listByVmGroupId(vmGroupId);
|
||||
for (AutoScaleVmGroupPolicyMapVO vo : vos) {
|
||||
AutoScalePolicy autoScalePolicy = _asPolicyDao.findById(vo.getPolicyId());
|
||||
if(autoScalePolicy.getAction().equals("scaleup"))
|
||||
scaleUpPolicyIds.add(autoScalePolicy.getId());
|
||||
else
|
||||
scaleDownPolicyIds.add(autoScalePolicy.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public static CounterVO getCounter(long counterId) {
|
||||
return _counterDao.findById(counterId);
|
||||
}
|
||||
public static void getAutoScaleVmGroupPolicies(long vmGroupId, List<AutoScalePolicy> scaleUpPolicies, List<AutoScalePolicy> scaleDownPolicies)
|
||||
{
|
||||
List<AutoScaleVmGroupPolicyMapVO> vos = _asVmGroupPolicyMapDao.listByVmGroupId(vmGroupId);
|
||||
for (AutoScaleVmGroupPolicyMapVO vo : vos) {
|
||||
AutoScalePolicy autoScalePolicy = _asPolicyDao.findById(vo.getPolicyId());
|
||||
if(autoScalePolicy.getAction().equals("scaleup"))
|
||||
scaleUpPolicies.add(autoScalePolicy);
|
||||
else
|
||||
scaleDownPolicies.add(autoScalePolicy);
|
||||
}
|
||||
}
|
||||
|
||||
public static CounterVO getCounter(long counterId) {
|
||||
return _counterDao.findById(counterId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.ApiDispatcher;
|
||||
import com.cloud.api.BaseListAccountResourcesCmd;
|
||||
import com.cloud.api.commands.CreateAutoScalePolicyCmd;
|
||||
|
|
@ -42,6 +43,8 @@ import com.cloud.api.commands.ListCountersCmd;
|
|||
import com.cloud.api.commands.UpdateAutoScalePolicyCmd;
|
||||
import com.cloud.api.commands.UpdateAutoScaleVmGroupCmd;
|
||||
import com.cloud.api.commands.UpdateAutoScaleVmProfileCmd;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
|
|
@ -61,7 +64,10 @@ import com.cloud.network.dao.LoadBalancerDao;
|
|||
import com.cloud.network.dao.LoadBalancerVMMapDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
import com.cloud.template.TemplateManager;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.User;
|
||||
|
|
@ -81,7 +87,7 @@ import com.cloud.utils.db.SearchCriteria.Op;
|
|||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@Local(value = { AutoScaleService.class })
|
||||
@Local(value = { AutoScaleService.class })
|
||||
public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(AutoScaleManagerImpl.class);
|
||||
|
||||
|
|
@ -91,6 +97,10 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
TemplateManager _templateMgr;
|
||||
@Inject
|
||||
LoadBalancingRulesManager _lbRulesMgr;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
|
|
@ -158,7 +168,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
for (Counter counter : counters) {
|
||||
if (!supportedCounters.contains(counter.getSource())) {
|
||||
throw new InvalidParameterException("AutoScale counter with source='" + counter.getSource() + "' is not supported " +
|
||||
"in the network where lb is configured");
|
||||
"in the network where lb is configured");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -182,7 +192,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
return policyVO.getAction().equals("scaleup");
|
||||
}
|
||||
|
||||
private List<AutoScalePolicyVO> getAutoScalePolicies(String paramName, List<Long> policyIds, List<Counter> counters, Integer interval, boolean scaleUpPolicies)
|
||||
private List<AutoScalePolicyVO> getAutoScalePolicies(String paramName, List<Long> policyIds, List<Counter> counters, int interval, boolean scaleUpPolicies)
|
||||
{
|
||||
SearchBuilder<AutoScalePolicyVO> policySearch = _autoScalePolicyDao.createSearchBuilder();
|
||||
policySearch.and("ids", policySearch.entity().getId(), Op.IN);
|
||||
|
|
@ -199,13 +209,13 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
if (prevQuietTime == 0) {
|
||||
prevQuietTime = quietTime;
|
||||
}
|
||||
Integer duration = policy.getDuration();
|
||||
if (interval != null && duration < interval) {
|
||||
throw new InvalidParameterValueException("duration - " + duration + " specified in a policy cannot be less than vm group's interval - " + interval);
|
||||
int duration = policy.getDuration();
|
||||
if (duration < interval) {
|
||||
throw new InvalidParameterValueException("duration : " + duration + " specified in a policy cannot be less than vm group's interval : " + interval);
|
||||
}
|
||||
|
||||
if (interval != null && quietTime < interval) {
|
||||
throw new InvalidParameterValueException("quietTime - " + quietTime + " specified in a policy cannot be less than vm group's interval - " + interval);
|
||||
if (quietTime < interval) {
|
||||
throw new InvalidParameterValueException("quietTime : " + quietTime + " specified in a policy cannot be less than vm group's interval : " + interval);
|
||||
}
|
||||
|
||||
if (quietTime != prevQuietTime) {
|
||||
|
|
@ -242,6 +252,27 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
Account caller = UserContext.current().getCaller();
|
||||
_accountMgr.checkAccess(caller, null, true, owner);
|
||||
|
||||
long zoneId = cmd.getZoneId();
|
||||
long serviceOfferingId = cmd.getServiceOfferingId();
|
||||
long templateId = cmd.getServiceOfferingId();
|
||||
|
||||
DataCenter zone = _configMgr.getZone(zoneId);
|
||||
|
||||
if (zone == null) {
|
||||
throw new InvalidParameterValueException("Unable to find zone by id=" + zoneId);
|
||||
}
|
||||
|
||||
ServiceOffering serviceOffering = _configMgr.getServiceOffering(serviceOfferingId);
|
||||
if (serviceOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||
}
|
||||
|
||||
VirtualMachineTemplate template = _templateMgr.getTemplate(templateId);
|
||||
// Make sure a valid template ID was specified
|
||||
if (template == null) {
|
||||
throw new InvalidParameterValueException("Unable to use template " + templateId);
|
||||
}
|
||||
|
||||
// validations
|
||||
HashMap<String, String> deployParams = cmd.getDeployParamMap();
|
||||
/*
|
||||
|
|
@ -316,7 +347,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
AutoScaleVmProfileVO vmProfile = getEntityInDatabase("Auto Scale Vm Profile", profileId, _autoScaleVmProfileDao);
|
||||
AutoScaleVmProfileVO bakUpProfile = getEntityInDatabase("Auto Scale Vm Profile", profileId, _autoScaleVmProfileDao);
|
||||
|
||||
if (templateId == null && otherDeployParams == null) {
|
||||
if(templateId == null && otherDeployParams == null) {
|
||||
throw new InvalidParameterValueException("Atleast one parameter should be passed for update");
|
||||
}
|
||||
|
||||
|
|
@ -346,7 +377,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
}
|
||||
}
|
||||
|
||||
private void isAutoScalePolicyValid(AutoScalePolicyVO autoScalePolicyVO, List<Long> conditionIds) {
|
||||
private AutoScalePolicyVO checkValidityAndPersist(AutoScalePolicyVO autoScalePolicyVO, List<Long> conditionIds) {
|
||||
Integer duration = autoScalePolicyVO.getDuration();
|
||||
Integer quietTime = autoScalePolicyVO.getQuietTime();
|
||||
|
||||
|
|
@ -358,10 +389,16 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
throw new InvalidParameterValueException("quiettime is an invalid value: " + quietTime);
|
||||
}
|
||||
|
||||
SearchBuilder<ConditionVO> policySearch = _conditionDao.createSearchBuilder();
|
||||
policySearch.and("ids", policySearch.entity().getId(), Op.IN);
|
||||
policySearch.done();
|
||||
SearchCriteria<ConditionVO> sc = policySearch.create();
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
autoScalePolicyVO = _autoScalePolicyDao.persist(autoScalePolicyVO);
|
||||
|
||||
if(conditionIds != null) {
|
||||
SearchBuilder<ConditionVO> conditionsSearch = _conditionDao.createSearchBuilder();
|
||||
conditionsSearch.and("ids", conditionsSearch.entity().getId(), Op.IN);
|
||||
conditionsSearch.done();
|
||||
SearchCriteria<ConditionVO> sc = conditionsSearch.create();
|
||||
|
||||
sc.setParameters("ids", conditionIds.toArray(new Object[0]));
|
||||
List<ConditionVO> conditions = _conditionDao.search(sc, null);
|
||||
|
|
@ -383,17 +420,14 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
counterIds.add(condition.getCounterid());
|
||||
}
|
||||
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
autoScalePolicyVO = _autoScalePolicyDao.persist(autoScalePolicyVO);
|
||||
|
||||
for (Long conditionId : conditionIds) {
|
||||
AutoScalePolicyConditionMapVO policyConditionMapVO = new AutoScalePolicyConditionMapVO(autoScalePolicyVO.getId(), conditionId);
|
||||
_autoScalePolicyConditionMapDao.persist(policyConditionMapVO);
|
||||
}
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
return autoScalePolicyVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -416,7 +450,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
|
||||
AutoScalePolicyVO policyVO = new AutoScalePolicyVO(cmd.getDomainId(), cmd.getAccountId(), duration, quietTime, action);
|
||||
|
||||
isAutoScalePolicyValid(policyVO, cmd.getConditionIds());
|
||||
policyVO = checkValidityAndPersist(policyVO, cmd.getConditionIds());
|
||||
|
||||
return policyVO;
|
||||
}
|
||||
|
|
@ -437,12 +471,16 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
|
||||
boolean success = true;
|
||||
success = _autoScalePolicyDao.remove(id);
|
||||
if (success) {
|
||||
if (!success) {
|
||||
s_logger.warn("Failed to remove AutoScale Policy db object");
|
||||
return false;
|
||||
}
|
||||
success = _autoScalePolicyConditionMapDao.removeByAutoScalePolicyId(id);
|
||||
if (!success) {
|
||||
s_logger.warn("Failed to remove AutoScale Policy Condition mappings");
|
||||
return false;
|
||||
}
|
||||
if (success) {
|
||||
txn.commit();
|
||||
}
|
||||
return success; // successful
|
||||
}
|
||||
|
||||
|
|
@ -479,7 +517,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean,
|
||||
ListProjectResourcesCriteria>(domainId, isRecursive, null);
|
||||
ListProjectResourcesCriteria>(domainId, isRecursive, null);
|
||||
_accountMgr.buildACLSearchParameters(caller, id, accountName, null, permittedAccounts, domainIdRecursiveListProject,
|
||||
listAll, false);
|
||||
domainId = domainIdRecursiveListProject.first();
|
||||
|
|
@ -541,9 +579,8 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
Integer quietTime = cmd.getQuietTime();
|
||||
List<Long> conditionIds = cmd.getConditionIds();
|
||||
AutoScalePolicyVO policy = getEntityInDatabase("Auto Scale Policy", policyId, _autoScalePolicyDao);
|
||||
AutoScalePolicyVO bakUpPolicy = getEntityInDatabase("Auto Scale Policy", policyId, _autoScalePolicyDao);
|
||||
|
||||
if (duration == null && quietTime == null && conditionIds == null) {
|
||||
if(duration == null && quietTime == null && conditionIds == null) {
|
||||
throw new InvalidParameterValueException("Atleast one parameter should be passed for update");
|
||||
}
|
||||
|
||||
|
|
@ -561,25 +598,19 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
if (!vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
|
||||
throw new InvalidParameterValueException("The AutoScale Policy can be updated only if the Vm Group it is associated with is disabled in state");
|
||||
}
|
||||
if (vmGroupVO.getInterval() < duration) {
|
||||
if(vmGroupVO.getInterval() < duration) {
|
||||
throw new InvalidParameterValueException("duration is less than the associated AutoScaleVmGroup's interval");
|
||||
}
|
||||
if (vmGroupVO.getInterval() < quietTime) {
|
||||
if(vmGroupVO.getInterval() < quietTime) {
|
||||
throw new InvalidParameterValueException("quietTime is less than the associated AutoScaleVmGroup's interval");
|
||||
}
|
||||
}
|
||||
|
||||
isAutoScalePolicyValid(policy, conditionIds);
|
||||
policy = checkValidityAndPersist(policy, conditionIds);
|
||||
|
||||
boolean success = _autoScalePolicyDao.update(policyId, policy);
|
||||
s_logger.debug("Updated Auto Scale Policy id:" + policyId);
|
||||
|
||||
if (success) {
|
||||
s_logger.debug("Updated Auto Scale Policy id:" + policyId);
|
||||
return policy;
|
||||
} else {
|
||||
_autoScalePolicyDao.update(bakUpPolicy.getId(), bakUpPolicy);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -590,8 +621,9 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
int maxMembers = cmd.getMaxMembers();
|
||||
Integer interval = cmd.getInterval();
|
||||
|
||||
if (interval == null)
|
||||
if(interval == null) {
|
||||
interval = NetUtils.DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME;
|
||||
}
|
||||
|
||||
LoadBalancerVO loadBalancer = getEntityInDatabase(ApiConstants.LBID, cmd.getLbRuleId(), _lbDao);
|
||||
|
||||
|
|
@ -601,7 +633,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
|
||||
Long zoneId = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId()).getDataCenterId();
|
||||
|
||||
if (_autoScaleVmGroupDao.isAutoScaleLoadBalancer(loadBalancer.getId())) {
|
||||
if(_autoScaleVmGroupDao.isAutoScaleLoadBalancer(loadBalancer.getId())) {
|
||||
throw new InvalidParameterValueException("an AutoScaleVmGroup is already attached to the lb rule, the existing vm group has to be first deleted");
|
||||
}
|
||||
|
||||
|
|
@ -612,25 +644,26 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
AutoScaleVmGroupVO vmGroupVO = new AutoScaleVmGroupVO(cmd.getLbRuleId(), zoneId, loadBalancer.getDomainId(), loadBalancer.getAccountId(), minMembers, maxMembers,
|
||||
loadBalancer.getDefaultPortStart(), interval, cmd.getProfileId(), AutoScaleVmGroup.State_New);
|
||||
|
||||
isAutoScaleVmGroupValid(vmGroupVO, cmd.getScaleUpPolicyIds(), cmd.getScaleDownPolicyIds());
|
||||
checkValidityAndPersist(vmGroupVO, cmd.getScaleUpPolicyIds(), cmd.getScaleDownPolicyIds());
|
||||
|
||||
return vmGroupVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configureAutoScaleVmGroup(CreateAutoScaleVmGroupCmd cmd) {
|
||||
return configureAutoScaleVmGroup(cmd.getEntityId(), true);
|
||||
return configureAutoScaleVmGroup(cmd.getEntityId());
|
||||
}
|
||||
|
||||
public boolean isLoadBalancerBasedAutoScaleVmGroup(AutoScaleVmGroup vmGroup) {
|
||||
return vmGroup.getLoadBalancerId() != null;
|
||||
}
|
||||
|
||||
public boolean configureAutoScaleVmGroup(long vmGroupid, boolean vmGroupCreation) {
|
||||
public boolean configureAutoScaleVmGroup(long vmGroupid) {
|
||||
AutoScaleVmGroup vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
|
||||
|
||||
if (isLoadBalancerBasedAutoScaleVmGroup(vmGroup))
|
||||
return _lbRulesMgr.configureLbAutoScaleVmGroup(vmGroupid, true);
|
||||
if(isLoadBalancerBasedAutoScaleVmGroup(vmGroup)) {
|
||||
return _lbRulesMgr.configureLbAutoScaleVmGroup(vmGroupid);
|
||||
}
|
||||
|
||||
// This should never happen, because today loadbalancerruleid is manadatory for AutoScaleVmGroup.
|
||||
throw new InvalidParameterValueException("Only LoadBalancer based AutoScale is supported");
|
||||
|
|
@ -641,23 +674,44 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_DELETE, eventDescription = "deleting autoscale vm group")
|
||||
public boolean deleteAutoScaleVmGroup(long id) {
|
||||
AutoScaleVmGroupVO autoScaleVmGroupVO = getEntityInDatabase("AutoScale Vm Group", id, _autoScaleVmGroupDao);
|
||||
|
||||
if(autoScaleVmGroupVO.getState().equals(AutoScaleVmGroup.State_New)) {
|
||||
/* This condition is for handling failures during creation command */
|
||||
return _autoScaleVmGroupDao.remove(id);
|
||||
}
|
||||
String bakupState = autoScaleVmGroupVO.getState();
|
||||
autoScaleVmGroupVO.setState(AutoScaleVmGroup.State_Revoke);
|
||||
_autoScaleVmGroupDao.persist(autoScaleVmGroupVO);
|
||||
boolean success = false;
|
||||
|
||||
// success = configureAutoScaleVmGroup(id, false);
|
||||
try {
|
||||
success = configureAutoScaleVmGroup(id);
|
||||
} finally {
|
||||
if(!success) {
|
||||
s_logger.warn("Could not delete AutoScale Vm Group id : " + id);
|
||||
autoScaleVmGroupVO.setState(bakupState);
|
||||
_autoScaleVmGroupDao.persist(autoScaleVmGroupVO);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
success = _autoScaleVmGroupDao.remove(id);
|
||||
|
||||
if (success)
|
||||
if (!success) {
|
||||
s_logger.warn("Failed to remove AutoScale Group db object");
|
||||
return false;
|
||||
}
|
||||
|
||||
success = _autoScaleVmGroupPolicyMapDao.removeByGroupId(id);
|
||||
if (!success) {
|
||||
s_logger.warn("Failed to remove AutoScale Group Policy mappings");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (success)
|
||||
txn.commit();
|
||||
|
||||
return success;
|
||||
return success; // Successfull
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -701,10 +755,10 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
return searchWrapper.search();
|
||||
}
|
||||
|
||||
private void isAutoScaleVmGroupValid(AutoScaleVmGroupVO vmGroup, List<Long> scaleUpPolicyIds, List<Long> scaleDownPolicyIds) {
|
||||
Integer minMembers = vmGroup.getMinMembers();
|
||||
Integer maxMembers = vmGroup.getMaxMembers();
|
||||
Integer interval = vmGroup.getInterval();
|
||||
private AutoScaleVmGroupVO checkValidityAndPersist(AutoScaleVmGroupVO vmGroup, List<Long> scaleUpPolicyIds, List<Long> scaleDownPolicyIds) {
|
||||
int minMembers = vmGroup.getMinMembers();
|
||||
int maxMembers = vmGroup.getMaxMembers();
|
||||
int interval = vmGroup.getInterval();
|
||||
List<Counter> counters = new ArrayList<Counter>();
|
||||
List<AutoScalePolicyVO> policies = new ArrayList<AutoScalePolicyVO>();
|
||||
|
||||
|
|
@ -724,11 +778,11 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
throw new InvalidParameterValueException("interval is an invalid value: " + interval);
|
||||
}
|
||||
|
||||
if (scaleUpPolicyIds != null) {
|
||||
if(scaleUpPolicyIds != null) {
|
||||
policies.addAll(getAutoScalePolicies("scaleuppolicyid", scaleUpPolicyIds, counters, interval, true));
|
||||
}
|
||||
|
||||
if (scaleDownPolicyIds != null) {
|
||||
if(scaleDownPolicyIds != null) {
|
||||
policies.addAll(getAutoScalePolicies("scaledownpolicyid", scaleDownPolicyIds, counters, interval, false));
|
||||
}
|
||||
|
||||
|
|
@ -751,6 +805,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
}
|
||||
txn.commit();
|
||||
|
||||
return vmGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -765,7 +820,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
List<Long> scaleUpPolicyIds = cmd.getScaleUpPolicyIds();
|
||||
List<Long> scaleDownPolicyIds = cmd.getScaleDownPolicyIds();
|
||||
|
||||
if (minMembers == null && maxMembers == null && interval == null && scaleUpPolicyIds == null && scaleDownPolicyIds == null) {
|
||||
if(minMembers == null && maxMembers == null && interval == null && scaleUpPolicyIds == null && scaleDownPolicyIds == null) {
|
||||
throw new InvalidParameterValueException("Atleast one parameter should be passed for update");
|
||||
}
|
||||
|
||||
|
|
@ -788,20 +843,39 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
vmGroupVO.setInterval(interval);
|
||||
}
|
||||
|
||||
boolean success = _autoScaleVmGroupPolicyMapDao.removeByGroupId(vmGroupVO.getId());
|
||||
List<AutoScaleVmGroupPolicyMapVO> bakupPolicyIds = _autoScaleVmGroupPolicyMapDao.listByVmGroupId(vmGroupId);
|
||||
boolean success = true;
|
||||
List<Long> bakupPolicyIds = new ArrayList<Long>();
|
||||
if(scaleUpPolicyIds != null || scaleDownPolicyIds != null) {
|
||||
List<Long> bakupScaleUpPolicyIds = new ArrayList<Long>();
|
||||
List<Long> bakupScaleDownPolicyIds = new ArrayList<Long>();
|
||||
ApiDBUtils.getAutoScaleVmGroupPolicyIds(vmGroupId, bakupScaleUpPolicyIds, bakupScaleDownPolicyIds);
|
||||
if(scaleUpPolicyIds != null) {
|
||||
bakupPolicyIds.addAll(bakupScaleUpPolicyIds);
|
||||
}
|
||||
if(scaleDownPolicyIds != null) {
|
||||
bakupPolicyIds.addAll(bakupScaleDownPolicyIds);
|
||||
}
|
||||
success = _autoScaleVmGroupPolicyMapDao.removeByGroupAndPolicies(vmGroupId, bakupPolicyIds);
|
||||
if(!success) {
|
||||
s_logger.warn("Removal of existing policy mappings for vmgroup failed");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
isAutoScaleVmGroupValid(vmGroupVO, scaleUpPolicyIds, scaleDownPolicyIds);
|
||||
success = configureAutoScaleVmGroup(vmGroupVO.getId(), false);
|
||||
vmGroupVO = checkValidityAndPersist(vmGroupVO, scaleUpPolicyIds, scaleDownPolicyIds);
|
||||
try {
|
||||
success = configureAutoScaleVmGroup(vmGroupVO.getId());
|
||||
}
|
||||
finally {
|
||||
if (!success) {
|
||||
Transaction.currentTxn().start();
|
||||
for (AutoScaleVmGroupPolicyMapVO backUpPolicies : bakupPolicyIds) {
|
||||
_autoScaleVmGroupPolicyMapDao.persist(new AutoScaleVmGroupPolicyMapVO(backUpPolicies.getVmGroupId(), backUpPolicies.getPolicyId()));
|
||||
for (Long backUpPolicyId : bakupPolicyIds) {
|
||||
_autoScaleVmGroupPolicyMapDao.persist(new AutoScaleVmGroupPolicyMapVO(vmGroupId, backUpPolicyId));
|
||||
}
|
||||
_autoScaleVmGroupDao.update(bakUpVmGroupVO.getId(), bakUpVmGroupVO);
|
||||
Transaction.currentTxn().commit();
|
||||
}
|
||||
|
||||
}
|
||||
if (success) {
|
||||
s_logger.debug("Updated Auto Scale VmGroup id:" + vmGroupId);
|
||||
return vmGroupVO;
|
||||
|
|
@ -819,21 +893,21 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
throw new InvalidParameterValueException("Only a AutoScale Vm Group which is in Disabled state can be enabled.");
|
||||
}
|
||||
|
||||
try {
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Enabled);
|
||||
vmGroup = _autoScaleVmGroupDao.persist(vmGroup);
|
||||
success = _lbRulesMgr.configureLbAutoScaleVmGroup(id);
|
||||
|
||||
success = _lbRulesMgr.configureLbAutoScaleVmGroup(id, false);
|
||||
|
||||
if (success) {
|
||||
return vmGroup;
|
||||
}
|
||||
else {
|
||||
} finally {
|
||||
if (!success) {
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Disabled);
|
||||
_autoScaleVmGroupDao.persist(vmGroup);
|
||||
s_logger.warn("Failed to enable AutoScale Vm Group id - " + id);
|
||||
s_logger.warn("Failed to enable AutoScale Vm Group id : " + id);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return vmGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_DISABLE, eventDescription = "disabling autoscale vm group")
|
||||
|
|
@ -845,21 +919,21 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
throw new InvalidParameterValueException("Only a AutoScale Vm Group which is in Disabled state can be disabled.");
|
||||
}
|
||||
|
||||
try {
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Disabled);
|
||||
vmGroup = _autoScaleVmGroupDao.persist(vmGroup);
|
||||
|
||||
success = _lbRulesMgr.configureLbAutoScaleVmGroup(id, false);
|
||||
|
||||
if (success) {
|
||||
return vmGroup;
|
||||
}
|
||||
else {
|
||||
success = _lbRulesMgr.configureLbAutoScaleVmGroup(id);
|
||||
} finally {
|
||||
if (!success) {
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Enabled);
|
||||
_autoScaleVmGroupDao.persist(vmGroup);
|
||||
s_logger.warn("Failed to disable AutoScale Vm Group id - " + id);
|
||||
s_logger.warn("Failed to disable AutoScale Vm Group id : " + id);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return vmGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_COUNTER_CREATE, eventDescription = "Counter", create = true)
|
||||
|
|
@ -920,7 +994,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
String name = cmd.getName();
|
||||
Long id = cmd.getId();
|
||||
String source = cmd.getSource();
|
||||
if (source != null)
|
||||
if(source != null )
|
||||
source = source.toLowerCase();
|
||||
|
||||
Filter searchFilter = new Filter(CounterVO.class, "created", false, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import javax.persistence.InheritanceType;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@Entity
|
||||
@Table(name = "autoscale_policies")
|
||||
|
|
@ -47,10 +46,10 @@ public class AutoScalePolicyVO implements AutoScalePolicy {
|
|||
private long accountId;
|
||||
|
||||
@Column(name = "duration")
|
||||
private Integer duration;
|
||||
private int duration;
|
||||
|
||||
@Column(name = "quiet_time", updatable = true, nullable = false)
|
||||
private Integer quietTime = NetUtils.DEFAULT_AUTOSCALE_POLICY_QUIET_TIME;
|
||||
private int quietTime;
|
||||
|
||||
@Column(name = "action", updatable = false, nullable = false)
|
||||
private String action;
|
||||
|
|
@ -64,14 +63,12 @@ public class AutoScalePolicyVO implements AutoScalePolicy {
|
|||
public AutoScalePolicyVO() {
|
||||
}
|
||||
|
||||
public AutoScalePolicyVO(long domainId, long accountId, Integer duration, Integer quietTime, String action) {
|
||||
public AutoScalePolicyVO(long domainId, long accountId, int duration, int quietTime, String action) {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
this.duration = duration;
|
||||
if (quietTime != null) {
|
||||
this.quietTime = quietTime;
|
||||
}
|
||||
this.quietTime = quietTime;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
|
|
@ -100,12 +97,12 @@ public class AutoScalePolicyVO implements AutoScalePolicy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer getDuration() {
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getQuietTime() {
|
||||
public int getQuietTime() {
|
||||
return quietTime;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import javax.persistence.InheritanceType;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@Entity
|
||||
@Table(name = "autoscale_vmgroups")
|
||||
|
|
@ -62,7 +61,7 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup {
|
|||
private int memberPort;
|
||||
|
||||
@Column(name = "interval")
|
||||
private Integer interval = NetUtils.DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME;
|
||||
private int interval;
|
||||
|
||||
@Column(name = "profile_id")
|
||||
private long profileId;
|
||||
|
|
@ -79,7 +78,7 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup {
|
|||
public AutoScaleVmGroupVO() {
|
||||
}
|
||||
|
||||
public AutoScaleVmGroupVO(long lbRuleId, long zoneId, long domainId, long accountId, Integer minMembers, Integer maxMembers, Integer memberPort, Integer interval, long profileId, String state) {
|
||||
public AutoScaleVmGroupVO(long lbRuleId, long zoneId, long domainId, long accountId, int minMembers, int maxMembers, int memberPort, int interval, long profileId, String state) {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.loadBalancerId = lbRuleId;
|
||||
this.minMembers = minMembers;
|
||||
|
|
@ -90,9 +89,7 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup {
|
|||
this.domainId = domainId;
|
||||
this.zoneId = zoneId;
|
||||
this.state = state;
|
||||
if (interval != null) {
|
||||
this.interval = interval;
|
||||
}
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -8,18 +8,18 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.network.as.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.LoadBalancerVMMapVO;
|
||||
import com.cloud.network.as.AutoScaleVmGroupPolicyMapVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface AutoScaleVmGroupPolicyMapDao extends GenericDao<AutoScaleVmGroupPolicyMapVO, Long> {
|
||||
boolean removeByGroupId(long vmGroupId);
|
||||
boolean removeByGroupAndPolicies(long vmGroupId, List<Long> bakupPolicyIds);
|
||||
List<AutoScaleVmGroupPolicyMapVO> listByVmGroupId(long vmGroupId);
|
||||
List<AutoScaleVmGroupPolicyMapVO> listByPolicyId(long policyId);
|
||||
public boolean isAutoScalePolicyInUse(long policyId);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.network.as.dao;
|
||||
|
||||
|
|
@ -18,7 +18,9 @@ import javax.ejb.Local;
|
|||
|
||||
import com.cloud.network.as.AutoScaleVmGroupPolicyMapVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
@Local(value={AutoScaleVmGroupPolicyMapDao.class})
|
||||
public class AutoScaleVmGroupPolicyMapDaoImpl extends GenericDaoBase<AutoScaleVmGroupPolicyMapVO, Long> implements AutoScaleVmGroupPolicyMapDao {
|
||||
|
|
@ -31,6 +33,18 @@ public class AutoScaleVmGroupPolicyMapDaoImpl extends GenericDaoBase<AutoScaleVm
|
|||
return expunge(sc) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeByGroupAndPolicies(long vmGroupId, List<Long> policyIds) {
|
||||
SearchBuilder<AutoScaleVmGroupPolicyMapVO> policySearch = createSearchBuilder();
|
||||
policySearch.and("vmGroupId", policySearch.entity().getVmGroupId(), Op.EQ);
|
||||
policySearch.and("policyIds", policySearch.entity().getPolicyId(), Op.IN);
|
||||
policySearch.done();
|
||||
SearchCriteria<AutoScaleVmGroupPolicyMapVO> sc = policySearch.create();
|
||||
sc.setParameters("vmGroupId", vmGroupId);
|
||||
sc.setParameters("policyIds", policyIds);
|
||||
return expunge(sc) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AutoScaleVmGroupPolicyMapVO> listByVmGroupId(long vmGroupId) {
|
||||
SearchCriteria<AutoScaleVmGroupPolicyMapVO> sc = createSearchCriteria();
|
||||
|
|
@ -46,10 +60,11 @@ public class AutoScaleVmGroupPolicyMapDaoImpl extends GenericDaoBase<AutoScaleVm
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoScalePolicyInUse(long policyId) {
|
||||
SearchCriteria<AutoScaleVmGroupPolicyMapVO> sc = createSearchCriteria();
|
||||
sc.addAnd("policyId", SearchCriteria.Op.EQ, policyId);
|
||||
return findOneBy(sc) != null;
|
||||
return findOneBy(sc) != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,5 +42,5 @@ public interface LoadBalancingRulesManager extends LoadBalancingRulesService {
|
|||
|
||||
boolean applyLoadBalancersForNetwork(long networkId) throws ResourceUnavailableException;
|
||||
String getLBCapability(long networkid, String capabilityName);
|
||||
boolean configureLbAutoScaleVmGroup(long vmGroupid, boolean vmGroupCreation);
|
||||
boolean configureLbAutoScaleVmGroup(long vmGroupid);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ import com.cloud.network.as.AutoScalePolicy;
|
|||
import com.cloud.network.as.AutoScalePolicyConditionMapVO;
|
||||
import com.cloud.network.as.AutoScaleVmGroup;
|
||||
import com.cloud.network.as.AutoScaleVmGroupPolicyMapVO;
|
||||
import com.cloud.network.as.AutoScaleVmGroupVO;
|
||||
import com.cloud.network.as.AutoScaleVmProfile;
|
||||
import com.cloud.network.as.Condition;
|
||||
import com.cloud.network.as.Counter;
|
||||
|
|
@ -266,7 +267,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
return new LbAutoScaleVmGroup(vmGroup, autoScalePolicies, lbAutoScaleVmProfile);
|
||||
}
|
||||
|
||||
private boolean applyAutoScaleConfig(LoadBalancerVO lb, LoadBalancingRule rule, boolean updateRulesInDB) throws ResourceUnavailableException {
|
||||
private boolean applyAutoScaleConfig(LoadBalancerVO lb, LoadBalancingRule rule) throws ResourceUnavailableException {
|
||||
if (!isRollBackAllowedForProvider(lb)) {
|
||||
// this is for Netscalar type of devices. if their is failure the db entries will be rollbacked.
|
||||
return false;
|
||||
|
|
@ -275,41 +276,31 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
List<LoadBalancingRule> rules = Arrays.asList(rule);
|
||||
|
||||
if (!_networkMgr.applyRules(rules, false)) {
|
||||
s_logger.debug("LB rules are not completely applied");
|
||||
s_logger.debug("LB rules' autoscale config are not completely applied");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (updateRulesInDB) {
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean configureLbAutoScaleVmGroup(long vmGroupid, boolean vmGroupCreation) {
|
||||
AutoScaleVmGroup vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
|
||||
public boolean configureLbAutoScaleVmGroup(long vmGroupid) {
|
||||
AutoScaleVmGroupVO vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
|
||||
boolean success = true;
|
||||
|
||||
LoadBalancerVO loadBalancer = _lbDao.findById(vmGroup.getLoadBalancerId());
|
||||
|
||||
List<LoadBalancerVMMapVO> vmLoadBalancerMappings = _lb2VmMapDao.listByLoadBalancerId(loadBalancer.getId());
|
||||
|
||||
boolean loadBalancerCreation = false;
|
||||
|
||||
if (vmLoadBalancerMappings.size() == 0 && vmGroupCreation) { // No manual binding exists, a loadbalancer will be
|
||||
// created eventually, setting to lb to Add state
|
||||
loadBalancerCreation = true;
|
||||
}
|
||||
|
||||
FirewallRule.State backupState = loadBalancer.getState();
|
||||
|
||||
if (loadBalancerCreation) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
if (vmGroup.getState().equals(AutoScaleVmGroup.State_New)) {
|
||||
loadBalancer.setState(FirewallRule.State.Add);
|
||||
_lbDao.persist(loadBalancer);
|
||||
}
|
||||
if (loadBalancer.getState() == FirewallRule.State.Active &&
|
||||
vmGroup.getState().equals(AutoScaleVmGroup.State_Revoke)) {
|
||||
loadBalancer.setState(FirewallRule.State.Add);
|
||||
_lbDao.persist(loadBalancer);
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
// LBTODO
|
||||
|
|
@ -317,10 +308,11 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup);
|
||||
LoadBalancingRule rule = new LoadBalancingRule(loadBalancer, null, null);
|
||||
rule.setAutoScaleVmGroup(lbAutoScaleVmGroup);
|
||||
success = applyAutoScaleConfig(loadBalancer, rule, true);
|
||||
success = applyAutoScaleConfig(loadBalancer, rule);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to configure AutoScaleVmGroup to the lb rule: " + loadBalancer.getId() + " because resource is unavaliable:", e);
|
||||
if (isRollBackAllowedForProvider(loadBalancer)) {
|
||||
} finally {
|
||||
if (!success && isRollBackAllowedForProvider(loadBalancer)) {
|
||||
loadBalancer.setState(backupState);
|
||||
_lbDao.persist(loadBalancer);
|
||||
s_logger.debug("LB Rollback rule id: " + loadBalancer.getId() + " lb state rolback while creating AutoscaleVmGroup");
|
||||
|
|
@ -328,6 +320,18 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
success = false;
|
||||
}
|
||||
|
||||
if(success) {
|
||||
if (vmGroup.getState().equals(AutoScaleVmGroup.State_New)) {
|
||||
Transaction.currentTxn().start();
|
||||
loadBalancer.setState(FirewallRule.State.Active);
|
||||
s_logger.debug("LB rule " + loadBalancer.getId() + " state is set to Active");
|
||||
_lbDao.persist(loadBalancer);
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Enabled);
|
||||
_autoScaleVmGroupDao.persist(vmGroup);
|
||||
Transaction.currentTxn().commit();
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
@ -907,19 +911,19 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
|
||||
try {
|
||||
if (ipVO.getAssociatedWithNetworkId() == null) {
|
||||
boolean assignToVpcNtwk = network.getVpcId() != null
|
||||
&& ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
boolean assignToVpcNtwk = network.getVpcId() != null
|
||||
&& ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
//set networkId just for verification purposes
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
|
||||
|
||||
s_logger.debug("The ip is not associated with the VPC network id="+ lb.getNetworkId() + " so assigning");
|
||||
s_logger.debug("The ip is not associated with the VPC network id="+ lb.getNetworkId() + " so assigning");
|
||||
ipVO = _networkMgr.associateIPToGuestNetwork(ipAddrId, lb.getNetworkId(), false);
|
||||
performedIpAssoc = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, null);
|
||||
}
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, null);
|
||||
}
|
||||
|
||||
if (ipVO.getAssociatedWithNetworkId() == null) {
|
||||
throw new InvalidParameterValueException("Ip address " + ipVO + " is not assigned to the network " + network);
|
||||
|
|
@ -944,9 +948,9 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
ipVO = _ipAddressDao.findById(ipVO.getId());
|
||||
_networkMgr.unassignIPFromVpcNetwork(ipVO.getId(), lb.getNetworkId());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
throw new CloudRuntimeException("Failed to create load balancer rule: " + lb.getName());
|
||||
|
|
|
|||
Loading…
Reference in New Issue