mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-20 04:23:34 +01:00
add more new files
This commit is contained in:
parent
28982486e7
commit
83e2b7ad63
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.platform.subsystem.api.storage;
|
||||||
|
|
||||||
|
import com.cloud.utils.fsm.StateMachine;
|
||||||
|
|
||||||
|
public enum DataObjectBackupStorageOperationState {
|
||||||
|
Copying,
|
||||||
|
Deleting,
|
||||||
|
Ready,
|
||||||
|
NonOperational;
|
||||||
|
|
||||||
|
public enum Event {
|
||||||
|
Initial("Init state machine"),
|
||||||
|
CopyingRequested("Copy operation is requested"),
|
||||||
|
DeleteRequested("Delete operation is requested"),
|
||||||
|
OperationSuccess("Operation successed"),
|
||||||
|
OperationFailed("Operation failed");
|
||||||
|
|
||||||
|
private final String _msg;
|
||||||
|
|
||||||
|
private Event(String msg) {
|
||||||
|
_msg = msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataObjectBackupStorageOperationState getNextState(Event a) {
|
||||||
|
return s_fsm.getNextState(this, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static final StateMachine<DataObjectBackupStorageOperationState, Event> s_fsm = new StateMachine<DataObjectBackupStorageOperationState, Event>();
|
||||||
|
static {
|
||||||
|
s_fsm.addTransition(null, Event.Initial, DataObjectBackupStorageOperationState.Ready);
|
||||||
|
s_fsm.addTransition(DataObjectBackupStorageOperationState.Ready, Event.CopyingRequested, DataObjectBackupStorageOperationState.Copying);
|
||||||
|
s_fsm.addTransition(DataObjectBackupStorageOperationState.Copying, Event.CopyingRequested, DataObjectBackupStorageOperationState.Copying);
|
||||||
|
s_fsm.addTransition(DataObjectBackupStorageOperationState.Copying, Event.OperationFailed, DataObjectBackupStorageOperationState.Ready);
|
||||||
|
s_fsm.addTransition(DataObjectBackupStorageOperationState.Copying, Event.OperationSuccess, DataObjectBackupStorageOperationState.Ready);
|
||||||
|
s_fsm.addTransition(DataObjectBackupStorageOperationState.Ready, Event.DeleteRequested, DataObjectBackupStorageOperationState.Deleting);
|
||||||
|
s_fsm.addTransition(DataObjectBackupStorageOperationState.Deleting, Event.OperationFailed, DataObjectBackupStorageOperationState.Ready);
|
||||||
|
s_fsm.addTransition(DataObjectBackupStorageOperationState.Deleting, Event.OperationSuccess, DataObjectBackupStorageOperationState.NonOperational);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,6 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||||
|
|
||||||
|
import com.cloud.storage.Snapshot;
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
|
|
||||||
public interface DataStore {
|
public interface DataStore {
|
||||||
public class DataStoreRef {
|
public class DataStoreRef {
|
||||||
|
|
||||||
@ -53,4 +57,12 @@ public interface DataStore {
|
|||||||
SnapshotStrategy getSnapshotStrategy();
|
SnapshotStrategy getSnapshotStrategy();
|
||||||
BackupStrategy getBackupStrategy();
|
BackupStrategy getBackupStrategy();
|
||||||
DataStoreLifeCycle getLifeCycle();
|
DataStoreLifeCycle getLifeCycle();
|
||||||
|
|
||||||
|
VolumeProfile prepareVolume(Volume volume, DataStore destStore);
|
||||||
|
SnapshotProfile prepareSnapshot(Snapshot snapshot, DataStore destStore);
|
||||||
|
TemplateProfile prepareTemplate(VirtualMachineTemplate template, DataStore destStore);
|
||||||
|
boolean contains(Volume volume);
|
||||||
|
boolean contains(Snapshot snapshot);
|
||||||
|
boolean contains(VirtualMachineTemplate template);
|
||||||
|
TemplateProfile get(VirtualMachineTemplate template);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.platform.subsystem.api.storage;
|
||||||
|
|
||||||
|
public class SnapshotProfile {
|
||||||
|
private String _uri;
|
||||||
|
public String getURI() {
|
||||||
|
return _uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.platform.subsystem.api.storage;
|
||||||
|
|
||||||
|
public class TemplateProfile {
|
||||||
|
private String _uri;
|
||||||
|
public String getURI() {
|
||||||
|
return _uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.platform.subsystem.api.storage;
|
||||||
|
|
||||||
|
public class VolumeProfile {
|
||||||
|
private String _uri;
|
||||||
|
public String getURI() {
|
||||||
|
return _uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,16 @@
|
|||||||
package org.apache.cloudstack.platform.subsystem.api.storage;
|
package org.apache.cloudstack.platform.subsystem.api.storage;
|
||||||
|
|
||||||
|
|
||||||
import com.cloud.storage.Volume;
|
import com.cloud.storage.Volume;
|
||||||
|
|
||||||
public interface VolumeStrategy {
|
public interface VolumeStrategy {
|
||||||
Volume createVolume(Volume vol);
|
Volume createVolume(Volume vol);
|
||||||
Volume createVolume(Volume vol, DataStore store);
|
Volume createDataVolume(Volume vol, DataStore store);
|
||||||
Volume copyVolume(Volume srcVol, Volume destVol);
|
Volume copyVolumeFromBackup(VolumeProfile srcVol, Volume destVol, DataStore destStore);
|
||||||
Volume createVolumeFromSnapshot(Volume vol, Snapshot snapshot);
|
Volume createVolumeFromSnapshot(SnapshotProfile snapshot, Volume vol, DataStore destStore);
|
||||||
Volume createVolumeFromTemplate(Volume vol, Template template);
|
Volume createVolumeFromTemplate(TemplateProfile template, Volume vol, DataStore destStore);
|
||||||
Volume migrateVolume(Volume srcVol, DataStore srcStore, Volume destVol, DataStore destStore);
|
Volume migrateVolume(Volume srcVol, DataStore srcStore, Volume destVol, DataStore destStore);
|
||||||
|
TemplateProfile createBaseVolume(TemplateProfile tp, DataStore destStore);
|
||||||
|
Volume createVolumeFromBaseTemplate(TemplateProfile tp, DataStore destStore);
|
||||||
boolean deleteVolume(Volume vol);
|
boolean deleteVolume(Volume vol);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,25 +18,35 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage;
|
package org.apache.cloudstack.storage;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.DataObjectBackupStorageOperationState;
|
||||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
||||||
import org.apache.cloudstack.platform.subsystem.api.storage.StorageProvider;
|
import org.apache.cloudstack.platform.subsystem.api.storage.StorageProvider;
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile;
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeProfile;
|
||||||
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeStrategy;
|
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeStrategy;
|
||||||
|
import org.apache.cloudstack.storage.db.VolumeHostVO;
|
||||||
|
import org.apache.cloudstack.storage.manager.BackupStorageManager;
|
||||||
|
import org.apache.cloudstack.storage.manager.ImageManager;
|
||||||
|
import org.apache.cloudstack.storage.manager.SecondaryStorageManager;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeManager;
|
import org.apache.cloudstack.storage.volume.VolumeManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
import com.cloud.offering.DiskOffering;
|
import com.cloud.offering.DiskOffering;
|
||||||
import com.cloud.storage.DiskOfferingVO;
|
import com.cloud.storage.DiskOfferingVO;
|
||||||
import com.cloud.storage.StoragePool;
|
import com.cloud.storage.StoragePool;
|
||||||
import com.cloud.storage.Volume;
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.storage.VolumeHostVO;
|
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
import com.cloud.storage.dao.DiskOfferingDao;
|
import com.cloud.storage.dao.DiskOfferingDao;
|
||||||
import com.cloud.storage.dao.StoragePoolDao;
|
import com.cloud.storage.dao.StoragePoolDao;
|
||||||
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import com.cloud.storage.dao.VolumeDao;
|
import com.cloud.storage.dao.VolumeDao;
|
||||||
import com.cloud.storage.dao.VolumeHostDao;
|
import com.cloud.storage.dao.VolumeHostDao;
|
||||||
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
import com.cloud.utils.component.Inject;
|
import com.cloud.utils.component.Inject;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
@ -63,21 +73,43 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
StorageProviderManager _storageProviderMgr;
|
StorageProviderManager _storageProviderMgr;
|
||||||
@Inject
|
@Inject
|
||||||
VolumeManager _volumeMgr;
|
VolumeManager _volumeMgr;
|
||||||
|
@Inject
|
||||||
|
SecondaryStorageManager _secondaryStorageMgr;
|
||||||
|
@Inject
|
||||||
|
ImageManager _imageMgr;
|
||||||
|
@Inject
|
||||||
|
VMTemplateDao _templateDao;
|
||||||
|
|
||||||
protected Volume copyVolumeFromBackupStorage(VolumeVO volume, DataStore destStore, String reservationId) {
|
@DB
|
||||||
StorageProvider sp = _storageProviderMgr.getBackupStorageProvider(volume.getDataCenterId());
|
protected Volume copyVolumeFromBackupStorage(VolumeVO volume, DataStore destStore, String reservationId) throws NoTransitionException {
|
||||||
|
DataStore ds = _secondaryStorageMgr.getBackupDataStore(volume);
|
||||||
|
if (!ds.contains(volume)) {
|
||||||
|
throw new CloudRuntimeException("volume: " + volume + "doesn't exist on backup storage");
|
||||||
|
}
|
||||||
|
|
||||||
VolumeHostVO volumeHostVO = _volumeHostDao.findByVolumeId(volume.getId());
|
VolumeProfile vp = ds.prepareVolume(volume, destStore);
|
||||||
long poolId = volumeHostVO.getHostId();
|
|
||||||
DataStore srcStore = _storageProviderMgr.getDataStore(poolId);
|
|
||||||
|
|
||||||
|
VolumeStrategy vs = destStore.getVolumeStrategy();
|
||||||
|
|
||||||
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
volume.setReservationId(reservationId);
|
||||||
|
_volumeMgr.processEvent(volume, Volume.Event.CopyRequested);
|
||||||
|
VolumeVO destVolume = _volumeMgr.allocateDuplicateVolume(volume);
|
||||||
|
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.CreateRequested);
|
||||||
|
txn.commit();
|
||||||
|
|
||||||
|
vs.copyVolumeFromBackup(vp, destVolume, destStore);
|
||||||
|
|
||||||
|
txn.start();
|
||||||
|
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
|
||||||
|
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.OperationSucceeded);
|
||||||
|
txn.commit();
|
||||||
|
|
||||||
|
return destVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DB
|
||||||
protected Volume migrateVolume(VolumeVO volume, DataStore srcStore, DataStore destStore, String reservationId) throws NoTransitionException {
|
protected Volume migrateVolume(VolumeVO volume, DataStore srcStore, DataStore destStore, String reservationId) throws NoTransitionException {
|
||||||
VolumeStrategy vs = srcStore.getVolumeStrategy();
|
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
volume.setReservationId(reservationId);
|
volume.setReservationId(reservationId);
|
||||||
@ -86,16 +118,74 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.CreateRequested);
|
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.CreateRequested);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
|
VolumeStrategy vs = srcStore.getVolumeStrategy();
|
||||||
vs.migrateVolume(volume, srcStore, destVolume, destStore);
|
vs.migrateVolume(volume, srcStore, destVolume, destStore);
|
||||||
|
|
||||||
txn.start();
|
txn.start();
|
||||||
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
|
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
|
||||||
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.OperationSucceeded);
|
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.OperationSucceeded);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
_volumeDao.remove(volume.getId());
|
|
||||||
|
volume = _volumeMgr.processEvent(volume, Volume.Event.DestroyRequested);
|
||||||
|
|
||||||
|
vs.deleteVolume(volume);
|
||||||
|
|
||||||
|
_volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
|
||||||
return destVolume;
|
return destVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DB
|
||||||
|
protected Volume recreateVolume(VolumeVO srcVolume, DataStore destStore, String reservationId) throws NoTransitionException {
|
||||||
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
txn.start();
|
||||||
|
srcVolume.setReservationId(reservationId);
|
||||||
|
srcVolume = _volumeMgr.processEvent(srcVolume, Volume.Event.CopyRequested);
|
||||||
|
Volume destVolume = _volumeMgr.allocateDuplicateVolume(srcVolume);
|
||||||
|
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.CreateRequested);
|
||||||
|
txn.commit();
|
||||||
|
|
||||||
|
DataStore srcStore = _storageProviderMgr.getDataStore(srcVolume.getPoolId());
|
||||||
|
VolumeStrategy vs = srcStore.getVolumeStrategy();
|
||||||
|
|
||||||
|
vs.migrateVolume(srcVolume, srcStore, destVolume, destStore);
|
||||||
|
|
||||||
|
txn.start();
|
||||||
|
srcVolume = _volumeMgr.processEvent(srcVolume, Volume.Event.OperationSucceeded);
|
||||||
|
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.OperationSucceeded);
|
||||||
|
txn.commit();
|
||||||
|
|
||||||
|
srcVolume = _volumeMgr.processEvent(srcVolume, Volume.Event.DestroyRequested);
|
||||||
|
|
||||||
|
vs.deleteVolume(srcVolume);
|
||||||
|
|
||||||
|
_volumeMgr.processEvent(srcVolume, Volume.Event.OperationSucceeded);
|
||||||
|
|
||||||
|
return destVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Volume createVolumeOnStorage(Volume volume, DataStore destStore, String reservationId) throws NoTransitionException {
|
||||||
|
VolumeStrategy vs = destStore.getVolumeStrategy();
|
||||||
|
volume.setReservationId(reservationId);
|
||||||
|
volume = _volumeMgr.processEvent(volume, Volume.Event.CreateRequested);
|
||||||
|
|
||||||
|
if (volume.getTemplateId() != null) {
|
||||||
|
VirtualMachineTemplate template = _templateDao.findById(volume.getTemplateId());
|
||||||
|
DataStore ds = _secondaryStorageMgr.getBackupDataStore(template);
|
||||||
|
TemplateProfile tp = ds.prepareTemplate(template, destStore);
|
||||||
|
if (!destStore.contains(template)) {
|
||||||
|
tp = vs.createBaseVolume(tp, destStore);
|
||||||
|
} else {
|
||||||
|
tp = destStore.get(template);
|
||||||
|
}
|
||||||
|
volume = vs.createVolumeFromBaseTemplate(tp, destStore);
|
||||||
|
} else {
|
||||||
|
volume = vs.createDataVolume(volume, destStore);
|
||||||
|
}
|
||||||
|
|
||||||
|
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
|
||||||
|
return volume;
|
||||||
|
}
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
protected void prepareVolumes(List<VolumeVO> vols, Long destPoolId, String reservationId) throws NoTransitionException {
|
protected void prepareVolumes(List<VolumeVO> vols, Long destPoolId, String reservationId) throws NoTransitionException {
|
||||||
DataStore destStore = null;
|
DataStore destStore = null;
|
||||||
@ -126,36 +216,35 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Mismatch in storage pool " + destStore.getId() + " assigned by deploymentPlanner and the one associated with volume " + volume);
|
s_logger.debug("Mismatch in storage pool " + destStore.getId() + " assigned by deploymentPlanner and the one associated with volume " + volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Volume.Type.ROOT == volume.getVolumeType()) {
|
if (volume.isRecreatable()) {
|
||||||
needToMigrateVolume = true;
|
needToRecreateVolume = true;
|
||||||
} else {
|
} else {
|
||||||
if (destStore.getCluterId() != srcStore.getCluterId()) {
|
if (Volume.Type.ROOT == volume.getVolumeType()) {
|
||||||
needToMigrateVolume = true;
|
|
||||||
} else if (!srcStore.isSharedStorage() && srcStore.getId() != destStore.getId()) {
|
|
||||||
needToMigrateVolume = true;
|
needToMigrateVolume = true;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
if (destStore.getCluterId() != srcStore.getCluterId()) {
|
||||||
}
|
needToMigrateVolume = true;
|
||||||
}
|
} else if (!srcStore.isSharedStorage() && srcStore.getId() != destStore.getId()) {
|
||||||
|
needToMigrateVolume = true;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
VolumeStrategy vs = srcStore.getVolumeStrategy();
|
|
||||||
if (needToCreateVolume) {
|
if (needToCreateVolume) {
|
||||||
volume.setReservationId(reservationId);
|
createVolumeOnStorage(volume, destStore, reservationId);
|
||||||
volume = _volumeMgr.processEvent(volume, Volume.Event.CreateRequested);
|
|
||||||
|
|
||||||
vs.createVolume(volume, destStore);
|
|
||||||
|
|
||||||
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
|
|
||||||
} else if (needToMigrateVolume) {
|
} else if (needToMigrateVolume) {
|
||||||
migrateVolume(volume, srcStore, destStore, reservationId);
|
migrateVolume(volume, srcStore, destStore, reservationId);
|
||||||
} else if (needToCopyFromSec) {
|
} else if (needToCopyFromSec) {
|
||||||
_volumeMgr.processEvent(volume, Volume.Event.CopyRequested);
|
copyVolumeFromBackupStorage(volume, destStore, reservationId);
|
||||||
} else if (needToRecreateVolume) {
|
} else if (needToRecreateVolume) {
|
||||||
|
recreateVolume(volume, destStore, reservationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,8 +257,12 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
prepareVolumes(vols, plan.getPoolId(), reservationId);
|
||||||
|
} catch (NoTransitionException e) {
|
||||||
|
s_logger.debug("Failed to prepare volume: " + e.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -188,9 +281,36 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepareAttachDiskToVM(long disk, long vm, String reservationId) {
|
public void prepareAttachDiskToVM(long diskId, long vmId, String reservationId) {
|
||||||
// TODO Auto-generated method stub
|
VirtualMachine vm = _vmDao.findById(vmId);
|
||||||
|
|
||||||
|
if (vm == null || vm.getState() != VirtualMachine.State.Running) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VolumeVO volume = _volumeDao.findById(diskId);
|
||||||
|
if (volume.getInstanceId() != null) {
|
||||||
|
if (volume.getInstanceId() != vmId) {
|
||||||
|
throw new InvalidParameterValueException("Volume " + volume + "already attached to " + volume.getInstanceId());
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<VolumeVO> vols = new ArrayList<VolumeVO>();
|
||||||
|
vols.add(volume);
|
||||||
|
|
||||||
|
List<VolumeVO> rootDisks = _volumeDao.findByInstanceAndType(vmId, Volume.Type.ROOT);
|
||||||
|
VolumeVO rootDisk = rootDisks.get(0);
|
||||||
|
try {
|
||||||
|
prepareVolumes(vols, rootDisk.getPoolId(), reservationId);
|
||||||
|
} catch (NoTransitionException e) {
|
||||||
|
s_logger.debug("Failed to prepare volume: " + volume + ", due to" + e.toString());
|
||||||
|
throw new CloudRuntimeException(e.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
volume = _volumeDao.findById(diskId);
|
||||||
|
volume.setInstanceId(vmId);
|
||||||
|
_volumeDao.update(volume.getId(), volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.DataObjectBackupStorageOperationState;
|
||||||
|
|
||||||
|
import com.cloud.storage.Storage;
|
||||||
|
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||||
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
|
|
||||||
|
public interface VolumeBackupRef {
|
||||||
|
public DataObjectBackupStorageOperationState getOperationState();
|
||||||
|
|
||||||
|
public String getInstallPath();
|
||||||
|
|
||||||
|
public long getHostId();
|
||||||
|
|
||||||
|
public long getVolumeId();
|
||||||
|
|
||||||
|
public long getZoneId();
|
||||||
|
|
||||||
|
public int getDownloadPercent();
|
||||||
|
|
||||||
|
public long getVolumeSize();
|
||||||
|
|
||||||
|
public Storage.ImageFormat getFormat();
|
||||||
|
|
||||||
|
public String getDownloadUrl();
|
||||||
|
|
||||||
|
public boolean getDestroyed();
|
||||||
|
|
||||||
|
public long getPhysicalSize();
|
||||||
|
|
||||||
|
public long getSize();
|
||||||
|
|
||||||
|
public String getLocalDownloadPath();
|
||||||
|
|
||||||
|
public String getChecksum();
|
||||||
|
|
||||||
|
public Status getDownloadState();
|
||||||
|
|
||||||
|
public Date getLastUpdated();
|
||||||
|
|
||||||
|
public Date getCreated();
|
||||||
|
|
||||||
|
public long getId();
|
||||||
|
}
|
||||||
328
platform/storage/src/org/apache/cloudstack/storage/db/VolumeHostVO.java
Executable file
328
platform/storage/src/org/apache/cloudstack/storage/db/VolumeHostVO.java
Executable file
@ -0,0 +1,328 @@
|
|||||||
|
// 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.db;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.DataObjectBackupStorageOperationState;
|
||||||
|
import org.apache.cloudstack.storage.VolumeBackupRef;
|
||||||
|
|
||||||
|
//import com.cloud.storage.VMVolumeStorageResourceAssoc.Status;
|
||||||
|
import com.cloud.storage.Storage;
|
||||||
|
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||||
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join table for storage hosts and volumes
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name="volume_host_ref")
|
||||||
|
public class VolumeHostVO implements VolumeBackupRef {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
Long id;
|
||||||
|
|
||||||
|
@Column(name="host_id")
|
||||||
|
private long hostId;
|
||||||
|
|
||||||
|
@Column(name="volume_id")
|
||||||
|
private long volumeId;
|
||||||
|
|
||||||
|
@Column(name="zone_id")
|
||||||
|
private long zoneId;
|
||||||
|
|
||||||
|
@Column(name=GenericDaoBase.CREATED_COLUMN)
|
||||||
|
private Date created = null;
|
||||||
|
|
||||||
|
@Column(name="last_updated")
|
||||||
|
@Temporal(value=TemporalType.TIMESTAMP)
|
||||||
|
private Date lastUpdated = null;
|
||||||
|
|
||||||
|
@Column (name="download_pct")
|
||||||
|
private int downloadPercent;
|
||||||
|
|
||||||
|
@Column (name="size")
|
||||||
|
private long size;
|
||||||
|
|
||||||
|
@Column (name="physical_size")
|
||||||
|
private long physicalSize;
|
||||||
|
|
||||||
|
@Column (name="download_state")
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private Status downloadState;
|
||||||
|
|
||||||
|
@Column (name="opt_state")
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private DataObjectBackupStorageOperationState optState;
|
||||||
|
|
||||||
|
@Column(name="checksum")
|
||||||
|
private String checksum;
|
||||||
|
|
||||||
|
@Column (name="local_path")
|
||||||
|
private String localDownloadPath;
|
||||||
|
|
||||||
|
@Column (name="error_str")
|
||||||
|
private String errorString;
|
||||||
|
|
||||||
|
@Column (name="job_id")
|
||||||
|
private String jobId;
|
||||||
|
|
||||||
|
@Column (name="install_path")
|
||||||
|
private String installPath;
|
||||||
|
|
||||||
|
@Column (name="url")
|
||||||
|
private String downloadUrl;
|
||||||
|
|
||||||
|
@Column(name="format")
|
||||||
|
private Storage.ImageFormat format;
|
||||||
|
|
||||||
|
@Column(name="destroyed")
|
||||||
|
boolean destroyed = false;
|
||||||
|
|
||||||
|
|
||||||
|
public String getInstallPath() {
|
||||||
|
return installPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getHostId() {
|
||||||
|
return hostId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHostId(long hostId) {
|
||||||
|
this.hostId = hostId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long getVolumeId() {
|
||||||
|
return volumeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setVolumeId(long volumeId) {
|
||||||
|
this.volumeId = volumeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long getZoneId() {
|
||||||
|
return zoneId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZoneId(long zoneId) {
|
||||||
|
this.zoneId = zoneId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDownloadPercent() {
|
||||||
|
return downloadPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setDownloadPercent(int downloadPercent) {
|
||||||
|
this.downloadPercent = downloadPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setDownloadState(Status downloadState) {
|
||||||
|
this.downloadState = downloadState;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Date getCreated() {
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastUpdated() {
|
||||||
|
return lastUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setLastUpdated(Date date) {
|
||||||
|
lastUpdated = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setInstallPath(String installPath) {
|
||||||
|
this.installPath = installPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Status getDownloadState() {
|
||||||
|
return downloadState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChecksum() {
|
||||||
|
return checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChecksum(String checksum) {
|
||||||
|
this.checksum = checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VolumeHostVO(long hostId, long volumeId) {
|
||||||
|
super();
|
||||||
|
this.hostId = hostId;
|
||||||
|
this.volumeId = volumeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VolumeHostVO(long hostId, long volumeId, long zoneId, Date lastUpdated,
|
||||||
|
int downloadPercent, Status downloadState,
|
||||||
|
String localDownloadPath, String errorString, String jobId,
|
||||||
|
String installPath, String downloadUrl, String checksum, ImageFormat format) {
|
||||||
|
//super();
|
||||||
|
this.hostId = hostId;
|
||||||
|
this.volumeId = volumeId;
|
||||||
|
this.zoneId = zoneId;
|
||||||
|
this.lastUpdated = lastUpdated;
|
||||||
|
this.downloadPercent = downloadPercent;
|
||||||
|
this.downloadState = downloadState;
|
||||||
|
this.localDownloadPath = localDownloadPath;
|
||||||
|
this.errorString = errorString;
|
||||||
|
this.jobId = jobId;
|
||||||
|
this.installPath = installPath;
|
||||||
|
this.setDownloadUrl(downloadUrl);
|
||||||
|
this.checksum = checksum;
|
||||||
|
this.format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected VolumeHostVO() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setLocalDownloadPath(String localPath) {
|
||||||
|
this.localDownloadPath = localPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalDownloadPath() {
|
||||||
|
return localDownloadPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setErrorString(String errorString) {
|
||||||
|
this.errorString = errorString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getErrorString() {
|
||||||
|
return errorString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setJobId(String jobId) {
|
||||||
|
this.jobId = jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getJobId() {
|
||||||
|
return jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj instanceof VolumeHostVO) {
|
||||||
|
VolumeBackupRef other = (VolumeBackupRef)obj;
|
||||||
|
return (this.volumeId==other.getVolumeId() && this.hostId==other.getHostId());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
Long tid = new Long(volumeId);
|
||||||
|
Long hid = new Long(hostId);
|
||||||
|
return tid.hashCode()+hid.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(long size) {
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setPhysicalSize(long physicalSize) {
|
||||||
|
this.physicalSize = physicalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long getPhysicalSize() {
|
||||||
|
return physicalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDestroyed(boolean destroyed) {
|
||||||
|
this.destroyed = destroyed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean getDestroyed() {
|
||||||
|
return destroyed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDownloadUrl(String downloadUrl) {
|
||||||
|
this.downloadUrl = downloadUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getDownloadUrl() {
|
||||||
|
return downloadUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Storage.ImageFormat getFormat() {
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFormat(Storage.ImageFormat format) {
|
||||||
|
this.format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return new StringBuilder("VolumeHost[").append(id).append("-").append(volumeId).append("-").append(hostId).append(installPath).append("]").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataObjectBackupStorageOperationState getOperationState() {
|
||||||
|
return optState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getVolumeSize() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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.manager;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.DataObjectBackupStorageOperationState;
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
||||||
|
|
||||||
|
import com.cloud.storage.Snapshot;
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
|
import com.cloud.utils.fsm.NoTransitionException;
|
||||||
|
|
||||||
|
public interface BackupStorageManager {
|
||||||
|
boolean contains(Volume vol);
|
||||||
|
boolean contains(Snapshot snapshot);
|
||||||
|
boolean contains(VirtualMachineTemplate template);
|
||||||
|
|
||||||
|
DataStore getBackupDataStore(Volume vol);
|
||||||
|
DataStore getBackupDataStore(Snapshot snapshot);
|
||||||
|
DataStore getBackupDataStore(VirtualMachineTemplate template);
|
||||||
|
|
||||||
|
boolean updateOperationState(Volume vol, DataObjectBackupStorageOperationState.Event event) throws NoTransitionException;
|
||||||
|
}
|
||||||
@ -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.manager;
|
||||||
|
|
||||||
|
public class BackupStorageManagerImpl implements BackupStorageManager {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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.manager;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.SnapshotProfile;
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile;
|
||||||
|
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeProfile;
|
||||||
|
|
||||||
|
import com.cloud.storage.Snapshot;
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
|
|
||||||
|
public interface ImageManager {
|
||||||
|
VolumeProfile prepareVolume(Volume volume, DataStore destStore);
|
||||||
|
SnapshotProfile prepareSnapshot(Snapshot snapshot, DataStore destStore);
|
||||||
|
TemplateProfile prepareTemplate(VirtualMachineTemplate template, DataStore destStore);
|
||||||
|
}
|
||||||
@ -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.manager;
|
||||||
|
|
||||||
|
public class ImageManagerImpl implements ImageManager {
|
||||||
|
|
||||||
|
}
|
||||||
@ -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.manager;
|
||||||
|
|
||||||
|
public interface SecondaryStorageManager {
|
||||||
|
|
||||||
|
}
|
||||||
@ -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.manager;
|
||||||
|
|
||||||
|
public class SecondaryStorageManagerImpl implements SecondaryStorageManager {
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,11 +1,13 @@
|
|||||||
package org.apache.cloudstack.storage.strategy;
|
package org.apache.cloudstack.storage.strategy;
|
||||||
|
|
||||||
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
|
||||||
import org.apache.cloudstack.platform.subsystem.api.storage.Snapshot;
|
import org.apache.cloudstack.platform.subsystem.api.storage.SnapshotProfile;
|
||||||
import org.apache.cloudstack.platform.subsystem.api.storage.Template;
|
import org.apache.cloudstack.platform.subsystem.api.storage.TemplateProfile;
|
||||||
import org.apache.cloudstack.platform.subsystem.api.storage.Volume;
|
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeProfile;
|
||||||
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeStrategy;
|
import org.apache.cloudstack.platform.subsystem.api.storage.VolumeStrategy;
|
||||||
|
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
|
|
||||||
public class DefaultVolumeStrategy implements VolumeStrategy {
|
public class DefaultVolumeStrategy implements VolumeStrategy {
|
||||||
protected DataStore _ds;
|
protected DataStore _ds;
|
||||||
public DefaultVolumeStrategy(DataStore ds) {
|
public DefaultVolumeStrategy(DataStore ds) {
|
||||||
@ -16,30 +18,39 @@ public class DefaultVolumeStrategy implements VolumeStrategy {
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public Volume createDataVolume(Volume vol, DataStore store) {
|
||||||
public Volume copyVolume(Volume srcVol, Volume destVol) {
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public Volume copyVolumeFromBackup(VolumeProfile srcVol, Volume destVol, DataStore destStore) {
|
||||||
public Volume createVolumeFromSnapshot(Volume vol, Snapshot snapshot) {
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public Volume createVolumeFromSnapshot(SnapshotProfile snapshot, Volume vol, DataStore destStore) {
|
||||||
public Volume createVolumeFromTemplate(Volume vol, Template template) {
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public Volume createVolumeFromTemplate(TemplateProfile template, Volume vol, DataStore destStore) {
|
||||||
public Volume migrateVolume(Volume srcVol, Volume destVol) {
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public Volume migrateVolume(Volume srcVol, DataStore srcStore, Volume destVol, DataStore destStore) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public TemplateProfile createBaseVolume(TemplateProfile tp, DataStore destStore) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public Volume createVolumeFromBaseTemplate(TemplateProfile tp, DataStore destStore) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteVolume(Volume vol) {
|
public boolean deleteVolume(Volume vol) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user