PlacementRequestType prt = rit.getPlacement();
UserDataType userData = rit.getUserData();
String type = rit.getInstanceType();
String keyName = rit.getKeyName();
EC2RunInstances request = new EC2RunInstances();
request.setTemplateId(rit.getImageId());
if (rit.getMinCount() < 1) {
throw new EC2ServiceException(ClientError.InvalidParameterValue,
"Value of parameter MinCount should be greater than 0");
} else request.setMinCount( rit.getMinCount() );
if (rit.getMaxCount() < 1) {
throw new EC2ServiceException(ClientError.InvalidParameterValue,
"Value of parameter MaxCount should be greater than 0");
} else request.setMaxCount(rit.getMaxCount());
if (null != type) request.setInstanceType(type);
if (null != prt) request.setZoneName(prt.getAvailabilityZone());
if (null != userData) request.setUserData(userData.getData());
if (null != keyName) request.setKeyName(rit.getKeyName() );
// -> we can only support one group per instance
if (null != gst) {
GroupItemType[] items = gst.getItem();
if (null != items) {
for( int i=0; i < items.length; i++ ) {
if ( items[i].getGroupName() != null) // either SG-name or SG-id can be provided
request.addSecuritGroupName( items[i].getGroupName());
else
request.addSecuritGroupId( items[i].getGroupId());
}
}
}
return toRunInstancesResponse( engine.runInstances( request ), engine);
}