remove unused code

This commit is contained in:
Edison Su 2012-11-26 18:45:49 -08:00
parent 5724f1ca96
commit 487a0ac43d
48 changed files with 214 additions and 3060 deletions

View File

@ -1,5 +0,0 @@
package org.apache.cloudstack.engine.subsystem.api.storage;
public interface BackupStrategy {
}

View File

@ -1,42 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.engine.subsystem.api.storage;
import java.util.List;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.DataStoreRef;
/*
* Logic entity
*/
public interface DataObject {
String getURI();
String getUUID();
DataStoreRef getStoreRef();
long getSize();
//volume/snapshot/template
String getType();
//db id
Long getId();
DataObject getParent();
void setParent(DataObject obj);
List<DataObject> getChidren();
boolean lock();
boolean unlock();
}

View File

@ -1,58 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.engine.subsystem.api.storage;
import 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

@ -1,76 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.storage.Snapshot;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Volume;
import com.cloud.template.VirtualMachineTemplate;
public interface DataStore {
public class DataStoreRef {
}
public class DataStoreDriverRef {
}
public enum StoreType {
Primary,
Image,
Backup;
}
public class StoreScope {
public long zoneId;
private long clusterId;
private long hostId;
}
String getURI();
String getUUID();
long getCluterId();
long getPodId();
long getZoneId();
String getPath();
StoreType getType();
StoragePoolType getPoolType();
StoreScope getScope();
boolean isSharedStorage();
Long getId();
DataStoreDriver getDataStoreDriver();
StorageProvider getProvider();
DataStoreEndPointSelector getEndPointSelector();
FileSystem getFileSystem();
VolumeStrategy getVolumeStrategy();
SnapshotStrategy getSnapshotStrategy();
BackupStrategy getBackupStrategy();
TemplateStrategy getTemplateStrategy();
DataStoreLifeCycle getLifeCycle();
VolumeProfile prepareVolume(Volume volume, DataStore destStore);
SnapshotProfile prepareSnapshot(Snapshot snapshot, DataStore destStore);
TemplateProfile prepareTemplate(long templateId, DataStore destStore);
boolean contains(Volume volume);
boolean contains(Snapshot snapshot);
boolean contains(TemplateProfile template);
TemplateProfile get(TemplateProfile template);
StorageFilerTO getTO();
}

View File

@ -1,16 +0,0 @@
package org.apache.cloudstack.engine.subsystem.api.storage;
import java.net.URI;
import java.util.List;
import java.util.Map;
import com.cloud.storage.StoragePool;
public interface DataStoreConfigurator {
String getProtocol();
StoragePool getStoragePool(Map<String, String> configs);
List<String> getConfigNames();
Map<String, String> getConfigs(URI uri, Map<String, String> extras);
boolean validate(Map<String, String> configs);
DataStore getDataStore(StoragePool pool);
}

View File

@ -1,35 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
public interface DataStoreDriver {
String getDriverType();
TemplateProfile install(TemplateProfile tp, DataStoreEndPoint ep);
TemplateProfile register(TemplateProfile tp, DataStoreEndPoint ep);
DataObject create(DataObject obj);
DataObject copy(DataObject src, DataStore dest);
DataObject copy(DataObject src, DataObject dest);
DataObject move(DataObject src, DataObject dest);
VolumeProfile createVolumeFromTemplate(VolumeProfile vol, TemplateProfile tp, DataStoreEndPoint dp);
Answer sendMessage(DataStoreEndPoint dsep, Command cmd);
boolean delete(DataObject obj);
}

View File

@ -1,26 +0,0 @@
package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
public class DataStoreEndPoint {
protected long hostId;
protected String privIp;
public DataStoreEndPoint(long host, String ip) {
hostId = host;
privIp = ip;
}
public long getHostId() {
return hostId;
}
public String getPrivateIp() {
return privIp;
}
public Answer sendCommand(Command cmd) {
return new Answer(cmd);
}
}

View File

@ -1,7 +0,0 @@
package org.apache.cloudstack.engine.subsystem.api.storage;
import java.util.List;
public interface DataStoreEndPointSelector {
List<DataStoreEndPoint> getEndPoints(StorageEvent event);
}

View File

@ -1,5 +0,0 @@
package org.apache.cloudstack.engine.subsystem.api.storage;
public interface DataStoreExtendedAttribute {
}

View File

@ -1,32 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.engine.subsystem.api.storage;
public interface FileSystem {
DataObject create(DataObject obj);
DataObject copy(DataObject Obj, DataStore destStore);
DataObject copy(DataObject obj, DataObject destObj);
DataObject move(DataObject srcObj, DataObject destObj);
boolean delete(DataObject obj);
long getStats(DataObject obj);
String getFileType();
boolean isWritable(DataObject obj);
boolean contains(DataObject obj);
DataObject ioctl(DataObject obj, Object... objects);
}

View File

@ -1,23 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.engine.subsystem.api.storage;
public interface Snapshot extends DataObject {
}

View File

@ -1,5 +0,0 @@
package org.apache.cloudstack.engine.subsystem.api.storage;
public interface SnapshotStrategy {
}

View File

@ -1,20 +0,0 @@
package org.apache.cloudstack.engine.subsystem.api.storage;
import java.util.List;
import java.util.Map;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.StoreType;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StoragePool;
import com.cloud.utils.component.Adapter;
public interface StorageProvider extends Adapter {
List<HypervisorType> supportedHypervisors();
String getProviderName();
List<StoreType> supportedStoreTypes();
void configure(Map<String, String> storeProviderInfo);
DataStore addDataStore(StoragePool sp, String uri, Map<String, String> params);
DataStore getDataStore(StoragePool pool);
Map<HypervisorType, Map<String,DataStoreConfigurator>> getDataStoreConfigs();
}

View File

@ -1,13 +0,0 @@
package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.agent.api.storage.DownloadCommand.Proxy;
public interface TemplateStrategy {
TemplateProfile install(TemplateProfile tp);
TemplateProfile get(long templateId);
TemplateProfile register(TemplateProfile tp);
boolean canRegister(long templateId);
int getDownloadWait();
long getMaxTemplateSizeInBytes();
Proxy getHttpProxy();
}

View File

@ -1,16 +0,0 @@
package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.storage.Volume;
public interface VolumeStrategy {
Volume createVolume(Volume vol);
Volume createDataVolume(Volume vol);
Volume copyVolumeFromBackup(VolumeProfile srcVol, Volume destVol);
Volume createVolumeFromSnapshot(SnapshotProfile snapshot, Volume vol);
Volume createVolumeFromTemplate(TemplateProfile template, Volume vol);
Volume migrateVolume(Volume srcVol, Volume destVol, DataStore destStore);
Volume createVolumeFromBaseTemplate(Volume destVol, TemplateProfile tp);
boolean deleteVolume(Volume vol);
VolumeProfile get(long volumeId);
}

View File

