RunInstancesResponse response = new RunInstancesResponse();
RunInstancesResponseType param1 = new RunInstancesResponseType();
param1.setReservationId("");
RunningInstancesSetType param6 = new RunningInstancesSetType();
EC2Instance[] instances = engineResponse.getInstanceSet();
for (EC2Instance inst : instances) {
RunningInstancesItemType param7 = new RunningInstancesItemType();
param7.setInstanceId(inst.getId());
param7.setImageId(inst.getTemplateId());
String accountName = inst.getAccountName();
String domainId = inst.getDomainId();
String ownerId = domainId + ":" + accountName;
param1.setOwnerId(ownerId);
EC2SecurityGroup[] groups = inst.getGroupSet();
GroupSetType param2 = new GroupSetType();
if (null == groups || 0 == groups.length) {
GroupItemType param3 = new GroupItemType();
param3.setGroupId("");
param2.addItem(param3);
} else {
for (EC2SecurityGroup group : groups) {
GroupItemType param3 = new GroupItemType();
param3.setGroupId(group.getId());
param2.addItem(param3);
}
}
param1.setGroupSet(param2);
InstanceStateType param8 = new InstanceStateType();
param8.setCode(toAmazonCode(inst.getState()));
param8.setName(toAmazonStateName(inst.getState()));
param7.setInstanceState(param8);
param7.setPrivateDnsName("");
param7.setDnsName("");
param7.setReason("");
param7.setKeyName(inst.getKeyPairName());
param7.setAmiLaunchIndex(null);
ProductCodesSetType param9 = new ProductCodesSetType();
ProductCodesSetItemType param10 = new ProductCodesSetItemType();
param10.setProductCode("");
param10.setType("");
param9.addItem(param10);
param7.setProductCodes(param9);
param7.setInstanceType(inst.getServiceOffering());
// -> CloudStack seems to have issues with timestamp formats so just in case
Calendar cal = inst.getCreated();
if (null == cal) {
cal = Calendar.getInstance();
cal.set(1970, 1, 1);
}
param7.setLaunchTime(cal);
PlacementResponseType param11 = new PlacementResponseType();
param11.setAvailabilityZone(inst.getZoneName());
param7.setPlacement(param11);
param7.setKernelId("");
param7.setRamdiskId("");
param7.setPlatform("");
InstanceMonitoringStateType param12 = new InstanceMonitoringStateType();
param12.setState("");
param7.setMonitoring(param12);
param7.setSubnetId("");
param7.setVpcId("");
String ipAddr = inst.getPrivateIpAddress();
param7.setPrivateIpAddress((null != ipAddr ? ipAddr : ""));
param7.setIpAddress(inst.getIpAddress());
StateReasonType param13 = new StateReasonType();
param13.setCode("");
param13.setMessage("");
param7.setStateReason(param13);
param7.setArchitecture("");
param7.setRootDeviceType("");
param7.setRootDeviceName("");
param7.setInstanceLifecycle("");
param7.setSpotInstanceRequestId("");
param7.setVirtualizationType("");
param7.setClientToken("");
ResourceTagSetType param18 = new ResourceTagSetType();
ResourceTagSetItemType param19 = new ResourceTagSetItemType();
param19.setKey("");
param19.setValue("");
param18.addItem(param19);
param7.setTagSet(param18);
GroupSetType param14 = new GroupSetType();
GroupItemType param15 = new GroupItemType();
param15.setGroupId("");
param15.setGroupName("");
param14.addItem(param15);
param7.setGroupSet(param14);
String hypervisor = inst.getHypervisor();
param7.setHypervisor((null != hypervisor ? hypervisor : ""));
param6.addItem(param7);
}
param1.setInstancesSet(param6);
param1.setRequesterId("");
param1.setRequestId(UUID.randomUUID().toString());