mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-1133: [EC2 Query API] In StopInstances add support for parameter 'force'
Propagate this parameter to CS to force stop an instance
This commit is contained in:
parent
3337106693
commit
57969843d6
|
|
@ -1269,6 +1269,11 @@ public class EC2RestServlet extends HttpServlet {
|
|||
}
|
||||
if (0 == count) { response.sendError(530, "Missing InstanceId parameter" ); return; }
|
||||
|
||||
String[] force = request.getParameterValues("Force");
|
||||
if ( force != null) {
|
||||
EC2request.setForce( Boolean.parseBoolean(force[0]));
|
||||
}
|
||||
|
||||
// -> execute the request
|
||||
StopInstancesResponse EC2response = EC2SoapServiceImpl.toStopInstancesResponse( ServiceProvider.getInstance().getEC2Engine().stopInstances( EC2request ));
|
||||
serializeResponse(response, EC2response);
|
||||
|
|
|
|||
|
|
@ -773,6 +773,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
|||
public StopInstancesResponse stopInstances(StopInstances stopInstances) {
|
||||
EC2StopInstances request = new EC2StopInstances();
|
||||
StopInstancesType sit = stopInstances.getStopInstances();
|
||||
Boolean force = sit.getForce();
|
||||
|
||||
// -> toEC2StopInstances
|
||||
InstanceIdSetType iist = sit.getInstancesSet();
|
||||
|
|
@ -780,6 +781,8 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
|
|||
if (null != items) { // -> should not be empty
|
||||
for( int i=0; i < items.length; i++ ) request.addInstanceId( items[i].getInstanceId());
|
||||
}
|
||||
|
||||
if (force) request.setForce(sit.getForce());
|
||||
return toStopInstancesResponse( engine.stopInstances( request ));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1512,6 +1512,7 @@ public class EC2Engine extends ManagerBase {
|
|||
// -> first determine the current state of each VM (becomes it previous state)
|
||||
try {
|
||||
String[] instanceSet = request.getInstancesSet();
|
||||
Boolean forced = request.getForce();
|
||||
|
||||
EC2DescribeInstancesResponse previousState = listVirtualMachines( instanceSet, null, null );
|
||||
virtualMachines = previousState.getInstanceSet();
|
||||
|
|
@ -1533,7 +1534,7 @@ public class EC2Engine extends ManagerBase {
|
|||
instances.addInstance(vm);
|
||||
continue;
|
||||
}
|
||||
resp = getApi().stopVirtualMachine(vm.getId(), false);
|
||||
resp = getApi().stopVirtualMachine(vm.getId(), forced);
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("Stopping VM " + vm.getId() + " job " + resp.getJobId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public class EC2StopInstances {
|
|||
|
||||
private List<String> instancesSet = new ArrayList<String>(); // a list of strings identifying instances
|
||||
private boolean destroyInstances; // we are destroying the instances rather than stopping them
|
||||
private Boolean force = false;
|
||||
|
||||
public EC2StopInstances() {
|
||||
destroyInstances = false;
|
||||
|
|
@ -43,5 +44,13 @@ public class EC2StopInstances {
|
|||
public boolean getDestroyInstances() {
|
||||
return this.destroyInstances;
|
||||
}
|
||||
|
||||
public void setForce( Boolean force ) {
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
public Boolean getForce() {
|
||||
return this.force;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue