ImageService imageService;
@Override
public Object go() throws CloudException {
// User user = getUser();
Project project = getProject();
// ImageId=ami-5168f861
// MinCount=1
// MaxCount=1
// DisableApiTermination=false
// Monitoring.Enabled=false
// EbsOptimized=false
StartInstancesAction action = new StartInstancesAction();
long imageId = decodeEc2Id(get("ImageId"));
{
ReservationData.Builder reservation = ReservationData.newBuilder();
ImageService.Image image = imageService.findImage(project, imageId);
if (image == null) {
throw new IllegalArgumentException();
}
reservation.setImageId(image.getId());
action.reservationTemplate = reservation.build();
}
List<SecurityGroupData> securityGroups = getSecurityGroups();
{
InstanceData.Builder instance = InstanceData.newBuilder();
for (SecurityGroupData securityGroup : securityGroups) {
instance.addSecurityGroupId(securityGroup.getId());
}
action.instanceTemplate = instance.build();
}
action.maxCount = get("MaxCount", 1);
action.minCount = get("MinCount", 1);
// action.user = getUser();
action.project = project;
StartInstancesAction.Result result = action.go();
RunInstancesResponse response = new RunInstancesResponse();
response.requestId = getRequestId();
response.reservationId = toEc2ReservationId(result.reservation.getId());
response.ownerId = toEc2Owner(project.getId());
response.groups = buildGroupsXml(securityGroups);
response.instances = Lists.newArrayList();