mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-3273: ClassCastException when adding cache store via API
Filter the detail map sent over the wire into Map<String, String> before
processing underneath by storage life cycle
Signed-off-by: Prasanna Santhanam <tsp@apache.org>
(cherry picked from commit f96b89f25e)
This commit is contained in:
parent
bccf5d8ea0
commit
e0e8cb0d96
|
|
@ -18,22 +18,22 @@
|
|||
*/
|
||||
package org.apache.cloudstack.api.command.admin.storage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.storage.ImageStore;
|
||||
import com.cloud.user.Account;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.BaseCmd.CommandType;
|
||||
import org.apache.cloudstack.api.response.ImageStoreResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
import com.cloud.storage.ImageStore;
|
||||
import com.cloud.user.Account;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
@APICommand(name = "createCacheStore", description="create cache store.", responseObject=ImageStoreResponse.class)
|
||||
public class CreateCacheStoreCmd extends BaseCmd {
|
||||
|
|
@ -76,7 +76,19 @@ public class CreateCacheStoreCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
public Map<String, String> getDetails() {
|
||||
return details;
|
||||
Map<String, String> detailsMap = null;
|
||||
if (details != null && !details.isEmpty()) {
|
||||
detailsMap = new HashMap<String, String>();
|
||||
Collection<?> props = details.values();
|
||||
Iterator<?> iter = props.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> detail = (HashMap<String, String>) iter.next();
|
||||
String key = detail.get("key");
|
||||
String value = detail.get("value");
|
||||
detailsMap.put(key, value);
|
||||
}
|
||||
}
|
||||
return detailsMap;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class ImageStoreHelper {
|
|||
if (details != null) {
|
||||
Iterator<String> keyIter = details.keySet().iterator();
|
||||
while (keyIter.hasNext()) {
|
||||
String key = keyIter.next();
|
||||
String key = keyIter.next().toString();
|
||||
ImageStoreDetailVO detail = new ImageStoreDetailVO();
|
||||
detail.setStoreId(store.getId());
|
||||
detail.setName(key);
|
||||
|
|
|
|||
|
|
@ -185,16 +185,12 @@ def get_process_status(hostip, port, username, password, linklocalip, process, h
|
|||
return res
|
||||
|
||||
|
||||
def isAlmostEqual(self, first_digit, second_digit, range=0):
|
||||
def isAlmostEqual(first_digit, second_digit, range=0):
|
||||
digits_equal_within_range = False
|
||||
|
||||
try:
|
||||
if ((first_digit - range) < second_digit < (first_digit + range)):
|
||||
digits_equal_within_range = True
|
||||
|
||||
except Exception as e:
|
||||
self.fail(
|
||||
"%s: Failed while comparing the numbers %s & %s" %
|
||||
(e, first_digit, second_digit))
|
||||
|
||||
raise e
|
||||
return digits_equal_within_range
|
||||
|
|
|
|||
Loading…
Reference in New Issue