mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
refactor apis
This commit is contained in:
parent
2251d5bb40
commit
a06eb4557e
@ -18,12 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.engine.cloud.entity.api;
|
package org.apache.cloudstack.engine.cloud.entity.api;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
|
||||||
import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
|
import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
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.datastore.PrimaryDataStore;
|
||||||
|
|
||||||
import com.cloud.storage.Volume;
|
|
||||||
|
|
||||||
public interface VolumeEntity extends CloudStackEntity {
|
public interface VolumeEntity extends CloudStackEntity {
|
||||||
|
|
||||||
@ -81,6 +81,6 @@ public interface VolumeEntity extends CloudStackEntity {
|
|||||||
String getTemplateUuid();
|
String getTemplateUuid();
|
||||||
VolumeDiskType getDiskType();
|
VolumeDiskType getDiskType();
|
||||||
VolumeType getType();
|
VolumeType getType();
|
||||||
PrimaryDataStore getDataStore();
|
StorageEntity getDataStore();
|
||||||
void setUuid(String uuid);
|
void setPath(String path);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,9 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.image;
|
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
|
||||||
|
|
||||||
public interface ImageService {
|
public interface ImageService {
|
||||||
boolean registerTemplate(long templateId, long imageStoreId);
|
boolean registerTemplate(long templateId, long imageStoreId);
|
||||||
@ -27,4 +29,5 @@ public interface ImageService {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
|
|
||||||
|
|
||||||
|
public interface PrimaryDataStoreProvider {
|
||||||
|
public PrimaryDataStore getDataStore(long dataStoreId);
|
||||||
|
public PrimaryDataStoreInfo getDataStoreInfo(long dataStoreId);
|
||||||
|
}
|
||||||
@ -16,10 +16,15 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage;
|
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
|
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
|
|
||||||
public interface StorageOrchestrator {
|
public interface StorageOrchestrator {
|
||||||
@ -56,4 +61,8 @@ public interface StorageOrchestrator {
|
|||||||
* If attaching a volume in allocated state to a running vm, need to create this volume
|
* If attaching a volume in allocated state to a running vm, need to create this volume
|
||||||
*/
|
*/
|
||||||
void prepareAttachDiskToVM(long diskId, long vmId, String reservationId);
|
void prepareAttachDiskToVM(long diskId, long vmId, String reservationId);
|
||||||
|
|
||||||
|
boolean createVolume(VolumeEntity volume, long dataStoreId, VolumeDiskType diskType);
|
||||||
|
boolean createVolumeFromTemplate(VolumeEntity volume, long dataStoreId, VolumeDiskType dis, TemplateEntity template);
|
||||||
|
VolumeEntity allocateVolumeInDb(long size, VolumeType type,String volName, Long templateId);
|
||||||
}
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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.Date;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
|
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
|
|
||||||
|
public interface VolumeInfo {
|
||||||
|
public long getSize();
|
||||||
|
public String getUuid();
|
||||||
|
public String getPath();
|
||||||
|
public PrimaryDataStoreInfo getDataStore() ;
|
||||||
|
public String getTemplateUuid();
|
||||||
|
public String getTemplatePath() ;
|
||||||
|
public VolumeType getType();
|
||||||
|
public VolumeDiskType getDiskType();
|
||||||
|
public long getId();
|
||||||
|
public Volume.State getCurrentState();
|
||||||
|
public Volume.State getDesiredState();
|
||||||
|
public Date getCreatedData();
|
||||||
|
}
|
||||||
@ -25,10 +25,10 @@ import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTyp
|
|||||||
|
|
||||||
|
|
||||||
public interface PrimaryDataStore {
|
public interface PrimaryDataStore {
|
||||||
VolumeEntity getVolume(long id);
|
VolumeEntity getVolume(String id);
|
||||||
List<VolumeEntity> getVolumes();
|
List<VolumeEntity> getVolumes();
|
||||||
boolean deleteVolume(long id);
|
boolean deleteVolume(VolumeEntity id);
|
||||||
VolumeEntity createVolume(long id, VolumeDiskType diskType);
|
VolumeEntity createVolume(String id, VolumeDiskType diskType);
|
||||||
List<EndPoint> getEndPoints();
|
List<EndPoint> getEndPoints();
|
||||||
PrimaryDataStoreInfo getDataStoreInfo();
|
PrimaryDataStoreInfo getDataStoreInfo();
|
||||||
}
|
}
|
||||||
@ -21,16 +21,27 @@ package org.apache.cloudstack.storage;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectBackupStorageOperationState;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectBackupStorageOperationState;
|
||||||
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.StorageOrchestrator;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
|
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile;
|
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeStrategy;
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeStrategy;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
|
import org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreManager;
|
||||||
import org.apache.cloudstack.storage.image.ImageManager;
|
import org.apache.cloudstack.storage.image.ImageManager;
|
||||||
import org.apache.cloudstack.storage.manager.BackupStorageManager;
|
import org.apache.cloudstack.storage.manager.BackupStorageManager;
|
||||||
import org.apache.cloudstack.storage.manager.SecondaryStorageManager;
|
import org.apache.cloudstack.storage.manager.SecondaryStorageManager;
|
||||||
|
import org.apache.cloudstack.storage.volume.VolumeEntityImpl;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeManager;
|
import org.apache.cloudstack.storage.volume.VolumeManager;
|
||||||
|
import org.apache.cloudstack.storage.volume.VolumeObject;
|
||||||
|
import org.apache.cloudstack.storage.volume.VolumeService;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
@ -78,6 +89,10 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
ImageManager _templateMgr;
|
ImageManager _templateMgr;
|
||||||
@Inject
|
@Inject
|
||||||
VMTemplateDao _templateDao;
|
VMTemplateDao _templateDao;
|
||||||
|
@Inject
|
||||||
|
VolumeService volumeService;
|
||||||
|
@Inject
|
||||||
|
PrimaryDataStoreManager primaryStorageMgr;
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
protected Volume copyVolumeFromBackupStorage(VolumeVO volume, DataStore destStore, String reservationId) throws NoTransitionException {
|
protected Volume copyVolumeFromBackupStorage(VolumeVO volume, DataStore destStore, String reservationId) throws NoTransitionException {
|
||||||
@ -312,4 +327,29 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
volume.setInstanceId(vmId);
|
volume.setInstanceId(vmId);
|
||||||
_volumeDao.update(volume.getId(), volume);
|
_volumeDao.update(volume.getId(), volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean createVolume(VolumeEntity volume, long dataStoreId, VolumeDiskType diskType) {
|
||||||
|
VolumeEntityImpl vei = ((VolumeEntityImpl)volume);
|
||||||
|
VolumeInfo vi = volumeService.createVolume(vei.getVolumeInfo(), dataStoreId, diskType);
|
||||||
|
vei.setVolumeInfo(vi);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VolumeEntity allocateVolumeInDb(long size, VolumeType type, String volName, Long templateId) {
|
||||||
|
return volumeService.allocateVolumeInDb(size, type, volName, templateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean createVolumeFromTemplate(VolumeEntity volume, long dataStoreId, VolumeDiskType diskType, TemplateEntity template) {
|
||||||
|
PrimaryDataStore pd = primaryStorageMgr.getPrimaryDataStore(dataStoreId);
|
||||||
|
boolean existsOnPrimaryStorage = pd.templateExists(template.getId());
|
||||||
|
if (!existsOnPrimaryStorage) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.command;
|
package org.apache.cloudstack.storage.command;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.volume.VolumeInfo;
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
import com.cloud.agent.api.Command;
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
import org.apache.cloudstack.storage.HypervisorHostEndPoint;
|
import org.apache.cloudstack.storage.HypervisorHostEndPoint;
|
||||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
||||||
@ -17,6 +17,7 @@ import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
|
|||||||
|
|
||||||
import org.apache.cloudstack.storage.volume.VolumeEntityImpl;
|
import org.apache.cloudstack.storage.volume.VolumeEntityImpl;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
||||||
|
import org.apache.cloudstack.storage.volume.VolumeObject;
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.utils.component.ComponentInject;
|
import com.cloud.utils.component.ComponentInject;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@ -45,14 +47,14 @@ public class DefaultPrimaryDataStoreImpl implements PrimaryDataStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VolumeEntity getVolume(long id) {
|
public VolumeInfo getVolume(long id) {
|
||||||
VolumeVO volumeVO = volumeDao.findById(id);
|
VolumeVO volumeVO = volumeDao.findById(id);
|
||||||
VolumeEntity vol = new VolumeEntityImpl(this, volumeVO);
|
VolumeObject vol = new VolumeObject(this, volumeVO);
|
||||||
return vol;
|
return vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VolumeEntity> getVolumes() {
|
public List<VolumeInfo> getVolumes() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -64,39 +66,10 @@ public class DefaultPrimaryDataStoreImpl implements PrimaryDataStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VolumeEntity createVolume(long id, VolumeDiskType diskType) {
|
public VolumeInfo createVolume(VolumeInfo vol, VolumeDiskType diskType) {
|
||||||
/*
|
|
||||||
VolumeEntity vol = this.getVolume(id);
|
|
||||||
if (vol == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pdsInfo.isVolumeDiskTypeSupported(diskType)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean result = vol.stateTransit(VolumeEvent.CreateRequested);
|
|
||||||
if (!result) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
vol.setVolumeDiskType(diskType);
|
|
||||||
result = this.driver.createVolume(vol);
|
|
||||||
vol.update();
|
|
||||||
return vol;
|
|
||||||
} catch (Exception e) {
|
|
||||||
result = false;
|
|
||||||
s_logger.debug("Failed to create volume: " + e.toString());
|
|
||||||
throw new CloudRuntimeException(e.toString());
|
|
||||||
} finally {
|
|
||||||
if (result == true) {
|
|
||||||
vol.stateTransit(VolumeEvent.OperationSucceeded);
|
|
||||||
} else {
|
|
||||||
vol.stateTransit(VolumeEvent.OperationFailed);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -121,4 +94,51 @@ public class DefaultPrimaryDataStoreImpl implements PrimaryDataStore {
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isHypervisorSupported(HypervisorType hypervisor) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLocalStorageSupported() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVolumeDiskTypeSupported(VolumeDiskType diskType) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getCapacity() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAvailableCapacity() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VolumeObject createVolume(VolumeObject vo, VolumeDiskType diskType) {
|
||||||
|
if (!pdsInfo.isVolumeDiskTypeSupported(diskType)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
vo.setVolumeDiskType(diskType);
|
||||||
|
this.driver.createVolume(vo);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean exists(VolumeInfo vi) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.storage.volume.VolumeObject;
|
||||||
|
|
||||||
|
|
||||||
|
public interface PrimaryDataStore extends PrimaryDataStoreInfo {
|
||||||
|
VolumeInfo getVolume(long id);
|
||||||
|
List<VolumeInfo> getVolumes();
|
||||||
|
boolean deleteVolume(long id);
|
||||||
|
VolumeObject createVolume(VolumeObject vo, VolumeDiskType diskType);
|
||||||
|
List<EndPoint> getEndPoints();
|
||||||
|
PrimaryDataStoreInfo getDataStoreInfo();
|
||||||
|
boolean exists(VolumeInfo vi);
|
||||||
|
boolean templateExists(long templateId);
|
||||||
|
}
|
||||||
@ -4,9 +4,10 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
|
import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
|
||||||
import org.apache.cloudstack.storage.command.CreateVolumeCommand;
|
import org.apache.cloudstack.storage.command.CreateVolumeCommand;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeInfo;
|
import org.apache.cloudstack.storage.volume.VolumeObject;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -17,11 +18,11 @@ 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(VolumeEntity 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 = new VolumeInfo(vol);
|
VolumeInfo volInfo = vol;
|
||||||
CreateVolumeCommand createCmd = new CreateVolumeCommand(volInfo);
|
CreateVolumeCommand createCmd = new CreateVolumeCommand(volInfo);
|
||||||
Answer answer = null;
|
Answer answer = null;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -36,7 +37,7 @@ public class DefaultPrimaryDataStoreDriverImpl implements
|
|||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
CreateVolumeAnswer volAnswer = (CreateVolumeAnswer)answer;
|
CreateVolumeAnswer volAnswer = (CreateVolumeAnswer)answer;
|
||||||
vol.setUuid(volAnswer.getVolumeUuid());
|
vol.setPath(volAnswer.getVolumeUuid());
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,19 +46,19 @@ public class DefaultPrimaryDataStoreDriverImpl implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteVolume(VolumeEntity vo) {
|
public boolean deleteVolume(VolumeObject vo) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String grantAccess(VolumeEntity vol, EndPoint ep) {
|
public String grantAccess(VolumeObject vol, EndPoint ep) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean revokeAccess(VolumeEntity vol, EndPoint ep) {
|
public boolean revokeAccess(VolumeObject vol, EndPoint ep) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,11 +2,12 @@ package org.apache.cloudstack.storage.datastore.driver;
|
|||||||
|
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||||
|
import org.apache.cloudstack.storage.volume.VolumeObject;
|
||||||
|
|
||||||
|
|
||||||
public interface PrimaryDataStoreDriver {
|
public interface PrimaryDataStoreDriver {
|
||||||
boolean createVolume(VolumeEntity vol);
|
boolean createVolume(VolumeObject vol);
|
||||||
boolean deleteVolume(VolumeEntity vo);
|
boolean deleteVolume(VolumeObject vo);
|
||||||
String grantAccess(VolumeEntity vol, EndPoint ep);
|
String grantAccess(VolumeObject vol, EndPoint ep);
|
||||||
boolean revokeAccess(VolumeEntity vol, EndPoint ep);
|
boolean revokeAccess(VolumeObject vol, EndPoint ep);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,12 +20,12 @@ package org.apache.cloudstack.storage.datastore.manager;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
|
||||||
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
||||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
|
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
|
||||||
import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
|
import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
|
||||||
import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
|
|
||||||
import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
|
import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.datastore.manager;
|
package org.apache.cloudstack.storage.datastore.manager;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
|
import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
|
||||||
|
|
||||||
public interface PrimaryDataStoreManager {
|
public interface PrimaryDataStoreManager {
|
||||||
|
|||||||
@ -2,9 +2,10 @@ package org.apache.cloudstack.storage.datastore.provider;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
|
||||||
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
|
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
|
||||||
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
||||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
|
import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
package org.apache.cloudstack.storage.datastore.provider;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
|
||||||
|
|
||||||
public interface PrimaryDataStoreProvider {
|
|
||||||
public PrimaryDataStore getDataStore(long dataStoreId);
|
|
||||||
public PrimaryDataStoreInfo getDataStoreInfo(long dataStoreId);
|
|
||||||
}
|
|
||||||
@ -1,5 +1,7 @@
|
|||||||
package org.apache.cloudstack.storage.datastore.provider;
|
package org.apache.cloudstack.storage.datastore.provider;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
|
||||||
|
|
||||||
public interface PrimaryDataStoreProviderManager {
|
public interface PrimaryDataStoreProviderManager {
|
||||||
public PrimaryDataStoreProvider getDataStoreProvider(Long providerId);
|
public PrimaryDataStoreProvider getDataStoreProvider(Long providerId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.datastore.provider;
|
package org.apache.cloudstack.storage.datastore.provider;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
|||||||
@ -20,6 +20,8 @@ package org.apache.cloudstack.storage.image;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.ImageService;
|
||||||
import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
|
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;
|
||||||
@ -29,10 +31,12 @@ public class ImageServiceImpl implements ImageService {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ImageDataStoreProviderManager imageStoreProviderMgr;
|
ImageDataStoreProviderManager imageStoreProviderMgr;
|
||||||
|
@Inject
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean registerTemplate(long templateId, long imageStoreId) {
|
public boolean registerTemplate(long templateId, long imageStoreId) {
|
||||||
ImageDataStore ids = imageStoreProviderMgr.getDataStore(imageStoreId);
|
ImageDataStore ids = imageStoreProviderMgr.getDataStore(imageStoreId);
|
||||||
Template template = ids.registerTemplate(templateId);
|
TemplateInfo template = ids.registerTemplate(templateId);
|
||||||
if (ids.needDownloadToCacheStorage()) {
|
if (ids.needDownloadToCacheStorage()) {
|
||||||
ImageDownloader imageDl = ids.getImageDownloader();
|
ImageDownloader imageDl = ids.getImageDownloader();
|
||||||
imageDl.downloadImage(template);
|
imageDl.downloadImage(template);
|
||||||
@ -82,4 +86,9 @@ public class ImageServiceImpl implements ImageService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TemplateEntity getTemplateEntity(long templateId) {
|
||||||
|
TemplateObject to = imageStoreProviderMgr.getTemplate(templateId);
|
||||||
|
return new TemplateEntityImpl(to);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,278 @@
|
|||||||
|
/*
|
||||||
|
* 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.image;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
|
||||||
|
import org.apache.cloudstack.storage.image.db.ImageDataVO;
|
||||||
|
import org.apache.cloudstack.storage.image.store.ImageDataStore;
|
||||||
|
import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
|
||||||
|
|
||||||
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
|
import com.cloud.storage.Storage.TemplateType;
|
||||||
|
|
||||||
|
public class TemplateEntityImpl implements TemplateEntity {
|
||||||
|
protected TemplateInfo templateInfo;
|
||||||
|
public TemplateEntityImpl(TemplateInfo templateInfo) {
|
||||||
|
this.templateInfo = templateInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageDataStoreInfo getImageDataStore() {
|
||||||
|
return templateInfo.getImageDataStore();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long getImageDataStoreId() {
|
||||||
|
return getImageDataStore().getImageDataStoreId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUuid() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExternalId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCurrentState() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDesiredState() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getCreatedTime() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getLastUpdatedTime() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwner() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getDetails(String source) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getDetailSources() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addDetail(String source, String name, String value) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delDetail(String source, String name, String value) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDetail(String source, String name, String value) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Method> getApplicableActions() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFeatured() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPublicTemplate() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isExtractable() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ImageFormat getFormat() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRequiresHvm() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayText() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getEnablePassword() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getEnableSshKey() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCrossZones() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getCreated() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getGuestOSId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBootable() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TemplateType getTemplateType() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HypervisorType getHypervisorType() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBits() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUniqueName() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUrl() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getChecksum() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getSourceTemplateId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplateTag() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map getDetails() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDomainId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -18,27 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.image;
|
package org.apache.cloudstack.storage.image;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.image.db.ImageDataVO;
|
import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
|
||||||
import org.apache.cloudstack.storage.image.store.ImageDataStore;
|
|
||||||
|
|
||||||
public class Template {
|
|
||||||
protected ImageDataVO imageVO;
|
|
||||||
protected ImageDataStore dataStore;
|
|
||||||
public Template(ImageDataStore dataStore, ImageDataVO imageVO) {
|
|
||||||
this.dataStore = dataStore;
|
|
||||||
this.imageVO = imageVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImageDataStore getImageDataStore() {
|
|
||||||
return this.dataStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImageDataStoreId(long dataStoreId) {
|
|
||||||
imageVO.setImageDataStoreId(dataStoreId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getImageDataStoreId() {
|
|
||||||
return imageVO.getImageDataStoreId();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public interface TemplateInfo {
|
||||||
|
ImageDataStoreInfo getImageDataStore();
|
||||||
}
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.cloudstack.storage.image;
|
||||||
|
|
||||||
|
public class TemplateObject implements TemplateInfo {
|
||||||
|
|
||||||
|
}
|
||||||
@ -18,8 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.image.downloader;
|
package org.apache.cloudstack.storage.image.downloader;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.image.Template;
|
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||||
|
|
||||||
public interface ImageDownloader {
|
public interface ImageDownloader {
|
||||||
public void downloadImage(Template template);
|
public void downloadImage(TemplateInfo template);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,10 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.image.provider;
|
package org.apache.cloudstack.storage.image.provider;
|
||||||
|
|
||||||
|
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 {
|
public interface ImageDataStoreProviderManager {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,11 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.image.store;
|
package org.apache.cloudstack.storage.image.store;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.image.Template;
|
import org.apache.cloudstack.storage.image.TemplateInfo;
|
||||||
import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
|
import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
|
||||||
|
|
||||||
public interface ImageDataStore {
|
public interface ImageDataStore extends ImageDataStoreInfo {
|
||||||
Template registerTemplate(long templateId);
|
TemplateInfo 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);
|
||||||
|
|||||||
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.cloudstack.storage.image.store;
|
||||||
|
|
||||||
|
public interface ImageDataStoreInfo {
|
||||||
|
public long getImageDataStoreId();
|
||||||
|
}
|
||||||
@ -21,7 +21,7 @@ package org.apache.cloudstack.storage.manager;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.storage.StoragePool;
|
import com.cloud.storage.StoragePool;
|
||||||
|
|||||||
@ -24,9 +24,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
|
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.StoreType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.StoreType;
|
||||||
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
|
|
||||||
import com.cloud.dc.ClusterVO;
|
import com.cloud.dc.ClusterVO;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
|
|||||||
@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* 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.volume;
|
package org.apache.cloudstack.storage.volume;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -5,113 +23,36 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTypeHelper;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper;
|
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.storage.Volume;
|
|
||||||
import com.cloud.utils.fsm.NoTransitionException;
|
|
||||||
import com.cloud.utils.fsm.StateMachine2;
|
|
||||||
|
|
||||||
public class VolumeEntityImpl implements VolumeEntity {
|
public class VolumeEntityImpl implements VolumeEntity {
|
||||||
private static final Logger s_logger = Logger.getLogger(VolumeEntityImpl.class);
|
private VolumeInfo volumeInfo;
|
||||||
protected VolumeVO volumeVO;
|
|
||||||
private StateMachine2<Volume.State, VolumeEvent, VolumeVO> _volStateMachine;
|
|
||||||
protected PrimaryDataStore dataStore;
|
|
||||||
@Inject
|
|
||||||
VolumeDiskTypeHelper diskTypeHelper;
|
|
||||||
@Inject
|
|
||||||
VolumeTypeHelper volumeTypeHelper;
|
|
||||||
@Inject
|
|
||||||
VolumeDao volumeDao;
|
|
||||||
|
|
||||||
public VolumeEntityImpl(PrimaryDataStore dataStore, VolumeVO volumeVO) {
|
public VolumeEntityImpl(VolumeInfo volumeObject) {
|
||||||
this.volumeVO = volumeVO;
|
this.volumeInfo = volumeObject;
|
||||||
this.dataStore = dataStore;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VolumeInfo getVolumeInfo() {
|
||||||
|
return volumeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolumeInfo(VolumeInfo vi) {
|
||||||
|
this.volumeInfo = vi;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
return volumeVO.getUuid();
|
return volumeInfo.getUuid();
|
||||||
}
|
|
||||||
|
|
||||||
public void setUuid(String uuid) {
|
|
||||||
volumeVO.setUuid(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPath() {
|
|
||||||
return volumeVO.getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTemplateUuid() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTemplatePath() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrimaryDataStoreInfo getDataStoreInfo() {
|
|
||||||
return dataStore.getDataStoreInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Volume.State getState() {
|
|
||||||
return volumeVO.getState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrimaryDataStore getDataStore() {
|
|
||||||
return dataStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSize() {
|
|
||||||
return volumeVO.getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public VolumeDiskType getDiskType() {
|
|
||||||
return diskTypeHelper.getDiskType(volumeVO.getDiskType());
|
|
||||||
}
|
|
||||||
|
|
||||||
public VolumeType getType() {
|
|
||||||
return volumeTypeHelper.getType(volumeVO.getVolumeType());
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getVolumeId() {
|
|
||||||
return volumeVO.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVolumeDiskType(VolumeDiskType type) {
|
|
||||||
volumeVO.setDiskType(type.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean stateTransit(VolumeEvent event) {
|
|
||||||
boolean result = false;
|
|
||||||
try {
|
|
||||||
result = _volStateMachine.transitTo(volumeVO, event, null, volumeDao);
|
|
||||||
} catch (NoTransitionException e) {
|
|
||||||
s_logger.debug("Failed to transit volume: " + this.getVolumeId() + ", due to: " + e.toString());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update() {
|
|
||||||
volumeDao.update(volumeVO.getId(), volumeVO);
|
|
||||||
volumeVO = volumeDao.findById(volumeVO.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getId() {
|
public long getId() {
|
||||||
// TODO Auto-generated method stub
|
return volumeInfo.getId();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -122,20 +63,17 @@ public class VolumeEntityImpl implements VolumeEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCurrentState() {
|
public String getCurrentState() {
|
||||||
// TODO Auto-generated method stub
|
return volumeInfo.getCurrentState().toString();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDesiredState() {
|
public String getDesiredState() {
|
||||||
// TODO Auto-generated method stub
|
return volumeInfo.getDesiredState().toString();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getCreatedTime() {
|
public Date getCreatedTime() {
|
||||||
// TODO Auto-generated method stub
|
return volumeInfo.getCreatedData();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -165,19 +103,19 @@ public class VolumeEntityImpl implements VolumeEntity {
|
|||||||
@Override
|
@Override
|
||||||
public void addDetail(String source, String name, String value) {
|
public void addDetail(String source, String name, String value) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delDetail(String source, String name, String value) {
|
public void delDetail(String source, String name, String value) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDetail(String source, String name, String value) {
|
public void updateDetail(String source, String name, String value) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -201,7 +139,7 @@ public class VolumeEntityImpl implements VolumeEntity {
|
|||||||
@Override
|
@Override
|
||||||
public void migrate(String reservationToken) {
|
public void migrate(String reservationToken) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -213,24 +151,67 @@ public class VolumeEntityImpl implements VolumeEntity {
|
|||||||
@Override
|
@Override
|
||||||
public void copy(VolumeEntity dest) {
|
public void copy(VolumeEntity dest) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attachTo(String vm, long deviceId) {
|
public void attachTo(String vm, long deviceId) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void detachFrom() {
|
public void detachFrom() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getSize() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplatePath() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplateUuid() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VolumeDiskType getDiskType() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VolumeType getType() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StorageEntity getDataStore() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPath(String path) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,77 +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.storage.volume;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
|
||||||
|
|
||||||
public class VolumeInfo {
|
|
||||||
private long size;
|
|
||||||
private String uuid;
|
|
||||||
private String path;
|
|
||||||
private PrimaryDataStoreInfo dataStoreInfo;
|
|
||||||
private String baseTemplateUuid;
|
|
||||||
private String baseTemplatePath;
|
|
||||||
private VolumeType type;
|
|
||||||
private VolumeDiskType diskType;
|
|
||||||
|
|
||||||
public VolumeInfo(VolumeEntity volume) {
|
|
||||||
this.size = volume.getSize();
|
|
||||||
this.uuid = volume.getUuid();
|
|
||||||
this.baseTemplatePath = volume.getTemplatePath();
|
|
||||||
this.baseTemplateUuid = volume.getTemplateUuid();
|
|
||||||
//this.dataStoreInfo = volume.getDataStoreInfo();
|
|
||||||
this.diskType = volume.getDiskType();
|
|
||||||
this.type = volume.getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSize() {
|
|
||||||
return this.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUuid() {
|
|
||||||
return this.uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPath() {
|
|
||||||
return this.path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrimaryDataStoreInfo getDataStore() {
|
|
||||||
return this.dataStoreInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTemplateUuid() {
|
|
||||||
return this.baseTemplateUuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTemplatePath() {
|
|
||||||
return this.baseTemplatePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VolumeType getType() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VolumeDiskType getDiskType() {
|
|
||||||
return this.diskType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,135 @@
|
|||||||
|
package org.apache.cloudstack.storage.volume;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTypeHelper;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper;
|
||||||
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
|
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
||||||
|
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
|
import com.cloud.storage.Volume.State;
|
||||||
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
import com.cloud.utils.fsm.NoTransitionException;
|
||||||
|
import com.cloud.utils.fsm.StateMachine2;
|
||||||
|
|
||||||
|
public class VolumeObject implements VolumeInfo {
|
||||||
|
private static final Logger s_logger = Logger.getLogger(VolumeObject.class);
|
||||||
|
protected VolumeVO volumeVO;
|
||||||
|
private StateMachine2<Volume.State, VolumeEvent, VolumeVO> _volStateMachine;
|
||||||
|
protected PrimaryDataStore dataStore;
|
||||||
|
@Inject
|
||||||
|
VolumeDiskTypeHelper diskTypeHelper;
|
||||||
|
@Inject
|
||||||
|
VolumeTypeHelper volumeTypeHelper;
|
||||||
|
@Inject
|
||||||
|
VolumeDao volumeDao;
|
||||||
|
|
||||||
|
public VolumeObject(PrimaryDataStore dataStore, VolumeVO volumeVO) {
|
||||||
|
this.volumeVO = volumeVO;
|
||||||
|
this.dataStore = dataStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUuid() {
|
||||||
|
return volumeVO.getUuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String uuid) {
|
||||||
|
volumeVO.setUuid(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return volumeVO.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemplateUuid() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemplatePath() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimaryDataStoreInfo getDataStoreInfo() {
|
||||||
|
return dataStore.getDataStoreInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Volume.State getState() {
|
||||||
|
return volumeVO.getState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimaryDataStore getDataStore() {
|
||||||
|
return dataStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSize() {
|
||||||
|
return volumeVO.getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VolumeDiskType getDiskType() {
|
||||||
|
return diskTypeHelper.getDiskType(volumeVO.getDiskType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public VolumeType getType() {
|
||||||
|
return volumeTypeHelper.getType(volumeVO.getVolumeType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getVolumeId() {
|
||||||
|
return volumeVO.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolumeDiskType(VolumeDiskType type) {
|
||||||
|
volumeVO.setDiskType(type.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean stateTransit(VolumeEvent event) {
|
||||||
|
boolean result = false;
|
||||||
|
try {
|
||||||
|
result = _volStateMachine.transitTo(volumeVO, event, null, volumeDao);
|
||||||
|
} catch (NoTransitionException e) {
|
||||||
|
String errorMessage = "Failed to transit volume: " + this.getVolumeId() + ", due to: " + e.toString();
|
||||||
|
s_logger.debug(errorMessage);
|
||||||
|
throw new CloudRuntimeException(errorMessage);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
volumeDao.update(volumeVO.getId(), volumeVO);
|
||||||
|
volumeVO = volumeDao.findById(volumeVO.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public State getCurrentState() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public State getDesiredState() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getCreatedData() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,15 +16,15 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
package org.apache.cloudstack.storage.volume;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
|
|
||||||
|
|
||||||
public interface VolumeService {
|
public interface VolumeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -37,7 +37,7 @@ public interface VolumeService {
|
|||||||
*
|
*
|
||||||
* @return the volume object
|
* @return the volume object
|
||||||
*/
|
*/
|
||||||
VolumeEntity createVolume(long volumeId, long dataStoreId, VolumeDiskType diskType);
|
VolumeInfo createVolume(VolumeInfo volume, long dataStoreId, VolumeDiskType diskType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete volume
|
* Delete volume
|
||||||
@ -66,4 +66,6 @@ public interface VolumeService {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
boolean rokeAccess(long volumeId, long endpointId);
|
boolean rokeAccess(long volumeId, long endpointId);
|
||||||
|
|
||||||
|
VolumeEntity getVolumeEntity(long volumeId);
|
||||||
}
|
}
|
||||||
@ -21,16 +21,22 @@ package org.apache.cloudstack.storage.volume;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
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.datastore.PrimaryDataStore;
|
||||||
import org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreManager;
|
import org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreManager;
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
||||||
|
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
|
//1. change volume state
|
||||||
|
//2. orchestrator of volume, control most of the information of volume, storage pool id, voluem state, scope etc.
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class VolumeServiceImpl implements VolumeService {
|
public class VolumeServiceImpl implements VolumeService {
|
||||||
@ -39,9 +45,27 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
@Inject
|
@Inject
|
||||||
PrimaryDataStoreManager dataStoreMgr;
|
PrimaryDataStoreManager dataStoreMgr;
|
||||||
@Override
|
@Override
|
||||||
public VolumeEntity createVolume(long volumeId, long dataStoreId, VolumeDiskType diskType) {
|
public VolumeInfo createVolume(VolumeInfo volume, long dataStoreId, VolumeDiskType diskType) {
|
||||||
PrimaryDataStore dataStore = dataStoreMgr.getPrimaryDataStore(dataStoreId);
|
PrimaryDataStore dataStore = dataStoreMgr.getPrimaryDataStore(dataStoreId);
|
||||||
return dataStore.createVolume(volumeId, diskType);
|
if (dataStore == null) {
|
||||||
|
throw new CloudRuntimeException("Can't find dataStoreId: " + dataStoreId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataStore.exists(volume)) {
|
||||||
|
return volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
VolumeObject vo = (VolumeObject)volume;
|
||||||
|
vo.stateTransit(VolumeEvent.CreateRequested);
|
||||||
|
|
||||||
|
try {
|
||||||
|
VolumeInfo vi = dataStore.createVolume(vo, diskType);
|
||||||
|
vo.stateTransit(VolumeEvent.OperationSucceeded);
|
||||||
|
return vi;
|
||||||
|
} catch (Exception e) {
|
||||||
|
vo.stateTransit(VolumeEvent.OperationFailed);
|
||||||
|
throw new CloudRuntimeException(e.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
@ -76,8 +100,22 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VolumeEntity allocateVolumeInDb(long size, VolumeType type, String volName, Long templateId) {
|
public VolumeEntity allocateVolumeInDb(long size, VolumeType type, String volName, Long templateId) {
|
||||||
volDao.allocVolume(size, type, volName, templateId);
|
VolumeVO vo = volDao.allocVolume(size, type, volName, templateId);
|
||||||
return null;
|
return new VolumeEntityImpl(new VolumeObject(null, vo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VolumeEntity getVolumeEntity(long volumeId) {
|
||||||
|
VolumeVO vo = volDao.findById(volumeId);
|
||||||
|
if (vo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vo.getPoolId() == null) {
|
||||||
|
return new VolumeEntityImpl(new VolumeObject(null, vo));
|
||||||
|
} else {
|
||||||
|
PrimaryDataStore dataStore = dataStoreMgr.getPrimaryDataStore(vo.getPoolId());
|
||||||
|
return new VolumeEntityImpl(dataStore.getVolume(volumeId));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import java.util.concurrent.Executors;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
|
||||||
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;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VMDK;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VMDK;
|
||||||
@ -36,13 +36,13 @@ 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.volume.VolumeMotionService;
|
||||||
|
import org.apache.cloudstack.storage.volume.VolumeService;
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user