mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Incremental checkin
This commit is contained in:
parent
492fa760ff
commit
7e502768ed
@ -24,6 +24,7 @@ import java.util.Map;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.api.commands.UpdateStoragePoolCmd;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
@ -260,7 +261,7 @@ public interface StorageManager extends Manager {
|
||||
* @param poolId ID of the storage pool to be updated
|
||||
* @param tags Tags that will be added to the storage pool
|
||||
*/
|
||||
StoragePoolVO updateStoragePool(long poolId, String tags) throws IllegalArgumentException;
|
||||
// StoragePoolVO updateStoragePool(long poolId, String tags) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Find all of the storage pools needed for this vm.
|
||||
@ -288,4 +289,6 @@ public interface StorageManager extends Manager {
|
||||
* @return
|
||||
*/
|
||||
public boolean cancelPrimaryStorageForMaintenance(long primaryStorageId, long userId);
|
||||
|
||||
public StoragePoolVO updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException;
|
||||
}
|
||||
|
||||
@ -18,30 +18,18 @@
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.StorageStats;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.api.BaseCmd.Manager;
|
||||
|
||||
@Implementation(method="updateTemplatePermissions", manager=Manager.StorageManager)
|
||||
public class UpdateStoragePoolCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateStoragePoolCmd.class.getName());
|
||||
|
||||
private static final String s_name = "updatestoragepoolresponse";
|
||||
private static final List<Pair<Enum, Boolean>> s_properties = new ArrayList<Pair<Enum, Boolean>>();
|
||||
|
||||
static {
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.ID, Boolean.TRUE));
|
||||
s_properties.add(new Pair<Enum, Boolean>(BaseCmd.Properties.TAGS, Boolean.FALSE));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
@ -73,68 +61,70 @@ public class UpdateStoragePoolCmd extends BaseCmd {
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
@Override
|
||||
public List<Pair<Enum, Boolean>> getProperties() {
|
||||
return s_properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("UpdateStoragePoolCmd Params @ " + params.toString());
|
||||
}
|
||||
|
||||
Long poolId = (Long) params.get(BaseCmd.Properties.ID.getName());
|
||||
String tags = (String) params.get(BaseCmd.Properties.TAGS.getName());
|
||||
|
||||
StoragePoolVO storagePool = null;
|
||||
try {
|
||||
storagePool = getManagementServer().updateStoragePool(poolId, tags);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
s_logger.debug("Successfully updated storagePool " + storagePool.toString() );
|
||||
|
||||
List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.toString(storagePool.getId())));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_ID.getName(), storagePool.getDataCenterId()));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_NAME.getName(), getManagementServer().getDataCenterBy(storagePool.getDataCenterId()).getName()));
|
||||
if (storagePool.getPodId() != null) {
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.POD_ID.getName(), storagePool.getPodId()));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.POD_NAME.getName(), getManagementServer().getPodBy(storagePool.getPodId()).getName()));
|
||||
}
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), storagePool.getName()));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.IP_ADDRESS.getName(), storagePool.getHostAddress()));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.PATH.getName(), storagePool.getPath()));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.CREATED.getName(), getDateString(storagePool.getCreated())));
|
||||
|
||||
if (storagePool.getPoolType() != null) {
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.TYPE.getName(), storagePool.getPoolType().toString()));
|
||||
}
|
||||
|
||||
if (storagePool.getClusterId() != null) {
|
||||
ClusterVO cluster = getManagementServer().findClusterById(storagePool.getClusterId());
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.CLUSTER_ID.getName(), cluster.getId()));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.CLUSTER_NAME.getName(), cluster.getName()));
|
||||
}
|
||||
|
||||
StorageStats stats = getManagementServer().getStoragePoolStatistics(storagePool.getId());
|
||||
long capacity = storagePool.getCapacityBytes();
|
||||
long available = storagePool.getAvailableBytes() ;
|
||||
long used = capacity - available;
|
||||
// @Override
|
||||
// public List<Pair<String, Object>> execute(Map<String, Object> params) {
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("UpdateStoragePoolCmd Params @ " + params.toString());
|
||||
// }
|
||||
//
|
||||
// Long poolId = (Long) params.get(BaseCmd.Properties.ID.getName());
|
||||
// String tags = (String) params.get(BaseCmd.Properties.TAGS.getName());
|
||||
//
|
||||
// StoragePoolVO storagePool = null;
|
||||
// try {
|
||||
// storagePool = getManagementServer().updateStoragePool(poolId, tags);
|
||||
// } catch (IllegalArgumentException e) {
|
||||
// throw new ServerApiException(BaseCmd.PARAM_ERROR, e.getMessage());
|
||||
// }
|
||||
//
|
||||
// s_logger.debug("Successfully updated storagePool " + storagePool.toString() );
|
||||
//
|
||||
// List<Pair<String, Object>> returnValues = new ArrayList<Pair<String, Object>>();
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ID.getName(), Long.toString(storagePool.getId())));
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_ID.getName(), storagePool.getDataCenterId()));
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.ZONE_NAME.getName(), getManagementServer().getDataCenterBy(storagePool.getDataCenterId()).getName()));
|
||||
// if (storagePool.getPodId() != null) {
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.POD_ID.getName(), storagePool.getPodId()));
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.POD_NAME.getName(), getManagementServer().getPodBy(storagePool.getPodId()).getName()));
|
||||
// }
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.NAME.getName(), storagePool.getName()));
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.IP_ADDRESS.getName(), storagePool.getHostAddress()));
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.PATH.getName(), storagePool.getPath()));
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.CREATED.getName(), getDateString(storagePool.getCreated())));
|
||||
//
|
||||
// if (storagePool.getPoolType() != null) {
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.TYPE.getName(), storagePool.getPoolType().toString()));
|
||||
// }
|
||||
//
|
||||
// if (storagePool.getClusterId() != null) {
|
||||
// ClusterVO cluster = getManagementServer().findClusterById(storagePool.getClusterId());
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.CLUSTER_ID.getName(), cluster.getId()));
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.CLUSTER_NAME.getName(), cluster.getName()));
|
||||
// }
|
||||
//
|
||||
// StorageStats stats = getManagementServer().getStoragePoolStatistics(storagePool.getId());
|
||||
// long capacity = storagePool.getCapacityBytes();
|
||||
// long available = storagePool.getAvailableBytes() ;
|
||||
// long used = capacity - available;
|
||||
//
|
||||
// if (stats != null) {
|
||||
// used = stats.getByteUsed();
|
||||
// available = capacity - used;
|
||||
// }
|
||||
// s_logger.debug("Successfully recieved the storagePool statistics. TotalDiskSize - " +capacity+ " AllocatedDiskSize - " +used );
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.DISK_SIZE_TOTAL.getName(), Long.valueOf(storagePool.getCapacityBytes()).toString()));
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.DISK_SIZE_ALLOCATED.getName(), Long.valueOf(used).toString()));
|
||||
// returnValues.add(new Pair<String, Object>(BaseCmd.Properties.TAGS.getName(), getManagementServer().getStoragePoolTags(storagePool.getId())));
|
||||
//
|
||||
// List<Pair<String, Object>> embeddedObject = new ArrayList<Pair<String, Object>>();
|
||||
// embeddedObject.add(new Pair<String, Object>("storagepool", new Object[] { returnValues } ));
|
||||
// return embeddedObject;
|
||||
// }
|
||||
|
||||
if (stats != null) {
|
||||
used = stats.getByteUsed();
|
||||
available = capacity - used;
|
||||
}
|
||||
s_logger.debug("Successfully recieved the storagePool statistics. TotalDiskSize - " +capacity+ " AllocatedDiskSize - " +used );
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.DISK_SIZE_TOTAL.getName(), Long.valueOf(storagePool.getCapacityBytes()).toString()));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.DISK_SIZE_ALLOCATED.getName(), Long.valueOf(used).toString()));
|
||||
returnValues.add(new Pair<String, Object>(BaseCmd.Properties.TAGS.getName(), getManagementServer().getStoragePoolTags(storagePool.getId())));
|
||||
|
||||
List<Pair<String, Object>> embeddedObject = new ArrayList<Pair<String, Object>>();
|
||||
embeddedObject.add(new Pair<String, Object>("storagepool", new Object[] { returnValues } ));
|
||||
return embeddedObject;
|
||||
}
|
||||
@Override
|
||||
public String getResponse() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -753,7 +753,7 @@ public interface ManagementServer {
|
||||
* @param poolId ID of the storage pool to be updated
|
||||
* @param tags Tags that will be added to the storage pool
|
||||
*/
|
||||
StoragePoolVO updateStoragePool(long poolId, String tags);
|
||||
// StoragePoolVO updateStoragePool(long poolId, String tags);
|
||||
|
||||
/**
|
||||
* Starts a Domain Router
|
||||
|
||||
@ -2770,10 +2770,10 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public StoragePoolVO updateStoragePool(long poolId, String tags) throws IllegalArgumentException {
|
||||
return _storageMgr.updateStoragePool(poolId, tags);
|
||||
}
|
||||
// @Override
|
||||
// public StoragePoolVO updateStoragePool(long poolId, String tags) throws IllegalArgumentException {
|
||||
// return _storageMgr.updateStoragePool(poolId, tags);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public DomainRouter startRouter(long routerId, long startEventId) throws InternalErrorException {
|
||||
|
||||
@ -59,6 +59,7 @@ import com.cloud.agent.api.to.DiskCharacteristicsTO;
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.commands.UpdateStoragePoolCmd;
|
||||
import com.cloud.async.AsyncInstanceCreateStatus;
|
||||
import com.cloud.async.AsyncJobExecutor;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
@ -1306,14 +1307,19 @@ public class StorageManagerImpl implements StorageManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoragePoolVO updateStoragePool(long poolId, String tags) throws IllegalArgumentException {
|
||||
StoragePoolVO pool = _storagePoolDao.findById(poolId);
|
||||
public StoragePoolVO updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException
|
||||
{
|
||||
//Input validation
|
||||
Long id = cmd.getId();
|
||||
String tags = cmd.getTags();
|
||||
|
||||
StoragePoolVO pool = _storagePoolDao.findById(id);
|
||||
if (pool == null) {
|
||||
throw new IllegalArgumentException("Unable to find storage pool with ID: " + poolId);
|
||||
throw new IllegalArgumentException("Unable to find storage pool with ID: " + id);
|
||||
}
|
||||
|
||||
if (tags != null) {
|
||||
Map<String, String> details = _storagePoolDao.getDetails(poolId);
|
||||
Map<String, String> details = _storagePoolDao.getDetails(id);
|
||||
String[] tagsList = tags.split(",");
|
||||
for (String tag : tagsList) {
|
||||
tag = tag.trim();
|
||||
@ -1322,7 +1328,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
_storagePoolDao.updateDetails(poolId, details);
|
||||
_storagePoolDao.updateDetails(id, details);
|
||||
}
|
||||
|
||||
return pool;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user