fix compile, after rebase to master
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/99318762 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/99318762 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/99318762 Branch: refs/heads/object_store Commit: 993187622e15514b61a06019e8885172d605dc7f Parents: 36146e7 Author: Edison Su <sudi...@gmail.com> Authored: Fri May 10 20:39:02 2013 -0700 Committer: Edison Su <sudi...@gmail.com> Committed: Fri May 10 20:39:02 2013 -0700 ---------------------------------------------------------------------- .../cloud/agent/api/MigrateWithStorageAnswer.java | 10 +- .../api/MigrateWithStorageCompleteAnswer.java | 9 +- .../cloudstack/storage/test/VolumeTestVmware.java | 445 +++++++++++++++ .../xen/resource/XenServer610Resource.java | 23 +- .../motion/XenServerStorageMotionStrategy.java | 5 +- .../driver/SwiftImageStoreDriverImpl.java | 6 +- .../SamplePrimaryDatastoreProviderImpl.java | 2 +- tools/apidoc/gen_toc.py | 4 + 8 files changed, 483 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/99318762/core/src/com/cloud/agent/api/MigrateWithStorageAnswer.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/agent/api/MigrateWithStorageAnswer.java b/core/src/com/cloud/agent/api/MigrateWithStorageAnswer.java index 06aff32..d87a5f1 100644 --- a/core/src/com/cloud/agent/api/MigrateWithStorageAnswer.java +++ b/core/src/com/cloud/agent/api/MigrateWithStorageAnswer.java @@ -17,23 +17,27 @@ package com.cloud.agent.api; import java.util.List; + +import org.apache.cloudstack.storage.to.VolumeObjectTO; + +import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.VolumeTO; public class MigrateWithStorageAnswer extends Answer { - List<VolumeTO> volumeTos; + List<VolumeObjectTO> volumeTos; public MigrateWithStorageAnswer(MigrateWithStorageCommand cmd, Exception ex) { super(cmd, ex); volumeTos = null; } - public MigrateWithStorageAnswer(MigrateWithStorageCommand cmd, List<VolumeTO> volumeTos) { + public MigrateWithStorageAnswer(MigrateWithStorageCommand cmd, List<VolumeObjectTO> volumeTos) { super(cmd, true, null); this.volumeTos = volumeTos; } - public List<VolumeTO> getVolumeTos() { + public List<VolumeObjectTO> getVolumeTos() { return volumeTos; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/99318762/core/src/com/cloud/agent/api/MigrateWithStorageCompleteAnswer.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/agent/api/MigrateWithStorageCompleteAnswer.java b/core/src/com/cloud/agent/api/MigrateWithStorageCompleteAnswer.java index 920cf48..fd8f22f 100644 --- a/core/src/com/cloud/agent/api/MigrateWithStorageCompleteAnswer.java +++ b/core/src/com/cloud/agent/api/MigrateWithStorageCompleteAnswer.java @@ -17,22 +17,25 @@ package com.cloud.agent.api; import java.util.List; + +import org.apache.cloudstack.storage.to.VolumeObjectTO; + import com.cloud.agent.api.to.VolumeTO; public class MigrateWithStorageCompleteAnswer extends Answer { - List<VolumeTO> volumeTos; + List<VolumeObjectTO> volumeTos; public MigrateWithStorageCompleteAnswer(MigrateWithStorageCompleteCommand cmd, Exception ex) { super(cmd, ex); volumeTos = null; } - public MigrateWithStorageCompleteAnswer(MigrateWithStorageCompleteCommand cmd, List<VolumeTO> volumeTos) { + public MigrateWithStorageCompleteAnswer(MigrateWithStorageCompleteCommand cmd, List<VolumeObjectTO> volumeTos) { super(cmd, true, null); this.volumeTos = volumeTos; } - public List<VolumeTO> getVolumeTos() { + public List<VolumeObjectTO> getVolumeTos() { return volumeTos; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/99318762/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTestVmware.java ---------------------------------------------------------------------- diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTestVmware.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTestVmware.java new file mode 100644 index 0000000..48f1a2a --- /dev/null +++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTestVmware.java @@ -0,0 +1,445 @@ +/* + * 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; + +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ExecutionException; + +import javax.inject.Inject; + +import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope; +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.DataStoreLifeCycle; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager; +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.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.VolumeInfo; +import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk; +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.TemplateService; +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.RemoteHostEndPoint; +import org.apache.cloudstack.storage.command.CopyCmdAnswer; +import org.apache.cloudstack.storage.datastore.db.ImageStoreDao; +import org.apache.cloudstack.storage.datastore.db.ImageStoreVO; +import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; +import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; +import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; +import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; +import org.apache.cloudstack.storage.to.TemplateObjectTO; +import org.apache.cloudstack.storage.volume.db.VolumeDao2; +import org.apache.cloudstack.storage.volume.db.VolumeVO; +import org.mockito.Mockito; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + +import com.cloud.agent.AgentManager; +import com.cloud.dc.ClusterDetailsDao; +import com.cloud.dc.ClusterDetailsVO; +import com.cloud.dc.ClusterVO; +import com.cloud.dc.DataCenterVO; +import com.cloud.dc.HostPodVO; +import com.cloud.dc.DataCenter.NetworkType; +import com.cloud.dc.dao.ClusterDao; +import com.cloud.dc.dao.DataCenterDao; +import com.cloud.dc.dao.HostPodDao; +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.host.Host; +import com.cloud.host.Host.Type; +import com.cloud.host.HostVO; +import com.cloud.host.dao.HostDao; +import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.org.Cluster.ClusterType; +import com.cloud.org.Managed.ManagedState; +import com.cloud.resource.ResourceManager; +import com.cloud.resource.ResourceState; +import com.cloud.storage.DataStoreRole; +import com.cloud.storage.ScopeType; +import com.cloud.storage.Storage; +import com.cloud.storage.StoragePoolStatus; +import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; +import com.cloud.storage.VMTemplateVO; +import com.cloud.storage.Storage.StoragePoolType; +import com.cloud.storage.Storage.TemplateType; +import com.cloud.storage.dao.VMTemplateDao; +import com.cloud.utils.component.ComponentContext; + +@ContextConfiguration(locations={"classpath:/storageContext.xml"}) +public class VolumeTestVmware extends CloudStackTestNGBase { + @Inject + ImageStoreDao imageStoreDao; + ImageStoreVO imageStore; + Long dcId; + Long clusterId; + Long podId; + HostVO host; + String primaryName = "my primary data store"; + DataStore primaryStore; + @Inject + HostDao hostDao; + @Inject + TemplateService imageService; + @Inject + VolumeService volumeService; + @Inject + VMTemplateDao imageDataDao; + @Inject + VolumeDao2 volumeDao; + @Inject + HostPodDao podDao; + @Inject + ClusterDao clusterDao; + @Inject + ClusterDetailsDao clusterDetailsDao; + @Inject + DataCenterDao dcDao; + @Inject + PrimaryDataStoreDao primaryStoreDao; + @Inject + DataStoreProviderManager dataStoreProviderMgr; + @Inject + TemplateDataStoreDao templateStoreDao; + @Inject + TemplateDataFactory templateFactory; + @Inject + PrimaryDataStoreDao primaryDataStoreDao; + @Inject + AgentManager agentMgr; + @Inject + DataStoreManager dataStoreMgr; + @Inject + ResourceManager resourceMgr; + @Inject + VolumeDataFactory volFactory; + @Inject + EndPointSelector epSelector; + long primaryStoreId; + VMTemplateVO image; + String imageStoreName = "testImageStore"; + @Test(priority = -1) + public void setUp() { + ComponentContext.initComponentsLifeCycle(); + + host = hostDao.findByGuid(this.getHostGuid()); + if (host != null) { + dcId = host.getDataCenterId(); + clusterId = host.getClusterId(); + podId = host.getPodId(); + imageStore = this.imageStoreDao.findByName(imageStoreName); + } else { + //create data center + DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", + null, null, NetworkType.Basic, null, null, true, true, null, null); + dc = dcDao.persist(dc); + dcId = dc.getId(); + //create pod + + HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), this.getHostGateway(), this.getHostCidr(), 8, "test"); + pod = podDao.persist(pod); + podId = pod.getId(); + //create xen cluster + ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster"); + cluster.setHypervisorType(HypervisorType.VMware.toString()); + cluster.setClusterType(ClusterType.ExternalManaged); + cluster.setManagedState(ManagedState.Managed); + cluster = clusterDao.persist(cluster); + clusterId = cluster.getId(); + + //setup vcenter + ClusterDetailsVO clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "url", null); + this.clusterDetailsDao.persist(clusterDetailVO); + clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "username", null); + this.clusterDetailsDao.persist(clusterDetailVO); + clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "password", null); + this.clusterDetailsDao.persist(clusterDetailVO); + //create xen host + + host = new HostVO(this.getHostGuid()); + host.setName("devcloud vmware host"); + host.setType(Host.Type.Routing); + host.setPrivateIpAddress(this.getHostIp()); + host.setDataCenterId(dc.getId()); + host.setVersion("6.0.1"); + host.setAvailable(true); + host.setSetup(true); + host.setPodId(podId); + host.setLastPinged(0); + host.setResourceState(ResourceState.Enabled); + host.setHypervisorType(HypervisorType.VMware); + host.setClusterId(cluster.getId()); + + host = hostDao.persist(host); + + imageStore = new ImageStoreVO(); + imageStore.setName(imageStoreName); + imageStore.setDataCenterId(dcId); + imageStore.setProviderName("CloudStack ImageStore Provider"); + imageStore.setRole(DataStoreRole.Image); + imageStore.setUrl(this.getSecondaryStorage()); + imageStore.setUuid(UUID.randomUUID().toString()); + imageStore.setProtocol("nfs"); + imageStore = imageStoreDao.persist(imageStore); + } + + image = new VMTemplateVO(); + image.setTemplateType(TemplateType.USER); + image.setUrl(this.getTemplateUrl()); + image.setUniqueName(UUID.randomUUID().toString()); + image.setName(UUID.randomUUID().toString()); + image.setPublicTemplate(true); + image.setFeatured(true); + image.setRequiresHvm(true); + image.setBits(64); + image.setFormat(Storage.ImageFormat.VHD); + image.setEnablePassword(true); + image.setEnableSshKey(true); + image.setGuestOSId(1); + image.setBootable(true); + image.setPrepopulate(true); + image.setCrossZones(true); + image.setExtractable(true); + + image = imageDataDao.persist(image); + + /*TemplateDataStoreVO templateStore = new TemplateDataStoreVO(); + + templateStore.setDataStoreId(imageStore.getId()); + templateStore.setDownloadPercent(100); + templateStore.setDownloadState(Status.DOWNLOADED); + templateStore.setDownloadUrl(imageStore.getUrl()); + templateStore.setInstallPath(this.getImageInstallPath()); + templateStore.setTemplateId(image.getId()); + templateStoreDao.persist(templateStore);*/ + + + DataStore store = this.dataStoreMgr.getDataStore(imageStore.getId(), DataStoreRole.Image); + TemplateInfo template = templateFactory.getTemplate(image.getId(), DataStoreRole.Image); + DataObject templateOnStore = store.create(template); + TemplateObjectTO to = new TemplateObjectTO(); + to.setPath(this.getImageInstallPath()); + CopyCmdAnswer answer = new CopyCmdAnswer(to); + templateOnStore.processEvent(Event.CreateOnlyRequested); + templateOnStore.processEvent(Event.OperationSuccessed, answer); + + + } + + @Override + protected void injectMockito() { + List<HostVO> hosts = new ArrayList<HostVO>(); + hosts.add(this.host); + Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type) Mockito.any(), Mockito.anyLong(), Mockito.anyLong(), Mockito.anyLong())).thenReturn(hosts); + + RemoteHostEndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(), this.host.getPrivateIpAddress()); + Mockito.when(epSelector.select(Mockito.any(DataObject.class), Mockito.any(DataObject.class))).thenReturn(ep); + Mockito.when(epSelector.select(Mockito.any(DataObject.class))).thenReturn(ep); + Mockito.when(epSelector.select(Mockito.any(DataStore.class))).thenReturn(ep); + } + + public DataStore createPrimaryDataStore() { + try { + String uuid = UUID.nameUUIDFromBytes(this.getPrimaryStorageUrl().getBytes()).toString(); + List<StoragePoolVO> pools = primaryDataStoreDao.findPoolByName(this.primaryName); + if (pools.size() > 0) { + return this.dataStoreMgr.getPrimaryDataStore(pools.get(0).getId()); + } + + /*DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("cloudstack primary data store provider"); + Map<String, Object> params = new HashMap<String, Object>(); + URI uri = new URI(this.getPrimaryStorageUrl()); + params.put("url", this.getPrimaryStorageUrl()); + params.put("server", uri.getHost()); + params.put("path", uri.getPath()); + params.put("protocol", Storage.StoragePoolType.NetworkFilesystem); + params.put("zoneId", dcId); + params.put("clusterId", clusterId); + params.put("name", this.primaryName); + params.put("port", 1); + params.put("podId", this.podId); + params.put("roles", DataStoreRole.Primary.toString()); + params.put("uuid", uuid); + params.put("providerName", String.valueOf(provider.getName())); + + DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle(); + DataStore store = lifeCycle.initialize(params); + ClusterScope scope = new ClusterScope(clusterId, podId, dcId); + 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.VMFS); + 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; + } catch (Exception e) { + return null; + } + } + + private VolumeVO createVolume(Long templateId, long dataStoreId) { + VolumeVO volume = new VolumeVO(1000, new RootDisk().toString(), UUID.randomUUID().toString(), templateId); + volume.setPoolId(dataStoreId); + volume = volumeDao.persist(volume); + return volume; + } + + //@Test + public void testCopyBaseImage() { + DataStore primaryStore = createPrimaryDataStore(); + primaryStoreId = primaryStore.getId(); + primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId); + VolumeVO volume = createVolume(image.getId(), primaryStore.getId()); + VolumeInfo volInfo = this.volFactory.getVolume(volume.getId()); + AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image)); + 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(); + } + + } + + private VMTemplateVO createTemplateInDb() { + image = new VMTemplateVO(); + image.setTemplateType(TemplateType.USER); + + image.setUniqueName(UUID.randomUUID().toString()); + image.setName(UUID.randomUUID().toString()); + image.setPublicTemplate(true); + image.setFeatured(true); + image.setRequiresHvm(true); + image.setBits(64); + image.setFormat(Storage.ImageFormat.VHD); + image.setEnablePassword(true); + image.setEnableSshKey(true); + image.setGuestOSId(1); + image.setBootable(true); + image.setPrepopulate(true); + image.setCrossZones(true); + image.setExtractable(true); + image = imageDataDao.persist(image); + return image; + } + + @Test + public void testCreateTemplateFromVolume() { + 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(); + + AssertJUnit.assertTrue(result.isSuccess()); + volInfo = result.getVolume(); + VMTemplateVO templateVO = createTemplateInDb(); + TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image); + DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId); + + this.imageService.createTemplateFromVolumeAsync(volInfo, tmpl, imageStore); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ExecutionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/99318762/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java index bb31136..9589661 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java @@ -26,6 +26,7 @@ import java.util.Set; import javax.ejb.Local; +import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.log4j.Logger; import com.cloud.resource.ServerResource; @@ -46,6 +47,7 @@ import com.cloud.agent.api.MigrateWithStorageCompleteAnswer; import com.cloud.agent.api.MigrateWithStorageCompleteCommand; import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.network.Networks.TrafficType; +import com.cloud.agent.api.to.DiskTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.api.to.VolumeTO; import com.cloud.agent.api.to.NicTO; @@ -103,9 +105,9 @@ public class XenServer610Resource extends XenServer56FP1Resource { } } - private List<VolumeTO> getUpdatedVolumePathsOfMigratedVm(Connection connection, VM migratedVm, - VolumeTO[] volumes) throws CloudRuntimeException { - List<VolumeTO> volumeToList = new ArrayList<VolumeTO>(); + private List<VolumeObjectTO> getUpdatedVolumePathsOfMigratedVm(Connection connection, VM migratedVm, + DiskTO[] volumes) throws CloudRuntimeException { + List<VolumeObjectTO> volumeToList = new ArrayList<VolumeObjectTO>(); try { // Volume paths would have changed. Return that information. @@ -120,11 +122,14 @@ public class XenServer610Resource extends XenServer56FP1Resource { } } - for (VolumeTO volumeTo : volumes) { - Long deviceId = volumeTo.getDeviceId(); + for (DiskTO volumeTo : volumes) { + VolumeObjectTO vol = (VolumeObjectTO)volumeTo.getData(); + Long deviceId = volumeTo.getDiskSeq(); VDI vdi = deviceIdToVdiMap.get(deviceId.toString()); - volumeTo.setPath(vdi.getUuid(connection)); - volumeToList.add(volumeTo); + VolumeObjectTO newVol = new VolumeObjectTO(); + newVol.setPath(vdi.getUuid(connection)); + newVol.setId(vol.getId()); + volumeToList.add(newVol); } } catch (Exception e) { s_logger.error("Unable to get the updated VDI paths of the migrated vm " + e.toString(), e); @@ -194,7 +199,7 @@ public class XenServer610Resource extends XenServer56FP1Resource { } // Volume paths would have changed. Return that information. - List<VolumeTO> volumeToList = getUpdatedVolumePathsOfMigratedVm(connection, vmToMigrate, vmSpec.getDisks()); + List<VolumeObjectTO> volumeToList = getUpdatedVolumePathsOfMigratedVm(connection, vmToMigrate, vmSpec.getDisks()); vmToMigrate.setAffinity(connection, host); state = State.Stopping; @@ -370,7 +375,7 @@ public class XenServer610Resource extends XenServer56FP1Resource { } // Volume paths would have changed. Return that information. - List<VolumeTO > volumeToSet = getUpdatedVolumePathsOfMigratedVm(connection, migratedVm, vmSpec.getDisks()); + List<VolumeObjectTO > volumeToSet = getUpdatedVolumePathsOfMigratedVm(connection, migratedVm, vmSpec.getDisks()); migratedVm.setAffinity(connection, host); synchronized (_cluster.intern()) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/99318762/plugins/hypervisors/xen/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xen/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java b/plugins/hypervisors/xen/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java index e92b818..49c61fa 100644 --- a/plugins/hypervisors/xen/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java +++ b/plugins/hypervisors/xen/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java @@ -35,6 +35,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; +import org.apache.cloudstack.storage.to.VolumeObjectTO; import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; @@ -213,12 +214,12 @@ public class XenServerStorageMotionStrategy implements DataMotionStrategy { } } - private void updateVolumePathsAfterMigration(Map<VolumeInfo, DataStore> volumeToPool, List<VolumeTO> volumeTos) { + private void updateVolumePathsAfterMigration(Map<VolumeInfo, DataStore> volumeToPool, List<VolumeObjectTO> volumeTos) { for (Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) { boolean updated = false; VolumeInfo volume = entry.getKey(); StoragePool pool = (StoragePool)entry.getValue(); - for (VolumeTO volumeTo : volumeTos) { + for (VolumeObjectTO volumeTo : volumeTos) { if (volume.getId() == volumeTo.getId()) { VolumeVO volumeVO = volDao.findById(volume.getId()); Long oldPoolId = volumeVO.getPoolId(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/99318762/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java ---------------------------------------------------------------------- diff --git a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java index 82df043..db3b225 100644 --- a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java +++ b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java @@ -203,7 +203,7 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver { answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.ABANDONED || answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.UNKNOWN) { CreateCmdResult result = new CreateCmdResult(null, null); - result.setSucess(false); + //result.setSucess(false); result.setResult(answer.getErrorString()); caller.complete(result); } else if (answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) { @@ -295,14 +295,14 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver { if (answer == null || !answer.getResult()) { s_logger.debug("Failed to deleted template at store: " + store.getName()); CommandResult result = new CommandResult(); - result.setSucess(false); + //result.setSucess(false); result.setResult("Delete template failed"); callback.complete(result); } else { s_logger.debug("Deleted template at: " + installPath); CommandResult result = new CommandResult(); - result.setSucess(true); + //result.setSucess(true); callback.complete(result); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/99318762/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java ---------------------------------------------------------------------- diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java index 93eae0a..57424a7 100644 --- a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java +++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java @@ -57,7 +57,7 @@ public class SamplePrimaryDatastoreProviderImpl implements PrimaryDataStoreProvi @Override public boolean configure(Map<String, Object> params) { - lifecyle = ComponentContext.inject(SamplePrimaryDataStoreLifeCycleImpl.class); + lifecycle = ComponentContext.inject(SamplePrimaryDataStoreLifeCycleImpl.class); driver = ComponentContext.inject(SamplePrimaryDataStoreDriverImpl.class); listener = ComponentContext.inject(DefaultHostListener.class); return true; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/99318762/tools/apidoc/gen_toc.py ---------------------------------------------------------------------- diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py index f8bdae2..f60c18e 100644 --- a/tools/apidoc/gen_toc.py +++ b/tools/apidoc/gen_toc.py @@ -140,6 +140,10 @@ known_categories = { 'removeIpFromNic': 'Nic', 'listNics':'Nic', 'AffinityGroup': 'Affinity Group', + 'addImageStore': 'Image Store', + 'listImageStore': 'Image Store', + 'deleteImageStore': 'Image Store', + 'createCacheStore': 'Image Store', }