Add support for CDROM drives.
This commit is contained in:
parent
cc7037be0b
commit
a28ccfc8e0
5 changed files with 32 additions and 9 deletions
|
|
@ -151,9 +151,9 @@ data:
|
|||
</#if>
|
||||
<#assign drvCounter = drvCounter + 1/>
|
||||
</#if>
|
||||
<#if disk.cdromImage??>
|
||||
<#if disk.cdrom??>
|
||||
- type: ide-cd
|
||||
file: "${ disk.cdromImage.path.asString }"
|
||||
file: "${ disk.cdrom.image.asString }"
|
||||
<#if disk.bootindex??>
|
||||
bootindex: ${ disk.bootindex.asInt?c }
|
||||
</#if>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ spec:
|
|||
- name: vm-data
|
||||
mountPath: /var/local/vm-data
|
||||
- name: vmop-image-repository
|
||||
mountPath: /var/local/vmop-image-repository
|
||||
mountPath: ${ constants.IMAGE_REPO_PATH }
|
||||
volumeDevices:
|
||||
<#assign diskCounter = 0/>
|
||||
<#list cr.spec.vm.disks.asList() as disk>
|
||||
|
|
|
|||
|
|
@ -41,4 +41,7 @@ public class Constants {
|
|||
/** The Constant STATE_STOPPED. */
|
||||
public static final String STATE_STOPPED = "Stopped";
|
||||
|
||||
/** The Constant IMAGE_REPO_PATH. */
|
||||
public static final String IMAGE_REPO_PATH
|
||||
= "/var/local/vmop-image-repository";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.jdrupes.vmoperator.manager;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import freemarker.core.ParseException;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.DefaultObjectWrapperBuilder;
|
||||
|
|
@ -108,7 +110,7 @@ public class Reconciler extends Component {
|
|||
|
||||
// Prepare Freemarker model
|
||||
model = new HashMap<>();
|
||||
model.put("cr", vmDef.getRaw());
|
||||
model.put("cr", patchCr(vmDef.getRaw().deepCopy()));
|
||||
model.put("constants",
|
||||
(TemplateHashModel) new DefaultObjectWrapperBuilder(
|
||||
Configuration.VERSION_2_3_32)
|
||||
|
|
@ -130,4 +132,22 @@ public class Reconciler extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
private Object patchCr(JsonObject vmDef) {
|
||||
// Adjust cdromImage path
|
||||
var disks
|
||||
= GsonPtr.to(vmDef).to("spec", "vm", "disks").get(JsonArray.class);
|
||||
for (var disk : disks) {
|
||||
var cdrom = (JsonObject) ((JsonObject) disk).get("cdrom");
|
||||
if (cdrom == null) {
|
||||
continue;
|
||||
}
|
||||
String image = cdrom.get("image").getAsString();
|
||||
if (!image.contains("/")) {
|
||||
cdrom.addProperty("image",
|
||||
Constants.IMAGE_REPO_PATH + "/" + image);
|
||||
}
|
||||
}
|
||||
return vmDef;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue