volume related operation works

This commit is contained in:
Edison Su 2013-05-06 13:52:55 -07:00
parent fdee284395
commit 2d544e7127
39 changed files with 219 additions and 61 deletions

View File

@ -1,3 +1,4 @@
package com.cloud.agent.api.storage;
// Licensed to the Apache Software Foundation (ASF) under one // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file // or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information // distributed with this work for additional information

View File

@ -18,6 +18,8 @@
*/ */
package org.apache.cloudstack.engine.subsystem.api.storage; package org.apache.cloudstack.engine.subsystem.api.storage;
import org.apache.cloudstack.storage.command.CommandResult;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
public class CopyCommandResult extends CommandResult { public class CopyCommandResult extends CommandResult {

View File

@ -18,6 +18,8 @@
*/ */
package org.apache.cloudstack.engine.subsystem.api.storage; package org.apache.cloudstack.engine.subsystem.api.storage;
import org.apache.cloudstack.storage.command.CommandResult;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
public class CreateCmdResult extends CommandResult { public class CreateCmdResult extends CommandResult {
@ -26,6 +28,7 @@ public class CreateCmdResult extends CommandResult {
public CreateCmdResult(String path, Answer answer) { public CreateCmdResult(String path, Answer answer) {
super(); super();
this.path = path; this.path = path;
this.answer = answer;
} }
public String getPath() { public String getPath() {

View File

@ -21,6 +21,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import java.util.Set; import java.util.Set;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult;
import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.DataStoreTO;

View File

@ -19,6 +19,7 @@
package org.apache.cloudstack.engine.subsystem.api.storage; package org.apache.cloudstack.engine.subsystem.api.storage;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult;
public interface PrimaryDataStoreDriver extends DataStoreDriver { public interface PrimaryDataStoreDriver extends DataStoreDriver {
public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback); public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);

View File

@ -1,6 +1,8 @@
package org.apache.cloudstack.engine.subsystem.api.storage; package org.apache.cloudstack.engine.subsystem.api.storage;
import org.apache.cloudstack.storage.command.CommandResult;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
public class SnapshotResult extends CommandResult { public class SnapshotResult extends CommandResult {

View File

@ -20,6 +20,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import org.apache.cloudstack.framework.async.AsyncCallFuture; import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult;

View File

@ -20,6 +20,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity; import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
import org.apache.cloudstack.framework.async.AsyncCallFuture; import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.storage.command.CommandResult;
import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ConcurrentOperationException;

View File

@ -18,6 +18,7 @@
*/ */
package org.apache.cloudstack.storage.command; package org.apache.cloudstack.storage.command;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
public class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand { public class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.cloudstack.engine.subsystem.api.storage; package org.apache.cloudstack.storage.command;
public class CommandResult { public class CommandResult {
private boolean success; private boolean success;

View File

@ -16,6 +16,7 @@
// under the License. // under the License.
package org.apache.cloudstack.storage.command; package org.apache.cloudstack.storage.command;
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO; import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;

View File

@ -16,6 +16,7 @@
// under the License. // under the License.
package org.apache.cloudstack.storage.command; package org.apache.cloudstack.storage.command;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
public class CreatePrimaryDataStoreCmd extends Command implements StorageSubSystemCommand { public class CreatePrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {

View File

@ -18,14 +18,14 @@
*/ */
package org.apache.cloudstack.storage.command; package org.apache.cloudstack.storage.command;
import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
public class DeleteCommand extends Command implements StorageSubSystemCommand { public class DeleteCommand extends Command implements StorageSubSystemCommand {
private String uri; private DataTO data;
public DeleteCommand(String uri) { public DeleteCommand(DataTO data) {
this.uri = uri; this.data = data;
} }
protected DeleteCommand() { protected DeleteCommand() {
@ -37,8 +37,8 @@ public class DeleteCommand extends Command implements StorageSubSystemCommand {
return false; return false;
} }
public String getUri() { public DataTO getData() {
return this.uri; return this.data;
} }
} }

View File

@ -33,6 +33,7 @@ public class VolumeObjectTO implements DataTO {
private long size; private long size;
private String path; private String path;
private Long volumeId; private Long volumeId;
private String vmName;
private long accountId; private long accountId;
public VolumeObjectTO() { public VolumeObjectTO() {
@ -48,7 +49,7 @@ public class VolumeObjectTO implements DataTO {
} else { } else {
this.dataStore = null; this.dataStore = null;
} }
//this.name = volume.getName(); this.vmName = volume.getAttachedVmName();
this.size = volume.getSize(); this.size = volume.getSize();
this.setVolumeId(volume.getId()); this.setVolumeId(volume.getId());
} }
@ -121,5 +122,13 @@ public class VolumeObjectTO implements DataTO {
this.accountId = accountId; this.accountId = accountId;
} }
public String getVmName() {
return vmName;
}
public void setVmName(String vmName) {
this.vmName = vmName;
}
} }

View File

@ -25,7 +25,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService; import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@ -38,6 +37,7 @@ import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext; import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.cache.allocator.StorageCacheAllocator; import org.apache.cloudstack.storage.cache.allocator.StorageCacheAllocator;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.command.CopyCmdAnswer; import org.apache.cloudstack.storage.command.CopyCmdAnswer;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;

View File

@ -29,7 +29,6 @@ import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService; import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
@ -51,6 +50,7 @@ import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext; import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.datastore.DataObjectManager; import org.apache.cloudstack.storage.datastore.DataObjectManager;
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager; import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
@ -377,7 +377,7 @@ public class TemplateServiceImpl implements TemplateService {
} }
} }
for (String uniqueName : templateInfos.keySet()) { /* for (String uniqueName : templateInfos.keySet()) {
TemplateProp tInfo = templateInfos.get(uniqueName); TemplateProp tInfo = templateInfos.get(uniqueName);
List<UserVmVO> userVmUsingIso = _userVmDao.listByIsoId(tInfo.getId()); List<UserVmVO> userVmUsingIso = _userVmDao.listByIsoId(tInfo.getId());
//check if there is any Vm using this ISO. //check if there is any Vm using this ISO.
@ -396,7 +396,7 @@ public class TemplateServiceImpl implements TemplateService {
} }
} }
} }*/
} }

View File

@ -43,6 +43,7 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
private String s3SecretKey; private String s3SecretKey;
private String s3EndPoint; private String s3EndPoint;
private String s3TemplateBucket; private String s3TemplateBucket;
private String primaryStorageUuid;
private boolean s3UseHttps; private boolean s3UseHttps;
protected void injectMockito() { protected void injectMockito() {
@ -70,11 +71,11 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
@Parameters({"devcloud-host-uuid", "devcloud-host-gateway", "devcloud-host-cidr", @Parameters({"devcloud-host-uuid", "devcloud-host-gateway", "devcloud-host-cidr",
"devcloud-host-ip", "template-url", "devcloud-local-storage-uuid", "devcloud-host-ip", "template-url", "devcloud-local-storage-uuid",
"primary-storage-want-to-add", "devcloud-secondary-storage", "s3-accesskey", "s3-secretkey", "s3-endpoint", "s3-template-bucket", "s3-usehttps", "image-install-path"}) "primary-storage-want-to-add", "devcloud-secondary-storage", "s3-accesskey", "s3-secretkey", "s3-endpoint", "s3-template-bucket", "s3-usehttps", "image-install-path", "primary-storage-uuid-want-to-add"})
protected void setup(String hostuuid, String gateway, String cidr, protected void setup(String hostuuid, String gateway, String cidr,
String hostIp, String templateUrl, String localStorageUuid, String hostIp, String templateUrl, String localStorageUuid,
String primaryStorage, String secondaryStorage, String s3_accessKey, String s3_secretKey, String s3_endpoint, String s3_template_bucket, String primaryStorage, String secondaryStorage, String s3_accessKey, String s3_secretKey, String s3_endpoint, String s3_template_bucket,
String s3_usehttps, String imageInstallPath) { String s3_usehttps, String imageInstallPath, String primaryStorageUuid) {
this.hostGuid = hostuuid; this.hostGuid = hostuuid;
this.hostGateway = gateway; this.hostGateway = gateway;
this.hostCidr = cidr; this.hostCidr = cidr;
@ -82,6 +83,7 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
this.templateUrl = templateUrl; this.templateUrl = templateUrl;
this.localStorageUuid = localStorageUuid; this.localStorageUuid = localStorageUuid;
this.primaryStorageUrl = primaryStorage; this.primaryStorageUrl = primaryStorage;
this.primaryStorageUuid = primaryStorageUuid;
this.imageInstallPath = imageInstallPath; this.imageInstallPath = imageInstallPath;
this.setSecondaryStorage(secondaryStorage); this.setSecondaryStorage(secondaryStorage);
// set S3 parameters // set S3 parameters
@ -157,4 +159,12 @@ public class CloudStackTestNGBase extends AbstractTestNGSpringContextTests {
this.imageInstallPath = imageInstallPath; this.imageInstallPath = imageInstallPath;
} }
public String getPrimaryStorageUuid() {
return primaryStorageUuid;
}
public void setPrimaryStorageUuid(String primaryStorageUuid) {
this.primaryStorageUuid = primaryStorageUuid;
}
} }

View File

@ -0,0 +1,23 @@
/*
* 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 org.apache.cloudstack.storage.test;
public class SnapshotTest {
}

View File

@ -26,11 +26,14 @@ import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.DataCenterDao;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
import com.cloud.storage.TemplateProfile;
import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.download.DownloadMonitor; import com.cloud.storage.download.DownloadMonitor;
import com.cloud.storage.download.DownloadMonitorImpl; import com.cloud.storage.download.DownloadMonitorImpl;
import com.cloud.template.HypervisorTemplateAdapter;
import com.cloud.template.TemplateAdapter;
import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ComponentContext;
@ContextConfiguration(locations={"classpath:/storageContext.xml"}) @ContextConfiguration(locations={"classpath:/storageContext.xml"})
@ -53,6 +56,8 @@ public class TemplateTest extends CloudStackTestNGBase {
EndPointSelector epSelector; EndPointSelector epSelector;
@Inject @Inject
DownloadMonitorImpl downloadMonitor; DownloadMonitorImpl downloadMonitor;
long dcId; long dcId;
long templateId; long templateId;

View File

@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
@ -37,6 +38,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManag
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector; import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk; import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk;
@ -44,6 +46,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo; import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService; import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.storage.LocalHostEndpoint; import org.apache.cloudstack.storage.LocalHostEndpoint;
import org.apache.cloudstack.storage.RemoteHostEndPoint; import org.apache.cloudstack.storage.RemoteHostEndPoint;
import org.apache.cloudstack.storage.command.CopyCmdAnswer; import org.apache.cloudstack.storage.command.CopyCmdAnswer;
@ -58,6 +61,7 @@ import org.apache.cloudstack.storage.volume.db.VolumeDao2;
import org.apache.cloudstack.storage.volume.db.VolumeVO; import org.apache.cloudstack.storage.volume.db.VolumeVO;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
@ -68,6 +72,7 @@ import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao; import com.cloud.dc.dao.HostPodDao;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.host.Host; import com.cloud.host.Host;
import com.cloud.host.Host.Type; import com.cloud.host.Host.Type;
import com.cloud.host.HostVO; import com.cloud.host.HostVO;
@ -78,9 +83,12 @@ import com.cloud.org.Managed.ManagedState;
import com.cloud.resource.ResourceManager; import com.cloud.resource.ResourceManager;
import com.cloud.resource.ResourceState; import com.cloud.resource.ResourceState;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
import com.cloud.storage.StoragePoolStatus;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ComponentContext;
@ -255,7 +263,7 @@ public class VolumeTest extends CloudStackTestNGBase {
return this.dataStoreMgr.getPrimaryDataStore(pools.get(0).getId()); return this.dataStoreMgr.getPrimaryDataStore(pools.get(0).getId());
} }
DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("cloudstack primary data store provider"); /*DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("cloudstack primary data store provider");
Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>();
URI uri = new URI(this.getPrimaryStorageUrl()); URI uri = new URI(this.getPrimaryStorageUrl());
params.put("url", this.getPrimaryStorageUrl()); params.put("url", this.getPrimaryStorageUrl());
@ -274,7 +282,24 @@ public class VolumeTest extends CloudStackTestNGBase {
DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle(); DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
DataStore store = lifeCycle.initialize(params); DataStore store = lifeCycle.initialize(params);
ClusterScope scope = new ClusterScope(clusterId, podId, dcId); ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
lifeCycle.attachCluster(store, scope); lifeCycle.attachCluster(store, scope);*/
StoragePoolVO pool = new StoragePoolVO();
pool.setClusterId(clusterId);
pool.setDataCenterId(dcId);
URI uri = new URI(this.getPrimaryStorageUrl());
pool.setHostAddress(uri.getHost());
pool.setPath(uri.getPath());
pool.setPort(0);
pool.setName(this.primaryName);
pool.setUuid(this.getPrimaryStorageUuid());
pool.setStatus(StoragePoolStatus.Up);
pool.setPoolType(StoragePoolType.NetworkFilesystem);
pool.setPodId(podId);
pool.setScope(ScopeType.CLUSTER);
pool.setStorageProviderName("cloudstack primary data store provider");
pool = this.primaryStoreDao.persist(pool);
DataStore store = this.dataStoreMgr.getPrimaryDataStore(pool.getId());
return store; return store;
} catch (Exception e) { } catch (Exception e) {
return null; return null;
@ -283,18 +308,75 @@ public class VolumeTest extends CloudStackTestNGBase {
private VolumeVO createVolume(Long templateId, long dataStoreId) { private VolumeVO createVolume(Long templateId, long dataStoreId) {
VolumeVO volume = new VolumeVO(1000, new RootDisk().toString(), UUID.randomUUID().toString(), templateId); VolumeVO volume = new VolumeVO(1000, new RootDisk().toString(), UUID.randomUUID().toString(), templateId);
//volume.setPoolId(dataStoreId); volume.setPoolId(dataStoreId);
volume = volumeDao.persist(volume); volume = volumeDao.persist(volume);
return volume; return volume;
} }
@Test //@Test
public void testCopyBaseImage() { public void testCopyBaseImage() {
DataStore primaryStore = createPrimaryDataStore(); DataStore primaryStore = createPrimaryDataStore();
primaryStoreId = primaryStore.getId(); primaryStoreId = primaryStore.getId();
primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId); primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
VolumeVO volume = createVolume(image.getId(), primaryStore.getId()); VolumeVO volume = createVolume(image.getId(), primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId()); VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId())); AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId()));
try {
VolumeApiResult result = future.get();
AssertJUnit.assertTrue(result.isSuccess());
VolumeInfo newVol = result.getVolume();
this.volumeService.destroyVolume(newVol.getId());
VolumeInfo vol = this.volFactory.getVolume(volume.getId());
this.volumeService.expungeVolumeAsync(vol);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ConcurrentOperationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void testCreateDataDisk() {
DataStore primaryStore = createPrimaryDataStore();
primaryStoreId = primaryStore.getId();
primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
VolumeVO volume = createVolume(null, primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
this.volumeService.createVolumeAsync(volInfo, primaryStore);
}
@Test
public void testDeleteDisk() {
DataStore primaryStore = createPrimaryDataStore();
primaryStoreId = primaryStore.getId();
primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
VolumeVO volume = createVolume(null, primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore);
try {
VolumeApiResult result = future.get();
VolumeInfo vol = result.getVolume();
this.volumeService.destroyVolume(volInfo.getId());
volInfo = this.volFactory.getVolume(vol.getId());
this.volumeService.expungeVolumeAsync(volInfo);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ConcurrentOperationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
} }

View File

@ -31,7 +31,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope; import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
@ -50,6 +49,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeAp
import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk; import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk;
import org.apache.cloudstack.framework.async.AsyncCallFuture; import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.storage.RemoteHostEndPoint; import org.apache.cloudstack.storage.RemoteHostEndPoint;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao; import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO; import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;

View File

@ -22,7 +22,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService; import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
@ -42,6 +41,7 @@ import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext; import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager; import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao; import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;

View File

@ -18,11 +18,11 @@
*/ */
package org.apache.cloudstack.storage.datastore; package org.apache.cloudstack.storage.datastore;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult;
public interface DataObjectManager { public interface DataObjectManager {
public void createAsync(DataObject data, DataStore store, AsyncCompletionCallback<CreateCmdResult> callback, boolean noCopy); public void createAsync(DataObject data, DataStore store, AsyncCompletionCallback<CreateCmdResult> callback, boolean noCopy);

View File

@ -20,7 +20,6 @@ package org.apache.cloudstack.storage.datastore;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService; import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
@ -32,6 +31,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreState
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext; import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

View File

@ -18,9 +18,9 @@
*/ */
package org.apache.cloudstack.storage.image.motion; package org.apache.cloudstack.storage.image.motion;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo; import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO; import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo; import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;

View File

@ -27,6 +27,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.storage.command.CopyCmdAnswer; import org.apache.cloudstack.storage.command.CopyCmdAnswer;
import org.apache.cloudstack.storage.command.CreateObjectAnswer;
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager; import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
@ -380,6 +381,13 @@ public class VolumeObject implements VolumeInfo {
vol.setPath(newVol.getPath()); vol.setPath(newVol.getPath());
vol.setSize(newVol.getSize()); vol.setSize(newVol.getSize());
volumeDao.update(vol.getId(), vol); volumeDao.update(vol.getId(), vol);
} else if (answer instanceof CreateObjectAnswer) {
CreateObjectAnswer createAnswer =(CreateObjectAnswer)answer;
VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData();
VolumeVO vol = this.volumeDao.findById(this.getId());
vol.setPath(newVol.getPath());
vol.setSize(newVol.getSize());
volumeDao.update(vol.getId(), vol);
} }
} else if (this.dataStore.getRole() == DataStoreRole.Image) { } else if (this.dataStore.getRole() == DataStoreRole.Image) {
if (answer instanceof DownloadAnswer) { if (answer instanceof DownloadAnswer) {

View File

@ -26,7 +26,6 @@ import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity; import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService; import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
@ -44,6 +43,7 @@ import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext; import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.datastore.DataObjectManager; import org.apache.cloudstack.storage.datastore.DataObjectManager;
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager; import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore; import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
@ -165,7 +165,7 @@ public class VolumeServiceImpl implements VolumeService {
DataObject vo = context.getVolume(); DataObject vo = context.getVolume();
String errMsg = null; String errMsg = null;
if (result.isSuccess()) { if (result.isSuccess()) {
vo.processEvent(Event.OperationSuccessed); vo.processEvent(Event.OperationSuccessed, result.getAnswer());
} else { } else {
vo.processEvent(Event.OperationFailed); vo.processEvent(Event.OperationFailed);
errMsg = result.getResult(); errMsg = result.getResult();

View File

@ -54,9 +54,10 @@ import javax.naming.ConfigurationException;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import com.cloud.agent.api.*; import com.cloud.agent.api.*;
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
import com.cloud.agent.api.to.*; import com.cloud.agent.api.to.*;
import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.FirewallRule;
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcException;
import org.w3c.dom.Document; import org.w3c.dom.Document;

View File

@ -42,11 +42,12 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO; import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreAnswer; import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreAnswer;
import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd; import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
import org.apache.cloudstack.storage.command.CopyCommand;
import org.apache.cloudstack.storage.command.CopyCmdAnswer; import org.apache.cloudstack.storage.command.CopyCmdAnswer;
import org.apache.cloudstack.storage.command.CopyCommand;
import org.apache.cloudstack.storage.command.CreateObjectAnswer; import org.apache.cloudstack.storage.command.CreateObjectAnswer;
import org.apache.cloudstack.storage.command.CreateObjectCommand; import org.apache.cloudstack.storage.command.CreateObjectCommand;
import org.apache.cloudstack.storage.command.CreatePrimaryDataStoreCmd; import org.apache.cloudstack.storage.command.CreatePrimaryDataStoreCmd;
import org.apache.cloudstack.storage.command.DeleteCommand;
import org.apache.cloudstack.storage.command.StorageSubSystemCommand; import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
import org.apache.cloudstack.storage.datastore.protocol.DataStoreProtocol; import org.apache.cloudstack.storage.datastore.protocol.DataStoreProtocol;
import org.apache.cloudstack.storage.to.ImageStoreTO; import org.apache.cloudstack.storage.to.ImageStoreTO;
@ -113,8 +114,8 @@ public class XenServerStorageResource {
return execute((CreatePrimaryDataStoreCmd) command); return execute((CreatePrimaryDataStoreCmd) command);
} else if (command instanceof CreateObjectCommand) { } else if (command instanceof CreateObjectCommand) {
return execute((CreateObjectCommand) command); return execute((CreateObjectCommand) command);
} else if (command instanceof DeleteVolumeCommand) { } else if (command instanceof DeleteCommand) {
return execute((DeleteVolumeCommand)command); return execute((DeleteCommand)command);
} }
return new Answer((Command)command, false, "not implemented yet"); return new Answer((Command)command, false, "not implemented yet");
} }
@ -222,15 +223,14 @@ public class XenServerStorageResource {
return new CreateObjectAnswer(e.toString()); return new CreateObjectAnswer(e.toString());
} }
} }
protected Answer execute(DeleteVolumeCommand cmd) { protected Answer deleteVolume(VolumeObjectTO volume) {
VolumeObjectTO volume = null;
Connection conn = hypervisorResource.getConnection(); Connection conn = hypervisorResource.getConnection();
String errorMsg = null; String errorMsg = null;
try { try {
VDI vdi = VDI.getByUuid(conn, volume.getUuid()); VDI vdi = VDI.getByUuid(conn, volume.getPath());
deleteVDI(conn, vdi); deleteVDI(conn, vdi);
return new Answer(cmd); return new Answer(null);
} catch (BadServerResponse e) { } catch (BadServerResponse e) {
s_logger.debug("Failed to delete volume", e); s_logger.debug("Failed to delete volume", e);
errorMsg = e.toString(); errorMsg = e.toString();
@ -241,8 +241,19 @@ public class XenServerStorageResource {
s_logger.debug("Failed to delete volume", e); s_logger.debug("Failed to delete volume", e);
errorMsg = e.toString(); errorMsg = e.toString();
} }
return new Answer(null, false, errorMsg);
}
return new Answer(cmd, false, errorMsg); protected Answer execute(DeleteCommand cmd) {
DataTO data = cmd.getData();
Answer answer = null;
if (data.getObjectType() == DataObjectType.VOLUME) {
answer = deleteVolume((VolumeObjectTO)data);
} else {
answer = new Answer(cmd, false, "unsupported type");
}
return answer;
} }
/* protected Answer execute(CreateVolumeFromBaseImageCommand cmd) { /* protected Answer execute(CreateVolumeFromBaseImageCommand cmd) {

View File

@ -24,7 +24,6 @@ import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@ -38,6 +37,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext; import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;

View File

@ -26,7 +26,6 @@ import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@ -40,6 +39,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext; import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao; import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;

View File

@ -22,7 +22,6 @@ import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@ -32,6 +31,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector; import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.command.CreateObjectAnswer; import org.apache.cloudstack.storage.command.CreateObjectAnswer;
import org.apache.cloudstack.storage.command.CreateObjectCommand; import org.apache.cloudstack.storage.command.CreateObjectCommand;
import org.apache.cloudstack.storage.image.ImageStoreDriver; import org.apache.cloudstack.storage.image.ImageStoreDriver;

View File

@ -26,7 +26,6 @@ import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@ -39,6 +38,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext; import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao; import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;

View File

@ -22,7 +22,6 @@ import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@ -30,11 +29,14 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO; import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver; import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.command.CreateObjectCommand; import org.apache.cloudstack.storage.command.CreateObjectCommand;
import org.apache.cloudstack.storage.command.DeleteCommand;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.to.SnapshotObjectTO; import org.apache.cloudstack.storage.to.SnapshotObjectTO;
import org.apache.cloudstack.storage.volume.VolumeObject; import org.apache.cloudstack.storage.volume.VolumeObject;
@ -80,6 +82,7 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
@Inject SnapshotDao snapshotDao; @Inject SnapshotDao snapshotDao;
@Inject PrimaryDataStoreDao primaryStoreDao; @Inject PrimaryDataStoreDao primaryStoreDao;
@Inject SnapshotManager snapshotMgr; @Inject SnapshotManager snapshotMgr;
@Inject EndPointSelector epSelecotor;
@Override @Override
public String grantAccess(DataObject data, EndPoint ep) { public String grantAccess(DataObject data, EndPoint ep) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -117,7 +120,8 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
} }
CreateObjectCommand cmd = new CreateObjectCommand(volume.getTO()); CreateObjectCommand cmd = new CreateObjectCommand(volume.getTO());
Answer answer = storageMgr.sendToPool((StoragePool)volume.getDataStore(), null, cmd); EndPoint ep = epSelecotor.select(volume);
Answer answer = ep.sendMessage(cmd);
return answer; return answer;
} }
@ -149,28 +153,17 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
@Override @Override
public void deleteAsync(DataObject data, public void deleteAsync(DataObject data,
AsyncCompletionCallback<CommandResult> callback) { AsyncCompletionCallback<CommandResult> callback) {
DeleteCommand cmd = new DeleteCommand(data.getTO());
String vmName = null;
VolumeVO vol = this.volumeDao.findById(data.getId());
StoragePool pool = (StoragePool)data.getDataStore();
DestroyCommand cmd = new DestroyCommand(pool, vol, vmName);
CommandResult result = new CommandResult(); CommandResult result = new CommandResult();
try { try {
Answer answer = this.storageMgr.sendToPool(pool, cmd); EndPoint ep = epSelecotor.select(data);
Answer answer = ep.sendMessage(cmd);
if (answer != null && !answer.getResult()) { if (answer != null && !answer.getResult()) {
result.setResult(answer.getDetails()); result.setResult(answer.getDetails());
s_logger.info("Will retry delete of " + vol + " from " + pool.getId());
} }
} catch (StorageUnavailableException e) {
s_logger.error("Storage is unavailable currently. Will retry delete of "
+ vol + " from " + pool.getId(), e);
result.setResult(e.toString());
} catch (Exception ex) { } catch (Exception ex) {
s_logger.debug("Unable to destoy volume" + vol + " from " + pool.getId(), ex); s_logger.debug("Unable to destoy volume" + data.getId(), ex);
result.setResult(ex.toString()); result.setResult(ex.toString());
} }
callback.complete(result); callback.complete(result);

View File

@ -21,7 +21,6 @@ import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@ -34,6 +33,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext; import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.command.CreateObjectAnswer; import org.apache.cloudstack.storage.command.CreateObjectAnswer;
import org.apache.cloudstack.storage.command.CreateObjectCommand; import org.apache.cloudstack.storage.command.CreateObjectCommand;
import org.apache.cloudstack.storage.command.DeleteCommand; import org.apache.cloudstack.storage.command.DeleteCommand;

View File

@ -18,7 +18,6 @@ package org.apache.cloudstack.storage.datastore.driver;
import java.util.Set; import java.util.Set;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@ -28,6 +27,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver; import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult;
import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.DataStoreTO;

View File

@ -46,6 +46,7 @@ public class TemplateProfile {
VMTemplateVO template; VMTemplateVO template;
String templateTag; String templateTag;
Map details; Map details;
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm, public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId, String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,

View File

@ -61,7 +61,7 @@ import com.cloud.utils.db.DB;
import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.exception.CloudRuntimeException;
@Local(value=TemplateAdapter.class) @Local(value=TemplateAdapter.class)
public class HypervisorTemplateAdapter extends TemplateAdapterBase implements TemplateAdapter { public class HypervisorTemplateAdapter extends TemplateAdapterBase {
private final static Logger s_logger = Logger.getLogger(HypervisorTemplateAdapter.class); private final static Logger s_logger = Logger.getLogger(HypervisorTemplateAdapter.class);
@Inject DownloadMonitor _downloadMonitor; @Inject DownloadMonitor _downloadMonitor;
@Inject AgentManager _agentMgr; @Inject AgentManager _agentMgr;

View File

@ -50,7 +50,6 @@ import org.apache.cloudstack.api.command.user.template.ListTemplatePermissionsCm
import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd; import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd; import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd;
import org.apache.cloudstack.api.command.user.template.UpdateTemplatePermissionsCmd; import org.apache.cloudstack.api.command.user.template.UpdateTemplatePermissionsCmd;
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
@ -65,6 +64,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope; import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
import org.apache.cloudstack.framework.async.AsyncCallFuture; import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao; import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO; import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;