mirror of https://github.com/apache/cloudstack.git
SWIFT : add listSwift api
This commit is contained in:
parent
8c85d8f05c
commit
fea9ca582c
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.HostResponse;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.SwiftResponse;
|
||||
import com.cloud.storage.Swift;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description = "List Swift.", responseObject = HostResponse.class)
|
||||
public class ListSwiftCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListSwiftCmd.class.getName());
|
||||
private static final String s_name = "ListSwiftresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "the id of the swift")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends Swift> result = _resourceService.listSwift(this);
|
||||
ListResponse<SwiftResponse> response = new ListResponse<SwiftResponse>();
|
||||
List<SwiftResponse> swiftResponses = new ArrayList<SwiftResponse>();
|
||||
|
||||
if (result != null) {
|
||||
SwiftResponse swiftResponse = null;
|
||||
for (Swift swift : result) {
|
||||
swiftResponse = _responseGenerator.createSwiftResponse(swift);
|
||||
swiftResponse.setResponseName(getCommandName());
|
||||
swiftResponse.setObjectName("swift");
|
||||
swiftResponses.add(swiftResponse);
|
||||
}
|
||||
response.setResponses(swiftResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Swift");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@ import com.cloud.api.commands.AddSecondaryStorageCmd;
|
|||
import com.cloud.api.commands.AddSwiftCmd;
|
||||
import com.cloud.api.commands.CancelMaintenanceCmd;
|
||||
import com.cloud.api.commands.DeleteClusterCmd;
|
||||
import com.cloud.api.commands.ListSwiftCmd;
|
||||
import com.cloud.api.commands.PrepareForMaintenanceCmd;
|
||||
import com.cloud.api.commands.ReconnectHostCmd;
|
||||
import com.cloud.api.commands.UpdateHostCmd;
|
||||
|
|
@ -92,4 +93,6 @@ public interface ResourceService {
|
|||
Swift discoverSwift(AddSwiftCmd addSwiftCmd) throws DiscoveryException;
|
||||
|
||||
List<HypervisorType> getSupportedHypervisorTypes(long zoneId);
|
||||
|
||||
List<? extends Swift> listSwift(ListSwiftCmd cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ listCapacity=com.cloud.api.commands.ListCapacityCmd;3
|
|||
|
||||
#### swift commands^M
|
||||
addSwift=com.cloud.api.commands.AddSwiftCmd;1
|
||||
listSwift=com.cloud.api.commands.ListSwiftCmd;1
|
||||
|
||||
|
||||
#### host commands
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ public enum Config {
|
|||
CopyVolumeWait("Storage", StorageManager.class, Integer.class, "copy.volume.wait", "10800", "In second, timeout for copy volume command", null),
|
||||
CreatePrivateTemplateFromVolumeWait("Storage", UserVmManager.class, Integer.class, "create.private.template.from.volume.wait", "10800", "In second, timeout for CreatePrivateTemplateFromVolumeCommand", null),
|
||||
CreatePrivateTemplateFromSnapshotWait("Storage", UserVmManager.class, Integer.class, "create.private.template.from.snapshot.wait", "10800", "In second, timeout for CreatePrivateTemplateFromSnapshotCommand", null),
|
||||
BackupSnapshotWait("Storage", StorageManager.class, Integer.class, "backup.snapshot.wait", "10800", "In second, timeout for BackupSnapshotCommand", null),
|
||||
BackupSnapshotWait(
|
||||
"Storage", StorageManager.class, Integer.class, "backup.snapshot.wait", "21600", "In second, timeout for BackupSnapshotCommand", null),
|
||||
|
||||
// Network
|
||||
NetworkLBHaproxyStatsVisbility("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.visibility", "global", "Load Balancer(haproxy) stats visibilty, the value can be one of the following six parameters : global,guest-network,link-local,disabled,all,default", null),
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import com.cloud.api.commands.AddSecondaryStorageCmd;
|
|||
import com.cloud.api.commands.AddSwiftCmd;
|
||||
import com.cloud.api.commands.CancelMaintenanceCmd;
|
||||
import com.cloud.api.commands.DeleteClusterCmd;
|
||||
import com.cloud.api.commands.ListSwiftCmd;
|
||||
import com.cloud.api.commands.PrepareForMaintenanceCmd;
|
||||
import com.cloud.api.commands.ReconnectHostCmd;
|
||||
import com.cloud.api.commands.UpdateHostCmd;
|
||||
|
|
@ -107,6 +108,7 @@ import com.cloud.storage.StoragePoolStatus;
|
|||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.StorageService;
|
||||
import com.cloud.storage.Swift;
|
||||
import com.cloud.storage.SwiftVO;
|
||||
import com.cloud.storage.dao.GuestOSCategoryDao;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
|
|
@ -515,6 +517,11 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
return _swiftMgr.addSwift(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SwiftVO> listSwift(ListSwiftCmd cmd) {
|
||||
return _swiftMgr.listSwift(cmd);
|
||||
}
|
||||
|
||||
private List<HostVO> discoverHostsFull(Long dcId, Long podId, Long clusterId, String clusterName, String url, String username, String password, String hypervisorType, List<String> hostTags,
|
||||
Map<String, String> params) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException {
|
||||
URI uri = null;
|
||||
|
|
|
|||
|
|
@ -24,12 +24,16 @@
|
|||
|
||||
package com.cloud.storage.swift;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.agent.api.to.SwiftTO;
|
||||
import com.cloud.api.commands.AddSwiftCmd;
|
||||
import com.cloud.api.commands.DeleteIsoCmd;
|
||||
import com.cloud.api.commands.DeleteTemplateCmd;
|
||||
import com.cloud.api.commands.ListSwiftCmd;
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
import com.cloud.storage.Swift;
|
||||
import com.cloud.storage.SwiftVO;
|
||||
import com.cloud.utils.component.Manager;
|
||||
public interface SwiftManager extends Manager {
|
||||
|
||||
|
|
@ -52,4 +56,6 @@ public interface SwiftManager extends Manager {
|
|||
void propagateSwiftTmplteOnZone(Long zoneId);
|
||||
|
||||
Long chooseZoneForTmpltExtract(Long tmpltId);
|
||||
|
||||
List<SwiftVO> listSwift(ListSwiftCmd cmd);
|
||||
}
|
||||
|
|
@ -42,6 +42,7 @@ import com.cloud.agent.api.to.SwiftTO;
|
|||
import com.cloud.api.commands.AddSwiftCmd;
|
||||
import com.cloud.api.commands.DeleteIsoCmd;
|
||||
import com.cloud.api.commands.DeleteTemplateCmd;
|
||||
import com.cloud.api.commands.ListSwiftCmd;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
|
|
@ -264,6 +265,18 @@ public class SwiftManagerImpl implements SwiftManager {
|
|||
return dcs.get(0).getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SwiftVO> listSwift(ListSwiftCmd cmd) {
|
||||
if (cmd.getId() == null) {
|
||||
return _swiftDao.listAll();
|
||||
} else {
|
||||
List<SwiftVO> list = new ArrayList<SwiftVO>();
|
||||
SwiftVO swift = _swiftDao.findById(cmd.getId());
|
||||
list.add(swift);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue