final String net = "'" + hackStatic(vm.getNetwork()) + "'";
cmd.add(net);
}
// sources:
VirtualMachinePartition rootdisk = null;
final ArrayList regularPartitions = new ArrayList();
final ArrayList blankPartitions = new ArrayList();
// results to send:
final ArrayList images = new ArrayList();
final ArrayList imagemounts = new ArrayList();
final VirtualMachinePartition[] partitions = vm.getPartitions();
if (partitions == null || partitions.length == 0) {
final String err = "should be at least one partition, Binding " +
"should have caught at the outset";
logger.error(err);
throw new WorkspaceException(err);
} else {
for (int i = 0; i < partitions.length; i++) {
if (partitions[i].isRootdisk()) {
rootdisk = partitions[i];
} else if (partitions[i].getBlankspace() > 0) {
blankPartitions.add(partitions[i]);
} else {
regularPartitions.add(partitions[i]);
}
}
}
// todo: generalize when propagating more than just rootdisk
if (rootdisk != null) {
String rootImageURI = rootdisk.getImage();
// We know that if Propagate was required and notificationInfo
// is null that this is a create command following a successful
// Propagate-only command, so we let the backend know it can
// find the file in its workspace-specific secureimage directory
// by setting this file URL to a relative path -- relative paths
// hitting the backend always cause the workspace-specific
// secureimage directory to be consulted first
if (vm.isPropagateRequired() && notificationInfo == null) {
final String newURI = convertToAlreadyPropagated(rootImageURI, vm);
logger.debug("turned '" + rootImageURI + "' into '" +
newURI + "' because file was already propagated");
// not handling readonly root partition yet
images.add(newURI);
} else {
// not handling readonly root partition yet
images.add(rootImageURI);
}
imagemounts.add(rootdisk.getImagemount());
}
if (!blankPartitions.isEmpty()) {
int blankNum = 0;
final Iterator iter = blankPartitions.iterator();
while (iter.hasNext()) {
final VirtualMachinePartition blank =
(VirtualMachinePartition) iter.next();
final int megs = blank.getBlankspace();
//When unpropagate support is added for blank partitions,
// this file will likely be unpropagated to the image node
// with the originally supplied filename as target -- and
// perhaps some schema change will allow the user to specify
// whether or not it should be saved at all (when serializing
// it would have to be)
images.add("blankcreate://blankpartition" + blankNum
+ "-size-" + megs);
imagemounts.add(blank.getImagemount());
blankNum += 1;
// (assuming blank partition will always be readwrite)
}
}
if (!regularPartitions.isEmpty()) {
final Iterator iter = regularPartitions.iterator();
while (iter.hasNext()) {
final VirtualMachinePartition regular =
(VirtualMachinePartition) iter.next();
String imgStr = regular.getImage();
if (!regular.isReadwrite()) {
imgStr += WC_FIELD_SEPARATOR + "ro";
}
images.add(imgStr);
imagemounts.add(regular.getImagemount());
}
}
if (images.isEmpty()) {
final String err = "should be at least one image here...";