add more new files

This commit is contained in:
Edison Su 2012-08-30 19:00:27 -07:00
parent 28982486e7
commit 83e2b7ad63
16 changed files with 888 additions and 47 deletions

View File

@ -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);
}
}

View File

@ -18,6 +18,10 @@
*/
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 class DataStoreRef {
@ -53,4 +57,12 @@ public interface DataStore {
SnapshotStrategy getSnapshotStrategy();
BackupStrategy getBackupStrategy();
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);
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -1,13 +1,16 @@
package org.apache.cloudstack.platform.subsystem.api.storage;
import com.cloud.storage.Volume;
public interface VolumeStrategy {
Volume createVolume(Volume vol);
Volume createVolume(Volume vol, DataStore store);
Volume copyVolume(Volume srcVol, Volume destVol);
Volume createVolumeFromSnapshot(Volume vol, Snapshot snapshot);
Volume createVolumeFromTemplate(Volume vol, Template template);
Volume createDataVolume(Volume vol, DataStore store);
Volume copyVolumeFromBackup(VolumeProfile srcVol, Volume destVol, DataStore destStore);
Volume createVolumeFromSnapshot(SnapshotProfile snapshot, Volume vol, DataStore destStore);
Volume createVolumeFromTemplate(TemplateProfile template, Volume vol, 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);
}

View File

@ -18,25 +18,35 @@
*/
package org.apache.cloudstack.storage;
import java.util.ArrayList;
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.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.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.log4j.Logger;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.offering.DiskOffering;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.StoragePool;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeHostVO;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.storage.dao.StoragePoolDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.dao.VolumeHostDao;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.utils.component.Inject;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
@ -63,21 +73,43 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
StorageProviderManager _storageProviderMgr;
@Inject
VolumeManager _volumeMgr;
@Inject
SecondaryStorageManager _secondaryStorageMgr;
@Inject
ImageManager _imageMgr;
@Inject
VMTemplateDao _templateDao;
protected Volume copyVolumeFromBackupStorage(VolumeVO volume, DataStore destStore, String reservationId) {
StorageProvider sp = _storageProviderMgr.getBackupStorageProvider(volume.getDataCenterId());
@DB
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());
long poolId = volumeHostVO.getHostId();
DataStore srcStore = _storageProviderMgr.getDataStore(poolId);
VolumeProfile vp = ds.prepareVolume(volume, destStore);
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 {
VolumeStrategy vs = srcStore.getVolumeStrategy();
Transaction txn = Transaction.currentTxn();
txn.start();
volume.setReservationId(reservationId);
@ -86,16 +118,74 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.CreateRequested);
txn.commit();
VolumeStrategy vs = srcStore.getVolumeStrategy();
vs.migrateVolume(volume, srcStore, destVolume, destStore);
txn.start();
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.OperationSucceeded);
txn.commit();
_volumeDao.remove(volume.getId());
volume = _volumeMgr.processEvent(volume, Volume.Event.DestroyRequested);
vs.deleteVolume(volume);
_volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
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
protected void prepareVolumes(List<VolumeVO> vols, Long destPoolId, String reservationId) throws NoTransitionException {
DataStore destStore = null;
@ -126,36 +216,35 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
if (s_logger.isDebugEnabled()) {
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()) {
needToMigrateVolume = true;
if (volume.isRecreatable()) {
needToRecreateVolume = true;
} else {
if (destStore.getCluterId() != srcStore.getCluterId()) {
needToMigrateVolume = true;
} else if (!srcStore.isSharedStorage() && srcStore.getId() != destStore.getId()) {
if (Volume.Type.ROOT == volume.getVolumeType()) {
needToMigrateVolume = true;
} else {
continue;
}
}
if (destStore.getCluterId() != srcStore.getCluterId()) {
needToMigrateVolume = true;
} else if (!srcStore.isSharedStorage() && srcStore.getId() != destStore.getId()) {
needToMigrateVolume = true;
} else {
continue;
}
}
}
} else {
continue;
}
VolumeStrategy vs = srcStore.getVolumeStrategy();
if (needToCreateVolume) {
volume.setReservationId(reservationId);
volume = _volumeMgr.processEvent(volume, Volume.Event.CreateRequested);
vs.createVolume(volume, destStore);
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
createVolumeOnStorage(volume, destStore, reservationId);
} else if (needToMigrateVolume) {
migrateVolume(volume, srcStore, destStore, reservationId);
} else if (needToCopyFromSec) {
_volumeMgr.processEvent(volume, Volume.Event.CopyRequested);
copyVolumeFromBackupStorage(volume, destStore, reservationId);
} else if (needToRecreateVolume) {
recreateVolume(volume, destStore, reservationId);
}
}
}
@ -168,8 +257,12 @@ public class StorageOrchestratorImpl implements StorageOrchestrator {
if (s_logger.isDebugEnabled()) {
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) {
// TODO Auto-generated method stub
public void prepareAttachDiskToVM(long diskId, long vmId, String reservationId) {
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);
}
}

View File

@ -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();
}

View 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;
}
}

View File

@ -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;
}

View File

@ -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 {
}

View File

@ -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);
}

View File

@ -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 {
}

View File

@ -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 {
}

View File

@ -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 {
}

View File

@ -1,11 +1,13 @@
package org.apache.cloudstack.storage.strategy;
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.Template;
import org.apache.cloudstack.platform.subsystem.api.storage.Volume;
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 org.apache.cloudstack.platform.subsystem.api.storage.VolumeStrategy;
import com.cloud.storage.Volume;
public class DefaultVolumeStrategy implements VolumeStrategy {
protected DataStore _ds;
public DefaultVolumeStrategy(DataStore ds) {
@ -16,30 +18,39 @@ public class DefaultVolumeStrategy implements VolumeStrategy {
// TODO Auto-generated method stub
return null;
}
public Volume copyVolume(Volume srcVol, Volume destVol) {
public Volume createDataVolume(Volume vol, DataStore store) {
// TODO Auto-generated method stub
return null;
}
public Volume createVolumeFromSnapshot(Volume vol, Snapshot snapshot) {
public Volume copyVolumeFromBackup(VolumeProfile srcVol, Volume destVol, DataStore destStore) {
// TODO Auto-generated method stub
return null;
}
public Volume createVolumeFromTemplate(Volume vol, Template template) {
public Volume createVolumeFromSnapshot(SnapshotProfile snapshot, Volume vol, DataStore destStore) {
// TODO Auto-generated method stub
return null;
}
public Volume migrateVolume(Volume srcVol, Volume destVol) {
public Volume createVolumeFromTemplate(TemplateProfile template, Volume vol, DataStore destStore) {
// 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
return null;
}
public boolean deleteVolume(Volume vol) {
// TODO Auto-generated method stub
return false;
}
}