Skip to content

Commit 9773ba3

Browse files
author
Rene Glover
authored
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
1 parent 4e9c4a5 commit 9773ba3

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

server/src/main/java/com/cloud/network/as/AutoScaleManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,8 @@ public interface AutoScaleManager extends AutoScaleService {
5555
void checkIfVmActionAllowed(Long vmId);
5656

5757
void removeVmFromVmGroup(Long vmId);
58+
59+
String getNextVmHostName(AutoScaleVmGroupVO asGroup);
60+
61+
void checkAutoScaleVmGroupName(String groupName);
5862
}

server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,15 +1938,17 @@ public void updateVmDetails(Map<String, String> deployParams, Map<String, String
19381938
}
19391939
}
19401940

1941-
private String getNextVmHostName(AutoScaleVmGroupVO asGroup) {
1941+
@Override
1942+
public String getNextVmHostName(AutoScaleVmGroupVO asGroup) {
19421943
String vmHostNameSuffix = "-" + asGroup.getNextVmSeq() + "-" +
19431944
RandomStringUtils.random(VM_HOSTNAME_RANDOM_SUFFIX_LENGTH, 0, 0, true, false, (char[])null, new SecureRandom()).toLowerCase();
19441945
// Truncate vm group name because max length of vm name is 63
19451946
int subStringLength = Math.min(asGroup.getName().length(), 63 - VM_HOSTNAME_PREFIX.length() - vmHostNameSuffix.length());
19461947
return VM_HOSTNAME_PREFIX + asGroup.getName().substring(0, subStringLength) + vmHostNameSuffix;
19471948
}
19481949

1949-
private void checkAutoScaleVmGroupName(String groupName) {
1950+
@Override
1951+
public void checkAutoScaleVmGroupName(String groupName) {
19501952
String errorMessage = "";
19511953
if (groupName == null || groupName.length() > 255 || groupName.length() < 1) {
19521954
errorMessage = "AutoScale Vm Group name must be between 1 and 255 characters long";

0 commit comments

Comments
 (0)