mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Bug 11126 - Give ability to define tags post storage addition
Changes: - Enabled updating storage tags - All existing tags are wiped out and new ones provided are stored. - Note that, if tags are updated on the storage, no changes are done to the deployment of already running VMs that were deployed prior to tag addition. - Also added some validation to host tags update API.
This commit is contained in:
parent
a3d221b842
commit
f56c3d7bc5
@ -18,6 +18,8 @@
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
@ -44,8 +46,9 @@ public class UpdateStoragePoolCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the Id of the storage pool")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for the storage pool")
|
||||
private String tags;
|
||||
@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 ///////////////////////
|
||||
@ -55,7 +58,7 @@ public class UpdateStoragePoolCmd extends BaseCmd {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
|
||||
@ -213,7 +213,7 @@ listAsyncJobs=com.cloud.api.commands.ListAsyncJobsCmd;15
|
||||
#### storage pools commands
|
||||
listStoragePools=com.cloud.api.commands.ListStoragePoolsCmd;3
|
||||
createStoragePool=com.cloud.api.commands.CreateStoragePoolCmd;1
|
||||
#### updateStoragePool=com.cloud.api.commands.UpdateStoragePoolCmd;1
|
||||
updateStoragePool=com.cloud.api.commands.UpdateStoragePoolCmd;1
|
||||
deleteStoragePool=com.cloud.api.commands.DeletePoolCmd;1
|
||||
listClusters=com.cloud.api.commands.ListClustersCmd;3
|
||||
enableStorageMaintenance=com.cloud.api.commands.PreparePrimaryStorageForMaintenanceCmd;1
|
||||
|
||||
@ -63,8 +63,11 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
|
||||
expunge(sc);
|
||||
|
||||
for (String tag : hostTags) {
|
||||
HostTagVO vo = new HostTagVO(hostId, tag);
|
||||
persist(vo);
|
||||
tag.trim();
|
||||
if(tag.length() > 0) {
|
||||
HostTagVO vo = new HostTagVO(hostId, tag);
|
||||
persist(vo);
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@ -1341,7 +1341,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
public StoragePoolVO updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException {
|
||||
// Input validation
|
||||
Long id = cmd.getId();
|
||||
String tags = cmd.getTags();
|
||||
List<String> tags = cmd.getTags();
|
||||
|
||||
StoragePoolVO pool = _storagePoolDao.findById(id);
|
||||
if (pool == null) {
|
||||
@ -1349,9 +1349,8 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
|
||||
if (tags != null) {
|
||||
Map<String, String> details = _storagePoolDao.getDetails(id);
|
||||
String[] tagsList = tags.split(",");
|
||||
for (String tag : tagsList) {
|
||||
Map<String, String> details = new HashMap<String, String>();
|
||||
for (String tag : tags) {
|
||||
tag = tag.trim();
|
||||
if (tag.length() > 0 && !details.containsKey(tag)) {
|
||||
details.put(tag, "true");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user