if (!(req.getRequestedRA() instanceof _ResourceAllocation)) {
throw new CannotTranslateException(
"expecting writable ResourceAllocation");
}
_ResourceAllocation ra = (_ResourceAllocation) req.getRequestedRA();
if (ra == null) {
ra = this.repr._newResourceAllocation();
req.setRequestedRA(ra);
}
final _Schedule sched = this.repr._newSchedule();
if (dep.getDeploymentTime() != null) {
final int requestedSecs;
try {
requestedSecs = CommonUtil.durationToSeconds(
dep.getDeploymentTime().getMinDuration());
} catch (InvalidDurationException e) {
throw new CannotTranslateException(e.getMessage(), e);
}
sched.setDurationSeconds(requestedSecs);
}
req.setRequestedSchedule(sched);
ra.setNodeNumber(dep.getNodeNumber());
// handled elsewhere: dep.getPostShutdown();
final ShutdownMechanism_Type shutdownMech = dep.getShutdownMechanism();
if (shutdownMech == null) {
req.setShutdownType(CreateRequest.SHUTDOWN_TYPE_NORMAL);
} else {
final String type = (String) shutdownMap.get(shutdownMech);
if (type == null) {
throw new CannotTranslateException("unknown shutdown " +
"mechanism '" + shutdownMech.toString() + "'");
} else {
req.setShutdownType(type);
}
}
final InitialState_Type initialState = dep.getInitialState();
if (initialState == null) {
req.setInitialStateRequest(CreateRequest.INITIAL_STATE_RUNNING);
} else {
final String state = (String) initialStateMap.get(initialState);
if (state == null) {
throw new CannotTranslateException("unknown initial " +
"state '" + initialState.toString() + "'");
} else {
req.setInitialStateRequest(state);
}
}
final ResourceAllocation_Type wsra = dep.getResourceAllocation();
if (wsra == null) {
throw new CannotTranslateException(
"ResourceAllocation_Type may not be missing");
}
ra.setMemory(this.getMemoryMB(wsra));
ra.setIndCpuCount(this.getCPUCount(wsra));
boolean noFiles = false;
final VMFile[] files = req.getVMFiles();
if (files == null || files.length == 0) {
noFiles = true;