Skip to content

Commit

Permalink
Ensuring that windows computer name prefixes is limited to 9 characte…
Browse files Browse the repository at this point in the history
…rs as restricted by azure (#4434)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
hkumarsulochana and mergify[bot] committed Mar 19, 2020
1 parent ab670b6 commit ef36d56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,13 @@ class AzureServerGroupResourceTemplate {

ScaleSetOsProfileProperty(AzureServerGroupDescription description) {
//Max length of 10 characters to allow for an aditional postfix within a max length of 15 characters
computerNamePrefix = description.getIdentifier().substring(0, 10)
log.info("computerNamePrefix will be truncated to 10 characters to maintain Azure restrictions")
String osType = description.image.ostype
int maxLengthOsSpecific = osType==null||osType.isEmpty()||osType.isAllWhitespace()||osType.equalsIgnoreCase("linux")?10:9
int identifierLength=description.getIdentifier().length()
//A guard to avoid nullpointer in case identifierLength is less than maxLengthOsSpecific
int identifierMaxIndex=identifierLength<maxLengthOsSpecific?identifierLength:maxLengthOsSpecific
computerNamePrefix = description.getIdentifier().substring(0, identifierMaxIndex)
log.info(String.format("computerNamePrefix will be truncated to %d characters to maintain Azure restrictions",maxLengthOsSpecific))
adminUsername = "[parameters('${vmUserNameParameterName}')]"
adminPassword = "[parameters('${vmPasswordParameterName}')]"
customData = "[base64(parameters('customData'))]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ class AzureServerGroupResourceTemplateSpec extends Specification {
"dataDisks" : null
},
"osProfile" : {
"computerNamePrefix" : "azureMASM-",
"computerNamePrefix" : "azureMASM",
"adminUsername" : "[parameters('vmUserName')]",
"adminPassword" : "[parameters('vmPassword')]",
"customData" : "[base64(parameters('customData'))]"
Expand Down

0 comments on commit ef36d56

Please sign in to comment.