Skip to content

Commit

Permalink
Add basic shared image gallery support
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinfish committed Feb 2, 2019
1 parent d0f07c8 commit bef0045
Show file tree
Hide file tree
Showing 19 changed files with 333 additions and 20 deletions.
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<azuresdk.version>1.3.0</azuresdk.version>
<azuresdk.version>1.19.0</azuresdk.version>
<azure-storage.version>4.4.0</azure-storage.version>
<jackson.version>2.7.2</jackson.version>
<jenkins.version>1.653</jenkins.version>
Expand Down Expand Up @@ -69,6 +69,10 @@
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-client-runtime</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
102 changes: 99 additions & 3 deletions src/main/java/com/microsoft/azure/vmagent/AzureVMAgentTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public static class ImageReferenceTypeClass {
private String imageOffer;
private String imageSku;
private String imageVersion;
private String galleryName;
private String galleryImageDefinition;
private String galleryImageVersion;
private String galleryResourceGroup;

@DataBoundConstructor
public ImageReferenceTypeClass(
Expand All @@ -95,13 +99,21 @@ public ImageReferenceTypeClass(
String imagePublisher,
String imageOffer,
String imageSku,
String imageVersion) {
String imageVersion,
String galleryName,
String galleryImageDefinition,
String galleryImageVersion,
String galleryResourceGroup) {
this.image = image;
this.imageId = imageId;
this.imagePublisher = imagePublisher;
this.imageOffer = imageOffer;
this.imageSku = imageSku;
this.imageVersion = imageVersion;
this.galleryName = galleryName;
this.galleryImageDefinition = galleryImageDefinition;
this.galleryImageVersion = galleryImageVersion;
this.galleryResourceGroup = galleryResourceGroup;
}

public String getImage() {
Expand All @@ -127,6 +139,22 @@ public String getImageSku() {
public String getImageVersion() {
return imageVersion;
}

public String getGalleryName() {
return galleryName;
}

public String getGalleryImageDefinition() {
return galleryImageDefinition;
}

public String getGalleryImageVersion() {
return galleryImageVersion;
}

public String getGalleryResourceGroup() {
return galleryResourceGroup;
}
}

public static class AvailabilityTypeClass {
Expand Down Expand Up @@ -209,6 +237,14 @@ public String getAvailabilitySet() {

private final String imageVersion;

private final String galleryName;

private final String galleryImageDefinition;

private final String galleryImageVersion;

private final String galleryResourceGroup;

private final String agentLaunchMethod;

private boolean preInstallSsh;
Expand Down Expand Up @@ -334,6 +370,10 @@ public AzureVMAgentTemplate(
this.imageOffer = imageReferenceTypeClass.getImageOffer();
this.imageSku = imageReferenceTypeClass.getImageSku();
this.imageVersion = imageReferenceTypeClass.getImageVersion();
this.galleryName = imageReferenceTypeClass.getGalleryName();
this.galleryImageDefinition = imageReferenceTypeClass.getGalleryImageDefinition();
this.galleryImageVersion = imageReferenceTypeClass.getGalleryImageVersion();
this.galleryResourceGroup = imageReferenceTypeClass.getGalleryResourceGroup();
this.shutdownOnIdle = shutdownOnIdle;
this.initScript = initScript;
this.agentLaunchMethod = agentLaunchMethod;
Expand Down Expand Up @@ -379,6 +419,17 @@ public static Map<String, Object> getTemplateProperties(AzureVMAgentTemplate tem
isBasic ? defaultProperties.get(imageSkuName) : template.getImageSku());
templateProperties.put("imageVersion",
isBasic ? defaultProperties.get(Constants.DEFAULT_IMAGE_VERSION) : template.getImageVersion());
templateProperties.put("galleryName",
isBasic ? defaultProperties.get(Constants.DEFAULT_GALLERY_NAME) : template.getGalleryName());
templateProperties.put("galleryImageDefinition",
isBasic ? defaultProperties.get(Constants.DEFAULT_GALLERY_IMAGE_DEFINITION)
: template.getGalleryImageDefinition());
templateProperties.put("galleryImageVersion",
isBasic ? defaultProperties.get(Constants.DEFAULT_GALLERY_IMAGE_VERSION)
: template.getGalleryImageVersion());
templateProperties.put("galleryResourceGroup",
isBasic ? defaultProperties.get(Constants.DEFAULT_GALLERY_RESOURCE_GROUP)
: template.getGalleryResourceGroup());
templateProperties.put("osType",
isBasic ? defaultProperties.get(Constants.DEFAULT_OS_TYPE) : template.getOsType());
templateProperties.put("agentLaunchMethod",
Expand Down Expand Up @@ -625,6 +676,9 @@ public String getImageReferenceType(ImageReferenceTypeClass imageReferenceTypeCl
if (imageReferenceTypeClass.imageId != null) {
return ImageReferenceType.CUSTOM_IMAGE.getName();
}
if (imageReferenceTypeClass.getGalleryName() != null) {
return ImageReferenceType.GALLERY.getName();
}
return ImageReferenceType.REFERENCE.getName();
}

Expand Down Expand Up @@ -676,6 +730,22 @@ public String getImageVersion() {
return imageVersion;
}

public String getGalleryName() {
return galleryName;
}

public String getGalleryImageDefinition() {
return galleryImageDefinition;
}

public String getGalleryImageVersion() {
return galleryImageVersion;
}

public String getGalleryResourceGroup() {
return galleryResourceGroup;
}

public String getInitScript() {
return initScript;
}
Expand Down Expand Up @@ -832,6 +902,12 @@ public AdvancedImage getAdvancedImageInside() {
return new AdvancedImageBuilder()
.withCustomImage(getImage())
.withCustomManagedImage(getImageId())
.withGalleryImage(
getGalleryName(),
getGalleryImageDefinition(),
getGalleryImageVersion(),
getGalleryResourceGroup()
)
.withReferenceImage(
getImagePublisher(),
getImageOffer(),
Expand Down Expand Up @@ -937,6 +1013,10 @@ public List<String> verifyTemplate() throws Exception {
imageOffer,
imageSku,
imageVersion,
galleryName,
galleryImageDefinition,
galleryImageVersion,
galleryResourceGroup,
agentLaunchMethod,
initScript,
credentialsId,
Expand Down Expand Up @@ -1259,6 +1339,10 @@ public FormValidation doVerifyConfiguration(
@RelativePath("imageReferenceTypeClass") @QueryParameter String imageOffer,
@RelativePath("imageReferenceTypeClass") @QueryParameter String imageSku,
@RelativePath("imageReferenceTypeClass") @QueryParameter String imageVersion,
@RelativePath("imageReferenceTypeClass") @QueryParameter String galleryName,
@RelativePath("imageReferenceTypeClass") @QueryParameter String galleryImageDefinition,
@RelativePath("imageReferenceTypeClass") @QueryParameter String galleryImageVersion,
@RelativePath("imageReferenceTypeClass") @QueryParameter String galleryResourceGroup,
@QueryParameter String agentLaunchMethod,
@QueryParameter String initScript,
@QueryParameter String credentialsId,
Expand Down Expand Up @@ -1313,7 +1397,11 @@ public FormValidation doVerifyConfiguration(
+ "subnetName: {25};\n\t"
+ "privateIP: {26};\n\t"
+ "nsgName: {27};\n\t"
+ "jvmOptions: {28};",
+ "jvmOptions: {28};\n\t"
+ "galleryName: {29}\n\t"
+ "galleryImageDefinition: {30}\n\t"
+ "galleryImageVersion: {31}\n\t"
+ "galleryResourceGroup: {32}",
new Object[]{
"",
"",
Expand Down Expand Up @@ -1343,7 +1431,11 @@ public FormValidation doVerifyConfiguration(
subnetName,
usePrivateIP,
nsgName,
jvmOptions});
jvmOptions,
galleryName,
galleryImageDefinition,
galleryImageVersion,
galleryResourceGroup});

// First validate the subscription info. If it is not correct,
// then we can't validate the
Expand Down Expand Up @@ -1371,6 +1463,10 @@ public FormValidation doVerifyConfiguration(
imageOffer,
imageSku,
imageVersion,
galleryName,
galleryImageDefinition,
galleryImageVersion,
galleryResourceGroup,
agentLaunchMethod,
initScript,
credentialsId,
Expand Down

0 comments on commit bef0045

Please sign in to comment.