@ -1,372 +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;
import java.util.ArrayList;
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.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
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.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.VolumeStrategy;
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
import org.apache.cloudstack.engine.subsystem.api.storage.type.BaseImage;
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.ImageService;
import org.apache.cloudstack.storage.image.TemplateEntityImpl;
import org.apache.cloudstack.storage.image.TemplateInfo;
import org.apache.cloudstack.storage.image.motion.ImageMotionService;
import org.apache.cloudstack.storage.manager.BackupStorageManager;
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.VolumeObject;
import org.apache.cloudstack.storage.volume.VolumeService;
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.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;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.fsm.NoTransitionException;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.dao.VMInstanceDao;
public class StorageOrchestratorImpl implements StorageOrchestrator {
private static final Logger s_logger = Logger.getLogger(StorageOrchestratorImpl.class);
@Inject
StoragePoolDao _storagePoolDao;
@Inject
StorageProviderManager _spManager;
@Inject
VolumeDao _volumeDao;
@Inject
VMInstanceDao _vmDao;
@Inject
DiskOfferingDao _diskOfferingDao;
@Inject
VolumeHostDao _volumeHostDao;
@Inject
StorageProviderManager _storageProviderMgr;
@Inject
VolumeManager _volumeMgr;
@Inject
SecondaryStorageManager _secondaryStorageMgr;
@Inject
ImageManager _templateMgr;
@Inject
VMTemplateDao _templateDao;
@Inject
VolumeService volumeService;
@Inject
ImageMotionService imageMotionService;
@Inject
ImageService imageService;
@Inject
PrimaryDataStoreManager primaryStorageMgr;
@DB
protected Volume copyVolumeFromBackupStorage(VolumeVO volume, DataStore destStore, String reservationId) throws NoTransitionException {
DataStore ds = _secondaryStorageMgr.getStore(volume);
if (!ds.contains(volume)) {
throw new CloudRuntimeException("volume: " + volume + "doesn't exist on backup storage");
}
/*
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);
txn.start();
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.OperationSucceeded);
txn.commit();
return destVolume;
*/
return null;
}
@DB
protected Volume migrateVolume(VolumeVO volume, DataStore srcStore, DataStore destStore, String reservationId) throws NoTransitionException {
Transaction txn = Transaction.currentTxn();
txn.start();
/*
volume.setReservationId(reservationId);
volume = _volumeMgr.processEvent(volume, Volume.Event.MigrationRequested);
Volume destVolume = _volumeMgr.allocateDuplicateVolume(volume);
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.CreateRequested);
txn.commit();
VolumeStrategy vs = srcStore.getVolumeStrategy();
vs.migrateVolume(volume, destVolume, destStore);
txn.start();
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
destVolume = _volumeMgr.processEvent(destVolume, Volume.Event.OperationSucceeded);
txn.commit();
volume = _volumeMgr.processEvent(volume, Volume.Event.DestroyRequested);
vs.deleteVolume(volume);
_volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
return destVolume;
*/
return null;
}
@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, 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;
*/
return null;
}
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) {
DataStore ds = _secondaryStorageMgr.getImageStore(destStore);
TemplateProfile tp = ds.prepareTemplate(volume.getTemplateId(), destStore);
if (!destStore.contains(tp)) {
tp = _templateMgr.AssociateTemplateStoragePool(tp, destStore);
tp = destStore.getTemplateStrategy().install(tp);
} else {
tp = destStore.getTemplateStrategy().get(tp.getId());
}
volume = vs.createVolumeFromBaseTemplate(volume, tp);
} else {
volume = vs.createDataVolume(volume);
}
volume = _volumeMgr.processEvent(volume, Volume.Event.OperationSucceeded);
return volume;
*/
return null;
}
@DB
protected void prepareVolumes(List<VolumeVO> vols, Long destPoolId, String reservationId) throws NoTransitionException {
DataStore destStore = null;
if (destPoolId != null) {
destStore = _storageProviderMgr.getDataStore(destPoolId);
}
for (VolumeVO volume : vols) {
if (volume.getPoolId() == null && destStore == null) {
throw new CloudRuntimeException("Volume has no pool associate and also no storage pool assigned in DeployDestination, Unable to create.");
}
if (destStore == null) {
continue;
}
DataStore srcStore = _storageProviderMgr.getDataStore(volume.getPoolId());
boolean needToCreateVolume = false;
boolean needToRecreateVolume = false;
boolean needToMigrateVolume = false;
boolean needToCopyFromSec = false;
Volume.State state = volume.getState();
if (state == Volume.State.Allocated) {
needToCreateVolume = true;
} else if (state == Volume.State.UploadOp) {
needToCopyFromSec = true;
} else if (destStore.getId() != srcStore.getId()) {
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.isRecreatable()) {
needToRecreateVolume = true;
} else {
if (Volume.Type.ROOT == volume.getVolumeType()) {
needToMigrateVolume = true;
} else {
if (destStore.getCluterId() != srcStore.getCluterId()) {
needToMigrateVolume = true;
} else if (!srcStore.isSharedStorage() && srcStore.getId() != destStore.getId()) {
needToMigrateVolume = true;
} else {
continue;
}
}
}
} else {
continue;
}
if (needToCreateVolume) {
createVolumeOnStorage(volume, destStore, reservationId);
} else if (needToMigrateVolume) {
migrateVolume(volume, srcStore, destStore, reservationId);
} else if (needToCopyFromSec) {
copyVolumeFromBackupStorage(volume, destStore, reservationId);
} else if (needToRecreateVolume) {
recreateVolume(volume, destStore, reservationId);
}
}
}
public void prepare(long vmId, DeploymentPlan plan, String reservationId) {
VirtualMachine vm = _vmDao.findById(vmId);
List<VolumeVO> vols = _volumeDao.findUsableVolumesForInstance(vm.getId());
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());
}
}
public void release(long vmId, String reservationId) {
// TODO Auto-generated method stub
}
public void destroy(List<Long> disks, String reservationId) {
// TODO Auto-generated method stub
}
public void cancel(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);
}
@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);
}
protected VolumeInfo getVolumeInfo(VolumeEntity volume) {
VolumeEntityImpl vei = (VolumeEntityImpl) volume;
return vei.getVolumeInfo();
}
@Override
public boolean createVolumeFromTemplate(VolumeEntity volume, long dataStoreId, VolumeDiskType diskType, TemplateEntity template) {
return false;
}
}

View File

@ -1,14 +0,0 @@
package org.apache.cloudstack.storage;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
public interface StorageProviderManager {
StorageProvider getProvider(String uuid);
StorageProvider getProvider(long poolId);
StorageProvider getBackupStorageProvider(long zoneId);
DataStore getDataStore(long poolId);
}

View File

@ -1,54 +0,0 @@
package org.apache.cloudstack.storage;
import java.util.Map;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
import com.cloud.utils.component.Manager;
public class StorageProviderManagerImpl implements StorageProviderManager, Manager {
public StorageProvider getProvider(String uuid) {
// TODO Auto-generated method stub
return null;
}
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
// TODO Auto-generated method stub
return false;
}
public boolean start() {
// TODO Auto-generated method stub
return false;
}
public boolean stop() {
// TODO Auto-generated method stub
return false;
}
public String getName() {
// TODO Auto-generated method stub
return null;
}
public StorageProvider getProvider(long poolId) {
// TODO Auto-generated method stub
return null;
}
public StorageProvider getBackupStorageProvider(long zoneId) {
// TODO Auto-generated method stub
return null;
}
public DataStore getDataStore(long poolId) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,66 +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;
import java.util.Date;
import org.apache.cloudstack.engine.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

