result.instances = Lists.newArrayList();
List<StartInstanceData> startInstances = Lists.newArrayList();
for (int i = 0; i < hosts.size(); i++) {
SchedulerHost host = hosts.get(i);
InstanceData instanceInfo;
{
InstanceData.Builder b = InstanceData.newBuilder(instanceTemplate);
b.setProjectId(project.getId());
b.setHostId(host.getId());
b.setReservationId(reservationInfo.getId());
b.setInstanceState(InstanceState.PENDING);
b.setLaunchIndex(i);
b.setLaunchTime(time);
instanceInfo = computeServices.createInstance(auth, project, b);
}
result.instances.add(instanceInfo);
StartInstanceData data = new StartInstanceData();
data.instanceInfo = instanceInfo;
data.token = authService.createServiceToken(auth, instanceInfo.getId());
startInstances.add(data);
}
asyncTasks.startInstances(auth, project, startInstances);