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/06 00:57:39 UTC
[2/5] git commit: api: Refactor move storagepool apis to storage pkg
api: Refactor move storagepool apis to storage pkg
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/73a0c3e0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/73a0c3e0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/73a0c3e0
Branch: refs/heads/api_refactoring
Commit: 73a0c3e07f41425cbeede88a2784bd9eb54b2f00
Parents: f07a98a
Author: Rohit Yadav <bh...@apache.org>
Authored: Sat Jan 5 15:32:58 2013 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Sat Jan 5 15:32:58 2013 -0800
----------------------------------------------------------------------
api/src/com/cloud/server/ManagementService.java | 2 +-
api/src/com/cloud/storage/StorageService.java | 10 +-
.../CancelPrimaryStorageMaintenanceCmd.java | 113 ++++++++++++
.../admin/storage/CreateStoragePoolCmd.java | 138 +++++++++++++++
.../api/command/admin/storage/DeletePoolCmd.java | 87 +++++++++
.../command/admin/storage/ListStoragePoolsCmd.java | 132 ++++++++++++++
.../PreparePrimaryStorageForMaintenanceCmd.java | 111 ++++++++++++
.../admin/storage/UpdateStoragePoolCmd.java | 84 +++++++++
.../CancelPrimaryStorageMaintenanceCmd.java | 113 ------------
.../admin/storagepool/CreateStoragePoolCmd.java | 138 ---------------
.../command/admin/storagepool/DeletePoolCmd.java | 87 ---------
.../admin/storagepool/ListStoragePoolsCmd.java | 132 --------------
.../PreparePrimaryStorageForMaintenanceCmd.java | 111 ------------
.../admin/storagepool/UpdateStoragePoolCmd.java | 84 ---------
client/tomcatconf/commands.properties.in | 12 +-
.../src/com/cloud/server/ManagementServerImpl.java | 14 +--
.../src/com/cloud/storage/StorageManagerImpl.java | 12 +-
17 files changed, 678 insertions(+), 702 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/com/cloud/server/ManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index cacf5cf..e547954 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -30,7 +30,7 @@ import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
import org.apache.cloudstack.api.command.admin.resource.ListCapacityCmd;
import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd;
-import org.apache.cloudstack.api.command.admin.storagepool.ListStoragePoolsCmd;
+import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
import org.apache.cloudstack.api.command.admin.systemvm.*;
import org.apache.cloudstack.api.command.admin.vlan.ListVlanIpRangesCmd;
import org.apache.cloudstack.api.command.user.address.ListPublicIpAddressesCmd;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/com/cloud/storage/StorageService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/StorageService.java b/api/src/com/cloud/storage/StorageService.java
index 1967cba..ff8ec13 100644
--- a/api/src/com/cloud/storage/StorageService.java
+++ b/api/src/com/cloud/storage/StorageService.java
@@ -17,14 +17,11 @@
package com.cloud.storage;
import java.net.UnknownHostException;
-import java.util.List;
-import org.apache.cloudstack.api.command.admin.storagepool.CancelPrimaryStorageMaintenanceCmd;
-import org.apache.cloudstack.api.command.admin.storagepool.CreateStoragePoolCmd;
-import org.apache.cloudstack.api.command.admin.storagepool.DeletePoolCmd;
-import org.apache.cloudstack.api.command.admin.storagepool.UpdateStoragePoolCmd;
+import org.apache.cloudstack.api.command.admin.storage.*;
+import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
+import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
-import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
@@ -33,7 +30,6 @@ import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
-import com.cloud.utils.Pair;
public interface StorageService{
/**
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java
new file mode 100644
index 0000000..24ef48b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java
@@ -0,0 +1,113 @@
+// 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 org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+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.StoragePoolResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.storage.StoragePool;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "cancelStorageMaintenance", description="Cancels maintenance for primary storage", responseObject=StoragePoolResponse.class)
+public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(CancelPrimaryStorageMaintenanceCmd.class.getName());
+
+ private static final String s_name = "cancelprimarystoragemaintenanceresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = StoragePoolResponse.class,
+ required=true, description="the primary storage ID")
+ private Long id;
+
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public static String getResultObjectName() {
+ return "primarystorage";
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.StoragePool;
+ }
+
+ @Override
+ public Long getInstanceId() {
+ return getId();
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account account = UserContext.current().getCaller();
+ if (account != null) {
+ return account.getId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_MAINTENANCE_CANCEL_PRIMARY_STORAGE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "canceling maintenance for primary storage pool: " + getId();
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException{
+ StoragePool result = _storageService.cancelPrimaryStorageForMaintenance(this);
+ if (result != null) {
+ StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel primary storage maintenance");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java
new file mode 100644
index 0000000..78a142a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java
@@ -0,0 +1,138 @@
+// 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.net.UnknownHostException;
+import java.util.Map;
+
+import org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.response.ClusterResponse;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.StoragePoolResponse;
+import com.cloud.exception.ResourceInUseException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.storage.StoragePool;
+import com.cloud.user.Account;
+
+@SuppressWarnings("rawtypes")
+@APICommand(name = "createStoragePool", description="Creates a storage pool.", responseObject=StoragePoolResponse.class)
+public class CreateStoragePoolCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(CreateStoragePoolCmd.class.getName());
+
+ private static final String s_name = "createstoragepoolresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType = ClusterResponse.class,
+ required=true, description="the cluster ID for the storage pool")
+ private Long clusterId;
+
+ @Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="the details for the storage pool")
+ private Map details;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name for the storage pool")
+ private String storagePoolName;
+
+ @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType = PodResponse.class,
+ required=true, description="the Pod ID for the storage pool")
+ private Long podId;
+
+ @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for the storage pool")
+ private String tags;
+
+ @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL of the storage pool")
+ private String url;
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
+ required=true, description="the Zone ID for the storage pool")
+ private Long zoneId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getClusterId() {
+ return clusterId;
+ }
+
+ public Map getDetails() {
+ return details;
+ }
+
+ public String getStoragePoolName() {
+ return storagePoolName;
+ }
+
+ public Long getPodId() {
+ return podId;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ try {
+ StoragePool result = _storageService.createPool(this);
+ if (result != null) {
+ StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add storage pool");
+ }
+ } catch (ResourceUnavailableException ex1) {
+ s_logger.warn("Exception: ", ex1);
+ throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex1.getMessage());
+ }catch (ResourceInUseException ex2) {
+ s_logger.warn("Exception: ", ex2);
+ throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex2.getMessage());
+ } catch (UnknownHostException ex3) {
+ s_logger.warn("Exception: ", ex3);
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex3.getMessage());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storage/DeletePoolCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/DeletePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/DeletePoolCmd.java
new file mode 100644
index 0000000..1510f78
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/DeletePoolCmd.java
@@ -0,0 +1,87 @@
+// 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 org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.response.StoragePoolResponse;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.StoragePoolStatus;
+import com.cloud.user.Account;
+
+@APICommand(name = "deleteStoragePool", description = "Deletes a storage pool.", responseObject = SuccessResponse.class)
+public class DeletePoolCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(DeletePoolCmd.class.getName());
+ private static final String s_name = "deletestoragepoolresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = StoragePoolResponse.class,
+ required = true, description = "Storage pool id")
+ private Long id;
+
+ @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force destroy storage pool " +
+ "(force expunge volumes in Destroyed state as a part of pool removal)")
+ private Boolean forced;
+
+ // ///////////////////////////////////////////////////
+ // ///////////////// Accessors ///////////////////////
+ // ///////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public boolean isForced() {
+ return (forced != null) ? forced : false;
+ }
+
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute() {
+ boolean result = _storageService.deletePool(this);
+ if (result) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ StoragePool pool = _storageService.getStoragePool(id);
+ if (pool != null && pool.getStatus() == StoragePoolStatus.Removed) {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to finish storage pool removal. The storage pool will not be used but cleanup is needed");
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete storage pool");
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java
new file mode 100644
index 0000000..3723f8b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java
@@ -0,0 +1,132 @@
+// 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.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ClusterResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.StoragePoolResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.storage.StoragePool;
+import com.cloud.utils.Pair;
+
+@APICommand(name = "listStoragePools", description="Lists storage pools.", responseObject=StoragePoolResponse.class)
+public class ListStoragePoolsCmd extends BaseListCmd {
+ public static final Logger s_logger = Logger.getLogger(ListStoragePoolsCmd.class.getName());
+
+ private static final String s_name = "liststoragepoolsresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType = ClusterResponse.class,
+ description="list storage pools belongig to the specific cluster")
+ private Long clusterId;
+
+ @Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="the IP address for the storage pool")
+ private String ipAddress;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the storage pool")
+ private String storagePoolName;
+
+ @Parameter(name=ApiConstants.PATH, type=CommandType.STRING, description="the storage pool path")
+ private String path;
+
+ @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType = PodResponse.class,
+ description="the Pod ID for the storage pool")
+ private Long podId;
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
+ description="the Zone ID for the storage pool")
+ private Long zoneId;
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = StoragePoolResponse.class,
+ description="the ID of the storage pool")
+ private Long id;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getClusterId() {
+ return clusterId;
+ }
+
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ public String getStoragePoolName() {
+ return storagePoolName;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public Long getPodId() {
+ return podId;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.StoragePool;
+ }
+
+ @Override
+ public void execute(){
+ Pair<List<? extends StoragePool>, Integer> pools = _mgr.searchForStoragePools(this);
+ ListResponse<StoragePoolResponse> response = new ListResponse<StoragePoolResponse>();
+ List<StoragePoolResponse> poolResponses = new ArrayList<StoragePoolResponse>();
+ for (StoragePool pool : pools.first()) {
+ StoragePoolResponse poolResponse = _responseGenerator.createStoragePoolResponse(pool);
+ poolResponse.setObjectName("storagepool");
+ poolResponses.add(poolResponse);
+ }
+
+ response.setResponses(poolResponses, pools.second());
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java
new file mode 100644
index 0000000..6a41755
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java
@@ -0,0 +1,111 @@
+// 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 org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+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.StoragePoolResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.storage.StoragePool;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "enableStorageMaintenance", description="Puts storage pool into maintenance state", responseObject=StoragePoolResponse.class)
+public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(PreparePrimaryStorageForMaintenanceCmd.class.getName());
+ private static final String s_name = "prepareprimarystorageformaintenanceresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = StoragePoolResponse.class,
+ required=true, description="Primary storage ID")
+ private Long id;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public static String getResultObjectName() {
+ return "primarystorage";
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.StoragePool;
+ }
+
+ @Override
+ public Long getInstanceId() {
+ return getId();
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account account = UserContext.current().getCaller();
+ if (account != null) {
+ return account.getId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_MAINTENANCE_PREPARE_PRIMARY_STORAGE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "preparing storage pool: " + getId() + " for maintenance";
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException{
+ StoragePool result = _storageService.preparePrimaryStorageForMaintenance(getId());
+ if (result != null){
+ StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
+ response.setResponseName("storagepool");
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to prepare primary storage for maintenance");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java
new file mode 100644
index 0000000..806df56
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java
@@ -0,0 +1,84 @@
+// 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.List;
+
+import org.apache.cloudstack.api.*;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.StoragePoolResponse;
+import com.cloud.storage.StoragePool;
+import com.cloud.user.Account;
+
+@APICommand(name = "updateStoragePool", description="Updates a storage pool.", responseObject=StoragePoolResponse.class, since="3.0.0")
+public class UpdateStoragePoolCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdateStoragePoolCmd.class.getName());
+
+ private static final String s_name = "updatestoragepoolresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = StoragePoolResponse.class,
+ required=true, description="the Id of the storage pool")
+ private Long id;
+
+ @Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma-separated list of tags for the storage pool")
+ private List<String> tags;
+
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public List<String> getTags() {
+ return tags;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ StoragePool result = _storageService.updateStoragePool(this);
+ if (result != null){
+ StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update storage pool");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storagepool/CancelPrimaryStorageMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storagepool/CancelPrimaryStorageMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storagepool/CancelPrimaryStorageMaintenanceCmd.java
deleted file mode 100644
index 4d62184..0000000
--- a/api/src/org/apache/cloudstack/api/command/admin/storagepool/CancelPrimaryStorageMaintenanceCmd.java
+++ /dev/null
@@ -1,113 +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 org.apache.cloudstack.api.command.admin.storagepool;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-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.StoragePoolResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.storage.StoragePool;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@APICommand(name = "cancelStorageMaintenance", description="Cancels maintenance for primary storage", responseObject=StoragePoolResponse.class)
-public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(CancelPrimaryStorageMaintenanceCmd.class.getName());
-
- private static final String s_name = "cancelprimarystoragemaintenanceresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = StoragePoolResponse.class,
- required=true, description="the primary storage ID")
- private Long id;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "primarystorage";
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.StoragePool;
- }
-
- @Override
- public Long getInstanceId() {
- return getId();
- }
-
- @Override
- public long getEntityOwnerId() {
- Account account = UserContext.current().getCaller();
- if (account != null) {
- return account.getId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_MAINTENANCE_CANCEL_PRIMARY_STORAGE;
- }
-
- @Override
- public String getEventDescription() {
- return "canceling maintenance for primary storage pool: " + getId();
- }
-
- @Override
- public void execute() throws ResourceUnavailableException{
- StoragePool result = _storageService.cancelPrimaryStorageForMaintenance(this);
- if (result != null) {
- StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel primary storage maintenance");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storagepool/CreateStoragePoolCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storagepool/CreateStoragePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storagepool/CreateStoragePoolCmd.java
deleted file mode 100644
index 3520017..0000000
--- a/api/src/org/apache/cloudstack/api/command/admin/storagepool/CreateStoragePoolCmd.java
+++ /dev/null
@@ -1,138 +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 org.apache.cloudstack.api.command.admin.storagepool;
-
-import java.net.UnknownHostException;
-import java.util.Map;
-
-import org.apache.cloudstack.api.*;
-import org.apache.cloudstack.api.response.ClusterResponse;
-import org.apache.cloudstack.api.response.PodResponse;
-import org.apache.cloudstack.api.response.ZoneResponse;
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.response.StoragePoolResponse;
-import com.cloud.exception.ResourceInUseException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.storage.StoragePool;
-import com.cloud.user.Account;
-
-@SuppressWarnings("rawtypes")
-@APICommand(name = "createStoragePool", description="Creates a storage pool.", responseObject=StoragePoolResponse.class)
-public class CreateStoragePoolCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(CreateStoragePoolCmd.class.getName());
-
- private static final String s_name = "createstoragepoolresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType = ClusterResponse.class,
- required=true, description="the cluster ID for the storage pool")
- private Long clusterId;
-
- @Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="the details for the storage pool")
- private Map details;
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name for the storage pool")
- private String storagePoolName;
-
- @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType = PodResponse.class,
- required=true, description="the Pod ID for the storage pool")
- private Long podId;
-
- @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for the storage pool")
- private String tags;
-
- @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL of the storage pool")
- private String url;
-
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
- required=true, description="the Zone ID for the storage pool")
- private Long zoneId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getClusterId() {
- return clusterId;
- }
-
- public Map getDetails() {
- return details;
- }
-
- public String getStoragePoolName() {
- return storagePoolName;
- }
-
- public Long getPodId() {
- return podId;
- }
-
- public String getTags() {
- return tags;
- }
-
- public String getUrl() {
- return url;
- }
-
- public Long getZoneId() {
- return zoneId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- try {
- StoragePool result = _storageService.createPool(this);
- if (result != null) {
- StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add storage pool");
- }
- } catch (ResourceUnavailableException ex1) {
- s_logger.warn("Exception: ", ex1);
- throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex1.getMessage());
- }catch (ResourceInUseException ex2) {
- s_logger.warn("Exception: ", ex2);
- throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex2.getMessage());
- } catch (UnknownHostException ex3) {
- s_logger.warn("Exception: ", ex3);
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex3.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storagepool/DeletePoolCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storagepool/DeletePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storagepool/DeletePoolCmd.java
deleted file mode 100644
index 6b45e3e..0000000
--- a/api/src/org/apache/cloudstack/api/command/admin/storagepool/DeletePoolCmd.java
+++ /dev/null
@@ -1,87 +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 org.apache.cloudstack.api.command.admin.storagepool;
-
-import org.apache.cloudstack.api.*;
-import org.apache.cloudstack.api.response.StoragePoolResponse;
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.response.SuccessResponse;
-import com.cloud.storage.StoragePool;
-import com.cloud.storage.StoragePoolStatus;
-import com.cloud.user.Account;
-
-@APICommand(name = "deleteStoragePool", description = "Deletes a storage pool.", responseObject = SuccessResponse.class)
-public class DeletePoolCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(DeletePoolCmd.class.getName());
- private static final String s_name = "deletestoragepoolresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = StoragePoolResponse.class,
- required = true, description = "Storage pool id")
- private Long id;
-
- @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force destroy storage pool " +
- "(force expunge volumes in Destroyed state as a part of pool removal)")
- private Boolean forced;
-
- // ///////////////////////////////////////////////////
- // ///////////////// Accessors ///////////////////////
- // ///////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- public boolean isForced() {
- return (forced != null) ? forced : false;
- }
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute() {
- boolean result = _storageService.deletePool(this);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- StoragePool pool = _storageService.getStoragePool(id);
- if (pool != null && pool.getStatus() == StoragePoolStatus.Removed) {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to finish storage pool removal. The storage pool will not be used but cleanup is needed");
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete storage pool");
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storagepool/ListStoragePoolsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storagepool/ListStoragePoolsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storagepool/ListStoragePoolsCmd.java
deleted file mode 100644
index 2ba3bbb..0000000
--- a/api/src/org/apache/cloudstack/api/command/admin/storagepool/ListStoragePoolsCmd.java
+++ /dev/null
@@ -1,132 +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 org.apache.cloudstack.api.command.admin.storagepool;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.cloudstack.api.APICommand;
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.response.ClusterResponse;
-import org.apache.cloudstack.api.response.ListResponse;
-import org.apache.cloudstack.api.response.PodResponse;
-import org.apache.cloudstack.api.response.StoragePoolResponse;
-import org.apache.cloudstack.api.response.ZoneResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.storage.StoragePool;
-import com.cloud.utils.Pair;
-
-@APICommand(name = "listStoragePools", description="Lists storage pools.", responseObject=StoragePoolResponse.class)
-public class ListStoragePoolsCmd extends BaseListCmd {
- public static final Logger s_logger = Logger.getLogger(ListStoragePoolsCmd.class.getName());
-
- private static final String s_name = "liststoragepoolsresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.UUID, entityType = ClusterResponse.class,
- description="list storage pools belongig to the specific cluster")
- private Long clusterId;
-
- @Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="the IP address for the storage pool")
- private String ipAddress;
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the storage pool")
- private String storagePoolName;
-
- @Parameter(name=ApiConstants.PATH, type=CommandType.STRING, description="the storage pool path")
- private String path;
-
- @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType = PodResponse.class,
- description="the Pod ID for the storage pool")
- private Long podId;
-
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
- description="the Zone ID for the storage pool")
- private Long zoneId;
-
- @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = StoragePoolResponse.class,
- description="the ID of the storage pool")
- private Long id;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getClusterId() {
- return clusterId;
- }
-
- public String getIpAddress() {
- return ipAddress;
- }
-
- public String getStoragePoolName() {
- return storagePoolName;
- }
-
- public String getPath() {
- return path;
- }
-
- public Long getPodId() {
- return podId;
- }
-
- public Long getZoneId() {
- return zoneId;
- }
-
- public Long getId() {
- return id;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.StoragePool;
- }
-
- @Override
- public void execute(){
- Pair<List<? extends StoragePool>, Integer> pools = _mgr.searchForStoragePools(this);
- ListResponse<StoragePoolResponse> response = new ListResponse<StoragePoolResponse>();
- List<StoragePoolResponse> poolResponses = new ArrayList<StoragePoolResponse>();
- for (StoragePool pool : pools.first()) {
- StoragePoolResponse poolResponse = _responseGenerator.createStoragePoolResponse(pool);
- poolResponse.setObjectName("storagepool");
- poolResponses.add(poolResponse);
- }
-
- response.setResponses(poolResponses, pools.second());
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storagepool/PreparePrimaryStorageForMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storagepool/PreparePrimaryStorageForMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storagepool/PreparePrimaryStorageForMaintenanceCmd.java
deleted file mode 100644
index 602f278..0000000
--- a/api/src/org/apache/cloudstack/api/command/admin/storagepool/PreparePrimaryStorageForMaintenanceCmd.java
+++ /dev/null
@@ -1,111 +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 org.apache.cloudstack.api.command.admin.storagepool;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-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.StoragePoolResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.storage.StoragePool;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@APICommand(name = "enableStorageMaintenance", description="Puts storage pool into maintenance state", responseObject=StoragePoolResponse.class)
-public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(PreparePrimaryStorageForMaintenanceCmd.class.getName());
- private static final String s_name = "prepareprimarystorageformaintenanceresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = StoragePoolResponse.class,
- required=true, description="Primary storage ID")
- private Long id;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public static String getResultObjectName() {
- return "primarystorage";
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.StoragePool;
- }
-
- @Override
- public Long getInstanceId() {
- return getId();
- }
-
- @Override
- public long getEntityOwnerId() {
- Account account = UserContext.current().getCaller();
- if (account != null) {
- return account.getId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_MAINTENANCE_PREPARE_PRIMARY_STORAGE;
- }
-
- @Override
- public String getEventDescription() {
- return "preparing storage pool: " + getId() + " for maintenance";
- }
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException{
- StoragePool result = _storageService.preparePrimaryStorageForMaintenance(getId());
- if (result != null){
- StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
- response.setResponseName("storagepool");
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to prepare primary storage for maintenance");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/api/src/org/apache/cloudstack/api/command/admin/storagepool/UpdateStoragePoolCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/storagepool/UpdateStoragePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storagepool/UpdateStoragePoolCmd.java
deleted file mode 100644
index c6796a8..0000000
--- a/api/src/org/apache/cloudstack/api/command/admin/storagepool/UpdateStoragePoolCmd.java
+++ /dev/null
@@ -1,84 +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 org.apache.cloudstack.api.command.admin.storagepool;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.*;
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.response.StoragePoolResponse;
-import com.cloud.storage.StoragePool;
-import com.cloud.user.Account;
-
-@APICommand(name = "updateStoragePool", description="Updates a storage pool.", responseObject=StoragePoolResponse.class, since="3.0.0")
-public class UpdateStoragePoolCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(UpdateStoragePoolCmd.class.getName());
-
- private static final String s_name = "updatestoragepoolresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = StoragePoolResponse.class,
- required=true, description="the Id of the storage pool")
- private Long id;
-
- @Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma-separated list of tags for the storage pool")
- private List<String> tags;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- public List<String> getTags() {
- return tags;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- StoragePool result = _storageService.updateStoragePool(this);
- if (result != null){
- StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update storage pool");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 72cdb4b..8348359 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -268,13 +268,13 @@ queryAsyncJobResult=org.apache.cloudstack.api.command.user.job.QueryAsyncJobResu
listAsyncJobs=org.apache.cloudstack.api.command.user.job.ListAsyncJobsCmd;15
#### storage pools commands
-listStoragePools=org.apache.cloudstack.api.command.admin.storagepool.ListStoragePoolsCmd;3
-createStoragePool=org.apache.cloudstack.api.command.admin.storagepool.CreateStoragePoolCmd;1
-updateStoragePool=org.apache.cloudstack.api.command.admin.storagepool.UpdateStoragePoolCmd;1
-deleteStoragePool=org.apache.cloudstack.api.command.admin.storagepool.DeletePoolCmd;1
+listStoragePools=org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;3
+createStoragePool=org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;1
+updateStoragePool=org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;1
+deleteStoragePool=org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;1
listClusters=org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;3
-enableStorageMaintenance=org.apache.cloudstack.api.command.admin.storagepool.PreparePrimaryStorageForMaintenanceCmd;1
-cancelStorageMaintenance=org.apache.cloudstack.api.command.admin.storagepool.CancelPrimaryStorageMaintenanceCmd;1
+enableStorageMaintenance=org.apache.cloudstack.api.command.admin.storage.PreparePrimaryStorageForMaintenanceCmd;1
+cancelStorageMaintenance=org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;1
#### security group commands
createSecurityGroup=org.apache.cloudstack.api.command.user.securitygroup.CreateSecurityGroupCmd;15
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index e500192..b08e4a4 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -45,8 +45,7 @@ import javax.crypto.spec.SecretKeySpec;
import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
-import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
-import org.apache.cloudstack.api.command.admin.storagepool.ListStoragePoolsCmd;
+import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
import org.apache.cloudstack.api.command.admin.systemvm.DestroySystemVmCmd;
import org.apache.cloudstack.api.command.admin.systemvm.UpgradeSystemVMCmd;
import org.apache.cloudstack.api.command.user.address.ListPublicIpAddressesCmd;
@@ -55,7 +54,6 @@ import org.apache.cloudstack.api.command.user.guest.ListGuestOsCategoriesCmd;
import org.apache.cloudstack.api.command.user.guest.ListGuestOsCmd;
import org.apache.cloudstack.api.command.user.iso.ListIsosCmd;
import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
-import org.apache.cloudstack.api.command.user.job.ListAsyncJobsCmd;
import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd;
@@ -64,7 +62,6 @@ import org.apache.cloudstack.api.command.user.ssh.RegisterSSHKeyPairCmd;
import org.apache.cloudstack.api.command.user.template.ListTemplatesCmd;
import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd;
import org.apache.cloudstack.api.command.user.vm.GetVMPasswordCmd;
-import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
@@ -85,8 +82,6 @@ import com.cloud.api.ApiDBUtils;
import org.apache.cloudstack.api.command.user.ssh.CreateSSHKeyPairCmd;
import org.apache.cloudstack.api.command.user.volume.ExtractVolumeCmd;
import org.apache.cloudstack.api.command.admin.resource.ListCapacityCmd;
-import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
-import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
import org.apache.cloudstack.api.command.admin.systemvm.ListSystemVMsCmd;
import org.apache.cloudstack.api.command.admin.vlan.ListVlanIpRangesCmd;
@@ -97,15 +92,11 @@ import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
import com.cloud.api.commands.UpdateTemplateOrIsoCmd;
import com.cloud.api.query.dao.DomainRouterJoinDao;
import com.cloud.api.query.dao.InstanceGroupJoinDao;
-import com.cloud.api.query.vo.DomainRouterJoinVO;
-import com.cloud.api.query.vo.EventJoinVO;
-import com.cloud.api.query.vo.InstanceGroupJoinVO;
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
import org.apache.cloudstack.api.response.ExtractResponse;
-import com.cloud.async.AsyncJob;
import com.cloud.async.AsyncJobExecutor;
import com.cloud.async.AsyncJobManager;
import com.cloud.async.AsyncJobResult;
@@ -220,7 +211,6 @@ import com.cloud.tags.dao.ResourceTagDao;
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
-import com.cloud.user.AccountVO;
import com.cloud.user.SSHKeyPair;
import com.cloud.user.SSHKeyPairVO;
import com.cloud.user.User;
@@ -244,7 +234,6 @@ import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.db.JoinBuilder;
import com.cloud.utils.db.JoinBuilder.JoinType;
-import com.cloud.utils.db.SearchCriteria.Func;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
@@ -254,7 +243,6 @@ import com.cloud.utils.net.NetUtils;
import com.cloud.utils.ssh.SSHKeysHelper;
import com.cloud.vm.ConsoleProxyVO;
import com.cloud.vm.DomainRouterVO;
-import com.cloud.vm.InstanceGroup;
import com.cloud.vm.InstanceGroupVO;
import com.cloud.vm.SecondaryStorageVmVO;
import com.cloud.vm.UserVmVO;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/73a0c3e0/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index 21ee972..5f1db66 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
-import org.apache.cloudstack.api.command.admin.storagepool.*;
+import org.apache.cloudstack.api.command.admin.storage.*;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
import org.apache.log4j.Logger;
@@ -74,10 +74,7 @@ import com.cloud.agent.api.to.VolumeTO;
import com.cloud.agent.manager.Commands;
import com.cloud.alert.AlertManager;
import com.cloud.api.ApiDBUtils;
-import org.apache.cloudstack.api.command.admin.storagepool.CancelPrimaryStorageMaintenanceCmd;
-import org.apache.cloudstack.api.command.admin.storagepool.CreateStoragePoolCmd;
-import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
-import org.apache.cloudstack.api.command.admin.storagepool.UpdateStoragePoolCmd;
+import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
import com.cloud.async.AsyncJobManager;
import com.cloud.capacity.Capacity;
import com.cloud.capacity.CapacityManager;
@@ -129,11 +126,9 @@ import com.cloud.network.NetworkManager;
import com.cloud.offering.ServiceOffering;
import com.cloud.org.Grouping;
import com.cloud.org.Grouping.AllocationState;
-import com.cloud.projects.Project.ListProjectResourcesCriteria;
import com.cloud.resource.ResourceManager;
import com.cloud.resource.ResourceState;
import com.cloud.server.ManagementServer;
-import com.cloud.server.ResourceTag.TaggedResourceType;
import com.cloud.server.StatsCollector;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
@@ -161,7 +156,6 @@ import com.cloud.storage.s3.S3Manager;
import com.cloud.storage.secondary.SecondaryStorageVmManager;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.storage.snapshot.SnapshotScheduler;
-import com.cloud.tags.ResourceTagVO;
import com.cloud.tags.dao.ResourceTagDao;
import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
@@ -175,7 +169,6 @@ import com.cloud.uservm.UserVm;
import com.cloud.utils.EnumUtils;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
-import com.cloud.utils.Ternary;
import com.cloud.utils.UriUtils;
import com.cloud.utils.component.Adapters;
import com.cloud.utils.component.ComponentLocator;
@@ -183,7 +176,6 @@ import com.cloud.utils.component.Inject;
import com.cloud.utils.component.Manager;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GenericSearchBuilder;
import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.db.JoinBuilder;