You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2013/01/09 05:37:25 UTC

[12/50] [abbrv] git commit: api: Refactor and move s3 to api.command.admin.storage

api: Refactor and move s3 to api.command.admin.storage

Signed-off-by: Rohit Yadav <bh...@apache.org>


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

Branch: refs/heads/master
Commit: f07a98a74097dc29f402f481704334146d0cf36d
Parents: 5119785
Author: Rohit Yadav <bh...@apache.org>
Authored: Sat Jan 5 15:30:38 2013 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Sat Jan 5 15:30:38 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/api/commands/AddS3Cmd.java       |  218 ---------------
 api/src/com/cloud/api/commands/ListS3sCmd.java     |   75 -----
 api/src/com/cloud/api/response/S3Response.java     |  210 --------------
 api/src/com/cloud/resource/ResourceService.java    |    4 +-
 .../apache/cloudstack/api/ResponseGenerator.java   |    2 +-
 .../api/command/admin/storage/AddS3Cmd.java        |  218 +++++++++++++++
 .../api/command/admin/storage/ListS3sCmd.java      |   75 +++++
 .../apache/cloudstack/api/response/S3Response.java |  210 ++++++++++++++
 client/tomcatconf/commands.properties.in           |    4 +-
 server/src/com/cloud/api/ApiResponseHelper.java    |   24 +--
 .../com/cloud/resource/ResourceManagerImpl.java    |    4 +-
 server/src/com/cloud/storage/s3/S3Manager.java     |    4 +-
 server/src/com/cloud/storage/s3/S3ManagerImpl.java |    4 +-
 13 files changed, 515 insertions(+), 537 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/api/src/com/cloud/api/commands/AddS3Cmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AddS3Cmd.java b/api/src/com/cloud/api/commands/AddS3Cmd.java
