Allow autoscale group and name override (#8324)

Updates AutoScaleManager/AutoScaleManagerImpl so that getNextVmHostName and checkAutoScaleVmGroupName can be overridden in derivative implementations to allow for custom naming conditions and restrictions. If possible, would like to include this in 4.19 since it is a trivial change.
This can be used to create an extension of AutoScaleManagerImpl.java, overriding these 2 methods
This commit is contained in:
Rene Glover 2023-12-07 23:51:25 -06:00 committed by GitHub
parent 4e9c4a5895
commit 9773ba3e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -55,4 +55,8 @@ public interface AutoScaleManager extends AutoScaleService {
void checkIfVmActionAllowed(Long vmId);
void removeVmFromVmGroup(Long vmId);
String getNextVmHostName(AutoScaleVmGroupVO asGroup);
void checkAutoScaleVmGroupName(String groupName);
}

View File

@ -1938,7 +1938,8 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
}
}
private String getNextVmHostName(AutoScaleVmGroupVO asGroup) {
@Override
public String getNextVmHostName(AutoScaleVmGroupVO asGroup) {
String vmHostNameSuffix = "-" + asGroup.getNextVmSeq() + "-" +
RandomStringUtils.random(VM_HOSTNAME_RANDOM_SUFFIX_LENGTH, 0, 0, true, false, (char[])null, new SecureRandom()).toLowerCase();
// Truncate vm group name because max length of vm name is 63
@ -1946,7 +1947,8 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
return VM_HOSTNAME_PREFIX + asGroup.getName().substring(0, subStringLength) + vmHostNameSuffix;
}
private void checkAutoScaleVmGroupName(String groupName) {
@Override
public void checkAutoScaleVmGroupName(String groupName) {
String errorMessage = "";
if (groupName == null || groupName.length() > 255 || groupName.length() < 1) {
errorMessage = "AutoScale Vm Group name must be between 1 and 255 characters long";