mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
starting unit test
This commit is contained in:
parent
d62da2a7b5
commit
573d13dd7c
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.engine.subsystem.api.storage;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
|
||||||
|
|
||||||
|
|
||||||
public interface PrimaryDataStore {
|
|
||||||
VolumeEntity getVolume(String id);
|
|
||||||
List<VolumeEntity> getVolumes();
|
|
||||||
boolean deleteVolume(VolumeEntity id);
|
|
||||||
VolumeEntity createVolume(String id, VolumeDiskType diskType);
|
|
||||||
List<EndPoint> getEndPoints();
|
|
||||||
PrimaryDataStoreInfo getDataStoreInfo();
|
|
||||||
}
|
|
||||||
@ -34,6 +34,7 @@ public class HypervisorHostEndPoint implements EndPoint {
|
|||||||
private long hostId;
|
private long hostId;
|
||||||
@Inject
|
@Inject
|
||||||
AgentManager agentMgr;
|
AgentManager agentMgr;
|
||||||
|
|
||||||
public HypervisorHostEndPoint(long hostId) {
|
public HypervisorHostEndPoint(long hostId) {
|
||||||
this.hostId = hostId;
|
this.hostId = hostId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -260,7 +260,6 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (needToCreateVolume) {
|
if (needToCreateVolume) {
|
||||||
createVolumeOnStorage(volume, destStore, reservationId);
|
createVolumeOnStorage(volume, destStore, reservationId);
|
||||||
} else if (needToMigrateVolume) {
|
} else if (needToMigrateVolume) {
|
||||||
@ -276,7 +275,6 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
public void prepare(long vmId, DeploymentPlan plan, String reservationId) {
|
public void prepare(long vmId, DeploymentPlan plan, String reservationId) {
|
||||||
VirtualMachine vm = _vmDao.findById(vmId);
|
VirtualMachine vm = _vmDao.findById(vmId);
|
||||||
|
|
||||||
|
|
||||||
List<VolumeVO> vols = _volumeDao.findUsableVolumesForInstance(vm.getId());
|
List<VolumeVO> vols = _volumeDao.findUsableVolumesForInstance(vm.getId());
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Prepare " + vols.size() + " volumes for " + vm.getInstanceName());
|
s_logger.debug("Prepare " + vols.size() + " volumes for " + vm.getInstanceName());
|
||||||
@ -289,7 +287,6 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void release(long vmId, String reservationId) {
|
public void release(long vmId, String reservationId) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
@ -338,8 +335,6 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
_volumeDao.update(volume.getId(), volume);
|
_volumeDao.update(volume.getId(), volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createVolume(VolumeEntity volume, long dataStoreId, VolumeDiskType diskType) {
|
public boolean createVolume(VolumeEntity volume, long dataStoreId, VolumeDiskType diskType) {
|
||||||
VolumeEntityImpl vei = ((VolumeEntityImpl) volume);
|
VolumeEntityImpl vei = ((VolumeEntityImpl) volume);
|
||||||
|
|||||||
@ -5,7 +5,10 @@ import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
|
|||||||
|
|
||||||
public interface StorageProviderManager {
|
public interface StorageProviderManager {
|
||||||
StorageProvider getProvider(String uuid);
|
StorageProvider getProvider(String uuid);
|
||||||
|
|
||||||
StorageProvider getProvider(long poolId);
|
StorageProvider getProvider(long poolId);
|
||||||
|
|
||||||
StorageProvider getBackupStorageProvider(long zoneId);
|
StorageProvider getBackupStorageProvider(long zoneId);
|
||||||
|
|
||||||
DataStore getDataStore(long poolId);
|
DataStore getDataStore(long poolId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,8 +16,7 @@ public class StorageProviderManagerImpl implements StorageProviderManager, Manag
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean configure(String name, Map<String, Object> params)
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
throws ConfigurationException {
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,5 +20,6 @@ package org.apache.cloudstack.storage.backup;
|
|||||||
|
|
||||||
public interface BackupService {
|
public interface BackupService {
|
||||||
String grantAccessSnapshot(long snapshotId, long endpointId);
|
String grantAccessSnapshot(long snapshotId, long endpointId);
|
||||||
|
|
||||||
boolean revokeAccessSnapshot(long snapshotId, long endpointId);
|
boolean revokeAccessSnapshot(long snapshotId, long endpointId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import com.cloud.agent.api.Answer;
|
|||||||
|
|
||||||
public class CreateVolumeAnswer extends Answer {
|
public class CreateVolumeAnswer extends Answer {
|
||||||
private String volumeUuid;
|
private String volumeUuid;
|
||||||
|
|
||||||
protected CreateVolumeAnswer() {
|
protected CreateVolumeAnswer() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import com.cloud.agent.api.Command;
|
|||||||
|
|
||||||
public class CreateVolumeCommand extends Command {
|
public class CreateVolumeCommand extends Command {
|
||||||
protected VolumeTO volumeInfo;
|
protected VolumeTO volumeInfo;
|
||||||
|
|
||||||
public CreateVolumeCommand(VolumeTO volumeInfo) {
|
public CreateVolumeCommand(VolumeTO volumeInfo) {
|
||||||
super();
|
super();
|
||||||
this.volumeInfo = volumeInfo;
|
this.volumeInfo = volumeInfo;
|
||||||
|
|||||||
@ -26,10 +26,12 @@ import com.cloud.agent.api.Command;
|
|||||||
public class CreateVolumeFromBaseImageCommand extends Command {
|
public class CreateVolumeFromBaseImageCommand extends Command {
|
||||||
private VolumeTO volume;
|
private VolumeTO volume;
|
||||||
private ImageOnPrimayDataStoreTO image;
|
private ImageOnPrimayDataStoreTO image;
|
||||||
|
|
||||||
public CreateVolumeFromBaseImageCommand(VolumeTO volume, ImageOnPrimayDataStoreTO image) {
|
public CreateVolumeFromBaseImageCommand(VolumeTO volume, ImageOnPrimayDataStoreTO image) {
|
||||||
this.volume = volume;
|
this.volume = volume;
|
||||||
this.image = image;
|
this.image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeInSequence() {
|
public boolean executeInSequence() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|||||||
@ -19,11 +19,5 @@
|
|||||||
package org.apache.cloudstack.storage.datastore;
|
package org.apache.cloudstack.storage.datastore;
|
||||||
|
|
||||||
public enum DataStoreStatus {
|
public enum DataStoreStatus {
|
||||||
Creating,
|
Creating, Up, PrepareForMaintenance, ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
|
||||||
Up,
|
|
||||||
PrepareForMaintenance,
|
|
||||||
ErrorInMaintenance,
|
|
||||||
CancelMaintenance,
|
|
||||||
Maintenance,
|
|
||||||
Removed;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,8 +38,7 @@ public class DefaultDataStore implements DataStore {
|
|||||||
protected long _id;
|
protected long _id;
|
||||||
protected DataStoreLifeCycle _dslf;
|
protected DataStoreLifeCycle _dslf;
|
||||||
|
|
||||||
public DefaultDataStore(
|
public DefaultDataStore() {
|
||||||
) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getURI() {
|
public String getURI() {
|
||||||
|
|||||||
@ -46,6 +46,7 @@ public class DefaultPrimaryDataStoreImpl implements PrimaryDataStore {
|
|||||||
private HostDao hostDao;
|
private HostDao hostDao;
|
||||||
@Inject
|
@Inject
|
||||||
TemplatePrimaryDataStoreManager templatePrimaryStoreMgr;
|
TemplatePrimaryDataStoreManager templatePrimaryStoreMgr;
|
||||||
|
|
||||||
public DefaultPrimaryDataStoreImpl(PrimaryDataStoreDriver driver, DataStoreVO pdsv, PrimaryDataStoreInfo pdsInfo) {
|
public DefaultPrimaryDataStoreImpl(PrimaryDataStoreDriver driver, DataStoreVO pdsv, PrimaryDataStoreInfo pdsInfo) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
this.pdsv = pdsv;
|
this.pdsv = pdsv;
|
||||||
|
|||||||
@ -30,19 +30,29 @@ import org.apache.cloudstack.storage.image.TemplateObject;
|
|||||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeObject;
|
import org.apache.cloudstack.storage.volume.VolumeObject;
|
||||||
|
|
||||||
|
|
||||||
public interface PrimaryDataStore extends PrimaryDataStoreInfo {
|
public interface PrimaryDataStore extends PrimaryDataStoreInfo {
|
||||||
VolumeInfo getVolume(long id);
|
VolumeInfo getVolume(long id);
|
||||||
|
|
||||||
List<VolumeInfo> getVolumes();
|
List<VolumeInfo> getVolumes();
|
||||||
|
|
||||||
boolean deleteVolume(long id);
|
boolean deleteVolume(long id);
|
||||||
|
|
||||||
VolumeInfo createVolume(VolumeInfo vo, VolumeDiskType diskType);
|
VolumeInfo createVolume(VolumeInfo vo, VolumeDiskType diskType);
|
||||||
|
|
||||||
VolumeInfo createVoluemFromBaseImage(VolumeInfo volume, TemplateOnPrimaryDataStoreInfo templateStore);
|
VolumeInfo createVoluemFromBaseImage(VolumeInfo volume, TemplateOnPrimaryDataStoreInfo templateStore);
|
||||||
|
|
||||||
List<EndPoint> getEndPoints();
|
List<EndPoint> getEndPoints();
|
||||||
|
|
||||||
PrimaryDataStoreInfo getDataStoreInfo();
|
PrimaryDataStoreInfo getDataStoreInfo();
|
||||||
|
|
||||||
boolean exists(VolumeInfo vi);
|
boolean exists(VolumeInfo vi);
|
||||||
|
|
||||||
boolean templateExists(TemplateInfo template);
|
boolean templateExists(TemplateInfo template);
|
||||||
|
|
||||||
TemplateOnPrimaryDataStoreInfo getTemplate(TemplateInfo template);
|
TemplateOnPrimaryDataStoreInfo getTemplate(TemplateInfo template);
|
||||||
|
|
||||||
boolean installTemplate(TemplateOnPrimaryDataStoreInfo template);
|
boolean installTemplate(TemplateOnPrimaryDataStoreInfo template);
|
||||||
|
|
||||||
VolumeDiskType getDefaultDiskType();
|
VolumeDiskType getDefaultDiskType();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,8 +33,7 @@ public class PrimaryDataStoreInfoImpl implements PrimaryDataStoreInfo {
|
|||||||
protected long avail;
|
protected long avail;
|
||||||
protected boolean localStorage;
|
protected boolean localStorage;
|
||||||
|
|
||||||
public PrimaryDataStoreInfoImpl(List<HypervisorType> hypers, List<VolumeDiskType> diskTypes,
|
public PrimaryDataStoreInfoImpl(List<HypervisorType> hypers, List<VolumeDiskType> diskTypes, long capacity, long avail, boolean localStorage) {
|
||||||
long capacity, long avail, boolean localStorage) {
|
|
||||||
this.avail = avail;
|
this.avail = avail;
|
||||||
this.caapcity = capacity;
|
this.caapcity = capacity;
|
||||||
this.localStorage = localStorage;
|
this.localStorage = localStorage;
|
||||||
|
|||||||
@ -122,7 +122,6 @@ public class DataStoreVO implements Identity {
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getPoolType() {
|
public String getPoolType() {
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
@ -175,7 +174,6 @@ public class DataStoreVO implements Identity {
|
|||||||
capacityBytes = capacity;
|
capacityBytes = capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Long getClusterId() {
|
public Long getClusterId() {
|
||||||
return clusterId;
|
return clusterId;
|
||||||
}
|
}
|
||||||
@ -196,8 +194,7 @@ public class DataStoreVO implements Identity {
|
|||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(DataStoreStatus status)
|
public void setStatus(DataStoreStatus status) {
|
||||||
{
|
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,40 +25,47 @@ import org.apache.cloudstack.storage.datastore.DataStoreStatus;
|
|||||||
|
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
|
||||||
|
|
||||||
public interface PrimaryDataStoreDao extends GenericDao<DataStoreVO, Long> {
|
public interface PrimaryDataStoreDao extends GenericDao<DataStoreVO, Long> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param datacenterId -- the id of the datacenter (availability zone)
|
* @param datacenterId
|
||||||
|
* -- the id of the datacenter (availability zone)
|
||||||
*/
|
*/
|
||||||
List<DataStoreVO> listByDataCenterId(long datacenterId);
|
List<DataStoreVO> listByDataCenterId(long datacenterId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param datacenterId -- the id of the datacenter (availability zone)
|
* @param datacenterId
|
||||||
|
* -- the id of the datacenter (availability zone)
|
||||||
*/
|
*/
|
||||||
List<DataStoreVO> listBy(long datacenterId, long podId, Long clusterId);
|
List<DataStoreVO> listBy(long datacenterId, long podId, Long clusterId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set capacity of storage pool in bytes
|
* Set capacity of storage pool in bytes
|
||||||
* @param id pool id.
|
*
|
||||||
* @param capacity capacity in bytes
|
* @param id
|
||||||
|
* pool id.
|
||||||
|
* @param capacity
|
||||||
|
* capacity in bytes
|
||||||
*/
|
*/
|
||||||
void updateCapacity(long id, long capacity);
|
void updateCapacity(long id, long capacity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set available bytes of storage pool in bytes
|
* Set available bytes of storage pool in bytes
|
||||||
* @param id pool id.
|
*
|
||||||
* @param available available capacity in bytes
|
* @param id
|
||||||
|
* pool id.
|
||||||
|
* @param available
|
||||||
|
* available capacity in bytes
|
||||||
*/
|
*/
|
||||||
void updateAvailable(long id, long available);
|
void updateAvailable(long id, long available);
|
||||||
|
|
||||||
|
|
||||||
DataStoreVO persist(DataStoreVO pool, Map<String, String> details);
|
DataStoreVO persist(DataStoreVO pool, Map<String, String> details);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find pool by name.
|
* Find pool by name.
|
||||||
*
|
*
|
||||||
* @param name name of pool.
|
* @param name
|
||||||
|
* name of pool.
|
||||||
* @return the single StoragePoolVO
|
* @return the single StoragePoolVO
|
||||||
*/
|
*/
|
||||||
List<DataStoreVO> findPoolByName(String name);
|
List<DataStoreVO> findPoolByName(String name);
|
||||||
@ -66,8 +73,10 @@ public interface PrimaryDataStoreDao extends GenericDao<DataStoreVO, Long> {
|
|||||||
/**
|
/**
|
||||||
* Find pools by the pod that matches the details.
|
* Find pools by the pod that matches the details.
|
||||||
*
|
*
|
||||||
* @param podId pod id to find the pools in.
|
* @param podId
|
||||||
* @param details details to match. All must match for the pool to be returned.
|
* pod id to find the pools in.
|
||||||
|
* @param details
|
||||||
|
* details to match. All must match for the pool to be returned.
|
||||||
* @return List of StoragePoolVO
|
* @return List of StoragePoolVO
|
||||||
*/
|
*/
|
||||||
List<DataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details);
|
List<DataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details);
|
||||||
@ -77,7 +86,8 @@ public interface PrimaryDataStoreDao extends GenericDao<DataStoreVO, Long> {
|
|||||||
/**
|
/**
|
||||||
* Find pool by UUID.
|
* Find pool by UUID.
|
||||||
*
|
*
|
||||||
* @param uuid uuid of pool.
|
* @param uuid
|
||||||
|
* uuid of pool.
|
||||||
* @return the single StoragePoolVO
|
* @return the single StoragePoolVO
|
||||||
*/
|
*/
|
||||||
DataStoreVO findPoolByUUID(String uuid);
|
DataStoreVO findPoolByUUID(String uuid);
|
||||||
|
|||||||
@ -34,6 +34,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import com.cloud.storage.StoragePoolDetailVO;
|
import com.cloud.storage.StoragePoolDetailVO;
|
||||||
import com.cloud.storage.dao.StoragePoolDetailsDao;
|
import com.cloud.storage.dao.StoragePoolDetailsDao;
|
||||||
import com.cloud.storage.dao.StoragePoolDetailsDaoImpl;
|
import com.cloud.storage.dao.StoragePoolDetailsDaoImpl;
|
||||||
|
import com.cloud.utils.component.ComponentInject;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
@ -53,9 +54,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>
|
|||||||
protected final SearchBuilder<DataStoreVO> DeleteLvmSearch;
|
protected final SearchBuilder<DataStoreVO> DeleteLvmSearch;
|
||||||
protected final GenericSearchBuilder<DataStoreVO, Long> StatusCountSearch;
|
protected final GenericSearchBuilder<DataStoreVO, Long> StatusCountSearch;
|
||||||
|
|
||||||
|
protected final PrimaryDataStoreDetailsDao _detailsDao = null;
|
||||||
|
|
||||||
protected final StoragePoolDetailsDao _detailsDao;
|
|
||||||
|
|
||||||
private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and (";
|
private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and (";
|
||||||
private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
|
private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
|
||||||
@ -97,14 +96,12 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>
|
|||||||
DeleteLvmSearch.cp();
|
DeleteLvmSearch.cp();
|
||||||
DeleteLvmSearch.done();
|
DeleteLvmSearch.done();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StatusCountSearch = createSearchBuilder(Long.class);
|
StatusCountSearch = createSearchBuilder(Long.class);
|
||||||
StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
|
StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
|
||||||
StatusCountSearch.select(null, Func.COUNT, null);
|
StatusCountSearch.select(null, Func.COUNT, null);
|
||||||
StatusCountSearch.done();
|
StatusCountSearch.done();
|
||||||
|
|
||||||
_detailsDao = ComponentLocator.inject(StoragePoolDetailsDaoImpl.class);
|
// _detailsDao = ComponentInject.inject(PrimaryDataStoreDetailsDaoImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,7 +111,6 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>
|
|||||||
return listIncludingRemovedBy(sc);
|
return listIncludingRemovedBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataStoreVO findPoolByUUID(String uuid) {
|
public DataStoreVO findPoolByUUID(String uuid) {
|
||||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||||
@ -122,8 +118,6 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>
|
|||||||
return findOneIncludingRemovedBy(sc);
|
return findOneIncludingRemovedBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid) {
|
public List<DataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid) {
|
||||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||||
@ -131,7 +125,6 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>
|
|||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataStoreVO> listByDataCenterId(long datacenterId) {
|
public List<DataStoreVO> listByDataCenterId(long datacenterId) {
|
||||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||||
@ -139,7 +132,6 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>
|
|||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAvailable(long id, long available) {
|
public void updateAvailable(long id, long available) {
|
||||||
DataStoreVO pool = createForUpdate(id);
|
DataStoreVO pool = createForUpdate(id);
|
||||||
@ -147,7 +139,6 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>
|
|||||||
update(id, pool);
|
update(id, pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCapacity(long id, long capacity) {
|
public void updateCapacity(long id, long capacity) {
|
||||||
DataStoreVO pool = createForUpdate(id);
|
DataStoreVO pool = createForUpdate(id);
|
||||||
@ -216,22 +207,22 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>
|
|||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataStoreVO listById(Integer id)
|
public DataStoreVO listById(Integer id) {
|
||||||
{
|
|
||||||
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
SearchCriteria<DataStoreVO> sc = AllFieldSearch.create();
|
||||||
sc.setParameters("id", id);
|
sc.setParameters("id", id);
|
||||||
|
|
||||||
return findOneIncludingRemovedBy(sc);
|
return findOneIncludingRemovedBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override
|
||||||
|
@DB
|
||||||
public DataStoreVO persist(DataStoreVO pool, Map<String, String> details) {
|
public DataStoreVO persist(DataStoreVO pool, Map<String, String> details) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
pool = super.persist(pool);
|
pool = super.persist(pool);
|
||||||
if (details != null) {
|
if (details != null) {
|
||||||
for (Map.Entry<String, String> detail : details.entrySet()) {
|
for (Map.Entry<String, String> detail : details.entrySet()) {
|
||||||
StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue());
|
PrimaryDataStoreDetailVO vo = new PrimaryDataStoreDetailVO(pool.getId(), detail.getKey(), detail.getValue());
|
||||||
_detailsDao.persist(vo);
|
_detailsDao.persist(vo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,9 +288,9 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>
|
|||||||
List<DataStoreVO> filteredStoragePools = new ArrayList<DataStoreVO>(storagePools);
|
List<DataStoreVO> filteredStoragePools = new ArrayList<DataStoreVO>(storagePools);
|
||||||
for (DataStoreVO pool : storagePools) {
|
for (DataStoreVO pool : storagePools) {
|
||||||
/*
|
/*
|
||||||
if (shared != pool.isShared()) {
|
* if (shared != pool.isShared()) {
|
||||||
filteredStoragePools.remove(pool);
|
* filteredStoragePools.remove(pool); }
|
||||||
}*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return filteredStoragePools;
|
return filteredStoragePools;
|
||||||
@ -351,8 +342,6 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<DataStoreVO, Long>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long countPoolsByStatus(DataStoreStatus... statuses) {
|
public long countPoolsByStatus(DataStoreStatus... statuses) {
|
||||||
SearchCriteria<Long> sc = StatusCountSearch.create();
|
SearchCriteria<Long> sc = StatusCountSearch.create();
|
||||||
|
|||||||
@ -0,0 +1,79 @@
|
|||||||
|
// 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.datastore.db;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name="storage_pool_details")
|
||||||
|
public class PrimaryDataStoreDetailVO {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
@Column(name="id")
|
||||||
|
long id;
|
||||||
|
|
||||||
|
@Column(name="pool_id")
|
||||||
|
long poolId;
|
||||||
|
|
||||||
|
@Column(name="name")
|
||||||
|
String name;
|
||||||
|
|
||||||
|
@Column(name="value")
|
||||||
|
String value;
|
||||||
|
|
||||||
|
public PrimaryDataStoreDetailVO(long poolId, String name, String value) {
|
||||||
|
this.poolId = poolId;
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getPoolId() {
|
||||||
|
return poolId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoolId(long poolId) {
|
||||||
|
this.poolId = poolId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PrimaryDataStoreDetailVO() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
// 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.datastore.db;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.cloud.storage.StoragePoolDetailVO;
|
||||||
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
|
||||||
|
public interface PrimaryDataStoreDetailsDao extends GenericDao<PrimaryDataStoreDetailVO, Long> {
|
||||||
|
|
||||||
|
void update(long poolId, Map<String, String> details);
|
||||||
|
Map<String, String> getDetails(long poolId);
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
// 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.datastore.db;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
|
import com.cloud.utils.db.Transaction;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PrimaryDataStoreDetailsDaoImpl extends GenericDaoBase<PrimaryDataStoreDetailVO, Long> implements PrimaryDataStoreDetailsDao {
|
||||||
|
|
||||||
|
protected final SearchBuilder<PrimaryDataStoreDetailVO> PoolSearch = null;
|
||||||
|
|
||||||
|
protected PrimaryDataStoreDetailsDaoImpl() {
|
||||||
|
/*
|
||||||
|
super();
|
||||||
|
PoolSearch = createSearchBuilder();
|
||||||
|
PoolSearch.and("pool", PoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||||
|
PoolSearch.done();
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(long poolId, Map<String, String> details) {
|
||||||
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
SearchCriteria<PrimaryDataStoreDetailVO> sc = PoolSearch.create();
|
||||||
|
sc.setParameters("pool", poolId);
|
||||||
|
|
||||||
|
txn.start();
|
||||||
|
expunge(sc);
|
||||||
|
for (Map.Entry<String, String> entry : details.entrySet()) {
|
||||||
|
PrimaryDataStoreDetailVO detail = new PrimaryDataStoreDetailVO(poolId, entry.getKey(), entry.getValue());
|
||||||
|
persist(detail);
|
||||||
|
}
|
||||||
|
txn.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getDetails(long poolId) {
|
||||||
|
SearchCriteria<PrimaryDataStoreDetailVO> sc = PoolSearch.create();
|
||||||
|
sc.setParameters("pool", poolId);
|
||||||
|
|
||||||
|
List<PrimaryDataStoreDetailVO> details = listBy(sc);
|
||||||
|
Map<String, String> detailsMap = new HashMap<String, String>();
|
||||||
|
for (PrimaryDataStoreDetailVO detail : details) {
|
||||||
|
detailsMap.put(detail.getName(), detail.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return detailsMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -20,12 +20,13 @@ import com.cloud.agent.api.Command;
|
|||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DefaultPrimaryDataStoreDriverImpl implements
|
public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
|
||||||
PrimaryDataStoreDriver {
|
|
||||||
private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreDriverImpl.class);
|
private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreDriverImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createVolume(VolumeObject vol) {
|
public boolean createVolume(VolumeObject vol) {
|
||||||
//The default driver will send createvolume command to one of hosts which can access its datastore
|
// The default driver will send createvolume command to one of hosts
|
||||||
|
// which can access its datastore
|
||||||
List<EndPoint> endPoints = vol.getDataStore().getEndPoints();
|
List<EndPoint> endPoints = vol.getDataStore().getEndPoints();
|
||||||
int retries = 3;
|
int retries = 3;
|
||||||
VolumeInfo volInfo = vol;
|
VolumeInfo volInfo = vol;
|
||||||
|
|||||||
@ -4,11 +4,14 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
|||||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeObject;
|
import org.apache.cloudstack.storage.volume.VolumeObject;
|
||||||
|
|
||||||
|
|
||||||
public interface PrimaryDataStoreDriver {
|
public interface PrimaryDataStoreDriver {
|
||||||
boolean createVolume(VolumeObject vol);
|
boolean createVolume(VolumeObject vol);
|
||||||
|
|
||||||
boolean createVolumeFromBaseImage(VolumeObject volume, TemplateOnPrimaryDataStoreInfo template);
|
boolean createVolumeFromBaseImage(VolumeObject volume, TemplateOnPrimaryDataStoreInfo template);
|
||||||
|
|
||||||
boolean deleteVolume(VolumeObject vo);
|
boolean deleteVolume(VolumeObject vo);
|
||||||
|
|
||||||
String grantAccess(VolumeObject vol, EndPoint ep);
|
String grantAccess(VolumeObject vol, EndPoint ep);
|
||||||
|
|
||||||
boolean revokeAccess(VolumeObject vol, EndPoint ep);
|
boolean revokeAccess(VolumeObject vol, EndPoint ep);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,10 +22,16 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface PrimaryDataStoreLifeCycle {
|
public interface PrimaryDataStoreLifeCycle {
|
||||||
public boolean registerDataStore(Map<String, String> dsInfos);
|
public boolean registerDataStore(Map<String, String> dsInfos);
|
||||||
|
|
||||||
public boolean attach(long scope);
|
public boolean attach(long scope);
|
||||||
|
|
||||||
public boolean dettach(long dataStoreId);
|
public boolean dettach(long dataStoreId);
|
||||||
|
|
||||||
public boolean unmanaged(long dataStoreId);
|
public boolean unmanaged(long dataStoreId);
|
||||||
|
|
||||||
public boolean maintain(long dataStoreId);
|
public boolean maintain(long dataStoreId);
|
||||||
|
|
||||||
public boolean cancelMaintain(long dataStoreId);
|
public boolean cancelMaintain(long dataStoreId);
|
||||||
|
|
||||||
public boolean deleteDataStore(long dataStoreId);
|
public boolean deleteDataStore(long dataStoreId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,7 @@ public class DefaultPrimaryDataStoreManagerImpl implements PrimaryDataStoreManag
|
|||||||
PrimaryDataStoreProviderManager providerManager;
|
PrimaryDataStoreProviderManager providerManager;
|
||||||
@Inject
|
@Inject
|
||||||
PrimaryDataStoreDao dataStoreDao;
|
PrimaryDataStoreDao dataStoreDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PrimaryDataStore getPrimaryDataStore(long dataStoreId) {
|
public PrimaryDataStore getPrimaryDataStore(long dataStoreId) {
|
||||||
DataStoreVO dataStoreVO = dataStoreDao.findById(dataStoreId);
|
DataStoreVO dataStoreVO = dataStoreDao.findById(dataStoreId);
|
||||||
|
|||||||
@ -23,5 +23,6 @@ import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCyc
|
|||||||
|
|
||||||
public interface PrimaryDataStoreManager {
|
public interface PrimaryDataStoreManager {
|
||||||
public PrimaryDataStore getPrimaryDataStore(long dataStoreId);
|
public PrimaryDataStore getPrimaryDataStore(long dataStoreId);
|
||||||
|
|
||||||
public PrimaryDataStoreLifeCycle getPrimaryDataStoreLifeCycle(long dataStoreId);
|
public PrimaryDataStoreLifeCycle getPrimaryDataStoreLifeCycle(long dataStoreId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import com.cloud.utils.component.ComponentInject;
|
import com.cloud.utils.component.ComponentInject;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DefaultPrimaryDatastoreProviderImpl implements
|
public class DefaultPrimaryDatastoreProviderImpl implements PrimaryDataStoreProvider {
|
||||||
PrimaryDataStoreProvider {
|
|
||||||
protected PrimaryDataStoreDriver driver;
|
protected PrimaryDataStoreDriver driver;
|
||||||
@Inject
|
@Inject
|
||||||
public PrimaryDataStoreDao dataStoreDao;
|
public PrimaryDataStoreDao dataStoreDao;
|
||||||
@ -23,6 +22,7 @@ public class DefaultPrimaryDatastoreProviderImpl implements
|
|||||||
public DefaultPrimaryDatastoreProviderImpl() {
|
public DefaultPrimaryDatastoreProviderImpl() {
|
||||||
this.driver = new DefaultPrimaryDataStoreDriverImpl();
|
this.driver = new DefaultPrimaryDataStoreDriverImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PrimaryDataStore getDataStore(long dataStoreId) {
|
public PrimaryDataStore getDataStore(long dataStoreId) {
|
||||||
DataStoreVO dsv = dataStoreDao.findById(dataStoreId);
|
DataStoreVO dsv = dataStoreDao.findById(dataStoreId);
|
||||||
|
|||||||
@ -3,9 +3,8 @@ package org.apache.cloudstack.storage.datastore.provider;
|
|||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface PrimaryDataStoreProvider {
|
public interface PrimaryDataStoreProvider {
|
||||||
public PrimaryDataStore getDataStore(long dataStoreId);
|
public PrimaryDataStore getDataStore(long dataStoreId);
|
||||||
|
|
||||||
public PrimaryDataStoreInfo getDataStoreInfo(long dataStoreId);
|
public PrimaryDataStoreInfo getDataStoreInfo(long dataStoreId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package org.apache.cloudstack.storage.datastore.provider;
|
package org.apache.cloudstack.storage.datastore.provider;
|
||||||
|
|
||||||
|
|
||||||
public interface PrimaryDataStoreProviderManager {
|
public interface PrimaryDataStoreProviderManager {
|
||||||
public PrimaryDataStoreProvider getDataStoreProvider(Long providerId);
|
public PrimaryDataStoreProvider getDataStoreProvider(Long providerId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class ISCSI extends BaseType implements DataStoreType {
|
public class ISCSI extends BaseType implements DataStoreType {
|
||||||
private final String type = "iscsi";
|
private final String type = "iscsi";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class NetworkFileSystem extends BaseType implements DataStoreType {
|
public class NetworkFileSystem extends BaseType implements DataStoreType {
|
||||||
private final String type = "nfs";
|
private final String type = "nfs";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import org.apache.cloudstack.storage.BaseType;
|
|||||||
|
|
||||||
public class SharedMount extends BaseType implements DataStoreType {
|
public class SharedMount extends BaseType implements DataStoreType {
|
||||||
private final String type = "SharedMountPoint";
|
private final String type = "SharedMountPoint";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
@ -40,8 +40,7 @@ public abstract class AbstractStorageDriver implements DataStoreDriver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TemplateProfile install(TemplateProfile tp, DataStoreEndPoint ep) {
|
public TemplateProfile install(TemplateProfile tp, DataStoreEndPoint ep) {
|
||||||
PrimaryStorageDownloadCommand dcmd = new PrimaryStorageDownloadCommand(tp.getName(), tp.getUrl(), tp.getFormat(),
|
PrimaryStorageDownloadCommand dcmd = new PrimaryStorageDownloadCommand(tp.getName(), tp.getUrl(), tp.getFormat(), 0, _ds.getId(), _ds.getUUID(), _ts.getDownloadWait());
|
||||||
0, _ds.getId(), _ds.getUUID(), _ts.getDownloadWait());
|
|
||||||
dcmd.setSecondaryStorageUrl(tp.getImageStorageUri());
|
dcmd.setSecondaryStorageUrl(tp.getImageStorageUri());
|
||||||
dcmd.setPrimaryStorageUrl(_ds.getURI());
|
dcmd.setPrimaryStorageUrl(_ds.getURI());
|
||||||
PrimaryStorageDownloadAnswer asw = (PrimaryStorageDownloadAnswer) ep.sendCommand(dcmd);
|
PrimaryStorageDownloadAnswer asw = (PrimaryStorageDownloadAnswer) ep.sendCommand(dcmd);
|
||||||
@ -52,8 +51,7 @@ public abstract class AbstractStorageDriver implements DataStoreDriver {
|
|||||||
|
|
||||||
public TemplateProfile register(TemplateProfile tp, DataStoreEndPoint ep, boolean freshDownload) {
|
public TemplateProfile register(TemplateProfile tp, DataStoreEndPoint ep, boolean freshDownload) {
|
||||||
|
|
||||||
DownloadCommand dcmd =
|
DownloadCommand dcmd = new DownloadCommand(_ds.getURI(), tp.getTemplate(), _ts.getMaxTemplateSizeInBytes());
|
||||||
new DownloadCommand(_ds.getURI(), tp.getTemplate(), _ts.getMaxTemplateSizeInBytes());
|
|
||||||
dcmd.setProxy(_ts.getHttpProxy());
|
dcmd.setProxy(_ts.getHttpProxy());
|
||||||
if (!freshDownload) {
|
if (!freshDownload) {
|
||||||
dcmd = new DownloadProgressCommand(dcmd, tp.getJobId(), RequestType.GET_OR_RESTART);
|
dcmd = new DownloadProgressCommand(dcmd, tp.getJobId(), RequestType.GET_OR_RESTART);
|
||||||
@ -63,14 +61,13 @@ public abstract class AbstractStorageDriver implements DataStoreDriver {
|
|||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
public VolumeProfile createVolumeFromTemplate(VolumeProfile volProfile, TemplateProfile tp, DataStoreEndPoint ep) {
|
* public VolumeProfile createVolumeFromTemplate(VolumeProfile volProfile,
|
||||||
CreateCommand cmd = new CreateCommand(volProfile, tp.getLocalPath(), _ds.getTO());
|
* TemplateProfile tp, DataStoreEndPoint ep) { CreateCommand cmd = new
|
||||||
CreateAnswer ans = (CreateAnswer)ep.sendCommand(cmd);
|
* CreateCommand(volProfile, tp.getLocalPath(), _ds.getTO()); CreateAnswer
|
||||||
VolumeTO created = ans.getVolume();
|
* ans = (CreateAnswer)ep.sendCommand(cmd); VolumeTO created =
|
||||||
DiskProfile diskProfile = new VolumeProfile(volProfile);
|
* ans.getVolume(); DiskProfile diskProfile = new VolumeProfile(volProfile);
|
||||||
diskProfile.setPath(created.getPath());
|
* diskProfile.setPath(created.getPath());
|
||||||
diskProfile.setSize(created.getSize());
|
* diskProfile.setSize(created.getSize()); return diskProfile; return null;
|
||||||
return diskProfile;
|
* }
|
||||||
return null;
|
*/
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,9 +26,9 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
|
|||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.Command;
|
import com.cloud.agent.api.Command;
|
||||||
|
|
||||||
|
|
||||||
public class XenServerStorageDriver extends AbstractStorageDriver {
|
public class XenServerStorageDriver extends AbstractStorageDriver {
|
||||||
protected DataStore _ds;
|
protected DataStore _ds;
|
||||||
|
|
||||||
public XenServerStorageDriver(DataStore ds) {
|
public XenServerStorageDriver(DataStore ds) {
|
||||||
super(ds);
|
super(ds);
|
||||||
_ds = ds;
|
_ds = ds;
|
||||||
|
|||||||
@ -21,12 +21,12 @@ package org.apache.cloudstack.storage.image;
|
|||||||
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.TemplateProfile;
|
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile;
|
||||||
|
|
||||||
|
|
||||||
import com.cloud.api.commands.RegisterTemplateCmd;
|
import com.cloud.api.commands.RegisterTemplateCmd;
|
||||||
|
|
||||||
|
|
||||||
public interface ImageManager {
|
public interface ImageManager {
|
||||||
TemplateProfile AssociateTemplateStoragePool(TemplateProfile tp, DataStore ds);
|
TemplateProfile AssociateTemplateStoragePool(TemplateProfile tp, DataStore ds);
|
||||||
|
|
||||||
TemplateProfile getProfile(long templateId);
|
TemplateProfile getProfile(long templateId);
|
||||||
|
|
||||||
TemplateProfile allocateTemplateInDB(RegisterTemplateCmd cmd);
|
TemplateProfile allocateTemplateInDB(RegisterTemplateCmd cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,11 +106,9 @@ public class ImageManagerImpl implements ImageManager {
|
|||||||
|
|
||||||
protected TemplateProfile persistTemplate(TemplateProfile profile) {
|
protected TemplateProfile persistTemplate(TemplateProfile profile) {
|
||||||
Long zoneId = profile.getZoneId();
|
Long zoneId = profile.getZoneId();
|
||||||
VMTemplateVO template = new VMTemplateVO(profile.getTemplateId(), profile.getName(), profile.getFormat(), profile.getIsPublic(),
|
VMTemplateVO template = new VMTemplateVO(profile.getTemplateId(), profile.getName(), profile.getFormat(), profile.getIsPublic(), profile.getFeatured(), profile.getIsExtractable(),
|
||||||
profile.getFeatured(), profile.getIsExtractable(), TemplateType.USER, profile.getUrl(), profile.getRequiresHVM(),
|
TemplateType.USER, profile.getUrl(), profile.getRequiresHVM(), profile.getBits(), profile.getAccountId(), profile.getCheckSum(), profile.getDisplayText(),
|
||||||
profile.getBits(), profile.getAccountId(), profile.getCheckSum(), profile.getDisplayText(),
|
profile.getPasswordEnabled(), profile.getGuestOsId(), profile.getBootable(), profile.getHypervisorType(), profile.getTemplateTag(), profile.getDetails(), profile.getSshKeyEnabled());
|
||||||
profile.getPasswordEnabled(), profile.getGuestOsId(), profile.getBootable(), profile.getHypervisorType(), profile.getTemplateTag(),
|
|
||||||
profile.getDetails(), profile.getSshKeyEnabled());
|
|
||||||
|
|
||||||
if (zoneId == null || zoneId.longValue() == -1) {
|
if (zoneId == null || zoneId.longValue() == -1) {
|
||||||
List<DataCenterVO> dcs = _dcDao.listAll();
|
List<DataCenterVO> dcs = _dcDao.listAll();
|
||||||
|
|||||||
@ -20,7 +20,10 @@ package org.apache.cloudstack.storage.image;
|
|||||||
|
|
||||||
public interface ImageOrchestrator {
|
public interface ImageOrchestrator {
|
||||||
void registerTemplate(long templateId);
|
void registerTemplate(long templateId);
|
||||||
|
|
||||||
void registerSnapshot(long snapshotId);
|
void registerSnapshot(long snapshotId);
|
||||||
|
|
||||||
void registerVolume(long volumeId);
|
void registerVolume(long volumeId);
|
||||||
|
|
||||||
void registerIso(long isoId);
|
void registerIso(long isoId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,7 @@ public class ImageOrchestratorImpl implements ImageOrchestrator {
|
|||||||
SecondaryStorageManager _secStorageMgr;
|
SecondaryStorageManager _secStorageMgr;
|
||||||
@Inject
|
@Inject
|
||||||
VMTemplateZoneDao _templateZoneDao;
|
VMTemplateZoneDao _templateZoneDao;
|
||||||
|
|
||||||
public void registerTemplate(long templateId) {
|
public void registerTemplate(long templateId) {
|
||||||
List<VMTemplateZoneVO> tpZones = _templateZoneDao.listByTemplateId(templateId);
|
List<VMTemplateZoneVO> tpZones = _templateZoneDao.listByTemplateId(templateId);
|
||||||
|
|
||||||
@ -74,5 +75,4 @@ public class ImageOrchestratorImpl implements ImageOrchestrator {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,15 +21,22 @@ package org.apache.cloudstack.storage.image;
|
|||||||
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||||
|
|
||||||
|
|
||||||
public interface ImageService {
|
public interface ImageService {
|
||||||
boolean registerTemplate(long templateId, long imageStoreId);
|
TemplateEntity registerTemplate(long templateId, long imageStoreId);
|
||||||
|
|
||||||
boolean deleteTemplate(long templateId);
|
boolean deleteTemplate(long templateId);
|
||||||
|
|
||||||
long registerIso(String isoUrl, long accountId);
|
long registerIso(String isoUrl, long accountId);
|
||||||
|
|
||||||
boolean deleteIso(long isoId);
|
boolean deleteIso(long isoId);
|
||||||
TemplateInfo grantTemplateAccess(TemplateInfo template, EndPoint endpointId);
|
|
||||||
|
boolean grantTemplateAccess(TemplateInfo template, EndPoint endpointId);
|
||||||
|
|
||||||
boolean revokeTemplateAccess(long templateId, long endpointId);
|
boolean revokeTemplateAccess(long templateId, long endpointId);
|
||||||
|
|
||||||
String grantIsoAccess(long isoId, long endpointId);
|
String grantIsoAccess(long isoId, long endpointId);
|
||||||
|
|
||||||
boolean revokeIsoAccess(long isoId, long endpointId);
|
boolean revokeIsoAccess(long isoId, long endpointId);
|
||||||
|
|
||||||
TemplateEntity getTemplateEntity(long templateId);
|
TemplateEntity getTemplateEntity(long templateId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,22 +26,18 @@ import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
|
|||||||
import org.apache.cloudstack.storage.image.manager.ImageDataStoreManager;
|
import org.apache.cloudstack.storage.image.manager.ImageDataStoreManager;
|
||||||
import org.apache.cloudstack.storage.image.provider.ImageDataStoreProviderManager;
|
import org.apache.cloudstack.storage.image.provider.ImageDataStoreProviderManager;
|
||||||
import org.apache.cloudstack.storage.image.store.ImageDataStore;
|
import org.apache.cloudstack.storage.image.store.ImageDataStore;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class ImageServiceImpl implements ImageService {
|
public class ImageServiceImpl implements ImageService {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ImageDataStoreProviderManager imageStoreProviderMgr;
|
ImageDataStoreProviderManager imageStoreProviderMgr;
|
||||||
@Inject
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean registerTemplate(long templateId, long imageStoreId) {
|
public TemplateEntity registerTemplate(long templateId, long imageStoreId) {
|
||||||
ImageDataStore ids = imageStoreProviderMgr.getDataStore(imageStoreId);
|
ImageDataStore ids = imageStoreProviderMgr.getDataStore(imageStoreId);
|
||||||
TemplateInfo template = ids.registerTemplate(templateId);
|
TemplateObject to = ids.registerTemplate(templateId);
|
||||||
if (ids.needDownloadToCacheStorage()) {
|
return new TemplateEntityImpl(to);
|
||||||
ImageDownloader imageDl = ids.getImageDownloader();
|
|
||||||
imageDl.downloadImage(template);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -82,13 +78,14 @@ public class ImageServiceImpl implements ImageService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TemplateEntity getTemplateEntity(long templateId) {
|
public TemplateEntity getTemplateEntity(long templateId) {
|
||||||
TemplateObject to = imageStoreProviderMgr.getTemplate(templateId);
|
ImageDataStore dataStore = imageStoreProviderMgr.getDataStoreFromTemplateId(templateId);
|
||||||
|
TemplateObject to = dataStore.getTemplate(templateId);
|
||||||
return new TemplateEntityImpl(to);
|
return new TemplateEntityImpl(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TemplateInfo grantTemplateAccess(TemplateInfo template, EndPoint endpointId) {
|
public boolean grantTemplateAccess(TemplateInfo template, EndPoint endpointId) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import com.cloud.storage.Storage.TemplateType;
|
|||||||
|
|
||||||
public class TemplateEntityImpl implements TemplateEntity {
|
public class TemplateEntityImpl implements TemplateEntity {
|
||||||
protected TemplateInfo templateInfo;
|
protected TemplateInfo templateInfo;
|
||||||
|
|
||||||
public TemplateEntityImpl(TemplateInfo templateInfo) {
|
public TemplateEntityImpl(TemplateInfo templateInfo) {
|
||||||
this.templateInfo = templateInfo;
|
this.templateInfo = templateInfo;
|
||||||
}
|
}
|
||||||
@ -40,7 +41,6 @@ public class TemplateEntityImpl implements TemplateEntity {
|
|||||||
return templateInfo.getImageDataStore();
|
return templateInfo.getImageDataStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public long getImageDataStoreId() {
|
public long getImageDataStoreId() {
|
||||||
return getImageDataStore().getImageDataStoreId();
|
return getImageDataStore().getImageDataStoreId();
|
||||||
}
|
}
|
||||||
@ -51,14 +51,18 @@ public class TemplateEntityImpl implements TemplateEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
// TODO Auto-generated method stub
|
return this.templateInfo.getUuid();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getId() {
|
public long getId() {
|
||||||
|
return this.templateInfo.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExternalId() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -23,6 +23,12 @@ import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
|
|||||||
|
|
||||||
public interface TemplateInfo {
|
public interface TemplateInfo {
|
||||||
ImageDataStoreInfo getImageDataStore();
|
ImageDataStoreInfo getImageDataStore();
|
||||||
|
|
||||||
long getId();
|
long getId();
|
||||||
|
|
||||||
VolumeDiskType getDiskType();
|
VolumeDiskType getDiskType();
|
||||||
|
|
||||||
|
String getPath();
|
||||||
|
|
||||||
|
String getUuid();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,23 +25,37 @@ import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
|
|||||||
|
|
||||||
public class TemplateObject implements TemplateInfo {
|
public class TemplateObject implements TemplateInfo {
|
||||||
private ImageDataVO imageVO;
|
private ImageDataVO imageVO;
|
||||||
public TemplateObject(ImageDataVO template) {
|
private ImageDataStoreInfo dataStore;
|
||||||
|
|
||||||
|
public TemplateObject(ImageDataVO template, ImageDataStoreInfo dataStore) {
|
||||||
this.imageVO = template;
|
this.imageVO = template;
|
||||||
|
this.dataStore = dataStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImageDataStoreInfo getImageDataStore() {
|
public ImageDataStoreInfo getImageDataStore() {
|
||||||
// TODO Auto-generated method stub
|
return this.dataStore;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getId() {
|
public long getId() {
|
||||||
// TODO Auto-generated method stub
|
return this.imageVO.getId();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VolumeDiskType getDiskType() {
|
public VolumeDiskType getDiskType() {
|
||||||
return VolumeDiskTypeHelper.getDiskType(imageVO.getFormat());
|
return VolumeDiskTypeHelper.getDiskType(imageVO.getFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPath() {
|
||||||
|
//TODO: add installation path if it's downloaded to cache storage already
|
||||||
|
return this.imageVO.getUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUuid() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package org.apache.cloudstack.storage.image.db;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ImageDaoStoreDaoImpl extends GenericDaoBase<ImageDataStoreVO, Long> implements ImageDataStoreDao {
|
public class ImageDaoStoreDaoImpl extends GenericDaoBase<ImageDataStoreVO, Long> implements ImageDataStoreDao {
|
||||||
|
|
||||||
|
|||||||
@ -32,40 +32,50 @@ import com.cloud.utils.db.GenericDao;
|
|||||||
|
|
||||||
public interface ImageDataDao extends GenericDao<ImageDataVO, Long> {
|
public interface ImageDataDao extends GenericDao<ImageDataVO, Long> {
|
||||||
public List<ImageDataVO> listByPublic();
|
public List<ImageDataVO> listByPublic();
|
||||||
|
|
||||||
public ImageDataVO findByName(String templateName);
|
public ImageDataVO findByName(String templateName);
|
||||||
|
|
||||||
public ImageDataVO findByTemplateName(String templateName);
|
public ImageDataVO findByTemplateName(String templateName);
|
||||||
|
|
||||||
// public void update(ImageDataVO template);
|
// public void update(ImageDataVO template);
|
||||||
|
|
||||||
|
|
||||||
public List<ImageDataVO> listAllSystemVMTemplates();
|
public List<ImageDataVO> listAllSystemVMTemplates();
|
||||||
|
|
||||||
public List<ImageDataVO> listDefaultBuiltinTemplates();
|
public List<ImageDataVO> listDefaultBuiltinTemplates();
|
||||||
|
|
||||||
public String getRoutingTemplateUniqueName();
|
public String getRoutingTemplateUniqueName();
|
||||||
|
|
||||||
public List<ImageDataVO> findIsosByIdAndPath(Long domainId, Long accountId, String path);
|
public List<ImageDataVO> findIsosByIdAndPath(Long domainId, Long accountId, String path);
|
||||||
|
|
||||||
public List<ImageDataVO> listReadyTemplates();
|
public List<ImageDataVO> listReadyTemplates();
|
||||||
|
|
||||||
public List<ImageDataVO> listByAccountId(long accountId);
|
public List<ImageDataVO> listByAccountId(long accountId);
|
||||||
public Set<Pair<Long, Long>> searchTemplates(String name, String keyword, TemplateFilter templateFilter, boolean isIso,
|
|
||||||
List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long pageSize, Long startIndex, Long zoneId,
|
public Set<Pair<Long, Long>> searchTemplates(String name, String keyword, TemplateFilter templateFilter, boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO domain,
|
||||||
HypervisorType hyperType, boolean onlyReady, boolean showDomr, List<Account> permittedAccounts, Account caller,
|
Long pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean onlyReady, boolean showDomr, List<Account> permittedAccounts, Account caller,
|
||||||
ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags);
|
ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags);
|
||||||
|
|
||||||
public Set<Pair<Long, Long>> searchSwiftTemplates(String name, String keyword, TemplateFilter templateFilter,
|
public Set<Pair<Long, Long>> searchSwiftTemplates(String name, String keyword, TemplateFilter templateFilter, boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO domain,
|
||||||
boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long pageSize, Long startIndex,
|
Long pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean onlyReady, boolean showDomr, List<Account> permittedAccounts, Account caller, Map<String, String> tags);
|
||||||
Long zoneId, HypervisorType hyperType, boolean onlyReady, boolean showDomr, List<Account> permittedAccounts, Account caller, Map<String, String> tags);
|
|
||||||
|
|
||||||
public long addTemplateToZone(ImageDataVO tmplt, long zoneId);
|
public long addTemplateToZone(ImageDataVO tmplt, long zoneId);
|
||||||
|
|
||||||
public List<ImageDataVO> listAllInZone(long dataCenterId);
|
public List<ImageDataVO> listAllInZone(long dataCenterId);
|
||||||
|
|
||||||
public List<ImageDataVO> listByHypervisorType(List<HypervisorType> hyperTypes);
|
public List<ImageDataVO> listByHypervisorType(List<HypervisorType> hyperTypes);
|
||||||
|
|
||||||
public List<ImageDataVO> publicIsoSearch(Boolean bootable, boolean listRemoved, Map<String, String> tags);
|
public List<ImageDataVO> publicIsoSearch(Boolean bootable, boolean listRemoved, Map<String, String> tags);
|
||||||
|
|
||||||
public List<ImageDataVO> userIsoSearch(boolean listRemoved);
|
public List<ImageDataVO> userIsoSearch(boolean listRemoved);
|
||||||
|
|
||||||
ImageDataVO findSystemVMTemplate(long zoneId);
|
ImageDataVO findSystemVMTemplate(long zoneId);
|
||||||
|
|
||||||
ImageDataVO findSystemVMTemplate(long zoneId, HypervisorType hType);
|
ImageDataVO findSystemVMTemplate(long zoneId, HypervisorType hType);
|
||||||
|
|
||||||
ImageDataVO findRoutingTemplate(HypervisorType type);
|
ImageDataVO findRoutingTemplate(HypervisorType type);
|
||||||
|
|
||||||
List<Long> listPrivateTemplatesByHost(Long hostId);
|
List<Long> listPrivateTemplatesByHost(Long hostId);
|
||||||
|
|
||||||
public Long countTemplatesForAccount(long accountId);
|
public Long countTemplatesForAccount(long accountId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,7 @@ import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
|||||||
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
|
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
|
import com.cloud.utils.component.ComponentInject;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Filter;
|
import com.cloud.utils.db.Filter;
|
||||||
@ -75,24 +76,24 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||||||
public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implements ImageDataDao {
|
public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implements ImageDataDao {
|
||||||
private static final Logger s_logger = Logger.getLogger(VMTemplateDaoImpl.class);
|
private static final Logger s_logger = Logger.getLogger(VMTemplateDaoImpl.class);
|
||||||
|
|
||||||
@Inject
|
|
||||||
VMTemplateZoneDao _templateZoneDao;
|
|
||||||
@Inject
|
|
||||||
VMTemplateDetailsDao _templateDetailsDao;
|
|
||||||
|
|
||||||
@Inject
|
VMTemplateZoneDao _templateZoneDao = null;
|
||||||
ConfigurationDao _configDao;
|
|
||||||
@Inject
|
|
||||||
HostDao _hostDao;
|
|
||||||
@Inject
|
|
||||||
DomainDao _domainDao;
|
|
||||||
@Inject
|
|
||||||
DataCenterDao _dcDao;
|
|
||||||
private final String SELECT_TEMPLATE_HOST_REF = "SELECT t.id, h.data_center_id, t.unique_name, t.name, t.public, t.featured, t.type, t.hvm, t.bits, t.url, t.format, t.created, t.account_id, " +
|
|
||||||
"t.checksum, t.display_text, t.enable_password, t.guest_os_id, t.bootable, t.prepopulate, t.cross_zones, t.hypervisor_type FROM vm_template t";
|
|
||||||
|
|
||||||
private final String SELECT_TEMPLATE_ZONE_REF = "SELECT t.id, tzr.zone_id, t.unique_name, t.name, t.public, t.featured, t.type, t.hvm, t.bits, t.url, t.format, t.created, t.account_id, " +
|
VMTemplateDetailsDao _templateDetailsDao = null;
|
||||||
"t.checksum, t.display_text, t.enable_password, t.guest_os_id, t.bootable, t.prepopulate, t.cross_zones, t.hypervisor_type FROM vm_template t INNER JOIN template_zone_ref tzr on (t.id = tzr.template_id) ";
|
|
||||||
|
|
||||||
|
ConfigurationDao _configDao = null;
|
||||||
|
|
||||||
|
HostDao _hostDao = null;
|
||||||
|
|
||||||
|
DomainDao _domainDao = null;
|
||||||
|
|
||||||
|
DataCenterDao _dcDao = null;
|
||||||
|
private final String SELECT_TEMPLATE_HOST_REF = "SELECT t.id, h.data_center_id, t.unique_name, t.name, t.public, t.featured, t.type, t.hvm, t.bits, t.url, t.format, t.created, t.account_id, "
|
||||||
|
+ "t.checksum, t.display_text, t.enable_password, t.guest_os_id, t.bootable, t.prepopulate, t.cross_zones, t.hypervisor_type FROM vm_template t";
|
||||||
|
|
||||||
|
private final String SELECT_TEMPLATE_ZONE_REF = "SELECT t.id, tzr.zone_id, t.unique_name, t.name, t.public, t.featured, t.type, t.hvm, t.bits, t.url, t.format, t.created, t.account_id, "
|
||||||
|
+ "t.checksum, t.display_text, t.enable_password, t.guest_os_id, t.bootable, t.prepopulate, t.cross_zones, t.hypervisor_type FROM vm_template t INNER JOIN template_zone_ref tzr on (t.id = tzr.template_id) ";
|
||||||
|
|
||||||
private final String SELECT_TEMPLATE_SWIFT_REF = "SELECT t.id, t.unique_name, t.name, t.public, t.featured, t.type, t.hvm, t.bits, t.url, t.format, t.created, t.account_id, "
|
private final String SELECT_TEMPLATE_SWIFT_REF = "SELECT t.id, t.unique_name, t.name, t.public, t.featured, t.type, t.hvm, t.bits, t.url, t.format, t.created, t.account_id, "
|
||||||
+ "t.checksum, t.display_text, t.enable_password, t.guest_os_id, t.bootable, t.prepopulate, t.cross_zones, t.hypervisor_type FROM vm_template t";
|
+ "t.checksum, t.display_text, t.enable_password, t.guest_os_id, t.bootable, t.prepopulate, t.cross_zones, t.hypervisor_type FROM vm_template t";
|
||||||
@ -111,9 +112,8 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
private SearchBuilder<ImageDataVO> UserIsoSearch;
|
private SearchBuilder<ImageDataVO> UserIsoSearch;
|
||||||
private GenericSearchBuilder<ImageDataVO, Long> CountTemplatesByAccount;
|
private GenericSearchBuilder<ImageDataVO, Long> CountTemplatesByAccount;
|
||||||
|
|
||||||
ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
|
//ResourceTagsDaoImpl _tagsDao = ComponentInject.inject(ResourceTagsDaoImpl.class);
|
||||||
|
ResourceTagsDaoImpl _tagsDao = null;
|
||||||
|
|
||||||
private String routerTmpltName;
|
private String routerTmpltName;
|
||||||
private String consoleProxyTmpltName;
|
private String consoleProxyTmpltName;
|
||||||
|
|
||||||
@ -208,6 +208,7 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ImageDataVO> listAllSystemVMTemplates() {
|
public List<ImageDataVO> listAllSystemVMTemplates() {
|
||||||
SearchCriteria<ImageDataVO> sc = tmpltTypeSearch.create();
|
SearchCriteria<ImageDataVO> sc = tmpltTypeSearch.create();
|
||||||
@ -338,7 +339,6 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
tmpltTypeHyperSearch2.and("templateType", tmpltTypeHyperSearch2.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
tmpltTypeHyperSearch2.and("templateType", tmpltTypeHyperSearch2.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
||||||
tmpltTypeHyperSearch2.and("hypervisorType", tmpltTypeHyperSearch2.entity().getHypervisorType(), SearchCriteria.Op.EQ);
|
tmpltTypeHyperSearch2.and("hypervisorType", tmpltTypeHyperSearch2.entity().getHypervisorType(), SearchCriteria.Op.EQ);
|
||||||
|
|
||||||
|
|
||||||
tmpltTypeSearch = createSearchBuilder();
|
tmpltTypeSearch = createSearchBuilder();
|
||||||
tmpltTypeSearch.and("removed", tmpltTypeSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
tmpltTypeSearch.and("removed", tmpltTypeSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||||
tmpltTypeSearch.and("templateType", tmpltTypeSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
tmpltTypeSearch.and("templateType", tmpltTypeSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
||||||
@ -493,12 +493,10 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
return templateZonePairList;
|
return templateZonePairList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Pair<Long, Long>> searchTemplates(String name, String keyword, TemplateFilter templateFilter,
|
public Set<Pair<Long, Long>> searchTemplates(String name, String keyword, TemplateFilter templateFilter, boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO domain,
|
||||||
boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long pageSize, Long startIndex,
|
Long pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean onlyReady, boolean showDomr, List<Account> permittedAccounts, Account caller,
|
||||||
Long zoneId, HypervisorType hyperType, boolean onlyReady, boolean showDomr,List<Account> permittedAccounts,
|
ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags) {
|
||||||
Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
if (!permittedAccounts.isEmpty()) {
|
if (!permittedAccounts.isEmpty()) {
|
||||||
for (Account permittedAccount : permittedAccounts) {
|
for (Account permittedAccount : permittedAccounts) {
|
||||||
@ -554,18 +552,18 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
sql += guestOSJoin + templateHostRefJoin + dataCenterJoin + lpjoin + tagsJoin;
|
sql += guestOSJoin + templateHostRefJoin + dataCenterJoin + lpjoin + tagsJoin;
|
||||||
String whereClause = "";
|
String whereClause = "";
|
||||||
|
|
||||||
//All joins have to be made before we start setting the condition settings
|
// All joins have to be made before we start setting the condition
|
||||||
if ((listProjectResourcesCriteria == ListProjectResourcesCriteria.SkipProjectResources
|
// settings
|
||||||
|| (!permittedAccounts.isEmpty() && !(templateFilter == TemplateFilter.community || templateFilter == TemplateFilter.featured))) &&
|
if ((listProjectResourcesCriteria == ListProjectResourcesCriteria.SkipProjectResources || (!permittedAccounts.isEmpty() && !(templateFilter == TemplateFilter.community || templateFilter == TemplateFilter.featured)))
|
||||||
!(caller.getType() != Account.ACCOUNT_TYPE_NORMAL && templateFilter == TemplateFilter.all)) {
|
&& !(caller.getType() != Account.ACCOUNT_TYPE_NORMAL && templateFilter == TemplateFilter.all)) {
|
||||||
whereClause += " INNER JOIN account a on (t.account_id = a.id)";
|
whereClause += " INNER JOIN account a on (t.account_id = a.id)";
|
||||||
if ((templateFilter == TemplateFilter.self || templateFilter == TemplateFilter.selfexecutable) && (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)) {
|
if ((templateFilter == TemplateFilter.self || templateFilter == TemplateFilter.selfexecutable)
|
||||||
|
&& (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)) {
|
||||||
whereClause += " INNER JOIN domain d on (a.domain_id = d.id) WHERE d.path LIKE '" + domain.getPath() + "%'";
|
whereClause += " INNER JOIN domain d on (a.domain_id = d.id) WHERE d.path LIKE '" + domain.getPath() + "%'";
|
||||||
if (listProjectResourcesCriteria == ListProjectResourcesCriteria.SkipProjectResources) {
|
if (listProjectResourcesCriteria == ListProjectResourcesCriteria.SkipProjectResources) {
|
||||||
whereClause += " AND a.type != " + Account.ACCOUNT_TYPE_PROJECT;
|
whereClause += " AND a.type != " + Account.ACCOUNT_TYPE_PROJECT;
|
||||||
}
|
}
|
||||||
} else
|
} else if (listProjectResourcesCriteria == ListProjectResourcesCriteria.SkipProjectResources) {
|
||||||
if (listProjectResourcesCriteria == ListProjectResourcesCriteria.SkipProjectResources) {
|
|
||||||
whereClause += " WHERE a.type != " + Account.ACCOUNT_TYPE_PROJECT;
|
whereClause += " WHERE a.type != " + Account.ACCOUNT_TYPE_PROJECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -621,8 +619,8 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!permittedAccounts.isEmpty() && !(templateFilter == TemplateFilter.featured ||
|
if (!permittedAccounts.isEmpty() && !(templateFilter == TemplateFilter.featured || templateFilter == TemplateFilter.community || templateFilter == TemplateFilter.executable)
|
||||||
templateFilter == TemplateFilter.community || templateFilter == TemplateFilter.executable) && !isAdmin(caller.getType()) ) {
|
&& !isAdmin(caller.getType())) {
|
||||||
whereClause += attr + "t.account_id IN (" + permittedAccountsStr + ")";
|
whereClause += attr + "t.account_id IN (" + permittedAccountsStr + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,9 +632,7 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
} else if (templateFilter == TemplateFilter.self || templateFilter == TemplateFilter.selfexecutable) {
|
} else if (templateFilter == TemplateFilter.self || templateFilter == TemplateFilter.selfexecutable) {
|
||||||
whereClause += " AND t.account_id IN (" + permittedAccountsStr + ")";
|
whereClause += " AND t.account_id IN (" + permittedAccountsStr + ")";
|
||||||
} else if (templateFilter == TemplateFilter.sharedexecutable) {
|
} else if (templateFilter == TemplateFilter.sharedexecutable) {
|
||||||
whereClause += " AND " +
|
whereClause += " AND " + " (t.account_id IN (" + permittedAccountsStr + ") OR" + " lp.account_id IN (" + permittedAccountsStr + "))";
|
||||||
" (t.account_id IN (" + permittedAccountsStr + ") OR" +
|
|
||||||
" lp.account_id IN (" + permittedAccountsStr + "))";
|
|
||||||
} else if (templateFilter == TemplateFilter.executable && !permittedAccounts.isEmpty()) {
|
} else if (templateFilter == TemplateFilter.executable && !permittedAccounts.isEmpty()) {
|
||||||
whereClause += attr + "(t.public = 1 OR t.account_id IN (" + permittedAccountsStr + "))";
|
whereClause += attr + "(t.public = 1 OR t.account_id IN (" + permittedAccountsStr + "))";
|
||||||
} else if (templateFilter == TemplateFilter.community) {
|
} else if (templateFilter == TemplateFilter.community) {
|
||||||
@ -667,8 +663,7 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
whereClause += " AND ";
|
whereClause += " AND ";
|
||||||
}
|
}
|
||||||
|
|
||||||
sql += whereClause + getExtrasWhere(templateFilter, name, keyword, isIso, bootable, hyperType, zoneId,
|
sql += whereClause + getExtrasWhere(templateFilter, name, keyword, isIso, bootable, hyperType, zoneId, onlyReady, showDomr) + groupByClause + getOrderByLimit(pageSize, startIndex);
|
||||||
onlyReady, showDomr) + groupByClause + getOrderByLimit(pageSize, startIndex);
|
|
||||||
|
|
||||||
pstmt = txn.prepareStatement(sql);
|
pstmt = txn.prepareStatement(sql);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
@ -677,15 +672,23 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
Pair<Long, Long> templateZonePair = new Pair<Long, Long>(rs.getLong(1), rs.getLong(2));
|
Pair<Long, Long> templateZonePair = new Pair<Long, Long>(rs.getLong(1), rs.getLong(2));
|
||||||
templateZonePairList.add(templateZonePair);
|
templateZonePairList.add(templateZonePair);
|
||||||
}
|
}
|
||||||
//for now, defaulting pageSize to a large val if null; may need to revisit post 2.2RC2
|
// for now, defaulting pageSize to a large val if null; may need to
|
||||||
if(isIso && templateZonePairList.size() < (pageSize != null ? pageSize : 500)
|
// revisit post 2.2RC2
|
||||||
&& templateFilter != TemplateFilter.community
|
if (isIso && templateZonePairList.size() < (pageSize != null ? pageSize : 500) && templateFilter != TemplateFilter.community
|
||||||
&& !(templateFilter == TemplateFilter.self && !BaseCmd.isRootAdmin(caller.getType())) ){ //evaluates to true If root admin and filter=self
|
&& !(templateFilter == TemplateFilter.self && !BaseCmd.isRootAdmin(caller.getType()))) { // evaluates
|
||||||
|
// to
|
||||||
|
// true
|
||||||
|
// If
|
||||||
|
// root
|
||||||
|
// admin
|
||||||
|
// and
|
||||||
|
// filter=self
|
||||||
|
|
||||||
List<ImageDataVO> publicIsos = publicIsoSearch(bootable, false, tags);
|
List<ImageDataVO> publicIsos = publicIsoSearch(bootable, false, tags);
|
||||||
List<ImageDataVO> userIsos = userIsoSearch(false);
|
List<ImageDataVO> userIsos = userIsoSearch(false);
|
||||||
|
|
||||||
//Listing the ISOs according to the page size.Restricting the total no. of ISOs on a page
|
// Listing the ISOs according to the page size.Restricting the
|
||||||
|
// total no. of ISOs on a page
|
||||||
// to be less than or equal to the pageSize parameter
|
// to be less than or equal to the pageSize parameter
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -729,7 +732,8 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
return templateZonePairList;
|
return templateZonePairList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getExtrasWhere(TemplateFilter templateFilter, String name, String keyword, boolean isIso, Boolean bootable, HypervisorType hyperType, Long zoneId, boolean onlyReady, boolean showDomr) {
|
private String getExtrasWhere(TemplateFilter templateFilter, String name, String keyword, boolean isIso, Boolean bootable, HypervisorType hyperType, Long zoneId, boolean onlyReady,
|
||||||
|
boolean showDomr) {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
if (keyword != null) {
|
if (keyword != null) {
|
||||||
sql += " t.name LIKE \"%" + keyword + "%\" AND";
|
sql += " t.name LIKE \"%" + keyword + "%\" AND";
|
||||||
@ -840,7 +844,8 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
sc.setJoinParameters("tmplHyper", "type", Host.Type.Routing);
|
sc.setJoinParameters("tmplHyper", "type", Host.Type.Routing);
|
||||||
sc.setJoinParameters("tmplHyper", "zoneId", zoneId);
|
sc.setJoinParameters("tmplHyper", "zoneId", zoneId);
|
||||||
|
|
||||||
//order by descending order of id and select the first (this is going to be the latest)
|
// order by descending order of id and select the first (this is going
|
||||||
|
// to be the latest)
|
||||||
List<ImageDataVO> tmplts = listBy(sc, new Filter(ImageDataVO.class, "id", false, null, 1l));
|
List<ImageDataVO> tmplts = listBy(sc, new Filter(ImageDataVO.class, "id", false, null, 1l));
|
||||||
|
|
||||||
if (tmplts.size() > 0) {
|
if (tmplts.size() > 0) {
|
||||||
@ -876,7 +881,8 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
sc.setParameters("templateType", Storage.TemplateType.SYSTEM);
|
sc.setParameters("templateType", Storage.TemplateType.SYSTEM);
|
||||||
sc.setParameters("hypervisorType", hType);
|
sc.setParameters("hypervisorType", hType);
|
||||||
|
|
||||||
//order by descending order of id and select the first (this is going to be the latest)
|
// order by descending order of id and select the first (this is going
|
||||||
|
// to be the latest)
|
||||||
List<ImageDataVO> tmplts = listBy(sc, new Filter(ImageDataVO.class, "id", false, null, 1l));
|
List<ImageDataVO> tmplts = listBy(sc, new Filter(ImageDataVO.class, "id", false, null, 1l));
|
||||||
|
|
||||||
if (tmplts.size() > 0) {
|
if (tmplts.size() > 0) {
|
||||||
@ -916,10 +922,7 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAdmin(short accountType) {
|
private boolean isAdmin(short accountType) {
|
||||||
return ((accountType == Account.ACCOUNT_TYPE_ADMIN) ||
|
return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
|
||||||
(accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) ||
|
|
||||||
(accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) ||
|
|
||||||
(accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -21,5 +21,4 @@ package org.apache.cloudstack.storage.image.db;
|
|||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
|
||||||
public interface ImageDataStoreProviderDao extends GenericDao<ImageDataStoreProviderVO, Long> {
|
public interface ImageDataStoreProviderDao extends GenericDao<ImageDataStoreProviderVO, Long> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,7 +135,6 @@ public class ImageDataVO implements Identity {
|
|||||||
@Transient
|
@Transient
|
||||||
Map details;
|
Map details;
|
||||||
|
|
||||||
|
|
||||||
public String getUniqueName() {
|
public String getUniqueName() {
|
||||||
return uniqueName;
|
return uniqueName;
|
||||||
}
|
}
|
||||||
@ -353,6 +352,7 @@ public class ImageDataVO implements Identity {
|
|||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
String toString;
|
String toString;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (toString == null) {
|
if (toString == null) {
|
||||||
@ -381,7 +381,7 @@ public class ImageDataVO implements Identity {
|
|||||||
enableSshKey = enable;
|
enableSshKey = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getImageDataStoreId() {
|
public Long getImageDataStoreId() {
|
||||||
return this.imageDataStoreId;
|
return this.imageDataStoreId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,10 @@ import org.apache.cloudstack.storage.image.TemplateInfo;
|
|||||||
|
|
||||||
public interface ImageDataStoreDriver {
|
public interface ImageDataStoreDriver {
|
||||||
boolean registerTemplate(TemplateInfo template);
|
boolean registerTemplate(TemplateInfo template);
|
||||||
|
|
||||||
String grantAccess(long templateId, long endPointId);
|
String grantAccess(long templateId, long endPointId);
|
||||||
|
|
||||||
boolean revokeAccess(long templateId, long endPointId);
|
boolean revokeAccess(long templateId, long endPointId);
|
||||||
|
|
||||||
boolean deleteTemplate(TemplateInfo template);
|
boolean deleteTemplate(TemplateInfo template);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ public class ImageDataStoreDriverImpl implements ImageDataStoreDriver {
|
|||||||
|
|
||||||
public ImageDataStoreDriverImpl() {
|
public ImageDataStoreDriverImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean registerTemplate(TemplateInfo template) {
|
public boolean registerTemplate(TemplateInfo template) {
|
||||||
// TODO: check the availability of template
|
// TODO: check the availability of template
|
||||||
@ -48,6 +49,4 @@ public class ImageDataStoreDriverImpl implements ImageDataStoreDriver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class BAREMETAL extends BaseType implements ImageFormat {
|
public class BAREMETAL extends BaseType implements ImageFormat {
|
||||||
private final String type = "BAREMETAL";
|
private final String type = "BAREMETAL";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class ISO extends BaseType implements ImageFormat {
|
public class ISO extends BaseType implements ImageFormat {
|
||||||
private final String type = "ISO";
|
private final String type = "ISO";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class ImageFormatHelper {
|
public class ImageFormatHelper {
|
||||||
private static List<ImageFormat> formats;
|
private static List<ImageFormat> formats;
|
||||||
private static final ImageFormat defaultFormat = new Unknown();
|
private static final ImageFormat defaultFormat = new Unknown();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public void setFormats(List<ImageFormat> formats) {
|
public void setFormats(List<ImageFormat> formats) {
|
||||||
ImageFormatHelper.formats = formats;
|
ImageFormatHelper.formats = formats;
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class OVA extends BaseType implements ImageFormat {
|
public class OVA extends BaseType implements ImageFormat {
|
||||||
private final String type = "OVA";
|
private final String type = "OVA";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component("imageformat_qcow2")
|
@Component("imageformat_qcow2")
|
||||||
public class QCOW2 extends BaseType implements ImageFormat {
|
public class QCOW2 extends BaseType implements ImageFormat {
|
||||||
private final String type = "QCOW2";
|
private final String type = "QCOW2";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
@ -19,9 +19,12 @@
|
|||||||
package org.apache.cloudstack.storage.image.format;
|
package org.apache.cloudstack.storage.image.format;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.BaseType;
|
import org.apache.cloudstack.storage.BaseType;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class VHD extends BaseType implements ImageFormat {
|
public class VHD extends BaseType implements ImageFormat {
|
||||||
private final String type = "VHD";
|
private final String type = "VHD";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
@ -31,6 +31,7 @@ public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
|
|||||||
ImageDataStoreDao dataStoreDao;
|
ImageDataStoreDao dataStoreDao;
|
||||||
@Inject
|
@Inject
|
||||||
ImageDataDao imageDataDao;
|
ImageDataDao imageDataDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImageDataStore getImageDataStore(long dataStoreId) {
|
public ImageDataStore getImageDataStore(long dataStoreId) {
|
||||||
ImageDataStoreVO dataStore = dataStoreDao.findById(dataStoreId);
|
ImageDataStoreVO dataStore = dataStoreDao.findById(dataStoreId);
|
||||||
|
|||||||
@ -29,7 +29,9 @@ import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
|
|||||||
import org.apache.cloudstack.storage.to.TemplateTO;
|
import org.apache.cloudstack.storage.to.TemplateTO;
|
||||||
import org.apache.cloudstack.storage.to.VolumeTO;
|
import org.apache.cloudstack.storage.to.VolumeTO;
|
||||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class DefaultImageMotionStrategy implements ImageMotionStrategy {
|
public class DefaultImageMotionStrategy implements ImageMotionStrategy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -22,5 +22,6 @@ import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
|||||||
|
|
||||||
public interface ImageMotionService {
|
public interface ImageMotionService {
|
||||||
boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore);
|
boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore);
|
||||||
|
|
||||||
boolean copyIso(String isoUri, String destIsoUri);
|
boolean copyIso(String isoUri, String destIsoUri);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,9 +31,11 @@ import org.apache.cloudstack.storage.image.ImageService;
|
|||||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeService;
|
import org.apache.cloudstack.storage.volume.VolumeService;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class ImageMotionServiceImpl implements ImageMotionService {
|
public class ImageMotionServiceImpl implements ImageMotionService {
|
||||||
@Inject
|
@Inject
|
||||||
List<ImageMotionStrategy> motionStrategies;
|
List<ImageMotionStrategy> motionStrategies;
|
||||||
@ -41,6 +43,7 @@ public class ImageMotionServiceImpl implements ImageMotionService {
|
|||||||
VolumeService volumeService;
|
VolumeService volumeService;
|
||||||
@Inject
|
@Inject
|
||||||
ImageService imageService;
|
ImageService imageService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean copyIso(String isoUri, String destIsoUri) {
|
public boolean copyIso(String isoUri, String destIsoUri) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|||||||
@ -23,6 +23,8 @@ import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
|||||||
|
|
||||||
public interface ImageMotionStrategy {
|
public interface ImageMotionStrategy {
|
||||||
public boolean canHandle(TemplateOnPrimaryDataStoreInfo templateStore);
|
public boolean canHandle(TemplateOnPrimaryDataStoreInfo templateStore);
|
||||||
|
|
||||||
public EndPoint getEndPoint(TemplateOnPrimaryDataStoreInfo templateStore);
|
public EndPoint getEndPoint(TemplateOnPrimaryDataStoreInfo templateStore);
|
||||||
|
|
||||||
public boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore, EndPoint ep);
|
public boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore, EndPoint ep);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,4 +50,10 @@ public class DefaultImageDataStoreProvider implements ImageDataStoreProvider {
|
|||||||
return providerName;
|
return providerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean register(long providerId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,5 +22,6 @@ import org.apache.cloudstack.storage.image.store.ImageDataStore;
|
|||||||
|
|
||||||
public interface ImageDataStoreProvider {
|
public interface ImageDataStoreProvider {
|
||||||
ImageDataStore getImageDataStore(long imageStoreId);
|
ImageDataStore getImageDataStore(long imageStoreId);
|
||||||
|
boolean register(long providerId);
|
||||||
public String getName();
|
public String getName();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,9 +21,12 @@ package org.apache.cloudstack.storage.image.provider;
|
|||||||
import org.apache.cloudstack.storage.image.TemplateObject;
|
import org.apache.cloudstack.storage.image.TemplateObject;
|
||||||
import org.apache.cloudstack.storage.image.store.ImageDataStore;
|
import org.apache.cloudstack.storage.image.store.ImageDataStore;
|
||||||
|
|
||||||
public interface ImageDataStoreProviderManager {
|
import com.cloud.utils.component.Manager;
|
||||||
|
|
||||||
|
public interface ImageDataStoreProviderManager extends Manager {
|
||||||
public ImageDataStoreProvider getProvider(long providerId);
|
public ImageDataStoreProvider getProvider(long providerId);
|
||||||
public ImageDataStore getDataStore(long dataStoreId);
|
|
||||||
|
public ImageDataStore getDataStore(Long dataStoreId);
|
||||||
|
|
||||||
public ImageDataStore getDataStoreFromTemplateId(long templateId);
|
public ImageDataStore getDataStoreFromTemplateId(long templateId);
|
||||||
public TemplateObject getTemplate(long templateId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,8 +19,10 @@
|
|||||||
package org.apache.cloudstack.storage.image.provider;
|
package org.apache.cloudstack.storage.image.provider;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.image.TemplateObject;
|
import org.apache.cloudstack.storage.image.TemplateObject;
|
||||||
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
||||||
@ -42,6 +44,7 @@ public class ImageDataStoreProviderManagerImpl implements ImageDataStoreProvider
|
|||||||
ImageDataDao imageDataDao;
|
ImageDataDao imageDataDao;
|
||||||
@Inject
|
@Inject
|
||||||
List<ImageDataStoreProvider> providers;
|
List<ImageDataStoreProvider> providers;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImageDataStoreProvider getProvider(long providerId) {
|
public ImageDataStoreProvider getProvider(long providerId) {
|
||||||
|
|
||||||
@ -58,8 +61,16 @@ public class ImageDataStoreProviderManagerImpl implements ImageDataStoreProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImageDataStore getDataStore(long dataStoreId) {
|
public ImageDataStore getDataStore(Long dataStoreId) {
|
||||||
|
if (dataStoreId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
ImageDataStoreVO idsv = dataStoreDao.findById(dataStoreId);
|
ImageDataStoreVO idsv = dataStoreDao.findById(dataStoreId);
|
||||||
|
if (idsv == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
long providerId = idsv.getProvider();
|
long providerId = idsv.getProvider();
|
||||||
ImageDataStoreProviderVO idspv = providerDao.findById(providerId);
|
ImageDataStoreProviderVO idspv = providerDao.findById(providerId);
|
||||||
ImageDataStoreProvider provider = getProvider(idspv.getName());
|
ImageDataStoreProvider provider = getProvider(idspv.getName());
|
||||||
@ -69,11 +80,49 @@ public class ImageDataStoreProviderManagerImpl implements ImageDataStoreProvider
|
|||||||
@Override
|
@Override
|
||||||
public ImageDataStore getDataStoreFromTemplateId(long templateId) {
|
public ImageDataStore getDataStoreFromTemplateId(long templateId) {
|
||||||
ImageDataVO iddv = imageDataDao.findById(templateId);
|
ImageDataVO iddv = imageDataDao.findById(templateId);
|
||||||
return getDataStore(iddv.getId());
|
return getDataStore(iddv.getImageDataStoreId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TemplateObject getTemplate(long templateId) {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
|
List<ImageDataStoreProviderVO> existingProviders = providerDao.listAll();
|
||||||
|
//TODO: hold global lock
|
||||||
|
boolean foundExistingProvider = false;
|
||||||
|
for (ImageDataStoreProvider provider : providers) {
|
||||||
|
foundExistingProvider = false;
|
||||||
|
for (ImageDataStoreProviderVO existingProvider : existingProviders) {
|
||||||
|
if (provider.getName().equalsIgnoreCase(existingProvider.getName())) {
|
||||||
|
foundExistingProvider = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundExistingProvider) {
|
||||||
|
//add a new provider into db
|
||||||
|
ImageDataStoreProviderVO nProvider = new ImageDataStoreProviderVO();
|
||||||
|
nProvider.setName(provider.getName());
|
||||||
|
nProvider = providerDao.persist(nProvider);
|
||||||
|
provider.register(nProvider.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean start() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stop() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,14 +19,21 @@
|
|||||||
package org.apache.cloudstack.storage.image.store;
|
package org.apache.cloudstack.storage.image.store;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||||
|
import org.apache.cloudstack.storage.image.TemplateObject;
|
||||||
import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
|
import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
|
||||||
|
|
||||||
public interface ImageDataStore extends ImageDataStoreInfo {
|
public interface ImageDataStore extends ImageDataStoreInfo {
|
||||||
TemplateInfo registerTemplate(long templateId);
|
TemplateObject registerTemplate(long templateId);
|
||||||
|
|
||||||
String grantAccess(long templateId, long endPointId);
|
String grantAccess(long templateId, long endPointId);
|
||||||
|
|
||||||
boolean revokeAccess(long templateId, long endPointId);
|
boolean revokeAccess(long templateId, long endPointId);
|
||||||
|
|
||||||
boolean deleteTemplate(long templateId);
|
boolean deleteTemplate(long templateId);
|
||||||
|
|
||||||
boolean needDownloadToCacheStorage();
|
boolean needDownloadToCacheStorage();
|
||||||
|
|
||||||
ImageDownloader getImageDownloader();
|
ImageDownloader getImageDownloader();
|
||||||
|
|
||||||
|
TemplateObject getTemplate(long templateId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package org.apache.cloudstack.storage.image.store;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||||
|
import org.apache.cloudstack.storage.image.TemplateObject;
|
||||||
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
import org.apache.cloudstack.storage.image.db.ImageDataDao;
|
||||||
import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
|
import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
|
import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
|
||||||
@ -36,25 +37,20 @@ public class ImageDataStoreImpl implements ImageDataStore {
|
|||||||
ImageDataStoreVO imageDataStoreVO;
|
ImageDataStoreVO imageDataStoreVO;
|
||||||
boolean needDownloadToCacheStorage = false;
|
boolean needDownloadToCacheStorage = false;
|
||||||
|
|
||||||
|
|
||||||
public ImageDataStoreImpl(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver driver, boolean needDownloadToCacheStorage, ImageDownloader downloader) {
|
public ImageDataStoreImpl(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver driver, boolean needDownloadToCacheStorage, ImageDownloader downloader) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
this.needDownloadToCacheStorage = needDownloadToCacheStorage;
|
this.needDownloadToCacheStorage = needDownloadToCacheStorage;
|
||||||
this.downloader = downloader;
|
this.downloader = downloader;
|
||||||
this.imageDataStoreVO = dataStoreVO;
|
this.imageDataStoreVO = dataStoreVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@Override
|
* @Override public TemplateInfo registerTemplate(long templateId) {
|
||||||
public TemplateInfo registerTemplate(long templateId) {
|
* ImageDataVO idv = imageDao.findById(templateId); TemplateInfo template =
|
||||||
ImageDataVO idv = imageDao.findById(templateId);
|
* new TemplateInfo(this, idv); if (driver.registerTemplate(template)) {
|
||||||
TemplateInfo template = new TemplateInfo(this, idv);
|
* template.setImageDataStoreId(imageDataStoreVO.getId()); return template;
|
||||||
if (driver.registerTemplate(template)) {
|
* } else { return null; } }
|
||||||
template.setImageDataStoreId(imageDataStoreVO.getId());
|
*/
|
||||||
return template;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String grantAccess(long templateId, long endPointId) {
|
public String grantAccess(long templateId, long endPointId) {
|
||||||
@ -92,9 +88,18 @@ public class ImageDataStoreImpl implements ImageDataStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TemplateInfo registerTemplate(long templateId) {
|
public TemplateObject registerTemplate(long templateId) {
|
||||||
// TODO Auto-generated method stub
|
ImageDataVO image = imageDao.findById(templateId);
|
||||||
return null;
|
image.setImageDataStoreId(this.getImageDataStoreId());
|
||||||
|
imageDao.update(templateId, image);
|
||||||
|
return getTemplate(templateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TemplateObject getTemplate(long templateId) {
|
||||||
|
ImageDataVO image = imageDao.findById(templateId);
|
||||||
|
TemplateObject to = new TemplateObject(image, this);
|
||||||
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,9 +23,11 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
|
|||||||
|
|
||||||
public class DefaultNfsSecondaryLifeCycle implements DataStoreLifeCycle {
|
public class DefaultNfsSecondaryLifeCycle implements DataStoreLifeCycle {
|
||||||
protected DataStore _ds;
|
protected DataStore _ds;
|
||||||
|
|
||||||
public DefaultNfsSecondaryLifeCycle(DataStore ds) {
|
public DefaultNfsSecondaryLifeCycle(DataStore ds) {
|
||||||
_ds = ds;
|
_ds = ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add() {
|
public void add() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
|||||||
@ -32,11 +32,11 @@ public class DefaultPrimaryDataStoreLifeCycle implements DataStoreLifeCycle {
|
|||||||
StoragePoolDao _storagePoolDao;
|
StoragePoolDao _storagePoolDao;
|
||||||
@Inject
|
@Inject
|
||||||
StoragePoolHostDao _poolHostDao;
|
StoragePoolHostDao _poolHostDao;
|
||||||
|
|
||||||
public DefaultPrimaryDataStoreLifeCycle(DataStore ds) {
|
public DefaultPrimaryDataStoreLifeCycle(DataStore ds) {
|
||||||
this._ds = ds;
|
this._ds = ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected boolean createStoragePool(DataStoreEndPoint ep, StoragePoolVO pool) {
|
protected boolean createStoragePool(DataStoreEndPoint ep, StoragePoolVO pool) {
|
||||||
DataStoreDriver dsDriver = _ds.getDataStoreDriver();
|
DataStoreDriver dsDriver = _ds.getDataStoreDriver();
|
||||||
CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, pool);
|
CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, pool);
|
||||||
|
|||||||
@ -28,11 +28,15 @@ import com.cloud.utils.fsm.NoTransitionException;
|
|||||||
|
|
||||||
public interface BackupStorageManager {
|
public interface BackupStorageManager {
|
||||||
boolean contains(Volume vol);
|
boolean contains(Volume vol);
|
||||||
|
|
||||||
boolean contains(Snapshot snapshot);
|
boolean contains(Snapshot snapshot);
|
||||||
|
|
||||||
boolean contains(VirtualMachineTemplate template);
|
boolean contains(VirtualMachineTemplate template);
|
||||||
|
|
||||||
DataStore getBackupDataStore(Volume vol);
|
DataStore getBackupDataStore(Volume vol);
|
||||||
|
|
||||||
DataStore getBackupDataStore(Snapshot snapshot);
|
DataStore getBackupDataStore(Snapshot snapshot);
|
||||||
|
|
||||||
DataStore getBackupDataStore(VirtualMachineTemplate template);
|
DataStore getBackupDataStore(VirtualMachineTemplate template);
|
||||||
|
|
||||||
boolean updateOperationState(Volume vol, DataObjectBackupStorageOperationState.Event event) throws NoTransitionException;
|
boolean updateOperationState(Volume vol, DataObjectBackupStorageOperationState.Event event) throws NoTransitionException;
|
||||||
|
|||||||
@ -27,16 +27,17 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|||||||
import com.cloud.storage.StoragePool;
|
import com.cloud.storage.StoragePool;
|
||||||
|
|
||||||
public interface PrimaryDataStoreManager {
|
public interface PrimaryDataStoreManager {
|
||||||
PrimaryDataStore addDataStore(long zoneId, long podId, long clusterId, long hostId,
|
PrimaryDataStore addDataStore(long zoneId, long podId, long clusterId, long hostId, String URI, String storageType, String poolName, String storageProviderName, Map<String, String> params);
|
||||||
String URI,
|
|
||||||
String storageType,
|
|
||||||
String poolName,
|
|
||||||
String storageProviderName,
|
|
||||||
Map<String, String> params);
|
|
||||||
void deleteStoragePool(long poolId);
|
void deleteStoragePool(long poolId);
|
||||||
|
|
||||||
void enableStoragePool(long poolId);
|
void enableStoragePool(long poolId);
|
||||||
|
|
||||||
void disableStoragePool(long poolId);
|
void disableStoragePool(long poolId);
|
||||||
|
|
||||||
Map<String, List<String>> getSupportedPrimaryStorages(long zoneId, HypervisorType hypervisor);
|
Map<String, List<String>> getSupportedPrimaryStorages(long zoneId, HypervisorType hypervisor);
|
||||||
|
|
||||||
Map<String, List<String>> getSupportedSecondaryStorages(long zoneId);
|
Map<String, List<String>> getSupportedSecondaryStorages(long zoneId);
|
||||||
|
|
||||||
PrimaryDataStore getDataStore(String id);
|
PrimaryDataStore getDataStore(String id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,10 @@ import com.cloud.template.VirtualMachineTemplate;
|
|||||||
|
|
||||||
public interface SecondaryStorageManager {
|
public interface SecondaryStorageManager {
|
||||||
DataStore getStore(Volume volume);
|
DataStore getStore(Volume volume);
|
||||||
|
|
||||||
DataStore getImageStore(DataStore destStore);
|
DataStore getImageStore(DataStore destStore);
|
||||||
|
|
||||||
List<DataStore> getImageStores(long zoneId);
|
List<DataStore> getImageStores(long zoneId);
|
||||||
|
|
||||||
DataStore getStore(Snapshot snapshot);
|
DataStore getStore(Snapshot snapshot);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import com.cloud.storage.StoragePool;
|
|||||||
public class DefaultNfsSecondaryStorageProvider implements StorageProvider {
|
public class DefaultNfsSecondaryStorageProvider implements StorageProvider {
|
||||||
private String _name = DefaultPrimaryStorageProvider.class.toString();
|
private String _name = DefaultPrimaryStorageProvider.class.toString();
|
||||||
protected Map<HypervisorType, Map<String, DataStoreConfigurator>> _supportedProtocols;
|
protected Map<HypervisorType, Map<String, DataStoreConfigurator>> _supportedProtocols;
|
||||||
|
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
Map<String, DataStoreConfigurator> dscs = new HashMap<String, DataStoreConfigurator>();
|
Map<String, DataStoreConfigurator> dscs = new HashMap<String, DataStoreConfigurator>();
|
||||||
DataStoreConfigurator nfsdc = null;
|
DataStoreConfigurator nfsdc = null;
|
||||||
|
|||||||
@ -68,8 +68,7 @@ public class DefaultPrimaryStorageProvider implements StorageProvider {
|
|||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataStore createDataStore(HypervisorType hypervisor,
|
public DataStore createDataStore(HypervisorType hypervisor, DataStoreConfigurator dsc) {
|
||||||
DataStoreConfigurator dsc) {
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,5 +20,6 @@ package org.apache.cloudstack.storage.snapshot;
|
|||||||
|
|
||||||
public interface SnapshotService {
|
public interface SnapshotService {
|
||||||
long takeSnapshot(long volumeId);
|
long takeSnapshot(long volumeId);
|
||||||
|
|
||||||
boolean deleteSnapshot(long snapshotId);
|
boolean deleteSnapshot(long snapshotId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,12 +16,10 @@ import org.apache.cloudstack.storage.volume.VolumeManager;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
import com.cloud.storage.Volume;
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
import com.cloud.utils.component.Inject;
|
import com.cloud.utils.component.Inject;
|
||||||
|
|
||||||
|
|
||||||
public class DefaultVolumeStrategy implements VolumeStrategy {
|
public class DefaultVolumeStrategy implements VolumeStrategy {
|
||||||
private static final Logger s_logger = Logger.getLogger(DefaultVolumeStrategy.class);
|
private static final Logger s_logger = Logger.getLogger(DefaultVolumeStrategy.class);
|
||||||
protected DataStore _ds;
|
protected DataStore _ds;
|
||||||
@ -36,26 +34,32 @@ public class DefaultVolumeStrategy implements VolumeStrategy {
|
|||||||
public DefaultVolumeStrategy(DataStore ds) {
|
public DefaultVolumeStrategy(DataStore ds) {
|
||||||
_ds = ds;
|
_ds = ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Volume createVolume(Volume vol) {
|
public Volume createVolume(Volume vol) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Volume createDataVolume(Volume vol) {
|
public Volume createDataVolume(Volume vol) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Volume copyVolumeFromBackup(VolumeProfile srcVol, Volume destVol) {
|
public Volume copyVolumeFromBackup(VolumeProfile srcVol, Volume destVol) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Volume createVolumeFromSnapshot(SnapshotProfile snapshot, Volume vol) {
|
public Volume createVolumeFromSnapshot(SnapshotProfile snapshot, Volume vol) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Volume createVolumeFromTemplate(TemplateProfile template, Volume vol) {
|
public Volume createVolumeFromTemplate(TemplateProfile template, Volume vol) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Volume migrateVolume(Volume srcVol, Volume destVol, DataStore destStore) {
|
public Volume migrateVolume(Volume srcVol, Volume destVol, DataStore destStore) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
@ -79,12 +83,10 @@ public class DefaultVolumeStrategy implements VolumeStrategy {
|
|||||||
|
|
||||||
return _volumeMgr.updateVolume(vlvo);
|
return _volumeMgr.updateVolume(vlvo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteVolume(Volume vol) {
|
public boolean deleteVolume(Volume vol) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
|||||||
|
|
||||||
public class XenBackupStrategy implements BackupStrategy {
|
public class XenBackupStrategy implements BackupStrategy {
|
||||||
protected DataStore _ds;
|
protected DataStore _ds;
|
||||||
|
|
||||||
public XenBackupStrategy(DataStore ds) {
|
public XenBackupStrategy(DataStore ds) {
|
||||||
_ds = ds;
|
_ds = ds;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy;
|
|||||||
|
|
||||||
public class XenSnapshotStrategy implements SnapshotStrategy {
|
public class XenSnapshotStrategy implements SnapshotStrategy {
|
||||||
protected DataStore _ds;
|
protected DataStore _ds;
|
||||||
|
|
||||||
public XenSnapshotStrategy(DataStore ds) {
|
public XenSnapshotStrategy(DataStore ds) {
|
||||||
_ds = ds;
|
_ds = ds;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,10 @@ import org.apache.cloudstack.storage.image.TemplateInfo;
|
|||||||
|
|
||||||
public interface TemplateOnPrimaryDataStoreInfo {
|
public interface TemplateOnPrimaryDataStoreInfo {
|
||||||
public String getPath();
|
public String getPath();
|
||||||
|
|
||||||
public void setPath(String path);
|
public void setPath(String path);
|
||||||
|
|
||||||
public PrimaryDataStoreInfo getPrimaryDataStore();
|
public PrimaryDataStoreInfo getPrimaryDataStore();
|
||||||
|
|
||||||
public TemplateInfo getTemplate();
|
public TemplateInfo getTemplate();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,5 +23,6 @@ import org.apache.cloudstack.storage.image.TemplateInfo;
|
|||||||
|
|
||||||
public interface TemplatePrimaryDataStoreManager {
|
public interface TemplatePrimaryDataStoreManager {
|
||||||
public TemplateOnPrimaryDataStoreInfo createTemplateOnPrimaryDataStore(TemplateInfo template, PrimaryDataStoreInfo dataStore);
|
public TemplateOnPrimaryDataStoreInfo createTemplateOnPrimaryDataStore(TemplateInfo template, PrimaryDataStoreInfo dataStore);
|
||||||
|
|
||||||
public TemplateOnPrimaryDataStoreInfo findTemplateOnPrimaryDataStore(TemplateInfo template, PrimaryDataStoreInfo dataStore);
|
public TemplateOnPrimaryDataStoreInfo findTemplateOnPrimaryDataStore(TemplateInfo template, PrimaryDataStoreInfo dataStore);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,15 +24,18 @@ import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
|||||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||||
import org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDao;
|
import org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreVO;
|
import org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreVO;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||||
import com.cloud.utils.db.SearchCriteria2;
|
import com.cloud.utils.db.SearchCriteria2;
|
||||||
import com.cloud.utils.db.SearchCriteriaService;
|
import com.cloud.utils.db.SearchCriteriaService;
|
||||||
import com.cloud.utils.db.SearchCriteria.Op;
|
import com.cloud.utils.db.SearchCriteria.Op;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class TemplatePrimaryDataStoreManagerImpl implements TemplatePrimaryDataStoreManager {
|
public class TemplatePrimaryDataStoreManagerImpl implements TemplatePrimaryDataStoreManager {
|
||||||
@Inject
|
@Inject
|
||||||
TemplatePrimaryDataStoreDao templateStoreDao;
|
TemplatePrimaryDataStoreDao templateStoreDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TemplateOnPrimaryDataStoreObject createTemplateOnPrimaryDataStore(TemplateInfo template, PrimaryDataStoreInfo dataStore) {
|
public TemplateOnPrimaryDataStoreObject createTemplateOnPrimaryDataStore(TemplateInfo template, PrimaryDataStoreInfo dataStore) {
|
||||||
|
|
||||||
@ -41,6 +44,7 @@ public class TemplatePrimaryDataStoreManagerImpl implements TemplatePrimaryDataS
|
|||||||
TemplateOnPrimaryDataStoreObject templateStoreObject = new TemplateOnPrimaryDataStoreObject(dataStore, template, templateStoreVO);
|
TemplateOnPrimaryDataStoreObject templateStoreObject = new TemplateOnPrimaryDataStoreObject(dataStore, template, templateStoreVO);
|
||||||
return templateStoreObject;
|
return templateStoreObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TemplateOnPrimaryDataStoreObject findTemplateOnPrimaryDataStore(TemplateInfo template, PrimaryDataStoreInfo dataStore) {
|
public TemplateOnPrimaryDataStoreObject findTemplateOnPrimaryDataStore(TemplateInfo template, PrimaryDataStoreInfo dataStore) {
|
||||||
SearchCriteriaService<TemplatePrimaryDataStoreVO, TemplatePrimaryDataStoreVO> sc = SearchCriteria2.create(TemplatePrimaryDataStoreVO.class);
|
SearchCriteriaService<TemplatePrimaryDataStoreVO, TemplatePrimaryDataStoreVO> sc = SearchCriteria2.create(TemplatePrimaryDataStoreVO.class);
|
||||||
|
|||||||
@ -55,6 +55,12 @@ public class VolumeEntityImpl implements VolumeEntity {
|
|||||||
return volumeInfo.getId();
|
return volumeInfo.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExternalId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCurrentState() {
|
public String getCurrentState() {
|
||||||
return volumeInfo.getCurrentState().toString();
|
return volumeInfo.getCurrentState().toString();
|
||||||
|
|||||||
@ -19,16 +19,5 @@
|
|||||||
package org.apache.cloudstack.storage.volume;
|
package org.apache.cloudstack.storage.volume;
|
||||||
|
|
||||||
public enum VolumeEvent {
|
public enum VolumeEvent {
|
||||||
CreateRequested,
|
CreateRequested, CopyRequested, CopySucceeded, CopyFailed, OperationFailed, OperationSucceeded, OperationRetry, UploadRequested, MigrationRequested, SnapshotRequested, DestroyRequested, ExpungingRequested;
|
||||||
CopyRequested,
|
|
||||||
CopySucceeded,
|
|
||||||
CopyFailed,
|
|
||||||
OperationFailed,
|
|
||||||
OperationSucceeded,
|
|
||||||
OperationRetry,
|
|
||||||
UploadRequested,
|
|
||||||
MigrationRequested,
|
|
||||||
SnapshotRequested,
|
|
||||||
DestroyRequested,
|
|
||||||
ExpungingRequested;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,8 +26,12 @@ import com.cloud.utils.fsm.NoTransitionException;
|
|||||||
|
|
||||||
public interface VolumeManager {
|
public interface VolumeManager {
|
||||||
VolumeVO allocateDuplicateVolume(VolumeVO oldVol);
|
VolumeVO allocateDuplicateVolume(VolumeVO oldVol);
|
||||||
|
|
||||||
VolumeVO processEvent(Volume vol, Volume.Event event) throws NoTransitionException;
|
VolumeVO processEvent(Volume vol, Volume.Event event) throws NoTransitionException;
|
||||||
|
|
||||||
VolumeProfile getProfile(long volumeId);
|
VolumeProfile getProfile(long volumeId);
|
||||||
|
|
||||||
VolumeVO getVolume(long volumeId);
|
VolumeVO getVolume(long volumeId);
|
||||||
|
|
||||||
VolumeVO updateVolume(VolumeVO volume);
|
VolumeVO updateVolume(VolumeVO volume);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,6 @@ public class VolumeManagerImpl implements VolumeManager {
|
|||||||
@Inject
|
@Inject
|
||||||
protected VolumeDao _volumeDao;
|
protected VolumeDao _volumeDao;
|
||||||
|
|
||||||
|
|
||||||
public VolumeVO allocateDuplicateVolume(VolumeVO oldVol) {
|
public VolumeVO allocateDuplicateVolume(VolumeVO oldVol) {
|
||||||
VolumeVO newVol = new VolumeVO(oldVol.getVolumeType(), oldVol.getName(), oldVol.getDataCenterId(), oldVol.getDomainId(), oldVol.getAccountId(), oldVol.getDiskOfferingId(), oldVol.getSize());
|
VolumeVO newVol = new VolumeVO(oldVol.getVolumeType(), oldVol.getName(), oldVol.getDataCenterId(), oldVol.getDomainId(), oldVol.getAccountId(), oldVol.getDiskOfferingId(), oldVol.getSize());
|
||||||
newVol.setTemplateId(oldVol.getTemplateId());
|
newVol.setTemplateId(oldVol.getTemplateId());
|
||||||
@ -44,25 +43,21 @@ public class VolumeManagerImpl implements VolumeManager {
|
|||||||
// return _volumeDao.persist(newVol);
|
// return _volumeDao.persist(newVol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public VolumeVO processEvent(Volume vol, Volume.Event event) throws NoTransitionException {
|
public VolumeVO processEvent(Volume vol, Volume.Event event) throws NoTransitionException {
|
||||||
// _volStateMachine.transitTo(vol, event, null, _volumeDao);
|
// _volStateMachine.transitTo(vol, event, null, _volumeDao);
|
||||||
return _volumeDao.findById(vol.getId());
|
return _volumeDao.findById(vol.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public VolumeProfile getProfile(long volumeId) {
|
public VolumeProfile getProfile(long volumeId) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public VolumeVO getVolume(long volumeId) {
|
public VolumeVO getVolume(long volumeId) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public VolumeVO updateVolume(VolumeVO volume) {
|
public VolumeVO updateVolume(VolumeVO volume) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package org.apache.cloudstack.storage.volume;
|
package org.apache.cloudstack.storage.volume;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|||||||
@ -26,7 +26,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTyp
|
|||||||
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
import org.apache.cloudstack.storage.image.TemplateInfo;
|
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||||
|
|
||||||
|
|
||||||
public interface VolumeService {
|
public interface VolumeService {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -44,6 +43,7 @@ public interface VolumeService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete volume
|
* Delete volume
|
||||||
|
*
|
||||||
* @param volumeId
|
* @param volumeId
|
||||||
* @return
|
* @return
|
||||||
* @throws ConcurrentOperationException
|
* @throws ConcurrentOperationException
|
||||||
@ -73,5 +73,6 @@ public interface VolumeService {
|
|||||||
boolean rokeAccess(long volumeId, long endpointId);
|
boolean rokeAccess(long volumeId, long endpointId);
|
||||||
|
|
||||||
VolumeEntity getVolumeEntity(long volumeId);
|
VolumeEntity getVolumeEntity(long volumeId);
|
||||||
|
|
||||||
VolumeInfo createVolumeFromTemplate(VolumeInfo volume, long dataStoreId, VolumeDiskType diskType, TemplateInfo template);
|
VolumeInfo createVolumeFromTemplate(VolumeInfo volume, long dataStoreId, VolumeDiskType diskType, TemplateInfo template);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
TemplatePrimaryDataStoreManager templatePrimaryStoreMgr;
|
TemplatePrimaryDataStoreManager templatePrimaryStoreMgr;
|
||||||
@Inject
|
@Inject
|
||||||
ImageMotionService imageMotion;
|
ImageMotionService imageMotion;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VolumeInfo createVolume(VolumeInfo volume, long dataStoreId, VolumeDiskType diskType) {
|
public VolumeInfo createVolume(VolumeInfo volume, long dataStoreId, VolumeDiskType diskType) {
|
||||||
PrimaryDataStore dataStore = dataStoreMgr.getPrimaryDataStore(dataStoreId);
|
PrimaryDataStore dataStore = dataStoreMgr.getPrimaryDataStore(dataStoreId);
|
||||||
@ -124,7 +125,6 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String grantAccess(VolumeInfo volume, EndPoint endpointId) {
|
public String grantAccess(VolumeInfo volume, EndPoint endpointId) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|||||||
@ -45,29 +45,40 @@ public class TemplatePrimaryDataStoreVO {
|
|||||||
@Column(name = "pool_id")
|
@Column(name = "pool_id")
|
||||||
private long poolId;
|
private long poolId;
|
||||||
|
|
||||||
@Column(name="template_id") long templateId;
|
@Column(name = "template_id")
|
||||||
|
long templateId;
|
||||||
|
|
||||||
@Column(name=GenericDaoBase.CREATED_COLUMN) Date created = null;
|
@Column(name = GenericDaoBase.CREATED_COLUMN)
|
||||||
|
Date created = null;
|
||||||
|
|
||||||
@Column(name = "last_updated")
|
@Column(name = "last_updated")
|
||||||
@Temporal(value=TemporalType.TIMESTAMP) Date lastUpdated = null;
|
@Temporal(value = TemporalType.TIMESTAMP)
|
||||||
|
Date lastUpdated = null;
|
||||||
|
|
||||||
@Column (name="download_pct") int downloadPercent;
|
@Column(name = "download_pct")
|
||||||
|
int downloadPercent;
|
||||||
|
|
||||||
@Column(name = "download_state")
|
@Column(name = "download_state")
|
||||||
@Enumerated(EnumType.STRING) Status downloadState;
|
@Enumerated(EnumType.STRING)
|
||||||
|
Status downloadState;
|
||||||
|
|
||||||
@Column (name="local_path") String localDownloadPath;
|
@Column(name = "local_path")
|
||||||
|
String localDownloadPath;
|
||||||
|
|
||||||
@Column (name="error_str") String errorString;
|
@Column(name = "error_str")
|
||||||
|
String errorString;
|
||||||
|
|
||||||
@Column (name="job_id") String jobId;
|
@Column(name = "job_id")
|
||||||
|
String jobId;
|
||||||
|
|
||||||
@Column (name="install_path") String installPath;
|
@Column(name = "install_path")
|
||||||
|
String installPath;
|
||||||
|
|
||||||
@Column (name="template_size") long templateSize;
|
@Column(name = "template_size")
|
||||||
|
long templateSize;
|
||||||
|
|
||||||
@Column (name="marked_for_gc") boolean markedForGC;
|
@Column(name = "marked_for_gc")
|
||||||
|
boolean markedForGC;
|
||||||
|
|
||||||
public String getInstallPath() {
|
public String getInstallPath() {
|
||||||
return installPath;
|
return installPath;
|
||||||
@ -137,9 +148,7 @@ public class TemplatePrimaryDataStoreVO {
|
|||||||
this.markedForGC = false;
|
this.markedForGC = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemplatePrimaryDataStoreVO(long poolId, long templateId, Date lastUpdated,
|
public TemplatePrimaryDataStoreVO(long poolId, long templateId, Date lastUpdated, int downloadPercent, Status downloadState, String localDownloadPath, String errorString, String jobId,
|
||||||
int downloadPercent, Status downloadState,
|
|
||||||
String localDownloadPath, String errorString, String jobId,
|
|
||||||
String installPath, long templateSize) {
|
String installPath, long templateSize) {
|
||||||
super();
|
super();
|
||||||
this.poolId = poolId;
|
this.poolId = poolId;
|
||||||
|
|||||||
@ -21,8 +21,6 @@ import java.util.List;
|
|||||||
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.Volume;
|
import com.cloud.storage.Volume;
|
||||||
|
|||||||
@ -61,14 +61,13 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
protected final SearchBuilder<VolumeVO> InstanceStatesSearch;
|
protected final SearchBuilder<VolumeVO> InstanceStatesSearch;
|
||||||
protected final SearchBuilder<VolumeVO> AllFieldsSearch;
|
protected final SearchBuilder<VolumeVO> AllFieldsSearch;
|
||||||
protected GenericSearchBuilder<VolumeVO, Long> CountByAccount;
|
protected GenericSearchBuilder<VolumeVO, Long> CountByAccount;
|
||||||
ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
|
//ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
|
||||||
|
ResourceTagsDaoImpl _tagsDao = null;
|
||||||
protected static final String SELECT_VM_SQL = "SELECT DISTINCT instance_id from volumes v where v.host_id = ? and v.mirror_state = ?";
|
protected static final String SELECT_VM_SQL = "SELECT DISTINCT instance_id from volumes v where v.host_id = ? and v.mirror_state = ?";
|
||||||
protected static final String SELECT_HYPERTYPE_FROM_VOLUME = "SELECT c.hypervisor_type from volumes v, storage_pool s, cluster c where v.pool_id = s.id and s.cluster_id = c.id and v.id = ?";
|
protected static final String SELECT_HYPERTYPE_FROM_VOLUME = "SELECT c.hypervisor_type from volumes v, storage_pool s, cluster c where v.pool_id = s.id and s.cluster_id = c.id and v.id = ?";
|
||||||
|
|
||||||
private static final String ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT = "SELECT pool.id, SUM(IF(vol.state='Ready' AND vol.account_id = ?, 1, 0)) FROM `cloud`.`storage_pool` pool LEFT JOIN `cloud`.`volumes` vol ON pool.id = vol.pool_id WHERE pool.data_center_id = ? " +
|
private static final String ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT = "SELECT pool.id, SUM(IF(vol.state='Ready' AND vol.account_id = ?, 1, 0)) FROM `cloud`.`storage_pool` pool LEFT JOIN `cloud`.`volumes` vol ON pool.id = vol.pool_id WHERE pool.data_center_id = ? "
|
||||||
" AND pool.pod_id = ? AND pool.cluster_id = ? " +
|
+ " AND pool.pod_id = ? AND pool.cluster_id = ? " + " GROUP BY pool.id ORDER BY 2 ASC ";
|
||||||
" GROUP BY pool.id ORDER BY 2 ASC ";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VolumeVO> findDetachedByAccount(long accountId) {
|
public List<VolumeVO> findDetachedByAccount(long accountId) {
|
||||||
@ -301,7 +300,8 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
CountByAccount.done();
|
CountByAccount.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB(txn=false)
|
@Override
|
||||||
|
@DB(txn = false)
|
||||||
public Pair<Long, Long> getCountAndTotalByPool(long poolId) {
|
public Pair<Long, Long> getCountAndTotalByPool(long poolId) {
|
||||||
SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
|
SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
|
||||||
sc.setParameters("poolId", poolId);
|
sc.setParameters("poolId", poolId);
|
||||||
@ -321,6 +321,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
public static class SumCount {
|
public static class SumCount {
|
||||||
public long sum;
|
public long sum;
|
||||||
public long count;
|
public long count;
|
||||||
|
|
||||||
public SumCount() {
|
public SumCount() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,9 +335,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateState(Volume.State currentState,
|
public boolean updateState(Volume.State currentState, VolumeEvent event, Volume.State nextState, VolumeVO vo, Object data) {
|
||||||
VolumeEvent event, Volume.State nextState, VolumeVO vo,
|
|
||||||
Object data) {
|
|
||||||
|
|
||||||
Long oldUpdated = vo.getUpdatedCount();
|
Long oldUpdated = vo.getUpdatedCount();
|
||||||
Date oldUpdatedTime = vo.getUpdated();
|
Date oldUpdatedTime = vo.getUpdated();
|
||||||
@ -357,9 +356,12 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
VolumeVO dbVol = findByIdIncludingRemoved(vo.getId());
|
VolumeVO dbVol = findByIdIncludingRemoved(vo.getId());
|
||||||
if (dbVol != null) {
|
if (dbVol != null) {
|
||||||
StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
|
StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
|
||||||
str.append(": DB Data={id=").append(dbVol.getId()).append("; state=").append(dbVol.getState()).append("; updatecount=").append(dbVol.getUpdatedCount()).append(";updatedTime=").append(dbVol.getUpdated());
|
str.append(": DB Data={id=").append(dbVol.getId()).append("; state=").append(dbVol.getState()).append("; updatecount=").append(dbVol.getUpdatedCount()).append(";updatedTime=")
|
||||||
str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatecount=").append(vo.getUpdatedCount()).append("; updatedTime=").append(vo.getUpdated());
|
.append(dbVol.getUpdated());
|
||||||
str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatecount=").append(oldUpdated).append("; updatedTime=").append(oldUpdatedTime);
|
str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatecount=").append(vo.getUpdatedCount())
|
||||||
|
.append("; updatedTime=").append(vo.getUpdated());
|
||||||
|
str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatecount=").append(oldUpdated)
|
||||||
|
.append("; updatedTime=").append(oldUpdatedTime);
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Unable to update volume: id=" + vo.getId() + ", as there is no such volume exists in the database anymore");
|
s_logger.debug("Unable to update volume: id=" + vo.getId() + ", as there is no such volume exists in the database anymore");
|
||||||
}
|
}
|
||||||
@ -392,7 +394,8 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB(txn=false)
|
@Override
|
||||||
|
@DB(txn = false)
|
||||||
public Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId) {
|
public Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId) {
|
||||||
SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
|
SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
|
||||||
sc.setParameters("poolId", poolId);
|
sc.setParameters("poolId", poolId);
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
//under the License.
|
//under the License.
|
||||||
|
|
||||||
package org.apache.cloudstack.storage.volume.db;
|
package org.apache.cloudstack.storage.volume.db;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -33,8 +34,6 @@ import javax.persistence.TemporalType;
|
|||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.Unknown;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.Unknown;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.cloud.api.Identity;
|
import com.cloud.api.Identity;
|
||||||
import com.cloud.storage.Volume;
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.storage.Storage.StoragePoolType;
|
import com.cloud.storage.Storage.StoragePoolType;
|
||||||
@ -124,7 +123,10 @@ public class VolumeVO implements Identity, StateObject<Volume.State>{
|
|||||||
Date updated;
|
Date updated;
|
||||||
|
|
||||||
@Column(name = "update_count", updatable = true, nullable = false)
|
@Column(name = "update_count", updatable = true, nullable = false)
|
||||||
protected long updatedCount; // This field should be updated everytime the state is updated. There's no set method in the vo object because it is done with in the dao code.
|
protected long updatedCount; // This field should be updated everytime the
|
||||||
|
// state is updated. There's no set method in
|
||||||
|
// the vo object because it is done with in the
|
||||||
|
// dao code.
|
||||||
|
|
||||||
@Column(name = "recreatable")
|
@Column(name = "recreatable")
|
||||||
boolean recreatable;
|
boolean recreatable;
|
||||||
@ -190,12 +192,10 @@ public class VolumeVO implements Identity, StateObject<Volume.State>{
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Long getPodId() {
|
public Long getPodId() {
|
||||||
return podId;
|
return podId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public long getDataCenterId() {
|
public long getDataCenterId() {
|
||||||
return dataCenterId;
|
return dataCenterId;
|
||||||
}
|
}
|
||||||
@ -423,4 +423,3 @@ public class VolumeVO implements Identity, StateObject<Volume.State>{
|
|||||||
diskType = type;
|
diskType = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,11 +21,13 @@ package org.apache.cloudstack.storage.test;
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.awt.List;
|
import java.awt.List;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.QCOW2;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.QCOW2;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VHD;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VHD;
|
||||||
@ -35,23 +37,18 @@ import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTyp
|
|||||||
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper;
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper;
|
||||||
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
|
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
|
||||||
import org.apache.cloudstack.storage.datastore.provider.DefaultPrimaryDatastoreProviderImpl;
|
import org.apache.cloudstack.storage.datastore.provider.DefaultPrimaryDatastoreProviderImpl;
|
||||||
import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
|
|
||||||
import org.apache.cloudstack.storage.image.format.ISO;
|
import org.apache.cloudstack.storage.image.format.ISO;
|
||||||
import org.apache.cloudstack.storage.image.format.ImageFormat;
|
import org.apache.cloudstack.storage.image.format.ImageFormat;
|
||||||
import org.apache.cloudstack.storage.image.format.ImageFormatHelper;
|
import org.apache.cloudstack.storage.image.format.ImageFormatHelper;
|
||||||
import org.apache.cloudstack.storage.image.format.OVA;
|
import org.apache.cloudstack.storage.image.format.OVA;
|
||||||
import org.apache.cloudstack.storage.image.format.Unknown;
|
import org.apache.cloudstack.storage.image.format.Unknown;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeMotionService;
|
import org.apache.cloudstack.storage.image.provider.ImageDataStoreProviderManager;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeService;
|
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.Mockito;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.mockito.Mockito.*;
|
import org.mockito.Mockito.*;
|
||||||
@ -61,37 +58,25 @@ import com.cloud.utils.component.ComponentInject;
|
|||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(locations="storageContext.xml")
|
@ContextConfiguration(locations="classpath:/resource/storageContext.xml")
|
||||||
public class volumeServiceTest {
|
public class volumeServiceTest {
|
||||||
@Autowired
|
|
||||||
protected VolumeService volService;
|
|
||||||
@Inject
|
@Inject
|
||||||
protected VolumeDao volumeDao;
|
ImageDataStoreProviderManager imageProviderMgr;
|
||||||
@Autowired
|
|
||||||
protected VolumeMotionService vmotion;
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
Mockito.when(vmotion.copyVolume(null, null)).thenReturn(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DB
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
assertTrue(volService.deleteVolume(1) != false);
|
try {
|
||||||
assertNotNull(volumeDao);
|
|
||||||
//VolumeVO vol = new VolumeVO(Volume.Type.DATADISK, "test", 1, 2, 2, 1, 1);
|
|
||||||
//volumeDao.persist(vol);
|
|
||||||
/*
|
|
||||||
VolumeVO volume = new VolumeVO();
|
|
||||||
String name = "test";
|
|
||||||
long size = 100;
|
|
||||||
volume.setName(name);
|
|
||||||
volume.setSize(size);
|
|
||||||
volumeDao.persist(volume);
|
|
||||||
VolumeVO newVol = volumeDao.getVolumeByName(name);
|
|
||||||
assertTrue(newVol.getSize() == volume.getSize());
|
|
||||||
*/
|
|
||||||
|
|
||||||
fail("Not yet implemented");
|
imageProviderMgr.configure("image Provider", new HashMap<String, Object>());
|
||||||
|
|
||||||
|
} catch (ConfigurationException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
<context:component-scan base-package="org.apache.cloudstack.storage" />
|
<context:component-scan base-package="org.apache.cloudstack.storage" />
|
||||||
<context:component-scan base-package="com.cloud.utils.db" />
|
<context:component-scan base-package="com.cloud.utils.db" />
|
||||||
<context:component-scan base-package="com.cloud.utils.component" />
|
<context:component-scan base-package="com.cloud.utils.component" />
|
||||||
<context:component-scan base-package="com.cloud.storage.dao" />
|
|
||||||
|
|
||||||
<context:component-scan base-package=" com.cloud.upgrade.dao" />
|
<context:component-scan base-package=" com.cloud.upgrade.dao" />
|
||||||
<tx:annotation-driven transaction-manager="transactionManager" />
|
<tx:annotation-driven transaction-manager="transactionManager" />
|
||||||
@ -50,7 +50,6 @@ import com.cloud.utils.db.Transaction;
|
|||||||
import com.cloud.utils.db.UpdateBuilder;
|
import com.cloud.utils.db.UpdateBuilder;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@Component
|
|
||||||
@Local(value=VolumeDao.class)
|
@Local(value=VolumeDao.class)
|
||||||
public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements VolumeDao {
|
public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements VolumeDao {
|
||||||
private static final Logger s_logger = Logger.getLogger(VolumeDaoImpl.class);
|
private static final Logger s_logger = Logger.getLogger(VolumeDaoImpl.class);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user