@ -1,228 +0,0 @@
package org.apache.cloudstack.storage.datastore;
import org.apache.cloudstack.engine.subsystem.api.storage.BackupStrategy;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreEndPointSelector;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
import org.apache.cloudstack.engine.subsystem.api.storage.FileSystem;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotProfile;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy;
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.TemplateStrategy;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeStrategy;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.storage.Snapshot;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Volume;
public class DefaultDataStore implements DataStore {
protected VolumeStrategy _volumeStrategy;
protected SnapshotStrategy _snapshotStrategy;
protected BackupStrategy _backupStrategy;
protected TemplateStrategy _templateStrategy;
protected String _uri;
protected String _uuid;
protected StoreType _type;
protected StoreScope _scope;
protected long _poolId;
protected DataStoreDriver _driverRef;
protected DataStoreEndPointSelector _selector;
protected FileSystem _fs;
protected VolumeStrategy _volumeSt;
protected SnapshotStrategy _snapshotSt;
protected BackupStrategy _backupSt;
protected long _id;
protected DataStoreLifeCycle _dslf;
public DefaultDataStore() {
}
public String getURI() {
// TODO Auto-generated method stub
return null;
}
public void setURI(String uri) {
this._uri = uri;
}
public String getUUID() {
return this._uuid;
}
public void setUUID(String uuid) {
this._uuid = uuid;
}
public StoreType getType() {
return this._type;
}
public void setType(StoreType type) {
this._type = type;
}
public StoreScope getScope() {
return this._scope;
}
public void setScope(StoreScope scope) {
this._scope = scope;
}
public Long getId() {
return this._id;
}
public void setId(long id) {
this._id = id;
}
public DataStoreDriver getDataStoreDriver() {
return this._driverRef;
}
public void setDataStoreDriver(DataStoreDriver drv) {
this._driverRef = drv;
}
public void setEndPointSelector(DataStoreEndPointSelector selector) {
this._selector = selector;
}
public DataStoreEndPointSelector getSelector() {
return this._selector;
}
public FileSystem getFileSystem() {
return this._fs;
}
public void setFileSystem(FileSystem fs) {
this._fs = fs;
}
public VolumeStrategy getVolumeStrategy() {
return this._volumeSt;
}
public void setVolumeStrategy(VolumeStrategy vs) {
this._volumeSt = vs;
}
public SnapshotStrategy getSnapshotStrategy() {
return this._snapshotSt;
}
public void setSnapshotStrategy(SnapshotStrategy ss) {
this._snapshotSt = ss;
}
public BackupStrategy getBackupStrategy() {
return this._backupSt;
}
public void setBackupStrategy(BackupStrategy bs) {
this._backupSt = bs;
}
public TemplateStrategy getTemplateStrategy() {
return this._templateStrategy;
}
public void setTemplateStrategy(TemplateStrategy ts) {
this._templateStrategy = ts;
}
public DataStoreLifeCycle getLifeCycle() {
return this._dslf;
}
public void setLifeCycle(DataStoreLifeCycle lf) {
this._dslf = lf;
}
public long getCluterId() {
// TODO Auto-generated method stub
return 0;
}
public long getPodId() {
// TODO Auto-generated method stub
return 0;
}
public long getZoneId() {
// TODO Auto-generated method stub
return 0;
}
public String getPath() {
// TODO Auto-generated method stub
return null;
}
public StoragePoolType getPoolType() {
// TODO Auto-generated method stub
return null;
}
public boolean isSharedStorage() {
// TODO Auto-generated method stub
return false;
}
public StorageProvider getProvider() {
// TODO Auto-generated method stub
return null;
}
public DataStoreEndPointSelector getEndPointSelector() {
// TODO Auto-generated method stub
return null;
}
public VolumeProfile prepareVolume(Volume volume, DataStore destStore) {
// TODO Auto-generated method stub
return null;
}
public SnapshotProfile prepareSnapshot(Snapshot snapshot, DataStore destStore) {
// TODO Auto-generated method stub
return null;
}
public TemplateProfile prepareTemplate(long templateId, DataStore destStore) {
// TODO Auto-generated method stub
return null;
}
public boolean contains(Volume volume) {
// TODO Auto-generated method stub
return false;
}
public boolean contains(Snapshot snapshot) {
// TODO Auto-generated method stub
return false;
}
public boolean contains(TemplateProfile template) {
// TODO Auto-generated method stub
return false;
}
public TemplateProfile get(TemplateProfile template) {
// TODO Auto-generated method stub
return null;
}
public StorageFilerTO getTO() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -7,7 +7,6 @@ import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderVO;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
@ -15,7 +14,6 @@ import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDri
import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
import org.apache.cloudstack.storage.datastore.lifecycle.DefaultPrimaryDataStoreLifeCycleImpl;
import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
import org.apache.cloudstack.storage.lifecycle.DefaultPrimaryDataStoreLifeCycle;
import org.springframework.stereotype.Component;
import com.cloud.utils.component.ComponentInject;

View File

@ -1,73 +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.driver;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreEndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateStrategy;
import com.cloud.agent.api.storage.DownloadProgressCommand;
import com.cloud.agent.api.storage.DownloadProgressCommand.RequestType;
import com.cloud.agent.api.storage.DownloadCommand;
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
public abstract class AbstractStorageDriver implements DataStoreDriver {
protected DataStore _ds;
protected TemplateStrategy _ts;
public AbstractStorageDriver(DataStore ds) {
_ds = ds;
_ts = ds.getTemplateStrategy();
}
public TemplateProfile install(TemplateProfile tp, DataStoreEndPoint ep) {
PrimaryStorageDownloadCommand dcmd = new PrimaryStorageDownloadCommand(tp.getName(), tp.getUrl(), tp.getFormat(), 0, _ds.getId(), _ds.getUUID(), _ts.getDownloadWait());
dcmd.setSecondaryStorageUrl(tp.getImageStorageUri());
dcmd.setPrimaryStorageUrl(_ds.getURI());
PrimaryStorageDownloadAnswer asw = (PrimaryStorageDownloadAnswer) ep.sendCommand(dcmd);
tp.setLocalPath(asw.getInstallPath());
return tp;
}
public TemplateProfile register(TemplateProfile tp, DataStoreEndPoint ep, boolean freshDownload) {
DownloadCommand dcmd = new DownloadCommand(_ds.getURI(), tp.getTemplate(), _ts.getMaxTemplateSizeInBytes());
dcmd.setProxy(_ts.getHttpProxy());
if (!freshDownload) {
dcmd = new DownloadProgressCommand(dcmd, tp.getJobId(), RequestType.GET_OR_RESTART);
}
ep.sendCommand(dcmd);
return tp;
}
/*
* public VolumeProfile createVolumeFromTemplate(VolumeProfile volProfile,
* TemplateProfile tp, DataStoreEndPoint ep) { CreateCommand cmd = new
* CreateCommand(volProfile, tp.getLocalPath(), _ds.getTO()); CreateAnswer
* ans = (CreateAnswer)ep.sendCommand(cmd); VolumeTO created =
* ans.getVolume(); DiskProfile diskProfile = new VolumeProfile(volProfile);
* diskProfile.setPath(created.getPath());
* diskProfile.setSize(created.getSize()); return diskProfile; return null;
* }
*/
}

View File

@ -1,90 +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.driver;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreEndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.storage.TemplateProfile;
public class DefaultNfsSecondaryDriver extends AbstractStorageDriver {
/**
* @param ds
*/
public DefaultNfsSecondaryDriver(DataStore ds) {
super(ds);
// TODO Auto-generated constructor stub
}
public String getDriverType() {
// TODO Auto-generated method stub
return null;
}
public TemplateProfile register(TemplateProfile tp, DataStoreEndPoint ep) {
// TODO Auto-generated method stub
return null;
}
public DataObject create(DataObject obj) {
// TODO Auto-generated method stub
return null;
}
public DataObject copy(DataObject src, DataStore dest) {
// TODO Auto-generated method stub
return null;
}
public DataObject copy(DataObject src, DataObject dest) {
// TODO Auto-generated method stub
return null;
}
public DataObject move(DataObject src, DataObject dest) {
// TODO Auto-generated method stub
return null;
}
public Answer sendMessage(DataStoreEndPoint dsep, Command cmd) {
// TODO Auto-generated method stub
return null;
}
public boolean delete(DataObject obj) {
// TODO Auto-generated method stub
return false;
}
public org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile register(org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile tp, DataStoreEndPoint ep) {
// TODO Auto-generated method stub
return null;
}
public VolumeProfile createVolumeFromTemplate(VolumeProfile vol, org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile tp, DataStoreEndPoint dp) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,81 +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.driver;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreEndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
public class XenServerStorageDriver extends AbstractStorageDriver {
protected DataStore _ds;
public XenServerStorageDriver(DataStore ds) {
super(ds);
_ds = ds;
}
public String getDriverType() {
// TODO Auto-generated method stub
return null;
}
public DataObject create(DataObject obj) {
// TODO Auto-generated method stub
return null;
}
public DataObject copy(DataObject src, DataStore dest) {
// TODO Auto-generated method stub
return null;
}
public DataObject copy(DataObject src, DataObject dest) {
// TODO Auto-generated method stub
return null;
}
public DataObject move(DataObject src, DataObject dest) {
// TODO Auto-generated method stub
return null;
}
public Answer sendMessage(DataStoreEndPoint dsep, Command cmd) {
// TODO Auto-generated method stub
return null;
}
public boolean delete(DataObject obj) {
// TODO Auto-generated method stub
return false;
}
public org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile register(org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile tp, DataStoreEndPoint ep) {
// TODO Auto-generated method stub
return null;
}
public VolumeProfile createVolumeFromTemplate(VolumeProfile vol, org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile tp, DataStoreEndPoint dp) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,32 +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.image;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile;
import com.cloud.api.commands.RegisterTemplateCmd;
public interface ImageManager {
TemplateProfile AssociateTemplateStoragePool(TemplateProfile tp, DataStore ds);
TemplateProfile getProfile(long templateId);
TemplateProfile allocateTemplateInDB(RegisterTemplateCmd cmd);
}

View File

@ -1,165 +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.image;
import java.util.List;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile;
import org.apache.log4j.Logger;
import com.cloud.api.commands.RegisterTemplateCmd;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateStoragePoolVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VMTemplatePoolDao;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.utils.EnumUtils;
import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException;
public class ImageManagerImpl implements ImageManager {
private static final Logger s_logger = Logger.getLogger(ImageManagerImpl.class);
@Inject
VMTemplateDao _templateDao;
@Inject
VMTemplatePoolDao _templatePoolDao;
@Inject
DataCenterDao _dcDao;
public boolean contains(VirtualMachineTemplate template, DataStore ds) {
long templateId = template.getId();
long poolId = ds.getId();
VMTemplateStoragePoolVO templateStoragePoolRef = null;
templateStoragePoolRef = _templatePoolDao.findByPoolTemplate(poolId, templateId);
return templateStoragePoolRef == null ? false : true;
}
public TemplateProfile AssociateTemplateStoragePool(TemplateProfile tp, DataStore ds) {
long templateId = tp.getTemplateId();
long poolId = ds.getId();
VMTemplateStoragePoolVO templateStoragePoolRef = null;
long templateStoragePoolRefId;
templateStoragePoolRef = _templatePoolDao.findByPoolTemplate(poolId, templateId);
if (templateStoragePoolRef != null) {
templateStoragePoolRef.setMarkedForGC(false);
_templatePoolDao.update(templateStoragePoolRef.getId(), templateStoragePoolRef);
if (templateStoragePoolRef.getDownloadState() == Status.DOWNLOADED) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Template " + templateId + " has already been downloaded to pool " + poolId);
}
tp.setLocalPath(templateStoragePoolRef.getInstallPath());
tp.setTemplatePoolRefId(templateStoragePoolRef.getId());
return tp;
}
}
if (templateStoragePoolRef == null) {
templateStoragePoolRef = new VMTemplateStoragePoolVO(poolId, templateId);
try {
templateStoragePoolRef = _templatePoolDao.persist(templateStoragePoolRef);
templateStoragePoolRefId = templateStoragePoolRef.getId();
} catch (Exception e) {
s_logger.debug("Assuming we're in a race condition: " + e.getMessage());
templateStoragePoolRef = _templatePoolDao.findByPoolTemplate(poolId, templateId);
if (templateStoragePoolRef == null) {
throw new CloudRuntimeException("Unable to persist a reference for pool " + poolId + " and template " + templateId);
}
templateStoragePoolRefId = templateStoragePoolRef.getId();
}
} else {
templateStoragePoolRefId = templateStoragePoolRef.getId();
}
tp.setTemplatePoolRefId(templateStoragePoolRefId);
return tp;
}
public TemplateProfile getProfile(long templateId) {
// TODO Auto-generated method stub
return null;
}
protected TemplateProfile persistTemplate(TemplateProfile profile) {
Long zoneId = profile.getZoneId();
VMTemplateVO template = new VMTemplateVO(profile.getTemplateId(), profile.getName(), profile.getFormat(), profile.getIsPublic(), profile.getFeatured(), profile.getIsExtractable(),
TemplateType.USER, profile.getUrl(), profile.getRequiresHVM(), profile.getBits(), profile.getAccountId(), profile.getCheckSum(), profile.getDisplayText(),
profile.getPasswordEnabled(), profile.getGuestOsId(), profile.getBootable(), profile.getHypervisorType(), profile.getTemplateTag(), profile.getDetails(), profile.getSshKeyEnabled());
if (zoneId == null || zoneId.longValue() == -1) {
List<DataCenterVO> dcs = _dcDao.listAll();
if (dcs.isEmpty()) {
throw new CloudRuntimeException("No zones are present in the system, can't add template");
}
template.setCrossZones(true);
for (DataCenterVO dc : dcs) {
_templateDao.addTemplateToZone(template, dc.getId());
}
} else {
_templateDao.addTemplateToZone(template, zoneId);
}
return getProfile(template.getId());
}
protected boolean parameterCheck(RegisterTemplateCmd cmd) {
Long zoneId = cmd.getZoneId();
if (zoneId == -1) {
zoneId = null;
}
ImageFormat imgfmt = ImageFormat.valueOf(cmd.getFormat().toUpperCase());
if (imgfmt == null) {
throw new IllegalArgumentException("Image format is incorrect " + cmd.getFormat() + ". Supported formats are " + EnumUtils.listValues(ImageFormat.values()));
}
// If a zoneId is specified, make sure it is valid
if (zoneId != null) {
DataCenterVO zone = _dcDao.findById(zoneId);
if (zone == null) {
throw new IllegalArgumentException("Please specify a valid zone.");
}
}
List<VMTemplateVO> systemvmTmplts = _templateDao.listAllSystemVMTemplates();
for (VMTemplateVO template : systemvmTmplts) {
if (template.getName().equalsIgnoreCase(cmd.getTemplateName()) || template.getDisplayText().equalsIgnoreCase(cmd.getDisplayText())) {
throw new IllegalArgumentException("Cannot use reserved names for templates");
}
}
return true;
}
public TemplateProfile allocateTemplateInDB(RegisterTemplateCmd cmd) {
parameterCheck(cmd);
// TemplateProfile tp = new TemplateProfile(cmd);
return persistTemplate(null);
}
}

View File

@ -1,78 +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.image;
import java.util.List;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotProfile;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateStrategy;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
import org.apache.cloudstack.storage.manager.SecondaryStorageManager;
import com.cloud.storage.TemplateProfile;
import com.cloud.storage.VMTemplateZoneVO;
import com.cloud.storage.dao.VMTemplateZoneDao;
import com.cloud.utils.component.Inject;
public class ImageOrchestratorImpl implements ImageOrchestrator {
@Inject
SecondaryStorageManager _secStorageMgr;
@Inject
VMTemplateZoneDao _templateZoneDao;
public void registerTemplate(long templateId) {
List<VMTemplateZoneVO> tpZones = _templateZoneDao.listByTemplateId(templateId);
for (VMTemplateZoneVO tpZone : tpZones) {
DataStore imageStore = null;
List<DataStore> imageStores = _secStorageMgr.getImageStores(tpZone.getZoneId());
for (DataStore imgStore : imageStores) {
TemplateStrategy ts = imgStore.getTemplateStrategy();
if (ts.canRegister(templateId)) {
imageStore = imgStore;
break;
}
}
if (imageStore == null) {
continue;
}
TemplateStrategy ts = imageStore.getTemplateStrategy();
ts.register(ts.get(templateId));
}
}
public void registerSnapshot(long snapshotId) {
// TODO Auto-generated method stub
}
public void registerVolume(long volumeId) {
// TODO Auto-generated method stub
}
public void registerIso(long isoId) {
// TODO Auto-generated method stub
}
}

View File

@ -1,56 +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.lifecycle;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
public class DefaultNfsSecondaryLifeCycle implements DataStoreLifeCycle {
protected DataStore _ds;
public DefaultNfsSecondaryLifeCycle(DataStore ds) {
_ds = ds;
}
public void add() {
// TODO Auto-generated method stub
}
public void delete() {
// TODO Auto-generated method stub
}
public void enable() {
// TODO Auto-generated method stub
}
public void disable() {
// TODO Auto-generated method stub
}
public void processEvent(DataStoreEvent event, Object... objs) {
// TODO Auto-generated method stub
}
}

View File

@ -1,123 +0,0 @@
package org.apache.cloudstack.storage.lifecycle;
import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreEndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreEndPointSelector;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.CreateStoragePoolCommand;
import com.cloud.agent.api.ModifyStoragePoolAnswer;
import com.cloud.agent.api.ModifyStoragePoolCommand;
import com.cloud.alert.AlertManager;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.HostVO;
import com.cloud.storage.StoragePoolHostVO;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.dao.StoragePoolDao;
import com.cloud.storage.dao.StoragePoolHostDao;
import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException;
public class DefaultPrimaryDataStoreLifeCycle implements DataStoreLifeCycle {
private static final Logger s_logger = Logger.getLogger(DataStoreLifeCycle.class);
private DataStore _ds;
@Inject
StoragePoolDao _storagePoolDao;
@Inject
StoragePoolHostDao _poolHostDao;
public DefaultPrimaryDataStoreLifeCycle(DataStore ds) {
this._ds = ds;
}
protected boolean createStoragePool(DataStoreEndPoint ep, StoragePoolVO pool) {
DataStoreDriver dsDriver = _ds.getDataStoreDriver();
CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, pool);
final Answer answer = dsDriver.sendMessage(ep, cmd);
if (answer != null && answer.getResult()) {
return true;
} else {
throw new CloudRuntimeException(answer.getDetails());
}
}
protected void connectHostToSharedPool(DataStoreEndPoint ep, StoragePoolVO pool) throws StorageUnavailableException {
DataStoreDriver dsDriver = _ds.getDataStoreDriver();
long hostId = ep.getHostId();
ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, pool);
final Answer answer = dsDriver.sendMessage(ep, cmd);
if (answer == null) {
throw new StorageUnavailableException("Unable to get an answer to the modify storage pool command", pool.getId());
}
if (!answer.getResult()) {
throw new StorageUnavailableException("Unable establish connection from storage head to storage pool " + pool.getId() + " due to " + answer.getDetails(), pool.getId());
}
assert (answer instanceof ModifyStoragePoolAnswer) : "Well, now why won't you actually return the ModifyStoragePoolAnswer when it's ModifyStoragePoolCommand? Pool=" + pool.getId();
ModifyStoragePoolAnswer mspAnswer = (ModifyStoragePoolAnswer) answer;
StoragePoolHostVO poolHost = _poolHostDao.findByPoolHost(pool.getId(), hostId);
if (poolHost == null) {
poolHost = new StoragePoolHostVO(pool.getId(), hostId, mspAnswer.getPoolInfo().getLocalPath().replaceAll("//", "/"));
_poolHostDao.persist(poolHost);
} else {
poolHost.setLocalPath(mspAnswer.getPoolInfo().getLocalPath().replaceAll("//", "/"));
}
pool.setAvailableBytes(mspAnswer.getPoolInfo().getAvailableBytes());
pool.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes());
_storagePoolDao.update(pool.getId(), pool);
}
public void add() {
DataStoreEndPointSelector dseps = _ds.getEndPointSelector();
List<DataStoreEndPoint> dsep = dseps.getEndPoints(null);
boolean success = false;
StoragePoolVO spool = _storagePoolDao.findById(_ds.getId());
for (DataStoreEndPoint ep : dsep) {
success = createStoragePool(ep, spool);
if (success) {
break;
}
}
List<DataStoreEndPoint> poolHosts = new ArrayList<DataStoreEndPoint>();
for (DataStoreEndPoint ep : dsep) {
try {
connectHostToSharedPool(ep, spool);
poolHosts.add(ep);
} catch (Exception e) {
s_logger.debug("Failed to add storage on this ep: " + ep.getHostId());
}
}
}
public void delete() {
// TODO Auto-generated method stub
}
public void enable() {
// TODO Auto-generated method stub
}
public void disable() {
// TODO Auto-generated method stub
}
public void processEvent(DataStoreEvent event, Object... objs) {
// TODO Auto-generated method stub
}
}

