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();
|
errMsg = e.toString();
|
||||||
}
|
}
|
||||||
CopyCommandResult result = new CopyCommandResult(null, answer);
|
CopyCommandResult result = new CopyCommandResult(null, answer);
|
||||||
result.setResult(errMsg);
|
if (!answer.getResult()) {
|
||||||
|
result.setResult(answer.getDetails());
|
||||||
|
}
|
||||||
callback.complete(result);
|
callback.complete(result);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -46,7 +46,13 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
<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>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -56,6 +62,7 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<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.engine.subsystem.api.storage.EndPointSelector;
|
||||||
import org.apache.cloudstack.framework.rpc.RpcProvider;
|
import org.apache.cloudstack.framework.rpc.RpcProvider;
|
||||||
import org.apache.cloudstack.storage.HostEndpointRpcServer;
|
import org.apache.cloudstack.storage.HostEndpointRpcServer;
|
||||||
|
import org.apache.cloudstack.storage.cache.manager.StorageCacheManagerImpl;
|
||||||
import org.apache.cloudstack.storage.test.ChildTestConfiguration.Library;
|
import org.apache.cloudstack.storage.test.ChildTestConfiguration.Library;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.springframework.context.annotation.Bean;
|
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.VMTemplateZoneDaoImpl;
|
||||||
import com.cloud.storage.dao.VolumeDaoImpl;
|
import com.cloud.storage.dao.VolumeDaoImpl;
|
||||||
import com.cloud.storage.dao.VolumeHostDaoImpl;
|
import com.cloud.storage.dao.VolumeHostDaoImpl;
|
||||||
|
import com.cloud.storage.download.DownloadMonitor;
|
||||||
import com.cloud.storage.s3.S3Manager;
|
import com.cloud.storage.s3.S3Manager;
|
||||||
import com.cloud.storage.snapshot.SnapshotManager;
|
import com.cloud.storage.snapshot.SnapshotManager;
|
||||||
import com.cloud.storage.swift.SwiftManager;
|
import com.cloud.storage.swift.SwiftManager;
|
||||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||||
import com.cloud.template.TemplateManager;
|
import com.cloud.template.TemplateManager;
|
||||||
|
import com.cloud.user.AccountManager;
|
||||||
|
import com.cloud.user.ResourceLimitService;
|
||||||
import com.cloud.user.dao.UserDaoImpl;
|
import com.cloud.user.dao.UserDaoImpl;
|
||||||
import com.cloud.utils.component.SpringComponentScanUtils;
|
import com.cloud.utils.component.SpringComponentScanUtils;
|
||||||
import com.cloud.vm.VirtualMachineManager;
|
import com.cloud.vm.VirtualMachineManager;
|
||||||
@ -121,9 +125,9 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDaoImpl;
|
|||||||
OCFS2ManagerImpl.class,
|
OCFS2ManagerImpl.class,
|
||||||
ClusterDetailsDaoImpl.class,
|
ClusterDetailsDaoImpl.class,
|
||||||
SecondaryStorageVmDaoImpl.class,
|
SecondaryStorageVmDaoImpl.class,
|
||||||
|
|
||||||
ConsoleProxyDaoImpl.class,
|
ConsoleProxyDaoImpl.class,
|
||||||
StoragePoolWorkDaoImpl.class,
|
StoragePoolWorkDaoImpl.class,
|
||||||
|
StorageCacheManagerImpl.class,
|
||||||
UserDaoImpl.class
|
UserDaoImpl.class
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -147,6 +151,20 @@ public class ChildTestConfiguration extends TestConfiguration {
|
|||||||
return new MockHostEndpointRpcServerDirectCallResource();
|
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
|
@Bean
|
||||||
public RpcProvider rpcProvider() {
|
public RpcProvider rpcProvider() {
|
||||||
return Mockito.mock(RpcProvider.class);
|
return Mockito.mock(RpcProvider.class);
|
||||||
|
|||||||
@ -24,20 +24,18 @@
|
|||||||
<context:component-scan
|
<context:component-scan
|
||||||
base-package="org.apache.cloudstack.storage" />
|
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 id="componentContext" class="com.cloud.utils.component.ComponentContext" />
|
||||||
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor">
|
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
|
||||||
<property name="requiredParameterValue" value="false" />
|
<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>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|||||||
@ -103,7 +103,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
@Inject
|
@Inject
|
||||||
ResourceLimitService _resourceLimitMgr;
|
ResourceLimitService _resourceLimitMgr;
|
||||||
@Inject
|
@Inject
|
||||||
DownloadMonitor _dlMonitor;
|
DownloadMonitor downloadMonitor;
|
||||||
@Inject
|
@Inject
|
||||||
AccountManager _accountMgr;
|
AccountManager _accountMgr;
|
||||||
@Inject
|
@Inject
|
||||||
@ -112,8 +112,6 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
@Inject
|
@Inject
|
||||||
ConfigurationDao configDao;
|
ConfigurationDao configDao;
|
||||||
@Inject
|
@Inject
|
||||||
SecondaryStorageVmManager _ssvmMgr;
|
|
||||||
@Inject
|
|
||||||
AgentManager _agentMgr;
|
AgentManager _agentMgr;
|
||||||
@Inject
|
@Inject
|
||||||
VolumeDataStoreDao _volumeStoreDao;
|
VolumeDataStoreDao _volumeStoreDao;
|
||||||
@ -815,7 +813,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
}
|
}
|
||||||
s_logger.debug("Volume " + volumeHost.getVolumeId() + " needs to be downloaded to " + store.getName());
|
s_logger.debug("Volume " + volumeHost.getVolumeId() + " needs to be downloaded to " + store.getName());
|
||||||
//TODO: pass a callback later
|
//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) {
|
protected CopyCmdAnswer copyTemplateToPrimaryStorage(DataTO srcData, DataTO destData, int wait) {
|
||||||
DataStoreTO srcStore = srcData.getDataStore();
|
DataStoreTO srcStore = srcData.getDataStore();
|
||||||
try {
|
try {
|
||||||
if (srcStore.getRole() == DataStoreRole.ImageCache && srcData.getObjectType() == DataObjectType.TEMPLATE) {
|
if ((srcStore instanceof NfsTO) && (srcData.getObjectType() == DataObjectType.TEMPLATE)) {
|
||||||
ImageStoreTO srcImageStore = (ImageStoreTO)srcStore;
|
NfsTO srcImageStore = (NfsTO)srcStore;
|
||||||
TemplateObjectTO srcTemplate = (TemplateObjectTO)srcData;
|
TemplateObjectTO srcTemplate = (TemplateObjectTO)srcData;
|
||||||
String storeUrl = srcImageStore.getUri();
|
String storeUrl = srcImageStore.getUrl();
|
||||||
if (!storeUrl.startsWith("nfs")) {
|
|
||||||
return new CopyCmdAnswer("only nfs image cache store supported");
|
URI uri = new URI(storeUrl);
|
||||||
}
|
String tmplpath = uri.getHost() + ":" + uri.getPath() + "/" + srcData.getPath();
|
||||||
String tmplpath = storeUrl + ":" + srcData.getPath();
|
|
||||||
PrimaryDataStoreTO destStore = (PrimaryDataStoreTO)destData.getDataStore();
|
PrimaryDataStoreTO destStore = (PrimaryDataStoreTO)destData.getDataStore();
|
||||||
String poolName = destStore.getUuid();
|
String poolName = destStore.getUuid();
|
||||||
Connection conn = hypervisorResource.getConnection();
|
Connection conn = hypervisorResource.getConnection();
|
||||||
@ -749,9 +748,8 @@ public class XenServerStorageResource {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VolumeObjectTO newVol = new VolumeObjectTO();
|
TemplateObjectTO newVol = new TemplateObjectTO();
|
||||||
newVol.setUuid(snapshotvdi.getUuid(conn));
|
newVol.setUuid(snapshotvdi.getUuid(conn));
|
||||||
newVol.setSize(phySize);
|
|
||||||
newVol.setPath(newVol.getUuid());
|
newVol.setPath(newVol.getUuid());
|
||||||
return new CopyCmdAnswer(newVol);
|
return new CopyCmdAnswer(newVol);
|
||||||
}
|
}
|
||||||
@ -1214,8 +1212,13 @@ public class XenServerStorageResource {
|
|||||||
DataTO destData = cmd.getDestTO();
|
DataTO destData = cmd.getDestTO();
|
||||||
DataStoreTO srcDataStore = srcData.getDataStore();
|
DataStoreTO srcDataStore = srcData.getDataStore();
|
||||||
DataStoreTO destDataStore = destData.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
|
//copy template to primary storage
|
||||||
return copyTemplateToPrimaryStorage(srcData, destData, cmd.getWait());
|
return copyTemplateToPrimaryStorage(srcData, destData, cmd.getWait());
|
||||||
} else if (srcData.getObjectType() == DataObjectType.TEMPLATE && srcDataStore.getRole() == DataStoreRole.Primary && destDataStore.getRole() == DataStoreRole.Primary) {
|
} else if (srcData.getObjectType() == DataObjectType.TEMPLATE && srcDataStore.getRole() == DataStoreRole.Primary && destDataStore.getRole() == DataStoreRole.Primary) {
|
||||||
|
|||||||
@ -83,7 +83,7 @@
|
|||||||
"internaldns1": "192.168.56.1",
|
"internaldns1": "192.168.56.1",
|
||||||
"secondaryStorages": [
|
"secondaryStorages": [
|
||||||
{
|
{
|
||||||
"url": "nfs://192.168.56.10:/opt/storage/secondary",
|
"url": "nfs://192.168.56.10/opt/storage/secondary",
|
||||||
"providerName": "CloudStack ImageStore Provider",
|
"providerName": "CloudStack ImageStore Provider",
|
||||||
"details": {
|
"details": {
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user