deleted file mode 100644
index 2dfc8ff..0000000
--- a/api/src/com/cloud/api/commands/AddS3Cmd.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.cloud.api.commands;
-
-import static org.apache.cloudstack.api.ApiConstants.S3_ACCESS_KEY;
-import static org.apache.cloudstack.api.ApiConstants.S3_CONNECTION_TIMEOUT;
-import static org.apache.cloudstack.api.ApiConstants.S3_END_POINT;
-import static org.apache.cloudstack.api.ApiConstants.S3_HTTPS_FLAG;
-import static org.apache.cloudstack.api.ApiConstants.S3_MAX_ERROR_RETRY;
-import static org.apache.cloudstack.api.ApiConstants.S3_SECRET_KEY;
-import static org.apache.cloudstack.api.ApiConstants.S3_SOCKET_TIMEOUT;
-import static org.apache.cloudstack.api.ApiConstants.S3_BUCKET_NAME;
-import static org.apache.cloudstack.api.BaseCmd.CommandType.INTEGER;
-import static org.apache.cloudstack.api.BaseCmd.CommandType.STRING;
-import static org.apache.cloudstack.api.BaseCmd.CommandType.BOOLEAN;
-import static com.cloud.user.Account.ACCOUNT_ID_SYSTEM;
-
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.S3Response;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.storage.S3;
-
-@APICommand(name = "addS3", description = "Adds S3", responseObject = S3Response.class, since = "4.0.0")
-public final class AddS3Cmd extends BaseCmd {
-
-    private static String COMMAND_NAME = "adds3response";
-
-    @Parameter(name = S3_ACCESS_KEY, type = STRING, required = true,
-            description = "S3 access key")
-    private String accessKey;
-
-    @Parameter(name = S3_SECRET_KEY, type = STRING, required = true,
-            description = "S3 secret key")
-    private String secretKey;
-
-    @Parameter(name = S3_END_POINT, type = STRING, required = false,
-            description = "S3 host name")
-    private String endPoint = null;
-
-    @Parameter(name = S3_BUCKET_NAME, type = STRING, required = true,
-            description = "name of the template storage bucket")
-    private String bucketName;
-
-    @Parameter(name = S3_HTTPS_FLAG, type = BOOLEAN, required = false,
-            description = "connect to the S3 endpoint via HTTPS?")
-    private Boolean httpsFlag = null;
-
-    @Parameter(name = S3_CONNECTION_TIMEOUT, type = INTEGER, required = false,
-            description = "connection timeout (milliseconds)")
-    private Integer connectionTimeout = null;
-
-    @Parameter(name = S3_MAX_ERROR_RETRY, type = INTEGER, required = false,
-            description = "maximum number of times to retry on error")
-    private Integer maxErrorRetry = null;
-
-    @Parameter(name = S3_SOCKET_TIMEOUT, type = INTEGER, required = false,
-            description = "socket timeout (milliseconds)")
-    private Integer socketTimeout = null;
-
-    @Override
-    public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
-            ServerApiException, ConcurrentOperationException, ResourceAllocationException,
-            NetworkRuleConflictException {
-
-        final S3 result;
-
-        try {
-
-            result = _resourceService.discoverS3(this);
-
-            if (result == null) {
-                throw new ServerApiException(INTERNAL_ERROR, "Failed to add S3.");
-            }
-
-        } catch (DiscoveryException e) {
-
-            throw new ServerApiException(INTERNAL_ERROR, "Failed to add S3 due to " + e.getMessage());
-
-        }
-
-        final S3Response response = _responseGenerator.createS3Response(result);
-        response.setResponseName(this.getCommandName());
-        this.setResponseObject(response);
-
-    }
-
-    @Override
-    public boolean equals(final Object thatObject) {
-
-        if (this == thatObject) {
-            return true;
-        }
-
-        if (thatObject == null || this.getClass() != thatObject.getClass()) {
-            return false;
-        }
-
-        final AddS3Cmd thatAddS3Cmd = (AddS3Cmd) thatObject;
-
-        if (this.httpsFlag != null ? !this.httpsFlag.equals(thatAddS3Cmd.httpsFlag) : thatAddS3Cmd.httpsFlag != null) {
-            return false;
-        }
-
-        if (this.accessKey != null ? !this.accessKey.equals(thatAddS3Cmd.accessKey) : thatAddS3Cmd.accessKey != null) {
-            return false;
-        }
-
-        if (this.connectionTimeout != null ? !this.connectionTimeout.equals(thatAddS3Cmd.connectionTimeout) : thatAddS3Cmd.connectionTimeout != null) {
-            return false;
-        }
-
-        if (this.endPoint != null ? !this.endPoint.equals(thatAddS3Cmd.endPoint) : thatAddS3Cmd.endPoint != null) {
-            return false;
-        }
-
-        if (this.maxErrorRetry != null ? !this.maxErrorRetry.equals(thatAddS3Cmd.maxErrorRetry) : thatAddS3Cmd.maxErrorRetry != null) {
-            return false;
-        }
-
-        if (this.secretKey != null ? !this.secretKey.equals(thatAddS3Cmd.secretKey) : thatAddS3Cmd.secretKey != null) {
-            return false;
-        }
-
-        if (this.socketTimeout != null ? !this.socketTimeout.equals(thatAddS3Cmd.socketTimeout) : thatAddS3Cmd.socketTimeout != null) {
-            return false;
-        }
-
-        if (this.bucketName != null ? !this.bucketName.equals(thatAddS3Cmd.bucketName) : thatAddS3Cmd.bucketName != null) {
-            return false;
-        }
-
-        return true;
-
-    }
-
-    @Override
-    public int hashCode() {
-
-        int result = this.accessKey != null ? this.accessKey.hashCode() : 0;
-        result = 31 * result + (this.secretKey != null ? this.secretKey.hashCode() : 0);
-        result = 31 * result + (this.endPoint != null ? this.endPoint.hashCode() : 0);
-        result = 31 * result + (this.bucketName != null ? this.bucketName.hashCode() : 0);
-        result = 31 * result + (this.httpsFlag != null && this.httpsFlag == true ? 1 : 0);
-        result = 31 * result + (this.connectionTimeout != null ? this.connectionTimeout.hashCode() : 0);
-        result = 31 * result + (this.maxErrorRetry != null ? this.maxErrorRetry.hashCode() : 0);
-        result = 31 * result + (this.socketTimeout != null ? this.socketTimeout.hashCode() : 0);
-
-        return result;
-
-    }
-
-    @Override
-    public String getCommandName() {
-        return COMMAND_NAME;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return ACCOUNT_ID_SYSTEM;
-    }
-
-    public String getAccessKey() {
-        return this.accessKey;
-    }
-
-    public String getSecretKey() {
-        return this.secretKey;
-    }
-
-    public String getEndPoint() {
-        return this.endPoint;
-    }
-
-    public String getBucketName() {
-        return this.bucketName;
-    }
-
-    public Boolean getHttpsFlag() {
-        return this.httpsFlag;
-    }
-
-    public Integer getConnectionTimeout() {
-        return this.connectionTimeout;
-    }
-
-    public Integer getMaxErrorRetry() {
-        return this.maxErrorRetry;
-    }
-
-    public Integer getSocketTimeout() {
-        return this.socketTimeout;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/api/src/com/cloud/api/commands/ListS3sCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListS3sCmd.java b/api/src/com/cloud/api/commands/ListS3sCmd.java
deleted file mode 100644
index 89da515..0000000
--- a/api/src/com/cloud/api/commands/ListS3sCmd.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.ListResponse;
-import com.cloud.api.response.S3Response;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.storage.S3;
-
-@APICommand(name = "listS3s", description = "Lists S3s", responseObject = S3Response.class, since = "4.0.0")
-public final class ListS3sCmd extends BaseListCmd {
-
-    private static final String COMMAND_NAME = "lists3sresponse";
-
-    @Override
-    public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
-            ServerApiException, ConcurrentOperationException, ResourceAllocationException,
-            NetworkRuleConflictException {
-
-        final List<? extends S3> result = _resourceService.listS3s(this);
-        final ListResponse<S3Response> response = new ListResponse<S3Response>();
-        final List<S3Response> s3Responses = new ArrayList<S3Response>();
-
-        if (result != null) {
-
-            for (S3 s3 : result) {
-
-                S3Response s3Response = _responseGenerator.createS3Response(s3);
-                s3Response.setResponseName(this.getCommandName());
-                s3Response.setObjectName("s3");
-                s3Responses.add(s3Response);
-
-            }
-
-        }
-
-        response.setResponses(s3Responses);
-        response.setResponseName(this.getCommandName());
-
-        this.setResponseObject(response);
-
-    }
-
-    @Override
-    public String getCommandName() {
-        return COMMAND_NAME;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/api/src/com/cloud/api/response/S3Response.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/S3Response.java b/api/src/com/cloud/api/response/S3Response.java
deleted file mode 100644
index 0d2cf7e..0000000
--- a/api/src/com/cloud/api/response/S3Response.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.cloud.api.response;
-
-import com.cloud.serializer.Param;
-import com.cloud.utils.IdentityProxy;
-import com.google.gson.annotations.SerializedName;
-import org.apache.cloudstack.api.BaseResponse;
-
-import static org.apache.cloudstack.api.ApiConstants.*;
-
-public class S3Response extends BaseResponse {
-
-    @SerializedName(ID)
-    @Param(description = "The ID of the S3 configuration")
-    private IdentityProxy id = new IdentityProxy("s3");
-
-    @SerializedName(S3_ACCESS_KEY)
-    @Param(description = "The S3 access key")
-    private String accessKey;
-
-    @SerializedName(S3_SECRET_KEY)
-    @Param(description = "The S3 secret key")
-    private String secretKey;
-
-    @SerializedName(S3_END_POINT)
-    @Param(description = "The S3 end point")
-    private String endPoint;
-
-    @SerializedName(S3_BUCKET_NAME)
-    @Param(description = "The name of the template storage bucket")
-    private String bucketName;
-
-    @SerializedName(S3_HTTPS_FLAG)
-    @Param(description = "Connect to S3 using HTTPS?")
-    private Integer httpsFlag;
-
-    @SerializedName(S3_CONNECTION_TIMEOUT)
-    @Param(description = "The connection timeout (milliseconds)")
-    private Integer connectionTimeout;
-
-    @SerializedName(S3_MAX_ERROR_RETRY)
-    @Param(description = "The maximum number of time to retry a connection on error.")
-    private Integer maxErrorRetry;
-
-    @SerializedName(S3_SOCKET_TIMEOUT)
-    @Param(description = "The connection socket (milliseconds)")
-    private Integer socketTimeout;
-
-    @Override
-    public boolean equals(final Object thatObject) {
-
-        if (this == thatObject) {
-            return true;
-        }
-
-        if (thatObject == null || this.getClass() != thatObject.getClass()) {
-            return false;
-        }
-
-        final S3Response thatS3Response = (S3Response) thatObject;
-
-        if (this.httpsFlag != null ? !this.httpsFlag.equals(thatS3Response.httpsFlag) : thatS3Response.httpsFlag != null) {
-            return false;
-        }
-
-        if (this.accessKey != null ? !this.accessKey.equals(thatS3Response.accessKey) : thatS3Response.accessKey != null) {
-            return false;
-        }
-
-        if (this.connectionTimeout != null ? !this.connectionTimeout.equals(thatS3Response.connectionTimeout) : thatS3Response.connectionTimeout != null) {
-            return false;
-        }
-
-        if (this.endPoint != null ? !this.endPoint.equals(thatS3Response.endPoint) : thatS3Response.endPoint != null) {
-            return false;
-        }
-
-        if (this.id != null ? !this.id.equals(thatS3Response.id) : thatS3Response.id != null) {
-            return false;
-        }
-
-        if (this.maxErrorRetry != null ? !this.maxErrorRetry.equals(thatS3Response.maxErrorRetry) : thatS3Response.maxErrorRetry != null) {
-            return false;
-        }
-
-        if (this.secretKey != null ? !this.secretKey.equals(thatS3Response.secretKey) : thatS3Response.secretKey != null) {
-            return false;
-        }
-
-        if (this.socketTimeout != null ? !this.socketTimeout.equals(thatS3Response.socketTimeout) : thatS3Response.socketTimeout != null) {
-            return false;
-        }
-
-        if (this.bucketName != null ? !this.bucketName.equals(thatS3Response.bucketName) : thatS3Response.bucketName != null) {
-            return false;
-        }
-
-        return true;
-
-    }
-
-    @Override
-    public int hashCode() {
-
-        int result = this.id != null ? this.id.hashCode() : 0;
-        result = 31 * result + (this.accessKey != null ? this.accessKey.hashCode() : 0);
-        result = 31 * result + (this.secretKey != null ? this.secretKey.hashCode() : 0);
-        result = 31 * result + (this.endPoint != null ? this.endPoint.hashCode() : 0);
-        result = 31 * result + (this.bucketName != null ? this.bucketName.hashCode() : 0);
-        result = 31 * result + (this.httpsFlag != null ? this.httpsFlag : 0);
-        result = 31 * result + (this.connectionTimeout != null ? this.connectionTimeout.hashCode() : 0);
-        result = 31 * result + (this.maxErrorRetry != null ? this.maxErrorRetry.hashCode() : 0);
-        result = 31 * result + (this.socketTimeout != null ? this.socketTimeout.hashCode() : 0);
-
-        return result;
-
-    }
-
-    @Override
-    public String getObjectId() {
-        return this.id.getValue().toString();
-    }
-
-    public void setObjectId(Long id) {
-        this.id.setValue(id);
-    }
-
-    public String getAccessKey() {
-        return this.accessKey;
-    }
-
-    public void setAccessKey(final String accessKey) {
-        this.accessKey = accessKey;
-    }
-
-    public String getSecretKey() {
-        return this.secretKey;
-    }
-
-    public void setSecretKey(final String secretKey) {
-        this.secretKey = secretKey;
-    }
-
-    public String getEndPoint() {
-        return this.endPoint;
-    }
-
-    public void setEndPoint(final String endPoint) {
-        this.endPoint = endPoint;
-    }
-
-
-    public String getTemplateBucketName() {
-        return this.bucketName;
-    }
-
-    public void setTemplateBucketName(final String templateBucketName) {
-        this.bucketName = templateBucketName;
-    }
-
-    public Integer getHttpsFlag() {
-        return this.httpsFlag;
-    }
-
-    public void setHttpsFlag(final Integer httpsFlag) {
-        this.httpsFlag = httpsFlag;
-    }
-
-    public Integer getConnectionTimeout() {
-        return this.connectionTimeout;
-    }
-
-    public void setConnectionTimeout(final Integer connectionTimeout) {
-        this.connectionTimeout = connectionTimeout;
-    }
-
-    public Integer getMaxErrorRetry() {
-        return this.maxErrorRetry;
-    }
-
-    public void setMaxErrorRetry(final Integer maxErrorRetry) {
-        this.maxErrorRetry = maxErrorRetry;
-    }
-
-    public Integer getSocketTimeout() {
-        return this.socketTimeout;
-    }
-
-    public void setSocketTimeout(final Integer socketTimeout) {
-        this.socketTimeout = socketTimeout;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/api/src/com/cloud/resource/ResourceService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/resource/ResourceService.java b/api/src/com/cloud/resource/ResourceService.java
index ade1012..b9db8e7 100755
--- a/api/src/com/cloud/resource/ResourceService.java
+++ b/api/src/com/cloud/resource/ResourceService.java
@@ -21,11 +21,11 @@ import java.util.List;
 import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
 import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
 import org.apache.cloudstack.api.command.admin.host.*;
+import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
+import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
 import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
 import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
 import org.apache.cloudstack.api.command.admin.host.PrepareForMaintenanceCmd;
-import com.cloud.api.commands.AddS3Cmd;
-import com.cloud.api.commands.ListS3sCmd;
 import com.cloud.exception.DiscoveryException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceInUseException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/api/src/org/apache/cloudstack/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
index 559a7ad..e9f988a 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -92,7 +92,7 @@ import org.apache.cloudstack.api.response.VpcResponse;
 import org.apache.cloudstack.api.response.VpnUsersResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 
-import com.cloud.api.response.S3Response;
+import org.apache.cloudstack.api.response.S3Response;
 
 import com.cloud.async.AsyncJob;
 import com.cloud.capacity.Capacity;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java
new file mode 100644
index 0000000..13f066a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.api.command.admin.storage;
+
+import static org.apache.cloudstack.api.ApiConstants.S3_ACCESS_KEY;
+import static org.apache.cloudstack.api.ApiConstants.S3_CONNECTION_TIMEOUT;
+import static org.apache.cloudstack.api.ApiConstants.S3_END_POINT;
+import static org.apache.cloudstack.api.ApiConstants.S3_HTTPS_FLAG;
+import static org.apache.cloudstack.api.ApiConstants.S3_MAX_ERROR_RETRY;
+import static org.apache.cloudstack.api.ApiConstants.S3_SECRET_KEY;
+import static org.apache.cloudstack.api.ApiConstants.S3_SOCKET_TIMEOUT;
+import static org.apache.cloudstack.api.ApiConstants.S3_BUCKET_NAME;
+import static org.apache.cloudstack.api.BaseCmd.CommandType.INTEGER;
+import static org.apache.cloudstack.api.BaseCmd.CommandType.STRING;
+import static org.apache.cloudstack.api.BaseCmd.CommandType.BOOLEAN;
+import static com.cloud.user.Account.ACCOUNT_ID_SYSTEM;
+
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.S3Response;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.DiscoveryException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.storage.S3;
+
+@APICommand(name = "addS3", description = "Adds S3", responseObject = S3Response.class, since = "4.0.0")
+public final class AddS3Cmd extends BaseCmd {
+
+    private static String COMMAND_NAME = "adds3response";
+
+    @Parameter(name = S3_ACCESS_KEY, type = STRING, required = true,
+            description = "S3 access key")
+    private String accessKey;
+
+    @Parameter(name = S3_SECRET_KEY, type = STRING, required = true,
+            description = "S3 secret key")
+    private String secretKey;
+
+    @Parameter(name = S3_END_POINT, type = STRING, required = false,
+            description = "S3 host name")
+    private String endPoint = null;
+
+    @Parameter(name = S3_BUCKET_NAME, type = STRING, required = true,
+            description = "name of the template storage bucket")
+    private String bucketName;
+
+    @Parameter(name = S3_HTTPS_FLAG, type = BOOLEAN, required = false,
+            description = "connect to the S3 endpoint via HTTPS?")
+    private Boolean httpsFlag = null;
+
+    @Parameter(name = S3_CONNECTION_TIMEOUT, type = INTEGER, required = false,
+            description = "connection timeout (milliseconds)")
+    private Integer connectionTimeout = null;
+
+    @Parameter(name = S3_MAX_ERROR_RETRY, type = INTEGER, required = false,
+            description = "maximum number of times to retry on error")
+    private Integer maxErrorRetry = null;
+
+    @Parameter(name = S3_SOCKET_TIMEOUT, type = INTEGER, required = false,
+            description = "socket timeout (milliseconds)")
+    private Integer socketTimeout = null;
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
+            ServerApiException, ConcurrentOperationException, ResourceAllocationException,
+            NetworkRuleConflictException {
+
+        final S3 result;
+
+        try {
+
+            result = _resourceService.discoverS3(this);
+
+            if (result == null) {
+                throw new ServerApiException(INTERNAL_ERROR, "Failed to add S3.");
+            }
+
+        } catch (DiscoveryException e) {
+
+            throw new ServerApiException(INTERNAL_ERROR, "Failed to add S3 due to " + e.getMessage());
+
+        }
+
+        final S3Response response = _responseGenerator.createS3Response(result);
+        response.setResponseName(this.getCommandName());
+        this.setResponseObject(response);
+
+    }
+
+    @Override
+    public boolean equals(final Object thatObject) {
+
+        if (this == thatObject) {
+            return true;
+        }
+
+        if (thatObject == null || this.getClass() != thatObject.getClass()) {
+            return false;
+        }
+
+        final AddS3Cmd thatAddS3Cmd = (AddS3Cmd) thatObject;
+
+        if (this.httpsFlag != null ? !this.httpsFlag.equals(thatAddS3Cmd.httpsFlag) : thatAddS3Cmd.httpsFlag != null) {
+            return false;
+        }
+
+        if (this.accessKey != null ? !this.accessKey.equals(thatAddS3Cmd.accessKey) : thatAddS3Cmd.accessKey != null) {
+            return false;
+        }
+
+        if (this.connectionTimeout != null ? !this.connectionTimeout.equals(thatAddS3Cmd.connectionTimeout) : thatAddS3Cmd.connectionTimeout != null) {
+            return false;
+        }
+
+        if (this.endPoint != null ? !this.endPoint.equals(thatAddS3Cmd.endPoint) : thatAddS3Cmd.endPoint != null) {
+            return false;
+        }
+
+        if (this.maxErrorRetry != null ? !this.maxErrorRetry.equals(thatAddS3Cmd.maxErrorRetry) : thatAddS3Cmd.maxErrorRetry != null) {
+            return false;
+        }
+
+        if (this.secretKey != null ? !this.secretKey.equals(thatAddS3Cmd.secretKey) : thatAddS3Cmd.secretKey != null) {
+            return false;
+        }
+
+        if (this.socketTimeout != null ? !this.socketTimeout.equals(thatAddS3Cmd.socketTimeout) : thatAddS3Cmd.socketTimeout != null) {
+            return false;
+        }
+
+        if (this.bucketName != null ? !this.bucketName.equals(thatAddS3Cmd.bucketName) : thatAddS3Cmd.bucketName != null) {
+            return false;
+        }
+
+        return true;
+
+    }
+
+    @Override
+    public int hashCode() {
+
+        int result = this.accessKey != null ? this.accessKey.hashCode() : 0;
+        result = 31 * result + (this.secretKey != null ? this.secretKey.hashCode() : 0);
+        result = 31 * result + (this.endPoint != null ? this.endPoint.hashCode() : 0);
+        result = 31 * result + (this.bucketName != null ? this.bucketName.hashCode() : 0);
+        result = 31 * result + (this.httpsFlag != null && this.httpsFlag == true ? 1 : 0);
+        result = 31 * result + (this.connectionTimeout != null ? this.connectionTimeout.hashCode() : 0);
+        result = 31 * result + (this.maxErrorRetry != null ? this.maxErrorRetry.hashCode() : 0);
+        result = 31 * result + (this.socketTimeout != null ? this.socketTimeout.hashCode() : 0);
+
+        return result;
+
+    }
+
+    @Override
+    public String getCommandName() {
+        return COMMAND_NAME;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return ACCOUNT_ID_SYSTEM;
+    }
+
+    public String getAccessKey() {
+        return this.accessKey;
+    }
+
+    public String getSecretKey() {
+        return this.secretKey;
+    }
+
+    public String getEndPoint() {
+        return this.endPoint;
+    }
+
+    public String getBucketName() {
+        return this.bucketName;
+    }
+
+    public Boolean getHttpsFlag() {
+        return this.httpsFlag;
+    }
+
+    public Integer getConnectionTimeout() {
+        return this.connectionTimeout;
+    }
+
+    public Integer getMaxErrorRetry() {
+        return this.maxErrorRetry;
+    }
+
+    public Integer getSocketTimeout() {
+        return this.socketTimeout;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/api/src/org/apache/cloudstack/api/command/admin/storage/ListS3sCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/ListS3sCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/ListS3sCmd.java
new file mode 100644
index 0000000..d0f6d72
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/ListS3sCmd.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.api.command.admin.storage;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.S3Response;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.storage.S3;
+
+@APICommand(name = "listS3s", description = "Lists S3s", responseObject = S3Response.class, since = "4.0.0")
+public final class ListS3sCmd extends BaseListCmd {
+
+    private static final String COMMAND_NAME = "lists3sresponse";
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
+            ServerApiException, ConcurrentOperationException, ResourceAllocationException,
+            NetworkRuleConflictException {
+
+        final List<? extends S3> result = _resourceService.listS3s(this);
+        final ListResponse<S3Response> response = new ListResponse<S3Response>();
+        final List<S3Response> s3Responses = new ArrayList<S3Response>();
+
+        if (result != null) {
+
+            for (S3 s3 : result) {
+
+                S3Response s3Response = _responseGenerator.createS3Response(s3);
+                s3Response.setResponseName(this.getCommandName());
+                s3Response.setObjectName("s3");
+                s3Responses.add(s3Response);
+
+            }
+
+        }
+
+        response.setResponses(s3Responses);
+        response.setResponseName(this.getCommandName());
+
+        this.setResponseObject(response);
+
+    }
+
+    @Override
+    public String getCommandName() {
+        return COMMAND_NAME;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/api/src/org/apache/cloudstack/api/response/S3Response.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/S3Response.java b/api/src/org/apache/cloudstack/api/response/S3Response.java
new file mode 100644
index 0000000..5dd0ef0
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/S3Response.java
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.api.response;
+
+import com.cloud.serializer.Param;
+import com.cloud.utils.IdentityProxy;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.BaseResponse;
+
+import static org.apache.cloudstack.api.ApiConstants.*;
+
+public class S3Response extends BaseResponse {
+
+    @SerializedName(ID)
+    @Param(description = "The ID of the S3 configuration")
+    private IdentityProxy id = new IdentityProxy("s3");
+
+    @SerializedName(S3_ACCESS_KEY)
+    @Param(description = "The S3 access key")
+    private String accessKey;
+
+    @SerializedName(S3_SECRET_KEY)
+    @Param(description = "The S3 secret key")
+    private String secretKey;
+
+    @SerializedName(S3_END_POINT)
+    @Param(description = "The S3 end point")
+    private String endPoint;
+
+    @SerializedName(S3_BUCKET_NAME)
+    @Param(description = "The name of the template storage bucket")
+    private String bucketName;
+
+    @SerializedName(S3_HTTPS_FLAG)
+    @Param(description = "Connect to S3 using HTTPS?")
+    private Integer httpsFlag;
+
+    @SerializedName(S3_CONNECTION_TIMEOUT)
+    @Param(description = "The connection timeout (milliseconds)")
+    private Integer connectionTimeout;
+
+    @SerializedName(S3_MAX_ERROR_RETRY)
+    @Param(description = "The maximum number of time to retry a connection on error.")
+    private Integer maxErrorRetry;
+
+    @SerializedName(S3_SOCKET_TIMEOUT)
+    @Param(description = "The connection socket (milliseconds)")
+    private Integer socketTimeout;
+
+    @Override
+    public boolean equals(final Object thatObject) {
+
+        if (this == thatObject) {
+            return true;
+        }
+
+        if (thatObject == null || this.getClass() != thatObject.getClass()) {
+            return false;
+        }
+
+        final S3Response thatS3Response = (S3Response) thatObject;
+
+        if (this.httpsFlag != null ? !this.httpsFlag.equals(thatS3Response.httpsFlag) : thatS3Response.httpsFlag != null) {
+            return false;
+        }
+
+        if (this.accessKey != null ? !this.accessKey.equals(thatS3Response.accessKey) : thatS3Response.accessKey != null) {
+            return false;
+        }
+
+        if (this.connectionTimeout != null ? !this.connectionTimeout.equals(thatS3Response.connectionTimeout) : thatS3Response.connectionTimeout != null) {
+            return false;
+        }
+
+        if (this.endPoint != null ? !this.endPoint.equals(thatS3Response.endPoint) : thatS3Response.endPoint != null) {
+            return false;
+        }
+
+        if (this.id != null ? !this.id.equals(thatS3Response.id) : thatS3Response.id != null) {
+            return false;
+        }
+
+        if (this.maxErrorRetry != null ? !this.maxErrorRetry.equals(thatS3Response.maxErrorRetry) : thatS3Response.maxErrorRetry != null) {
+            return false;
+        }
+
+        if (this.secretKey != null ? !this.secretKey.equals(thatS3Response.secretKey) : thatS3Response.secretKey != null) {
+            return false;
+        }
+
+        if (this.socketTimeout != null ? !this.socketTimeout.equals(thatS3Response.socketTimeout) : thatS3Response.socketTimeout != null) {
+            return false;
+        }
+
+        if (this.bucketName != null ? !this.bucketName.equals(thatS3Response.bucketName) : thatS3Response.bucketName != null) {
+            return false;
+        }
+
+        return true;
+
+    }
+
+    @Override
+    public int hashCode() {
+
+        int result = this.id != null ? this.id.hashCode() : 0;
+        result = 31 * result + (this.accessKey != null ? this.accessKey.hashCode() : 0);
+        result = 31 * result + (this.secretKey != null ? this.secretKey.hashCode() : 0);
+        result = 31 * result + (this.endPoint != null ? this.endPoint.hashCode() : 0);
+        result = 31 * result + (this.bucketName != null ? this.bucketName.hashCode() : 0);
+        result = 31 * result + (this.httpsFlag != null ? this.httpsFlag : 0);
+        result = 31 * result + (this.connectionTimeout != null ? this.connectionTimeout.hashCode() : 0);
+        result = 31 * result + (this.maxErrorRetry != null ? this.maxErrorRetry.hashCode() : 0);
+        result = 31 * result + (this.socketTimeout != null ? this.socketTimeout.hashCode() : 0);
+
+        return result;
+
+    }
+
+    @Override
+    public String getObjectId() {
+        return this.id.getValue().toString();
+    }
+
+    public void setObjectId(Long id) {
+        this.id.setValue(id);
+    }
+
+    public String getAccessKey() {
+        return this.accessKey;
+    }
+
+    public void setAccessKey(final String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getSecretKey() {
+        return this.secretKey;
+    }
+
+    public void setSecretKey(final String secretKey) {
+        this.secretKey = secretKey;
+    }
+
+    public String getEndPoint() {
+        return this.endPoint;
+    }
+
+    public void setEndPoint(final String endPoint) {
+        this.endPoint = endPoint;
+    }
+
+
+    public String getTemplateBucketName() {
+        return this.bucketName;
+    }
+
+    public void setTemplateBucketName(final String templateBucketName) {
+        this.bucketName = templateBucketName;
+    }
+
+    public Integer getHttpsFlag() {
+        return this.httpsFlag;
+    }
+
+    public void setHttpsFlag(final Integer httpsFlag) {
+        this.httpsFlag = httpsFlag;
+    }
+
+    public Integer getConnectionTimeout() {
+        return this.connectionTimeout;
+    }
+
+    public void setConnectionTimeout(final Integer connectionTimeout) {
+        this.connectionTimeout = connectionTimeout;
+    }
+
+    public Integer getMaxErrorRetry() {
+        return this.maxErrorRetry;
+    }
+
+    public void setMaxErrorRetry(final Integer maxErrorRetry) {
+        this.maxErrorRetry = maxErrorRetry;
+    }
+
+    public Integer getSocketTimeout() {
+        return this.socketTimeout;
+    }
+
+    public void setSocketTimeout(final Integer socketTimeout) {
+        this.socketTimeout = socketTimeout;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index fdd594e..72cdb4b 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -229,8 +229,8 @@ addSwift=org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;1
 listSwifts=org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;1
 
 #### s3 commands
-addS3=com.cloud.api.commands.AddS3Cmd;1
-listS3s=com.cloud.api.commands.ListS3sCmd;1
+addS3=org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;1
+listS3s=org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;1
 
 #### host commands
 addHost=org.apache.cloudstack.api.command.admin.host.AddHostCmd;3

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 21b2c2e..ebe7abb 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -21,11 +21,9 @@ import static java.util.Collections.singletonList;
 
 import java.text.DecimalFormat;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -33,8 +31,6 @@ import java.util.StringTokenizer;
 
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.ResponseGenerator;
-import org.apache.cloudstack.api.ResponseObject;
-import org.apache.cloudstack.api.ServerApiException;
 import org.apache.log4j.Logger;
 
 import com.cloud.acl.ControlledEntity;
@@ -134,14 +130,13 @@ import org.apache.cloudstack.api.response.VpcResponse;
 import org.apache.cloudstack.api.response.VpnUsersResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 
-import com.cloud.api.response.S3Response;
+import org.apache.cloudstack.api.response.S3Response;
 import com.cloud.async.AsyncJob;
 import com.cloud.capacity.Capacity;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
 import com.cloud.configuration.Configuration;
 import com.cloud.configuration.Resource.ResourceOwnerType;
-import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.configuration.ResourceCount;
 import com.cloud.configuration.ResourceLimit;
 import com.cloud.dc.ClusterVO;
@@ -156,7 +151,6 @@ import com.cloud.dc.VlanVO;
 import com.cloud.domain.Domain;
 import com.cloud.event.Event;
 import com.cloud.host.Host;
-import com.cloud.host.HostStats;
 import com.cloud.host.HostVO;
 import com.cloud.hypervisor.HypervisorCapabilities;
 import com.cloud.network.IPAddressVO;
@@ -174,23 +168,17 @@ import com.cloud.network.PhysicalNetworkTrafficType;
 import com.cloud.network.PhysicalNetworkVO;
 import com.cloud.network.RemoteAccessVpn;
 import com.cloud.network.Site2SiteCustomerGateway;
-import com.cloud.network.Site2SiteCustomerGatewayVO;
 import com.cloud.network.Site2SiteVpnConnection;
 import com.cloud.network.Site2SiteVpnGateway;
-import com.cloud.network.Site2SiteVpnGatewayVO;
 import com.cloud.network.VirtualRouterProvider;
 import com.cloud.network.VpnUser;
 import com.cloud.network.as.AutoScalePolicy;
-import com.cloud.network.as.AutoScalePolicyVO;
 import com.cloud.network.as.AutoScaleVmGroup;
-import com.cloud.network.as.AutoScaleVmGroupVO;
 import com.cloud.network.as.AutoScaleVmProfile;
 import com.cloud.network.as.AutoScaleVmProfileVO;
 import com.cloud.network.as.Condition;
 import com.cloud.network.as.ConditionVO;
 import com.cloud.network.as.Counter;
-import com.cloud.network.as.CounterVO;
-import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.FirewallRuleVO;
@@ -203,11 +191,8 @@ import com.cloud.network.security.SecurityRule;
 import com.cloud.network.security.SecurityRule.SecurityRuleType;
 import com.cloud.network.vpc.PrivateGateway;
 import com.cloud.network.vpc.StaticRoute;
-import com.cloud.network.vpc.StaticRouteVO;
 import com.cloud.network.vpc.Vpc;
-import com.cloud.network.vpc.VpcGatewayVO;
 import com.cloud.network.vpc.VpcOffering;
-import com.cloud.network.vpc.VpcVO;
 import com.cloud.offering.DiskOffering;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
@@ -218,12 +203,10 @@ import com.cloud.projects.ProjectInvitation;
 import com.cloud.server.Criteria;
 import com.cloud.server.ResourceTag;
 import com.cloud.server.ResourceTag.TaggedResourceType;
-import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.GuestOS;
 import com.cloud.storage.GuestOSCategoryVO;
 import com.cloud.storage.S3;
 import com.cloud.storage.Snapshot;
-import com.cloud.storage.Storage;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.Storage.TemplateType;
@@ -242,13 +225,10 @@ import com.cloud.storage.VolumeVO;
 import com.cloud.storage.snapshot.SnapshotPolicy;
 import com.cloud.storage.snapshot.SnapshotSchedule;
 import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.test.PodZoneConfig;
 import com.cloud.user.Account;
 import com.cloud.user.User;
 import com.cloud.user.UserAccount;
 import com.cloud.user.UserContext;
-import com.cloud.user.UserStatisticsVO;
-import com.cloud.user.UserVO;
 import com.cloud.uservm.UserVm;
 import com.cloud.utils.Pair;
 import com.cloud.utils.StringUtils;
@@ -256,9 +236,7 @@ import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.ConsoleProxyVO;
 import com.cloud.vm.InstanceGroup;
 import com.cloud.vm.NicProfile;
-import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachine.State;
 import com.cloud.vm.VirtualMachine.Type;
 
 public class ApiResponseHelper implements ResponseGenerator {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index db01c3d..ffc09f0 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -31,12 +31,12 @@ import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
+import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
 import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
 import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
 import org.apache.cloudstack.api.command.admin.host.*;
 import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
-import com.cloud.api.commands.AddS3Cmd;
-import com.cloud.api.commands.ListS3sCmd;
+import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
 import com.cloud.storage.S3;
 import com.cloud.storage.S3VO;
 import com.cloud.storage.s3.S3Manager;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/server/src/com/cloud/storage/s3/S3Manager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/s3/S3Manager.java b/server/src/com/cloud/storage/s3/S3Manager.java
index 357f2ae..0e47d72 100644
--- a/server/src/com/cloud/storage/s3/S3Manager.java
+++ b/server/src/com/cloud/storage/s3/S3Manager.java
@@ -21,8 +21,8 @@ package com.cloud.storage.s3;
 import java.util.List;
 
 import com.cloud.agent.api.to.S3TO;
-import com.cloud.api.commands.AddS3Cmd;
-import com.cloud.api.commands.ListS3sCmd;
+import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
+import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
 import com.cloud.dc.DataCenterVO;
 import com.cloud.exception.DiscoveryException;
 import com.cloud.storage.S3;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f07a98a7/server/src/com/cloud/storage/s3/S3ManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/s3/S3ManagerImpl.java b/server/src/com/cloud/storage/s3/S3ManagerImpl.java
index 0da11ff..1db809b 100644
--- a/server/src/com/cloud/storage/s3/S3ManagerImpl.java
+++ b/server/src/com/cloud/storage/s3/S3ManagerImpl.java
@@ -44,6 +44,7 @@ import java.util.concurrent.Callable;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.command.admin.storage.AddS3Cmd;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
@@ -52,8 +53,7 @@ import com.cloud.agent.api.DeleteTemplateFromS3Command;
 import com.cloud.agent.api.DownloadTemplateFromS3ToSecondaryStorageCommand;
 import com.cloud.agent.api.UploadTemplateToS3FromSecondaryStorageCommand;
 import com.cloud.agent.api.to.S3TO;
-import com.cloud.api.commands.AddS3Cmd;
-import com.cloud.api.commands.ListS3sCmd;
+import org.apache.cloudstack.api.command.admin.storage.ListS3sCmd;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.DataCenterVO;