View File

@ -1,43 +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.manager;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectBackupStorageOperationState;
import org.apache.cloudstack.engine.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

@ -1,66 +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.manager;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectBackupStorageOperationState.Event;
import com.cloud.storage.Snapshot;
import com.cloud.storage.Volume;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.utils.fsm.NoTransitionException;
public class BackupStorageManagerImpl implements BackupStorageManager {
public boolean contains(Volume vol) {
// TODO Auto-generated method stub
return false;
}
public boolean contains(Snapshot snapshot) {
// TODO Auto-generated method stub
return false;
}
public boolean contains(VirtualMachineTemplate template) {
// TODO Auto-generated method stub
return false;
}
public DataStore getBackupDataStore(Volume vol) {
// TODO Auto-generated method stub
return null;
}
public DataStore getBackupDataStore(Snapshot snapshot) {
// TODO Auto-generated method stub
return null;
}
public DataStore getBackupDataStore(VirtualMachineTemplate template) {
// TODO Auto-generated method stub
return null;
}
public boolean updateOperationState(Volume vol, Event event) throws NoTransitionException {
// TODO Auto-generated method stub
return false;
}
}

View File

@ -1,43 +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.manager;
import java.util.List;
import java.util.Map;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StoragePool;
public interface PrimaryDataStoreManager {
PrimaryDataStore addDataStore(long zoneId, long podId, long clusterId, long hostId, String URI, String storageType, String poolName, String storageProviderName, Map<String, String> params);
void deleteStoragePool(long poolId);
void enableStoragePool(long poolId);
void disableStoragePool(long poolId);
Map<String, List<String>> getSupportedPrimaryStorages(long zoneId, HypervisorType hypervisor);
Map<String, List<String>> getSupportedSecondaryStorages(long zoneId);
PrimaryDataStore getDataStore(String id);
}

