You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/02/20 00:12:51 UTC
git commit: refs/heads/master - CLOUDSTACK-1330: ec2-run-instances -
When -n option is used to deploy multiple Vms API returns error even though
few of the Vms have been deployed successfully.
Updated Branches:
refs/heads/master 11d5eadc7 -> 8296d41b5
CLOUDSTACK-1330: ec2-run-instances - When -n option is used to deploy multiple Vms API returns error even though few of the Vms have been deployed successfully.
Changes:
- Instead of throwing out error, return the response containing the info about the instances that were launched.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/8296d41b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/8296d41b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/8296d41b
Branch: refs/heads/master
Commit: 8296d41b5bd340e98d9e48ced884aab56f61e0ac
Parents: 11d5ead
Author: Prachi Damle <pr...@cloud.com>
Authored: Tue Feb 19 15:12:06 2013 -0800
Committer: Prachi Damle <pr...@cloud.com>
Committed: Tue Feb 19 15:12:06 2013 -0800
----------------------------------------------------------------------
.../cloud/bridge/service/core/ec2/EC2Engine.java | 72 ++++++++-------
1 files changed, 39 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8296d41b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
index 281ecbd..e92f845 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
@@ -1423,47 +1423,53 @@ public class EC2Engine extends ManagerBase {
// now actually deploy the vms
for( int i=0; i < createInstances; i++ ) {
- CloudStackUserVm resp = getApi().deployVirtualMachine(svcOffering.getId(),
- request.getTemplateId(), zoneId, null, null, null, null,
- null, null, null, request.getKeyName(), null, (network != null ? network.getId() : null),
- null, constructList(request.getGroupSet()), request.getSize().longValue(), request.getUserData());
- EC2Instance vm = new EC2Instance();
- vm.setId(resp.getId().toString());
- vm.setName(resp.getName());
- vm.setZoneName(resp.getZoneName());
- vm.setTemplateId(resp.getTemplateId().toString());
- if (resp.getSecurityGroupList() != null && resp.getSecurityGroupList().size() > 0) {
- List<CloudStackSecurityGroup> securityGroupList = resp.getSecurityGroupList();
- for (CloudStackSecurityGroup securityGroup : securityGroupList) {
- EC2SecurityGroup param = new EC2SecurityGroup();
- param.setId(securityGroup.getId());
- param.setName(securityGroup.getName());
- vm.addGroupName(param);
+ try{
+ CloudStackUserVm resp = getApi().deployVirtualMachine(svcOffering.getId(),
+ request.getTemplateId(), zoneId, null, null, null, null,
+ null, null, null, request.getKeyName(), null, (network != null ? network.getId() : null),
+ null, constructList(request.getGroupSet()), request.getSize().longValue(), request.getUserData());
+ EC2Instance vm = new EC2Instance();
+ vm.setId(resp.getId().toString());
+ vm.setName(resp.getName());
+ vm.setZoneName(resp.getZoneName());
+ vm.setTemplateId(resp.getTemplateId().toString());
+ if (resp.getSecurityGroupList() != null && resp.getSecurityGroupList().size() > 0) {
+ List<CloudStackSecurityGroup> securityGroupList = resp.getSecurityGroupList();
+ for (CloudStackSecurityGroup securityGroup : securityGroupList) {
+ EC2SecurityGroup param = new EC2SecurityGroup();
+ param.setId(securityGroup.getId());
+ param.setName(securityGroup.getName());
+ vm.addGroupName(param);
+ }
}
- }
- vm.setState(resp.getState());
- vm.setCreated(resp.getCreated());
- List <CloudStackNic> nicList = resp.getNics();
- for (CloudStackNic nic : nicList) {
- if (nic.getIsDefault()) {
- vm.setPrivateIpAddress(nic.getIpaddress());
- break;
+ vm.setState(resp.getState());
+ vm.setCreated(resp.getCreated());
+ List <CloudStackNic> nicList = resp.getNics();
+ for (CloudStackNic nic : nicList) {
+ if (nic.getIsDefault()) {
+ vm.setPrivateIpAddress(nic.getIpaddress());
+ break;
+ }
}
+ vm.setIpAddress(resp.getIpAddress());
+ vm.setAccountName(resp.getAccountName());
+ vm.setDomainId(resp.getDomainId());
+ vm.setHypervisor(resp.getHypervisor());
+ vm.setServiceOffering( svcOffering.getName());
+ vm.setKeyPairName(resp.getKeyPairName());
+ instances.addInstance(vm);
+ countCreated++;
+ }catch(Exception e){
+ logger.error("Failed to deploy VM number: "+ (i+1) +" due to error: "+e.getMessage());
+ break;
}
- vm.setIpAddress(resp.getIpAddress());
- vm.setAccountName(resp.getAccountName());
- vm.setDomainId(resp.getDomainId());
- vm.setHypervisor(resp.getHypervisor());
- vm.setServiceOffering( svcOffering.getName());
- vm.setKeyPairName(resp.getKeyPairName());
- instances.addInstance(vm);
- countCreated++;
}
if (0 == countCreated) {
// TODO, we actually need to destroy left-over VMs when the exception is thrown
- throw new EC2ServiceException(ServerError.InsufficientInstanceCapacity, "Insufficient Instance Capacity" );
+ throw new EC2ServiceException(ServerError.InternalError, "Failed to deploy instances" );
}
+ logger.debug("Could deploy "+ countCreated + " VM's successfully");
return instances;
} catch( Exception e ) {