diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/BackupStrategy.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/BackupStrategy.java deleted file mode 100644 index d93a509a296..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/BackupStrategy.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.apache.cloudstack.engine.subsystem.api.storage; - -public interface BackupStrategy { - -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java deleted file mode 100644 index 70aca358e1d..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java +++ /dev/null @@ -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 getChidren(); - boolean lock(); - boolean unlock(); -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectBackupStorageOperationState.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectBackupStorageOperationState.java deleted file mode 100644 index 974a4002ac2..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectBackupStorageOperationState.java +++ /dev/null @@ -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 s_fsm = new StateMachine(); - 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); - } -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStore.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStore.java deleted file mode 100644 index 06580499ee8..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStore.java +++ /dev/null @@ -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(); -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreConfigurator.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreConfigurator.java deleted file mode 100644 index d9fb86b05ac..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreConfigurator.java +++ /dev/null @@ -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 configs); - List getConfigNames(); - Map getConfigs(URI uri, Map extras); - boolean validate(Map configs); - DataStore getDataStore(StoragePool pool); -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java deleted file mode 100644 index 0167f482527..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java +++ /dev/null @@ -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); -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreEndPoint.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreEndPoint.java deleted file mode 100644 index 3bdbbb5723f..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreEndPoint.java +++ /dev/null @@ -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); - } -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreEndPointSelector.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreEndPointSelector.java deleted file mode 100644 index 3328a3a3b10..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreEndPointSelector.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.apache.cloudstack.engine.subsystem.api.storage; - -import java.util.List; - -public interface DataStoreEndPointSelector { - List getEndPoints(StorageEvent event); -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreExtendedAttribute.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreExtendedAttribute.java deleted file mode 100644 index 9f6df82334d..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreExtendedAttribute.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.apache.cloudstack.engine.subsystem.api.storage; - -public interface DataStoreExtendedAttribute { - -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/FileSystem.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/FileSystem.java deleted file mode 100644 index 734fc598bca..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/FileSystem.java +++ /dev/null @@ -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); -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Snapshot.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Snapshot.java deleted file mode 100644 index f8d4b59ff01..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/Snapshot.java +++ /dev/null @@ -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 { - -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotStrategy.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotStrategy.java deleted file mode 100644 index 91bebee0fb4..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotStrategy.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.apache.cloudstack.engine.subsystem.api.storage; - -public interface SnapshotStrategy { - -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageProvider.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageProvider.java deleted file mode 100644 index 9d410934e54..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageProvider.java +++ /dev/null @@ -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 supportedHypervisors(); - String getProviderName(); - List supportedStoreTypes(); - void configure(Map storeProviderInfo); - DataStore addDataStore(StoragePool sp, String uri, Map params); - DataStore getDataStore(StoragePool pool); - Map> getDataStoreConfigs(); -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateStrategy.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateStrategy.java deleted file mode 100644 index b0458aab688..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateStrategy.java +++ /dev/null @@ -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(); -} diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeStrategy.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeStrategy.java deleted file mode 100644 index dba0077b934..00000000000 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeStrategy.java +++ /dev/null @@ -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); -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/StorageOrchestratorImpl.java b/engine/storage/src/org/apache/cloudstack/storage/StorageOrchestratorImpl.java deleted file mode 100644 index d71b72aa2ca..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/StorageOrchestratorImpl.java +++ /dev/null @@ -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 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 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 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 vols = new ArrayList(); - vols.add(volume); - - List 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; - } -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/StorageProviderManager.java b/engine/storage/src/org/apache/cloudstack/storage/StorageProviderManager.java deleted file mode 100644 index 4260115db37..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/StorageProviderManager.java +++ /dev/null @@ -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); -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/StorageProviderManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/StorageProviderManagerImpl.java deleted file mode 100644 index bbed9f44b93..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/StorageProviderManagerImpl.java +++ /dev/null @@ -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 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; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/VolumeBackupRef.java b/engine/storage/src/org/apache/cloudstack/storage/VolumeBackupRef.java deleted file mode 100644 index 4b512ba133f..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/VolumeBackupRef.java +++ /dev/null @@ -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(); -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDataStore.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDataStore.java deleted file mode 100644 index 206f917e00e..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/datastore/DefaultDataStore.java +++ /dev/null @@ -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; - } -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java index 8437872d714..bd7c878230a 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java @@ -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; diff --git a/engine/storage/src/org/apache/cloudstack/storage/driver/AbstractStorageDriver.java b/engine/storage/src/org/apache/cloudstack/storage/driver/AbstractStorageDriver.java deleted file mode 100644 index 8b7837810a2..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/driver/AbstractStorageDriver.java +++ /dev/null @@ -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; - * } - */ -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/driver/DefaultNfsSecondaryDriver.java b/engine/storage/src/org/apache/cloudstack/storage/driver/DefaultNfsSecondaryDriver.java deleted file mode 100644 index df1e0b3b05a..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/driver/DefaultNfsSecondaryDriver.java +++ /dev/null @@ -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; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/driver/XenServerStorageDriver.java b/engine/storage/src/org/apache/cloudstack/storage/driver/XenServerStorageDriver.java deleted file mode 100644 index 4b3bbe5c3b3..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/driver/XenServerStorageDriver.java +++ /dev/null @@ -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; - } -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/ImageManager.java b/engine/storage/src/org/apache/cloudstack/storage/image/ImageManager.java deleted file mode 100644 index a5b449779dd..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/image/ImageManager.java +++ /dev/null @@ -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); -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/ImageManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/ImageManagerImpl.java deleted file mode 100644 index bcf42ce6cf3..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/image/ImageManagerImpl.java +++ /dev/null @@ -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 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 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); - } -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/ImageOrchestratorImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/ImageOrchestratorImpl.java deleted file mode 100644 index 8da27b5a1d5..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/image/ImageOrchestratorImpl.java +++ /dev/null @@ -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 tpZones = _templateZoneDao.listByTemplateId(templateId); - - for (VMTemplateZoneVO tpZone : tpZones) { - DataStore imageStore = null; - List 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 - - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/lifecycle/DefaultNfsSecondaryLifeCycle.java b/engine/storage/src/org/apache/cloudstack/storage/lifecycle/DefaultNfsSecondaryLifeCycle.java deleted file mode 100644 index 4c71e436a9b..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/lifecycle/DefaultNfsSecondaryLifeCycle.java +++ /dev/null @@ -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 - - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/lifecycle/DefaultPrimaryDataStoreLifeCycle.java b/engine/storage/src/org/apache/cloudstack/storage/lifecycle/DefaultPrimaryDataStoreLifeCycle.java deleted file mode 100644 index 098c56a8020..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/lifecycle/DefaultPrimaryDataStoreLifeCycle.java +++ /dev/null @@ -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 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 poolHosts = new ArrayList(); - 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 - - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/manager/BackupStorageManager.java b/engine/storage/src/org/apache/cloudstack/storage/manager/BackupStorageManager.java deleted file mode 100644 index fe28ce9e14e..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/manager/BackupStorageManager.java +++ /dev/null @@ -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; -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/manager/BackupStorageManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/manager/BackupStorageManagerImpl.java deleted file mode 100644 index 49bc673c002..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/manager/BackupStorageManagerImpl.java +++ /dev/null @@ -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; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManager.java b/engine/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManager.java deleted file mode 100644 index 3745e6777f9..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManager.java +++ /dev/null @@ -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 params); - - void deleteStoragePool(long poolId); - - void enableStoragePool(long poolId); - - void disableStoragePool(long poolId); - - Map> getSupportedPrimaryStorages(long zoneId, HypervisorType hypervisor); - - Map> getSupportedSecondaryStorages(long zoneId); - - PrimaryDataStore getDataStore(String id); -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManagerImpl.java deleted file mode 100644 index 6c3ce746c71..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManagerImpl.java +++ /dev/null @@ -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 _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> getSupportedPrimaryStorages(long zoneId, HypervisorType hypervisor) { - // TODO Auto-generated method stub - return null; - } - - public Map> getSupportedSecondaryStorages(long zoneId) { - // TODO Auto-generated method stub - return null; - } - - protected StorageProvider findStorageProvider(String name) { - Iterator 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 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 params) { - // TODO Auto-generated method stub - return null; - } - - @Override - public PrimaryDataStore getDataStore(String id) { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/manager/SecondaryStorageManager.java b/engine/storage/src/org/apache/cloudstack/storage/manager/SecondaryStorageManager.java deleted file mode 100644 index fb6baf67a36..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/manager/SecondaryStorageManager.java +++ /dev/null @@ -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 getImageStores(long zoneId); - - DataStore getStore(Snapshot snapshot); -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/manager/SecondaryStorageManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/manager/SecondaryStorageManagerImpl.java deleted file mode 100644 index 5c58bd770e6..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/manager/SecondaryStorageManagerImpl.java +++ /dev/null @@ -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 getImageStores() { - - return null; - } - - public DataStore getStore(Snapshot snapshot) { - // TODO Auto-generated method stub - return null; - } - - public List getImageStores(long zoneId) { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/provider/DefaultNfsSecondaryStorageProvider.java b/engine/storage/src/org/apache/cloudstack/storage/provider/DefaultNfsSecondaryStorageProvider.java deleted file mode 100644 index 0d375fa4f0d..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/provider/DefaultNfsSecondaryStorageProvider.java +++ /dev/null @@ -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> _supportedProtocols; - - public boolean configure(String name, Map params) throws ConfigurationException { - Map dscs = new HashMap(); - 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 supportedHypervisors() { - List hypervisors = new ArrayList(); - Set 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 storeProviderInfo) { - // TODO Auto-generated method stub - - } - - public DataStore addDataStore(StoragePool sp, String url, Map 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 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> getDataStoreConfigs() { - // TODO Auto-generated method stub - return null; - } - - public List supportedStoreTypes() { - List types = new ArrayList(); - types.add(StoreType.Image); - types.add(StoreType.Backup); - return types; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/provider/DefaultPrimaryStorageProvider.java b/engine/storage/src/org/apache/cloudstack/storage/provider/DefaultPrimaryStorageProvider.java deleted file mode 100644 index a5f73174cd9..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/provider/DefaultPrimaryStorageProvider.java +++ /dev/null @@ -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> _supportedProtocols; - @Inject - protected ClusterDao _clusterDao; - - public List supportedHypervisors() { - List hypervisors = new ArrayList(); - hypervisors.add(Hypervisor.HypervisorType.XenServer); - return hypervisors; - } - - public DefaultPrimaryStorageProvider() { - Map dscs = new HashMap(); - DataStoreConfigurator nfsdc = null; - dscs.put(nfsdc.getProtocol(), nfsdc); - - _supportedProtocols.put(HypervisorType.XenServer, dscs); - } - - public List supportedStoreType() { - List type = new ArrayList(); - type.add(StoreType.Primary); - return type; - } - - public void configure(Map storeProviderInfo) { - // TODO Auto-generated method stub - - } - - public Map> 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 dscs = _supportedProtocols.get(hy); - DataStoreConfigurator dsc = dscs.get(pool.getPoolType().toString()); - return dsc.getDataStore(pool); - } - - public boolean configure(String name, Map 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 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 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 configs = dsc.getConfigs(uri, params); - dsc.validate(configs); - DataStore ds = dsc.getDataStore(spool); - - return ds; - } - - public List supportedStoreTypes() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/provider/HttpImageStoreProvider.java b/engine/storage/src/org/apache/cloudstack/storage/provider/HttpImageStoreProvider.java deleted file mode 100644 index 846ff7a6bdc..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/provider/HttpImageStoreProvider.java +++ /dev/null @@ -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 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 supportedHypervisors() { - // TODO Auto-generated method stub - return null; - } - - public String getProviderName() { - // TODO Auto-generated method stub - return null; - } - - public List supportedStoreTypes() { - // TODO Auto-generated method stub - return null; - } - - public void configure(Map storeProviderInfo) { - // TODO Auto-generated method stub - - } - - public DataStore addDataStore(StoragePool sp, String uri, Map params) { - // TODO Auto-generated method stub - return null; - } - - public DataStore getDataStore(StoragePool pool) { - // TODO Auto-generated method stub - return null; - } - - public Map> getDataStoreConfigs() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/provider/S3SecondaryStorageProvider.java b/engine/storage/src/org/apache/cloudstack/storage/provider/S3SecondaryStorageProvider.java deleted file mode 100644 index d21e5e03d94..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/provider/S3SecondaryStorageProvider.java +++ /dev/null @@ -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 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 supportedHypervisors() { - // TODO Auto-generated method stub - return null; - } - - public String getProviderName() { - // TODO Auto-generated method stub - return null; - } - - public List supportedStoreTypes() { - // TODO Auto-generated method stub - return null; - } - - public void configure(Map storeProviderInfo) { - // TODO Auto-generated method stub - - } - - public DataStore addDataStore(StoragePool sp, String uri, Map params) { - // TODO Auto-generated method stub - return null; - } - - public DataStore getDataStore(StoragePool pool) { - // TODO Auto-generated method stub - return null; - } - - public Map> getDataStoreConfigs() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/provider/SwiftSecondaryStorageProvider.java b/engine/storage/src/org/apache/cloudstack/storage/provider/SwiftSecondaryStorageProvider.java deleted file mode 100644 index c62b8b1d050..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/provider/SwiftSecondaryStorageProvider.java +++ /dev/null @@ -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 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 supportedHypervisors() { - // TODO Auto-generated method stub - return null; - } - - public String getProviderName() { - // TODO Auto-generated method stub - return null; - } - - public List supportedStoreTypes() { - // TODO Auto-generated method stub - return null; - } - - public void configure(Map storeProviderInfo) { - // TODO Auto-generated method stub - - } - - public DataStore addDataStore(StoragePool sp, String uri, Map params) { - // TODO Auto-generated method stub - return null; - } - - public DataStore getDataStore(StoragePool pool) { - // TODO Auto-generated method stub - return null; - } - - public Map> getDataStoreConfigs() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/strategy/DefaultTemplateStratey.java b/engine/storage/src/org/apache/cloudstack/storage/strategy/DefaultTemplateStratey.java deleted file mode 100644 index 8c2339f36fc..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/strategy/DefaultTemplateStratey.java +++ /dev/null @@ -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 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 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 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; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/strategy/DefaultVolumeStrategy.java b/engine/storage/src/org/apache/cloudstack/storage/strategy/DefaultVolumeStrategy.java deleted file mode 100644 index 0f8410907cb..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/strategy/DefaultVolumeStrategy.java +++ /dev/null @@ -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 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; - } - -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/strategy/XenBackupStrategy.java b/engine/storage/src/org/apache/cloudstack/storage/strategy/XenBackupStrategy.java deleted file mode 100644 index 86953f476f6..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/strategy/XenBackupStrategy.java +++ /dev/null @@ -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; - } -} diff --git a/engine/storage/src/org/apache/cloudstack/storage/strategy/XenSnapshotStrategy.java b/engine/storage/src/org/apache/cloudstack/storage/strategy/XenSnapshotStrategy.java deleted file mode 100644 index 32581dde721..00000000000 --- a/engine/storage/src/org/apache/cloudstack/storage/strategy/XenSnapshotStrategy.java +++ /dev/null @@ -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; - } -} diff --git a/engine/storage/test/org/apache/cloudstack/storage/test/AopTestAdvice.java b/engine/storage/test/org/apache/cloudstack/storage/test/AopTestAdvice.java index 9bdec741eb1..ba356e3e6b5 100644 --- a/engine/storage/test/org/apache/cloudstack/storage/test/AopTestAdvice.java +++ b/engine/storage/test/org/apache/cloudstack/storage/test/AopTestAdvice.java @@ -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; } } diff --git a/engine/storage/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java b/engine/storage/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java index 9077a5a7e38..51679ba88f9 100644 --- a/engine/storage/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java +++ b/engine/storage/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java @@ -18,7 +18,7 @@ public class ChildTestConfiguration extends TestConfiguration { @Bean public AgentManager agentMgr() { - return Mockito.mock(AgentManager.class); + return new DirectAgentManagerImpl(); } /* @Override @Bean diff --git a/engine/storage/test/org/apache/cloudstack/storage/test/DirectAgentManagerImpl.java b/engine/storage/test/org/apache/cloudstack/storage/test/DirectAgentManagerImpl.java new file mode 100644 index 00000000000..13454106cc0 --- /dev/null +++ b/engine/storage/test/org/apache/cloudstack/storage/test/DirectAgentManagerImpl.java @@ -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 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; + } + +} diff --git a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotService.java b/engine/storage/test/org/apache/cloudstack/storage/test/SimpleTest.java similarity index 66% rename from engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotService.java rename to engine/storage/test/org/apache/cloudstack/storage/test/SimpleTest.java index d13582ce045..a9b3f93f446 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotService.java +++ b/engine/storage/test/org/apache/cloudstack/storage/test/SimpleTest.java @@ -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); }