View File

@ -1,142 +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.manager;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
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.StorageProvider;
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.DataCenterVO;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolStatus;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.dao.StoragePoolDao;
import com.cloud.utils.component.Adapters;
import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException;
public class PrimaryDataStoreManagerImpl implements PrimaryDataStoreManager {
@Inject(adapter = StorageProvider.class)
protected Adapters<StorageProvider> _storageProviders;
@Inject
protected DataCenterDao _dcDao;
@Inject
protected HostPodDao _podDao;
@Inject
protected ClusterDao _clusterDao;
@Inject
protected StoragePoolDao _storagePoolDao;
public void deleteStoragePool(long poolId) {
StoragePool spool = _storagePoolDao.findById(poolId);
StorageProvider sp = findStorageProvider(spool.getStorageProvider());
DataStore ds = sp.getDataStore(spool);
DataStoreLifeCycle dslc = ds.getLifeCycle();
dslc.delete();
}
public void enableStoragePool(long poolId) {
// TODO Auto-generated method stub
}
public void disableStoragePool(long poolId) {
// TODO Auto-generated method stub
}
public Map<String, List<String>> getSupportedPrimaryStorages(long zoneId, HypervisorType hypervisor) {
// TODO Auto-generated method stub
return null;
}
public Map<String, List<String>> getSupportedSecondaryStorages(long zoneId) {
// TODO Auto-generated method stub
return null;
}
protected StorageProvider findStorageProvider(String name) {
Iterator<StorageProvider> spIter = _storageProviders.iterator();
StorageProvider sp = null;
while (spIter.hasNext()) {
sp = spIter.next();
if (sp.getProviderName().equalsIgnoreCase(name)) {
break;
}
}
return sp;
}
public StoragePool addStoragePool(long zoneId, long podId, long clusterId, long hostId, String URI, String storageType, String poolName, String storageProviderName, Map<String, String> params) {
StoragePoolVO spool = new StoragePoolVO();
long poolId = _storagePoolDao.getNextInSequence(Long.class, "id");
spool.setId(poolId);
spool.setDataCenterId(zoneId);
spool.setPodId(podId);
spool.setName(poolName);
spool.setClusterId(clusterId);
spool.setStorageProvider(storageProviderName);
spool.setStorageType(storageType);
spool.setStatus(StoragePoolStatus.Creating);
spool = _storagePoolDao.persist(spool);
StorageProvider sp = findStorageProvider(storageProviderName);
DataStore ds = sp.addDataStore((StoragePool) spool, URI, params);
DataStoreLifeCycle dslc = ds.getLifeCycle();
try {
dslc.add();
} catch (CloudRuntimeException e) {
_storagePoolDao.remove(spool.getId());
throw e;
}
spool.setPath(ds.getURI());
spool.setUuid(ds.getUUID());
spool.setStatus(StoragePoolStatus.Up);
_storagePoolDao.update(spool.getId(), spool);
spool = _storagePoolDao.findById(spool.getId());
return spool;
}
@Override
public PrimaryDataStore addDataStore(long zoneId, long podId, long clusterId, long hostId, String URI, String storageType, String poolName, String storageProviderName, Map<String, String> params) {
// TODO Auto-generated method stub
return null;
}
@Override
public PrimaryDataStore getDataStore(String id) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,37 +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.manager;
import java.util.List;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import com.cloud.storage.Snapshot;
import com.cloud.storage.Volume;
import com.cloud.template.VirtualMachineTemplate;
public interface SecondaryStorageManager {
DataStore getStore(Volume volume);
DataStore getImageStore(DataStore destStore);
List<DataStore> getImageStores(long zoneId);
DataStore getStore(Snapshot snapshot);
}

View File

@ -1,55 +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.manager;
import java.util.List;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import com.cloud.storage.Snapshot;
import com.cloud.storage.Volume;
import com.cloud.storage.dao.VMTemplateZoneDao;
public class SecondaryStorageManagerImpl implements SecondaryStorageManager {
public DataStore getStore(Volume volume) {
// TODO Auto-generated method stub
return null;
}
public DataStore getImageStore(DataStore destStore) {
// TODO Auto-generated method stub
return null;
}
public List<DataStore> getImageStores() {
return null;
}
public DataStore getStore(Snapshot snapshot) {
// TODO Auto-generated method stub
return null;
}
public List<DataStore> getImageStores(long zoneId) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,130 +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.provider;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreConfigurator;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.StoreType;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StoragePool;
public class DefaultNfsSecondaryStorageProvider implements StorageProvider {
private String _name = DefaultPrimaryStorageProvider.class.toString();
protected Map<HypervisorType, Map<String, DataStoreConfigurator>> _supportedProtocols;
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
Map<String, DataStoreConfigurator> dscs = new HashMap<String, DataStoreConfigurator>();
DataStoreConfigurator nfsdc = null;
dscs.put(nfsdc.getProtocol(), nfsdc);
_supportedProtocols.put(HypervisorType.XenServer, dscs);
_supportedProtocols.put(HypervisorType.KVM, dscs);
_supportedProtocols.put(HypervisorType.VMware, dscs);
_supportedProtocols.put(HypervisorType.Ovm, dscs);
return true;
}
public String getName() {
// TODO Auto-generated method stub
return null;
}
public boolean start() {
// TODO Auto-generated method stub
return false;
}
public boolean stop() {
// TODO Auto-generated method stub
return false;
}
public List<HypervisorType> supportedHypervisors() {
List<HypervisorType> hypervisors = new ArrayList<HypervisorType>();
Set<HypervisorType> hyps = _supportedProtocols.keySet();
for (HypervisorType hy : hyps) {
hypervisors.add(hy);
}
return hypervisors;
}
public String getProviderName() {
// TODO Auto-generated method stub
return null;
}
public void configure(Map<String, String> storeProviderInfo) {
// TODO Auto-generated method stub
}
public DataStore addDataStore(StoragePool sp, String url, Map<String, String> params) {
URI uri;
try {
uri = new URI(url);
} catch (URISyntaxException e) {
throw new InvalidParameterValueException("invalide url" + url);
}
String protocol = uri.getScheme();
if (protocol == null) {
throw new InvalidParameterValueException("the protocol can't be null");
}
DataStoreConfigurator dscf = _supportedProtocols.get(HypervisorType.XenServer).get(protocol);
Map<String, String> configs = dscf.getConfigs(uri, params);
dscf.validate(configs);
DataStore ds = dscf.getDataStore(sp);
return ds;
}
public DataStore getDataStore(StoragePool pool) {
// TODO Auto-generated method stub
return null;
}
public Map<HypervisorType, Map<String, DataStoreConfigurator>> getDataStoreConfigs() {
// TODO Auto-generated method stub
return null;
}
public List<StoreType> supportedStoreTypes() {
List<StoreType> types = new ArrayList<StoreType>();
types.add(StoreType.Image);
types.add(StoreType.Backup);
return types;
}
}

View File

@ -1,141 +0,0 @@
package org.apache.cloudstack.storage.provider;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreConfigurator;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.StoreType;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolStatus;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.dao.StoragePoolDao;
public class DefaultPrimaryStorageProvider implements StorageProvider {
private String _name = DefaultPrimaryStorageProvider.class.toString();
static Map<HypervisorType, Map<String, DataStoreConfigurator>> _supportedProtocols;
@Inject
protected ClusterDao _clusterDao;
public List<HypervisorType> supportedHypervisors() {
List<HypervisorType> hypervisors = new ArrayList<HypervisorType>();
hypervisors.add(Hypervisor.HypervisorType.XenServer);
return hypervisors;
}
public DefaultPrimaryStorageProvider() {
Map<String, DataStoreConfigurator> dscs = new HashMap<String, DataStoreConfigurator>();
DataStoreConfigurator nfsdc = null;
dscs.put(nfsdc.getProtocol(), nfsdc);
_supportedProtocols.put(HypervisorType.XenServer, dscs);
}
public List<StoreType> supportedStoreType() {
List<StoreType> type = new ArrayList<StoreType>();
type.add(StoreType.Primary);
return type;
}
public void configure(Map<String, String> storeProviderInfo) {
// TODO Auto-generated method stub
}
public Map<HypervisorType, Map<String, DataStoreConfigurator>> getDataStoreConfigs() {
return _supportedProtocols;
}
public String getProviderName() {
return _name;
}
public DataStore createDataStore(HypervisorType hypervisor, DataStoreConfigurator dsc) {
// TODO Auto-generated method stub
return null;
}
public DataStore getDataStore(StoragePool pool) {
ClusterVO clu = _clusterDao.findById(pool.getClusterId());
HypervisorType hy = clu.getHypervisorType();
Map<String, DataStoreConfigurator> dscs = _supportedProtocols.get(hy);
DataStoreConfigurator dsc = dscs.get(pool.getPoolType().toString());
return dsc.getDataStore(pool);
}
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
// TODO Auto-generated method stub
return false;
}
public String getName() {
// TODO Auto-generated method stub
return null;
}
public boolean start() {
// TODO Auto-generated method stub
return false;
}
public boolean stop() {
// TODO Auto-generated method stub
return false;
}
public DataStore addDataStore(StoragePool spool, String url, Map<String, String> params) {
URI uri;
try {
uri = new URI(url);
} catch (URISyntaxException e) {
throw new InvalidParameterValueException("invalide url" + url);
}
String protocol = uri.getScheme();
if (protocol == null) {
throw new InvalidParameterValueException("the protocol can't be null");
}
ClusterVO cluster = _clusterDao.findById(spool.getClusterId());
Map<String, DataStoreConfigurator> dscs = _supportedProtocols.get(cluster.getHypervisorType());
if (dscs.isEmpty()) {
throw new InvalidParameterValueException("Doesn't support this hypervisor");
}
DataStoreConfigurator dsc = dscs.get(protocol);
if (dsc == null) {
throw new InvalidParameterValueException("Doesn't support this protocol");
}
Map<String, String> configs = dsc.getConfigs(uri, params);
dsc.validate(configs);
DataStore ds = dsc.getDataStore(spool);
return ds;
}
public List<StoreType> supportedStoreTypes() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,91 +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.provider;
import java.util.List;
import java.util.Map;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreConfigurator;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.StoreType;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StoragePool;
public class HttpImageStoreProvider implements StorageProvider {
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
// TODO Auto-generated method stub
return false;
}
public String getName() {
// TODO Auto-generated method stub
return null;
}
public boolean start() {
// TODO Auto-generated method stub
return false;
}
public boolean stop() {
// TODO Auto-generated method stub
return false;
}
public List<HypervisorType> supportedHypervisors() {
// TODO Auto-generated method stub
return null;
}
public String getProviderName() {
// TODO Auto-generated method stub
return null;
}
public List<StoreType> supportedStoreTypes() {
// TODO Auto-generated method stub
return null;
}
public void configure(Map<String, String> storeProviderInfo) {
// TODO Auto-generated method stub
}
public DataStore addDataStore(StoragePool sp, String uri, Map<String, String> params) {
// TODO Auto-generated method stub
return null;
}
public DataStore getDataStore(StoragePool pool) {
// TODO Auto-generated method stub
return null;
}
public Map<HypervisorType, Map<String, DataStoreConfigurator>> getDataStoreConfigs() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,91 +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.provider;
import java.util.List;
import java.util.Map;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreConfigurator;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.StoreType;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StoragePool;
public class S3SecondaryStorageProvider implements StorageProvider {
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
// TODO Auto-generated method stub
return false;
}
public String getName() {
// TODO Auto-generated method stub
return null;
}
public boolean start() {
// TODO Auto-generated method stub
return false;
}
public boolean stop() {
// TODO Auto-generated method stub
return false;
}
public List<HypervisorType> supportedHypervisors() {
// TODO Auto-generated method stub
return null;
}
public String getProviderName() {
// TODO Auto-generated method stub
return null;
}
public List<StoreType> supportedStoreTypes() {
// TODO Auto-generated method stub
return null;
}
public void configure(Map<String, String> storeProviderInfo) {
// TODO Auto-generated method stub
}
public DataStore addDataStore(StoragePool sp, String uri, Map<String, String> params) {
// TODO Auto-generated method stub
return null;
}
public DataStore getDataStore(StoragePool pool) {
// TODO Auto-generated method stub
return null;
}
public Map<HypervisorType, Map<String, DataStoreConfigurator>> getDataStoreConfigs() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,91 +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.provider;
import java.util.List;
import java.util.Map;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreConfigurator;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.StoreType;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StoragePool;
public class SwiftSecondaryStorageProvider implements StorageProvider {
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
// TODO Auto-generated method stub
return false;
}
public String getName() {
// TODO Auto-generated method stub
return null;
}
public boolean start() {
// TODO Auto-generated method stub
return false;
}
public boolean stop() {
// TODO Auto-generated method stub
return false;
}
public List<HypervisorType> supportedHypervisors() {
// TODO Auto-generated method stub
return null;
}
public String getProviderName() {
// TODO Auto-generated method stub
return null;
}
public List<StoreType> supportedStoreTypes() {
// TODO Auto-generated method stub
return null;
}
public void configure(Map<String, String> storeProviderInfo) {
// TODO Auto-generated method stub
}
public DataStore addDataStore(StoragePool sp, String uri, Map<String, String> params) {
// TODO Auto-generated method stub
return null;
}
public DataStore getDataStore(StoragePool pool) {
// TODO Auto-generated method stub
return null;
}
public Map<HypervisorType, Map<String, DataStoreConfigurator>> getDataStoreConfigs() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,191 +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.strategy;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreEndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreEndPointSelector;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageEvent;
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.TemplateStrategy;
import org.apache.cloudstack.storage.image.ImageManager;
import org.apache.log4j.Logger;
import com.cloud.agent.api.storage.DownloadCommand.Proxy;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateStoragePoolVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.dao.VMTemplateHostDao;
import com.cloud.storage.dao.VMTemplatePoolDao;
import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException;
public class DefaultTemplateStratey implements TemplateStrategy {
private static final Logger s_logger = Logger.getLogger(DefaultTemplateStratey.class);
protected DataStore _ds;
protected DataStoreDriver _driver;
protected int _primaryStorageDownloadWait;
protected int _installTries = 3;
protected int _storagePoolMaxWaitSeconds = 3600;
@Inject
VMTemplatePoolDao _templatePoolDao;
@Inject
VMTemplateHostDao _templateImageStoreDao;
@Inject
ImageManager _templateMgr;
public DefaultTemplateStratey(DataStore ds) {
_ds = ds;
}
public TemplateProfile get(long templateId) {
return _templateMgr.getProfile(templateId);
}
public TemplateProfile install(TemplateProfile tp) {
DataStoreEndPointSelector dseps = _ds.getEndPointSelector();
List<DataStoreEndPoint> eps = dseps.getEndPoints(StorageEvent.DownloadTemplateToPrimary);
int tries = Math.min(eps.size(), _installTries);
VMTemplateStoragePoolVO templateStoragePoolRef = _templatePoolDao.acquireInLockTable(tp.getTemplatePoolRefId(), _storagePoolMaxWaitSeconds);
if (templateStoragePoolRef == null) {
throw new CloudRuntimeException("Unable to acquire lock on VMTemplateStoragePool: " + tp.getTemplatePoolRefId());
}
try {
for (int retry = 0; retry < tries; retry++) {
Collections.shuffle(eps);
DataStoreEndPoint ep = eps.get(0);
try {
tp = _driver.install(tp, ep);
templateStoragePoolRef.setDownloadPercent(100);
templateStoragePoolRef.setDownloadState(Status.DOWNLOADED);
templateStoragePoolRef.setLocalDownloadPath(tp.getLocalPath());
templateStoragePoolRef.setInstallPath(tp.getLocalPath());
templateStoragePoolRef.setTemplateSize(tp.getSize());
_templatePoolDao.update(templateStoragePoolRef.getId(), templateStoragePoolRef);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Template " + tp.getTemplateId() + " is installed via " + ep.getHostId());
}
return get(tp.getTemplateId());
} catch (CloudRuntimeException e) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Template " + tp.getTemplateId() + " download to pool " + _ds.getId() + " failed due to " + e.toString());
}
}
}
} finally {
_templatePoolDao.releaseFromLockTable(tp.getTemplatePoolRefId());
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Template " + tp.getTemplateId() + " is not found on and can not be downloaded to pool " + _ds.getId());
}
return null;
}
public TemplateProfile register(TemplateProfile tp) {
VMTemplateHostVO vmTemplateHost = _templateImageStoreDao.findByHostTemplate(_ds.getId(), tp.getTemplateId());
if (vmTemplateHost == null) {
vmTemplateHost = new VMTemplateHostVO(_ds.getId(), tp.getTemplateId(), new Date(), 0, VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED, null, null, "jobid0000", null, tp.getUrl());
_templateImageStoreDao.persist(vmTemplateHost);
}
DataStoreEndPointSelector dseps = _ds.getEndPointSelector();
List<DataStoreEndPoint> eps = dseps.getEndPoints(StorageEvent.RegisterTemplate);
Collections.shuffle(eps);
DataStoreEndPoint ep = eps.get(0);
_driver.register(tp, ep);
return null;
}
protected boolean checkHypervisor(HypervisorType hypervisor) {
StorageProvider sp = _ds.getProvider();
List<HypervisorType> spHys = sp.supportedHypervisors();
boolean checkHypervisor = false;
for (HypervisorType hy : spHys) {
if (hy == hypervisor) {
checkHypervisor = true;
}
}
return checkHypervisor;
}
protected boolean checkFormat(String url, String format) {
if ((!url.toLowerCase().endsWith("vhd")) && (!url.toLowerCase().endsWith("vhd.zip")) && (!url.toLowerCase().endsWith("vhd.bz2")) && (!url.toLowerCase().endsWith("vhd.gz"))
&& (!url.toLowerCase().endsWith("qcow2")) && (!url.toLowerCase().endsWith("qcow2.zip")) && (!url.toLowerCase().endsWith("qcow2.bz2")) && (!url.toLowerCase().endsWith("qcow2.gz"))
&& (!url.toLowerCase().endsWith("ova")) && (!url.toLowerCase().endsWith("ova.zip")) && (!url.toLowerCase().endsWith("ova.bz2")) && (!url.toLowerCase().endsWith("ova.gz"))
&& (!url.toLowerCase().endsWith("img")) && (!url.toLowerCase().endsWith("raw"))) {
throw new InvalidParameterValueException("Please specify a valid " + format.toLowerCase());
}
if ((format.equalsIgnoreCase("vhd") && (!url.toLowerCase().endsWith("vhd") && !url.toLowerCase().endsWith("vhd.zip") && !url.toLowerCase().endsWith("vhd.bz2") && !url.toLowerCase().endsWith(
"vhd.gz")))
|| (format.equalsIgnoreCase("qcow2") && (!url.toLowerCase().endsWith("qcow2") && !url.toLowerCase().endsWith("qcow2.zip") && !url.toLowerCase().endsWith("qcow2.bz2") && !url
.toLowerCase().endsWith("qcow2.gz")))
|| (format.equalsIgnoreCase("ova") && (!url.toLowerCase().endsWith("ova") && !url.toLowerCase().endsWith("ova.zip") && !url.toLowerCase().endsWith("ova.bz2") && !url.toLowerCase()
.endsWith("ova.gz"))) || (format.equalsIgnoreCase("raw") && (!url.toLowerCase().endsWith("img") && !url.toLowerCase().endsWith("raw")))) {
throw new InvalidParameterValueException("Please specify a valid URL. URL:" + url + " is an invalid for the format " + format.toLowerCase());
}
return true;
}
public boolean canRegister(long templateId) {
TemplateProfile tp = get(templateId);
if (!checkHypervisor(tp.getHypervisorType())) {
return false;
}
if (!checkFormat(tp.getUrl(), tp.getFormat().toString())) {
return false;
}
return true;
}
public int getDownloadWait() {
// TODO Auto-generated method stub
return 0;
}
public long getMaxTemplateSizeInBytes() {
// TODO Auto-generated method stub
return 0;
}
public Proxy getHttpProxy() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,95 +0,0 @@
package org.apache.cloudstack.storage.strategy;
import java.util.List;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreEndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreEndPointSelector;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotProfile;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageEvent;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateProfile;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeStrategy;
import org.apache.cloudstack.storage.volume.VolumeManager;
import org.apache.log4j.Logger;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO;
import com.cloud.utils.component.Inject;
public class DefaultVolumeStrategy implements VolumeStrategy {
private static final Logger s_logger = Logger.getLogger(DefaultVolumeStrategy.class);
protected DataStore _ds;
protected DataStoreDriver _driver;
@Inject
VolumeManager _volumeMgr;
public VolumeProfile get(long volumeId) {
return _volumeMgr.getProfile(volumeId);
}
public DefaultVolumeStrategy(DataStore ds) {
_ds = ds;
}
public Volume createVolume(Volume vol) {
// TODO Auto-generated method stub
return null;
}
public Volume createDataVolume(Volume vol) {
// TODO Auto-generated method stub
return null;
}
public Volume copyVolumeFromBackup(VolumeProfile srcVol, Volume destVol) {
// TODO Auto-generated method stub
return null;
}
public Volume createVolumeFromSnapshot(SnapshotProfile snapshot, Volume vol) {
// TODO Auto-generated method stub
return null;
}
public Volume createVolumeFromTemplate(TemplateProfile template, Volume vol) {
// TODO Auto-generated method stub
return null;
}
public Volume migrateVolume(Volume srcVol, Volume destVol, DataStore destStore) {
// TODO Auto-generated method stub
return null;
}
public Volume createVolumeFromBaseTemplate(Volume volume, TemplateProfile tp) {
DataStoreEndPointSelector dsep = _ds.getEndPointSelector();
List<DataStoreEndPoint> dseps = dsep.getEndPoints(StorageEvent.CreateVolumeFromTemplate);
DataStoreEndPoint dp = dseps.get(0);
VolumeProfile vp = _driver.createVolumeFromTemplate(get(volume.getId()), tp, dp);
/*
VolumeVO vlvo = _volumeMgr.getVolume(volume.getId());
vlvo.setFolder(_ds.getPath());
vlvo.setPath(vp.getPath());
vlvo.setSize(vp.getSize());
vlvo.setPoolType(_ds.getPoolType());
vlvo.setPoolId(_ds.getId());
vlvo.setPodId(_ds.getPodId());
return _volumeMgr.updateVolume(vlvo);
*/
return null;
}
public boolean deleteVolume(Volume vol) {
// TODO Auto-generated method stub
return false;
}
}

