incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [11/50] [abbrv] git commit: refs/heads/ui-plugins - CLOUDSTACK-1133: [EC2 Query API] In StopInstances add support for parameter 'force'
Date Wed, 13 Feb 2013 22:04:22 GMT
CLOUDSTACK-1133: [EC2 Query API] In StopInstances add support for parameter 'force'

Propagate this parameter to CS to force stop an instance


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/57969843
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/57969843
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/57969843

Branch: refs/heads/ui-plugins
Commit: 57969843d658fe01cf1f55bb7990a0716726250f
Parents: 3337106
Author: Likitha Shetty <Likitha.Shetty@citrix.com>
Authored: Tue Feb 12 14:03:51 2013 -0800
Committer: Prachi Damle <prachi@cloud.com>
Committed: Tue Feb 12 14:04:07 2013 -0800

----------------------------------------------------------------------
 .../com/cloud/bridge/service/EC2RestServlet.java   |    5 +++++
 .../cloud/bridge/service/EC2SoapServiceImpl.java   |    3 +++
 .../cloud/bridge/service/core/ec2/EC2Engine.java   |    3 ++-
 .../bridge/service/core/ec2/EC2StopInstances.java  |    9 +++++++++
 4 files changed, 19 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/57969843/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
index fe93038..e209662 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/57969843/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
index 4e9445e..9fc581b 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
@@ -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 ));
 	}
 	

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/57969843/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 277cdc8..a835d8a 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
@@ -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());
                 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/57969843/awsapi/src/com/cloud/bridge/service/core/ec2/EC2StopInstances.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2StopInstances.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2StopInstances.java
index 13e23d1..be14000 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2StopInstances.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2StopInstances.java
@@ -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;
+    }
 	
 }


Mime
View raw message