mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-15 18:12:35 +01:00
fix template download to primary storage
This commit is contained in:
parent
50066a602b
commit
4d992fd18f
@ -307,7 +307,9 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
|
||||
errMsg = e.toString();
|
||||
}
|
||||
CopyCommandResult result = new CopyCommandResult(null, answer);
|
||||
result.setResult(errMsg);
|
||||
if (!answer.getResult()) {
|
||||
result.setResult(answer.getDetails());
|
||||
}
|
||||
callback.complete(result);
|
||||
|
||||
return null;
|
||||
|
||||
@ -46,7 +46,13 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-storage-imagemotion</artifactId>
|
||||
<artifactId>cloud-engine-storage-datamotion</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-storage-cache</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@ -56,6 +62,7 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
|
||||
@ -23,6 +23,7 @@ import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.framework.rpc.RpcProvider;
|
||||
import org.apache.cloudstack.storage.HostEndpointRpcServer;
|
||||
import org.apache.cloudstack.storage.cache.manager.StorageCacheManagerImpl;
|
||||
import org.apache.cloudstack.storage.test.ChildTestConfiguration.Library;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -69,11 +70,14 @@ import com.cloud.storage.dao.VMTemplatePoolDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDaoImpl;
|
||||
import com.cloud.storage.dao.VolumeDaoImpl;
|
||||
import com.cloud.storage.dao.VolumeHostDaoImpl;
|
||||
import com.cloud.storage.download.DownloadMonitor;
|
||||
import com.cloud.storage.s3.S3Manager;
|
||||
import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.cloud.storage.swift.SwiftManager;
|
||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||
import com.cloud.template.TemplateManager;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.user.dao.UserDaoImpl;
|
||||
import com.cloud.utils.component.SpringComponentScanUtils;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
@ -121,9 +125,9 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDaoImpl;
|
||||
OCFS2ManagerImpl.class,
|
||||
ClusterDetailsDaoImpl.class,
|
||||
SecondaryStorageVmDaoImpl.class,
|
||||
|
||||
ConsoleProxyDaoImpl.class,
|
||||
StoragePoolWorkDaoImpl.class,
|
||||
StorageCacheManagerImpl.class,
|
||||
UserDaoImpl.class
|
||||
|
||||
},
|
||||
@ -147,6 +151,20 @@ public class ChildTestConfiguration extends TestConfiguration {
|
||||
return new MockHostEndpointRpcServerDirectCallResource();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ResourceLimitService limtServe() {
|
||||
return Mockito.mock(ResourceLimitService.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DownloadMonitor downloadMonitor() {
|
||||
return Mockito.mock(DownloadMonitor.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AccountManager acctMgt() {
|
||||
return Mockito.mock(AccountManager.class);
|
||||
}
|
||||
@Bean
|
||||
public RpcProvider rpcProvider() {
|
||||
return Mockito.mock(RpcProvider.class);
|
||||
|
||||
@ -24,20 +24,18 @@
|
||||
<context:component-scan
|
||||
base-package="org.apache.cloudstack.storage" />
|
||||
|
||||
<!-- @DB support -->
|
||||
<aop:config proxy-target-class="true">
|
||||
<aop:aspect id="dbContextBuilder" ref="transactionContextBuilder">
|
||||
<aop:pointcut id="captureAnyMethod" expression="execution(* *(..))" />
|
||||
|
||||
<aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod" />
|
||||
</aop:aspect>
|
||||
|
||||
</aop:config>
|
||||
|
||||
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
|
||||
<bean id="componentContext" class="com.cloud.utils.component.ComponentContext" />
|
||||
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor">
|
||||
<property name="requiredParameterValue" value="false" />
|
||||
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
|
||||
<bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
|
||||
<bean class="org.apache.cloudstack.storage.test.ChildTestConfiguration" />
|
||||
<bean id="instantiatePostProcessor" class="com.cloud.utils.component.ComponentInstantiationPostProcessor">
|
||||
<property name="Interceptors">
|
||||
<list>
|
||||
<ref bean="transactionContextBuilder" />
|
||||
<ref bean="actionEventInterceptor" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
@ -103,7 +103,7 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
@Inject
|
||||
ResourceLimitService _resourceLimitMgr;
|
||||
@Inject
|
||||
DownloadMonitor _dlMonitor;
|
||||
DownloadMonitor downloadMonitor;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
@ -112,8 +112,6 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
@Inject
|
||||
ConfigurationDao configDao;
|
||||
@Inject
|
||||
SecondaryStorageVmManager _ssvmMgr;
|
||||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
@Inject
|
||||
VolumeDataStoreDao _volumeStoreDao;
|
||||
@ -815,7 +813,7 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
}
|
||||
s_logger.debug("Volume " + volumeHost.getVolumeId() + " needs to be downloaded to " + store.getName());
|
||||
//TODO: pass a callback later
|
||||
_dlMonitor.downloadVolumeToStorage(this.volFactory.getVolume(volumeHost.getVolumeId()), store, volumeHost.getDownloadUrl(), volumeHost.getChecksum(), volumeHost.getFormat(), null);
|
||||
downloadMonitor.downloadVolumeToStorage(this.volFactory.getVolume(volumeHost.getVolumeId()), store, volumeHost.getDownloadUrl(), volumeHost.getChecksum(), volumeHost.getFormat(), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -711,14 +711,13 @@ public class XenServerStorageResource {
|
||||
protected CopyCmdAnswer copyTemplateToPrimaryStorage(DataTO srcData, DataTO destData, int wait) {
|
||||
DataStoreTO srcStore = srcData.getDataStore();
|
||||
try {
|
||||
if (srcStore.getRole() == DataStoreRole.ImageCache && srcData.getObjectType() == DataObjectType.TEMPLATE) {
|
||||
ImageStoreTO srcImageStore = (ImageStoreTO)srcStore;
|
||||
if ((srcStore instanceof NfsTO) && (srcData.getObjectType() == DataObjectType.TEMPLATE)) {
|
||||
NfsTO srcImageStore = (NfsTO)srcStore;
|
||||
TemplateObjectTO srcTemplate = (TemplateObjectTO)srcData;
|
||||
String storeUrl = srcImageStore.getUri();
|
||||
if (!storeUrl.startsWith("nfs")) {
|
||||
return new CopyCmdAnswer("only nfs image cache store supported");
|
||||
}
|
||||
String tmplpath = storeUrl + ":" + srcData.getPath();
|
||||
String storeUrl = srcImageStore.getUrl();
|
||||
|
||||
URI uri = new URI(storeUrl);
|
||||
String tmplpath = uri.getHost() + ":" + uri.getPath() + "/" + srcData.getPath();
|
||||
PrimaryDataStoreTO destStore = (PrimaryDataStoreTO)destData.getDataStore();
|
||||
String poolName = destStore.getUuid();
|
||||
Connection conn = hypervisorResource.getConnection();
|
||||
@ -749,9 +748,8 @@ public class XenServerStorageResource {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
VolumeObjectTO newVol = new VolumeObjectTO();
|
||||
TemplateObjectTO newVol = new TemplateObjectTO();
|
||||
newVol.setUuid(snapshotvdi.getUuid(conn));
|
||||
newVol.setSize(phySize);
|
||||
newVol.setPath(newVol.getUuid());
|
||||
return new CopyCmdAnswer(newVol);
|
||||
}
|
||||
@ -1214,8 +1212,13 @@ public class XenServerStorageResource {
|
||||
DataTO destData = cmd.getDestTO();
|
||||
DataStoreTO srcDataStore = srcData.getDataStore();
|
||||
DataStoreTO destDataStore = destData.getDataStore();
|
||||
DataObjectType srcType = srcData.getObjectType();
|
||||
DataObjectType destType = destData.getObjectType();
|
||||
DataStoreRole destRole = destDataStore.getRole();
|
||||
|
||||
if (srcData.getObjectType() == DataObjectType.TEMPLATE && (srcDataStore instanceof NfsTO) && destData.getDataStore().getRole() == DataStoreRole.Primary) {
|
||||
boolean nfs = (srcDataStore instanceof NfsTO) ? true : false;
|
||||
|
||||
if ((srcData.getObjectType() == DataObjectType.TEMPLATE) && (srcDataStore instanceof NfsTO) && (destData.getDataStore().getRole() == DataStoreRole.Primary)) {
|
||||
//copy template to primary storage
|
||||
return copyTemplateToPrimaryStorage(srcData, destData, cmd.getWait());
|
||||
} else if (srcData.getObjectType() == DataObjectType.TEMPLATE && srcDataStore.getRole() == DataStoreRole.Primary && destDataStore.getRole() == DataStoreRole.Primary) {
|
||||
|
||||
@ -83,7 +83,7 @@
|
||||
"internaldns1": "192.168.56.1",
|
||||
"secondaryStorages": [
|
||||
{
|
||||
"url": "nfs://192.168.56.10:/opt/storage/secondary",
|
||||
"url": "nfs://192.168.56.10/opt/storage/secondary",
|
||||
"providerName": "CloudStack ImageStore Provider",
|
||||
"details": {
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user