forked from jenkinsci/azure-vm-agents-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdvancedImageBuilder.java
104 lines (94 loc) · 4.67 KB
/
AdvancedImageBuilder.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
package com.microsoft.azure.vmagent.builders;
import com.microsoft.azure.vmagent.ImageReferenceType;
public class AdvancedImageBuilder extends AdvancedImageFluent<AdvancedImageBuilder> {
private AdvancedImageFluent<?> fluent;
public AdvancedImageBuilder(AdvancedImageFluent<?> fluent) {
this.fluent = fluent;
}
public AdvancedImageBuilder(AdvancedImageFluent<?> fluent, AdvancedImage image) {
this.fluent = fluent;
if (ImageReferenceType.CUSTOM.getName().equals(image.getImageReferenceType())) {
fluent.withCustomImage(image.getImage());
} else if (ImageReferenceType.CUSTOM_IMAGE.getName().equals(image.getImageReferenceType())) {
fluent.withCustomManagedImage(image.getImageId());
} else {
fluent.withReferenceImage(image.getImagePublisher(),
image.getImageOffer(),
image.getImageSku(),
image.getImageVersion());
}
fluent.withNumberOfExecutors(String.valueOf(image.getNoOfParallelJobs()));
fluent.withOsType(image.getOsType());
fluent.withLaunchMethod(image.getAgentLaunchMethod());
fluent.withPreInstallSsh(image.isPreInstallSsh());
fluent.withInitScript(image.getInitScript());
fluent.withVirtualNetworkName(image.getVirtualNetworkName());
fluent.withVirtualNetworkResourceGroupName(image.getVirtualNetworkResourceGroupName());
fluent.withSubnetName(image.getSubnetName());
fluent.withUsePrivateIP(image.isUsePrivateIP());
fluent.withNetworkSecurityGroupName(image.getNsgName());
fluent.withJvmOptions(image.getJvmOptions());
fluent.withDisableTemplate(image.isTemplateDisabled());
fluent.withRunScriptAsRoot(image.isExecuteInitScriptAsRoot());
fluent.withDoNotUseMachineIfInitFails(image.isDoNotUseMachineIfInitFails());
}
public AdvancedImageBuilder() {
this.fluent = this;
}
public AdvancedImageBuilder(AdvancedImage image) {
this.fluent = this;
if (ImageReferenceType.CUSTOM.getName().equals(image.getImageReferenceType())) {
fluent.withCustomImage(image.getImage());
} else if (ImageReferenceType.CUSTOM_IMAGE.getName().equals(image.getImageReferenceType())) {
fluent.withCustomManagedImage(image.getImageId());
} else {
fluent.withReferenceImage(image.getImagePublisher(),
image.getImageOffer(),
image.getImageSku(),
image.getImageVersion());
}
fluent.withNumberOfExecutors(String.valueOf(image.getNoOfParallelJobs()));
fluent.withOsType(image.getOsType());
fluent.withLaunchMethod(image.getAgentLaunchMethod());
fluent.withPreInstallSsh(image.isPreInstallSsh());
fluent.withInitScript(image.getInitScript());
fluent.withVirtualNetworkName(image.getVirtualNetworkName());
fluent.withVirtualNetworkResourceGroupName(image.getVirtualNetworkResourceGroupName());
fluent.withSubnetName(image.getSubnetName());
fluent.withUsePrivateIP(image.isUsePrivateIP());
fluent.withNetworkSecurityGroupName(image.getNsgName());
fluent.withJvmOptions(image.getJvmOptions());
fluent.withDisableTemplate(image.isTemplateDisabled());
fluent.withRunScriptAsRoot(image.isExecuteInitScriptAsRoot());
fluent.withDoNotUseMachineIfInitFails(image.isDoNotUseMachineIfInitFails());
}
public AdvancedImage build() {
return new AdvancedImage(fluent.getImageReferenceType(),
fluent.getImage(),
fluent.getOsType(),
fluent.getImageId(),
fluent.getImagePublisher(),
fluent.getImageOffer(),
fluent.getImageSku(),
fluent.getImageVersion(),
fluent.getGalleryName(),
fluent.getGalleryImageDefinition(),
fluent.getGalleryImageVersion(),
fluent.getGallerySubscriptionId(),
fluent.getGalleryResourceGroup(),
fluent.getAgentLaunchMethod(),
fluent.isPreInstallSsh(),
fluent.getInitScript(),
fluent.isExecuteInitScriptAsRoot(),
fluent.isDoNotUseMachineIfInitFails(),
fluent.isEnableMSI(),
fluent.getVirtualNetworkName(),
fluent.getVirtualNetworkResourceGroupName(),
fluent.getSubnetName(),
fluent.isUsePrivateIP(),
fluent.getNsgName(),
fluent.getJvmOptions(),
fluent.getNoOfParallelJobs(),
fluent.isTemplateDisabled());
}
}