View File

@ -1,12 +0,0 @@
package org.apache.cloudstack.storage.strategy;
import org.apache.cloudstack.engine.subsystem.api.storage.BackupStrategy;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
public class XenBackupStrategy implements BackupStrategy {
protected DataStore _ds;
public XenBackupStrategy(DataStore ds) {
_ds = ds;
}
}

View File

@ -1,12 +0,0 @@
package org.apache.cloudstack.storage.strategy;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy;
public class XenSnapshotStrategy implements SnapshotStrategy {
protected DataStore _ds;
public XenSnapshotStrategy(DataStore ds) {
_ds = ds;
}
}

View File

@ -7,14 +7,12 @@ import com.cloud.utils.db.Transaction;
public class AopTestAdvice {
public Object AopTestMethod(ProceedingJoinPoint call) throws Throwable {
Transaction txn = Transaction.open(call.getSignature().getName());
System.out.println(call.getSignature().getName());
Object ret = null;
try {
ret = call.proceed();
} finally {
txn.close();
}
System.out.println("end");
return ret;
}
}

View File

@ -18,7 +18,7 @@ public class ChildTestConfiguration extends TestConfiguration {
@Bean
public AgentManager agentMgr() {
return Mockito.mock(AgentManager.class);
return new DirectAgentManagerImpl();
}
/* @Override
@Bean

View File

@ -0,0 +1,193 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.test;
import java.util.Map;
import javax.naming.ConfigurationException;
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
import com.cloud.agent.StartupCommandProcessor;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.manager.AgentAttache;
import com.cloud.agent.manager.Commands;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConnectionException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.host.HostVO;
import com.cloud.host.Status.Event;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.resource.ServerResource;
public class DirectAgentManagerImpl implements AgentManager {
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean start() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean stop() {
// TODO Auto-generated method stub
return false;
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
@Override
public Answer easySend(Long hostId, Command cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public Answer send(Long hostId, Command cmd) throws AgentUnavailableException, OperationTimedoutException {
// TODO Auto-generated method stub
return null;
}
@Override
public Answer[] send(Long hostId, Commands cmds) throws AgentUnavailableException, OperationTimedoutException {
// TODO Auto-generated method stub
return null;
}
@Override
public Answer[] send(Long hostId, Commands cmds, int timeout) throws AgentUnavailableException, OperationTimedoutException {
// TODO Auto-generated method stub
return null;
}
@Override
public long send(Long hostId, Commands cmds, Listener listener) throws AgentUnavailableException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int registerForHostEvents(Listener listener, boolean connections, boolean commands, boolean priority) {
// TODO Auto-generated method stub
return 0;
}
@Override
public int registerForInitialConnects(StartupCommandProcessor creator, boolean priority) {
// TODO Auto-generated method stub
return 0;
}
@Override
public void unregisterForHostEvents(int id) {
// TODO Auto-generated method stub
}
@Override
public boolean executeUserRequest(long hostId, Event event) throws AgentUnavailableException {
// TODO Auto-generated method stub
return false;
}
@Override
public Answer sendTo(Long dcId, HypervisorType type, Command cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public void sendToSecStorage(HostVO ssHost, Command cmd, Listener listener) throws AgentUnavailableException {
// TODO Auto-generated method stub
}
@Override
public Answer sendToSecStorage(HostVO ssHost, Command cmd) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action) {
// TODO Auto-generated method stub
return false;
}
@Override
public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean agentStatusTransitTo(HostVO host, Event e, long msId) {
// TODO Auto-generated method stub
return false;
}
@Override
public AgentAttache findAttache(long hostId) {
// TODO Auto-generated method stub
return null;
}
@Override
public void disconnectWithoutInvestigation(long hostId, Event event) {
// TODO Auto-generated method stub
}
@Override
public void pullAgentToMaintenance(long hostId) {
// TODO Auto-generated method stub
}
@Override
public void pullAgentOutMaintenance(long hostId) {
// TODO Auto-generated method stub
}
@Override
public boolean reconnect(long hostId) {
// TODO Auto-generated method stub
return false;
}
@Override
public Answer sendToSSVM(Long dcId, Command cmd) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -16,10 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.snapshot;
package org.apache.cloudstack.storage.test;
public interface SnapshotService {
long takeSnapshot(long volumeId);
import static org.junit.Assert.*;
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.Test;
public class SimpleTest {
@Test
public void test() {
try {
URI u = new URI("http://myproxy.domain.com:3128");
System.out.print(u.getHost());
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
boolean deleteSnapshot(long snapshotId);
}