-
Notifications
You must be signed in to change notification settings - Fork 102
Adding support for VMLimit in AzureVMTemplateBuilder #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,15 @@ | |
import com.microsoft.azure.vmagent.launcher.AzureInboundLauncher; | ||
import com.microsoft.azure.vmagent.launcher.AzureSSHLauncher; | ||
import com.microsoft.azure.vmagent.util.Constants; | ||
import com.microsoft.azure.vmagent.availability.NoAvailabilityRequired; | ||
|
||
public class AzureVMTemplateBuilder extends AzureVMTemplateFluent<AzureVMTemplateBuilder> { | ||
|
||
private AzureVMTemplateFluent<?> fluent; | ||
|
||
public AzureVMTemplateBuilder() { | ||
this.fluent = this; | ||
fluent.withMaxVirtualMachinesLimit("10"); | ||
} | ||
|
||
public AzureVMTemplateBuilder(AzureVMAgentTemplate template) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you also need to call |
||
|
@@ -96,7 +98,7 @@ | |
fluent.getDescription(), | ||
fluent.getLabels(), | ||
fluent.getLocation(), | ||
null, | ||
new NoAvailabilityRequired(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this change here? |
||
fluent.getVirtualMachineSize(), | ||
fluent.getStorageAccountNameReferenceType(), | ||
fluent.getStorageAccountType(), | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -12,6 +12,8 @@ | |||||
|
||||||
public class AzureVMTemplateFluent<T extends AzureVMTemplateFluent<T>> { | ||||||
|
||||||
private String maxVirtualMachinesLimit; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
private String name; | ||||||
|
||||||
private String description; | ||||||
|
@@ -57,157 +59,167 @@ | |||||
private List<AzureTagPair> cloudTags; | ||||||
|
||||||
public AzureVMTemplateFluent() { | ||||||
maxVirtualMachinesLimit = "10"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
location = "Japan West"; | ||||||
virtualMachineSize = "Standard_A0"; | ||||||
storageAccountType = "Standard_LRS"; | ||||||
storageAccountNameReferenceType = "new"; | ||||||
diskType = Constants.DISK_MANAGED; | ||||||
osDiskSize = 0; | ||||||
retentionStrategy = new AzureVMCloudRetensionStrategy(Constants.DEFAULT_IDLE_RETENTION_TIME); | ||||||
shutdownOnIdle = false; | ||||||
usageMode = Node.Mode.NORMAL; | ||||||
imageTopLevelType = Constants.IMAGE_TOP_LEVEL_BASIC; | ||||||
builtInImage = new BuiltInImageBuilder().build(); | ||||||
advancedImage = new AdvancedImageBuilder().build(); | ||||||
cloudTags = new ArrayList<>(); | ||||||
} | ||||||
|
||||||
//CHECKSTYLE:OFF | ||||||
public T withMaxVirtualMachinesLimit(String maxVirtualMachinesLimit) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
this.maxVirtualMachinesLimit = maxVirtualMachinesLimit; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withName(String name) { | ||||||
this.name = name; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withTags(List<AzureTagPair> tags) { | ||||||
this.cloudTags = new ArrayList<>(tags); | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withDescription(String description) { | ||||||
this.description = description; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withWorkspace(String workspace) { | ||||||
this.workspace = workspace; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withLabels(String labels) { | ||||||
this.labels = labels; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withLocation(String location) { | ||||||
this.location = location; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withVirtualMachineSize(String virtualMachineSize) { | ||||||
this.virtualMachineSize = virtualMachineSize; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withStorageAccountType(String storageAccountType) { | ||||||
this.storageAccountType = storageAccountType; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withNewStorageAccount(String storageAccountName) { | ||||||
this.storageAccountNameReferenceType = "new"; | ||||||
this.newStorageAccountName = storageAccountName; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withExistingStorageAccount(String storageAccountName) { | ||||||
this.storageAccountNameReferenceType = "existing"; | ||||||
this.existingStorageAccountName = storageAccountName; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withDiskType(String diskType) { | ||||||
this.diskType = diskType; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withEphemeralOSDisk(boolean isEphemeral) { | ||||||
this.ephemeralOSDisk = isEphemeral; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withEncryptionAtHost(boolean isEncryptionAtHost) { | ||||||
this.encryptionAtHost = isEncryptionAtHost; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withOsDiskSize(int osDiskSize) { | ||||||
this.osDiskSize = osDiskSize; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withRetentionStrategy(AzureVMCloudBaseRetentionStrategy retentionStrategy) { | ||||||
this.retentionStrategy = retentionStrategy; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T addNewIdleRetentionStrategy(String retentionTime) { | ||||||
this.retentionStrategy = new AzureVMCloudRetensionStrategy(Integer.parseInt(retentionTime)); | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T addNewPoolRetentionStrategy(String retentionTime, String poolSize, boolean singleUseAgents) { | ||||||
AzureVMCloudPoolRetentionStrategy retentionStrategy1 = | ||||||
new AzureVMCloudPoolRetentionStrategy(Integer.parseInt(retentionTime), | ||||||
Integer.parseInt(poolSize)); | ||||||
retentionStrategy1.setSingleUseAgents(singleUseAgents); | ||||||
this.retentionStrategy = retentionStrategy1; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withShutdownOnIdle(boolean isShutdown) { | ||||||
this.shutdownOnIdle = isShutdown; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withUsageMode(Node.Mode usageMode) { | ||||||
this.usageMode = usageMode; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public T withBuiltInImage(BuiltInImage builtInImage) { | ||||||
this.imageTopLevelType = Constants.IMAGE_TOP_LEVEL_BASIC; | ||||||
this.builtInImage = builtInImage; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public BuiltInImageNested addNewBuiltInImage() { | ||||||
return new BuiltInImageNested(); | ||||||
} | ||||||
|
||||||
public BuiltInImageNested addNewBuiltInImageLike(BuiltInImage image) { | ||||||
return new BuiltInImageNested(image); | ||||||
} | ||||||
|
||||||
public T withAdvancedImage(AdvancedImage advancedImage) { | ||||||
this.imageTopLevelType = Constants.IMAGE_TOP_LEVEL_ADVANCED; | ||||||
this.advancedImage = advancedImage; | ||||||
return (T) this; | ||||||
} | ||||||
|
||||||
public AdvancedImageNested addNewAdvancedImage() { | ||||||
return new AdvancedImageNested(); | ||||||
} | ||||||
|
||||||
public AdvancedImageNested addNewAdvancedImageLike(AdvancedImage image) { | ||||||
return new AdvancedImageNested(image); | ||||||
} | ||||||
|
||||||
public T withAdminCredential(String credentialsId) { | ||||||
this.credentialsId = credentialsId; | ||||||
return (T) this; | ||||||
} | ||||||
//CHECKSTYLE:ON | ||||||
|
||||||
public String getMaxVirtualMachinesLimit() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return maxVirtualMachinesLimit; | ||||||
} | ||||||
|
||||||
public String getName() { | ||||||
return name; | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't right it shouldn't be here