mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4338: fix NPE if create volume failed
This commit is contained in:
parent
e6d7cdf70f
commit
3c40e8bb3f
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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 com.cloud.hypervisor.kvm.storage;
|
||||
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class KVMStorageProcessorTest {
|
||||
KVMStorageProcessor processor;
|
||||
LibvirtComputingResource resource;
|
||||
@Before
|
||||
public void setUp() throws ConfigurationException {
|
||||
System.setProperty("paths.script", "/devel/asf-master");
|
||||
resource = new LibvirtComputingResource();
|
||||
resource.configure("testResource", new HashMap<String, Object>());
|
||||
}
|
||||
@Test
|
||||
public void testCloneVolumeFromBaseTemplate() throws Exception {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyVolumeFromImageCacheToPrimary() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -104,9 +104,18 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
|
|||
public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
|
||||
String errMsg = null;
|
||||
Answer answer = null;
|
||||
CreateCmdResult result = new CreateCmdResult(null, null);
|
||||
if (data.getType() == DataObjectType.VOLUME) {
|
||||
try {
|
||||
answer = createVolume((VolumeInfo) data);
|
||||
if ((answer == null) || (!answer.getResult())) {
|
||||
result.setSuccess(false);
|
||||
if (answer != null) {
|
||||
result.setResult(answer.getDetails());
|
||||
}
|
||||
} else {
|
||||
result.setAnswer(answer);
|
||||
}
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.debug("failed to create volume", e);
|
||||
errMsg = e.toString();
|
||||
|
|
@ -115,7 +124,6 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
|
|||
errMsg = e.toString();
|
||||
}
|
||||
}
|
||||
CreateCmdResult result = new CreateCmdResult(null, answer);
|
||||
if (errMsg != null) {
|
||||
result.setResult(errMsg);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue