Skip to content

Commit bb06c11

Browse files
smirgelMagnus Lundin
andauthored
Supply purchase plan for gallery images (#452)
Co-authored-by: Magnus Lundin <magnusl@thermocalc.se>
1 parent 571c13a commit bb06c11

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/main/java/com/microsoft/azure/vmagent/AzureVMManagementServiceDelegate.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,27 @@ public AzureVMDeploymentInfo createDeployment(
533533
imageId = galleryImageVersion.id();
534534
LOGGER.log(Level.INFO, "Create VM with gallery image id {0}", new Object[]{imageId});
535535
putVariableIfNotBlank(tmp, "imageId", imageId);
536+
537+
Map<String, String> imageTags = galleryImageVersion.tags();
538+
if (imageTags != null) {
539+
String planInfo = imageTags.get("PlanInfo");
540+
String planProduct = imageTags.get("PlanProduct");
541+
String planPublisher = imageTags.get("PlanPublisher");
542+
543+
if (StringUtils.isNotBlank(planInfo) && StringUtils.isNotBlank(planProduct)
544+
&& StringUtils.isNotBlank(planPublisher)) {
545+
for (JsonNode resource : resources) {
546+
String type = resource.get("type").asText();
547+
if (type.contains("virtualMachine")) {
548+
ObjectNode planNode = MAPPER.createObjectNode();
549+
planNode.put("name", planInfo);
550+
planNode.put("publisher", planPublisher);
551+
planNode.put("product", planProduct);
552+
((ObjectNode) resource).replace("plan", planNode);
553+
}
554+
}
555+
}
556+
}
536557
}
537558

538559
if (imageId != null) {

0 commit comments

Comments
 (0)