forked from jenkinsci/azure-vm-agents-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAzureVMTemplateBuilder.java
127 lines (117 loc) · 6.25 KB
/
AzureVMTemplateBuilder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package com.microsoft.azure.vmagent.builders;
import com.microsoft.azure.vmagent.AzureVMAgentTemplate;
public class AzureVMTemplateBuilder extends AzureVMTemplateFluent<AzureVMTemplateBuilder> {
private AzureVMTemplateFluent<?> fluent;
public AzureVMTemplateBuilder() {
this.fluent = this;
}
public AzureVMTemplateBuilder(AzureVMAgentTemplate template) {
this.fluent = this;
fluent.withName(template.getTemplateName());
fluent.withDescription(template.getTemplateDesc());
fluent.withLabels(template.getLabels());
fluent.withLocation(template.getLocation());
fluent.withAvailability(template.getAvailabilityInside());
fluent.withVirtualMachineSize(template.getVirtualMachineSize());
if (template.getStorageAccountNameReferenceType().equalsIgnoreCase("new")) {
fluent.withNewStorageAccount(template.getNewStorageAccountName());
} else {
fluent.withExistingStorageAccount(template.getExistingStorageAccountName());
}
fluent.withStorageAccountType(template.getStorageAccountType());
fluent.withDiskType(template.getDiskType());
fluent.withOsDiskSize(template.getOsDiskSize());
fluent.withRetentionStrategy(template.getRetentionStrategy());
fluent.withUsageMode(template.getUsageMode());
fluent.withAdminCredential(template.getCredentialsId());
fluent.withWorkspace(template.getAgentWorkspace());
fluent.withShutdownOnIdle(template.isShutdownOnIdle());
if (template.getImageTopLevelType().equalsIgnoreCase("basic")) {
fluent.withBuiltInImage(template.getBuiltInImageInside());
} else {
fluent.withAdvancedImage(template.getAdvancedImageInside());
}
}
public AzureVMTemplateBuilder(AzureVMTemplateFluent<?> fluent) {
this.fluent = fluent;
}
public AzureVMTemplateBuilder(AzureVMTemplateFluent<?> fluent, AzureVMAgentTemplate template) {
this.fluent = fluent;
fluent.withName(template.getTemplateName());
fluent.withDescription(template.getTemplateDesc());
fluent.withLabels(template.getLabels());
fluent.withLocation(template.getLocation());
fluent.withAvailability(template.getAvailabilityInside());
fluent.withVirtualMachineSize(template.getVirtualMachineSize());
if (template.getStorageAccountNameReferenceType().equalsIgnoreCase("new")) {
fluent.withNewStorageAccount(template.getNewStorageAccountName());
} else {
fluent.withExistingStorageAccount(template.getExistingStorageAccountName());
}
fluent.withStorageAccountType(template.getStorageAccountType());
fluent.withDiskType(template.getDiskType());
fluent.withOsDiskSize(template.getOsDiskSize());
fluent.withRetentionStrategy(template.getRetentionStrategy());
fluent.withUsageMode(template.getUsageMode());
fluent.withAdminCredential(template.getCredentialsId());
fluent.withWorkspace(template.getAgentWorkspace());
fluent.withShutdownOnIdle(template.isShutdownOnIdle());
if (template.getImageTopLevelType().equalsIgnoreCase("basic")) {
fluent.withBuiltInImage(template.getBuiltInImageInside());
} else {
fluent.withAdvancedImage(template.getAdvancedImageInside());
}
}
public AzureVMAgentTemplate build() {
return new AzureVMAgentTemplate(fluent.getName(),
fluent.getDescription(),
fluent.getLabels(),
fluent.getLocation(),
new AzureVMAgentTemplate.AvailabilityTypeClass(fluent.getAvailability().getAvailabilitySet()),
fluent.getVirtualMachineSize(),
fluent.getStorageAccountNameReferenceType(),
fluent.getStorageAccountType(),
fluent.getNewStorageAccountName(),
fluent.getExistingStorageAccountName(),
fluent.getDiskType(),
fluent.getOsDiskSize(),
fluent.getAdvancedImage().getNoOfParallelJobs(),
fluent.getUsageMode(),
fluent.getBuiltInImage().getBuiltInImage(),
fluent.getBuiltInImage().isInstallGit(),
fluent.getBuiltInImage().isInstallMaven(),
fluent.getBuiltInImage().isInstallDocker(),
fluent.getAdvancedImage().getOsType(),
fluent.getImageTopLevelType(),
false,
new AzureVMAgentTemplate.ImageReferenceTypeClass(fluent.getAdvancedImage().getImage(),
fluent.getAdvancedImage().getImageId(),
fluent.getAdvancedImage().getImagePublisher(),
fluent.getAdvancedImage().getImageOffer(),
fluent.getAdvancedImage().getImageSku(),
fluent.getAdvancedImage().getImageVersion(),
fluent.getAdvancedImage().getGalleryName(),
fluent.getAdvancedImage().getGalleryImageDefinition(),
fluent.getAdvancedImage().getGalleryImageVersion(),
fluent.getAdvancedImage().getGallerySubscriptionId(),
fluent.getAdvancedImage().getGalleryResourceGroup()),
fluent.getAdvancedImage().getAgentLaunchMethod(),
fluent.getAdvancedImage().isPreInstallSsh(),
fluent.getAdvancedImage().getInitScript(),
fluent.getCredentialsId(),
fluent.getAdvancedImage().getVirtualNetworkName(),
fluent.getAdvancedImage().getVirtualNetworkResourceGroupName(),
fluent.getAdvancedImage().getSubnetName(),
fluent.getAdvancedImage().isUsePrivateIP(),
fluent.getAdvancedImage().getNsgName(),
fluent.getWorkspace(),
fluent.getAdvancedImage().getJvmOptions(),
fluent.getRetentionStrategy(),
fluent.isShutdownOnIdle(),
fluent.getAdvancedImage().isTemplateDisabled(),
null,
fluent.getAdvancedImage().isExecuteInitScriptAsRoot(),
fluent.getAdvancedImage().isDoNotUseMachineIfInitFails(),
fluent.getAdvancedImage().isEnableMSI());
}
}