You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2012/11/28 04:17:38 UTC
[1/6] git commit: seperate code into different modules: storage,
storage/volume, storage/image, storage/snapshot, storage/backup,
storage/integration-test
Updated Branches:
refs/heads/javelin 487a0ac43 -> 225ad3c28
seperate code into different modules: storage, storage/volume, storage/image, storage/snapshot, storage/backup, storage/integration-test
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/225ad3c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/225ad3c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/225ad3c2
Branch: refs/heads/javelin
Commit: 225ad3c289f22da72d9a90ccd8472087fc1030d4
Parents: 487a0ac
Author: Edison Su <ed...@citrix.com>
Authored: Tue Nov 27 19:16:28 2012 -0800
Committer: Edison Su <ed...@citrix.com>
Committed: Tue Nov 27 19:16:28 2012 -0800
----------------------------------------------------------------------
engine/pom.xml | 7 +-
engine/storage/backup/pom.xml | 50 ++
.../storage/backup/BackupMotionService.java | 23 +
.../cloudstack/storage/backup/BackupService.java | 25 +
engine/storage/image/pom.xml | 50 ++
.../storage/image/ImageOrchestrator.java | 29 ++
.../cloudstack/storage/image/ImageService.java | 42 ++
.../cloudstack/storage/image/ImageServiceImpl.java | 91 ++++
.../cloudstack/storage/image/TemplateObject.java | 61 +++
.../storage/image/downloader/ImageDownloader.java | 25 +
.../storage/image/driver/ImageDataStoreDriver.java | 31 ++
.../image/driver/ImageDataStoreDriverImpl.java | 52 ++
.../image/manager/ImageDataStoreManager.java | 25 +
.../image/manager/ImageDataStoreManagerImpl.java | 41 ++
.../image/motion/DefaultImageMotionStrategy.java | 51 ++
.../image/motion/ImageMotionServiceImpl.java | 74 +++
.../storage/image/motion/ImageMotionStrategy.java | 30 ++
.../provider/DefaultImageDataStoreProvider.java | 82 ++++
.../image/provider/ImageDataStoreProvider.java | 33 ++
.../provider/ImageDataStoreProviderManager.java | 39 ++
.../ImageDataStoreProviderManagerImpl.java | 135 ++++++
.../storage/image/store/ImageDataStore.java | 39 ++
.../storage/image/store/ImageDataStoreImpl.java | 104 ++++
.../store/lifecycle/ImageDataStoreLifeCycle.java | 27 ++
engine/storage/integration-test/pom.xml | 85 ++++
.../apache/cloudstack/storage/test/AllTests.java | 29 ++
.../apache/cloudstack/storage/test/AopTest.java | 14 +
.../cloudstack/storage/test/AopTestAdvice.java | 18 +
.../storage/test/ChildTestConfiguration.java | 28 ++
.../storage/test/DirectAgentManagerImpl.java | 193 ++++++++
.../apache/cloudstack/storage/test/Future2.java | 114 +++++
.../apache/cloudstack/storage/test/SimpleTest.java | 41 ++
.../storage/test/StorageFactoryBean.java | 42 ++
.../cloudstack/storage/test/StorageTest.java | 20 +
.../cloudstack/storage/test/TestConfiguration.java | 21 +
.../cloudstack/storage/test/XenEndpoint.java | 5 +
.../cloudstack/storage/test/volumeServiceTest.java | 299 ++++++++++++
.../test/resource/storageContext.xml | 42 ++
engine/storage/pom.xml | 37 +-
engine/storage/snapshot/pom.xml | 50 ++
.../storage/backup/BackupMotionService.java | 23 -
.../cloudstack/storage/backup/BackupService.java | 25 -
.../storage/datastore/DataStoreStatus.java | 23 -
.../datastore/DefaultPrimaryDataStoreImpl.java | 183 --------
.../storage/datastore/PrimaryDataStore.java | 3 -
.../datastore/PrimaryDataStoreInfoImpl.java | 80 ----
.../storage/datastore/db/PrimaryDataStoreDao.java | 116 -----
.../datastore/db/PrimaryDataStoreDaoImpl.java | 365 ---------------
.../datastore/db/PrimaryDataStoreDetailVO.java | 79 ----
.../datastore/db/PrimaryDataStoreDetailsDao.java | 28 --
.../db/PrimaryDataStoreDetailsDaoImpl.java | 71 ---
.../datastore/db/PrimaryDataStoreProviderDao.java | 25 -
.../db/PrimaryDataStoreProviderDaoImpl.java | 38 --
.../datastore/db/PrimaryDataStoreProviderVO.java | 49 --
.../storage/datastore/db/PrimaryDataStoreVO.java | 256 ----------
.../driver/DefaultPrimaryDataStoreDriverImpl.java | 112 -----
.../datastore/driver/PrimaryDataStoreDriver.java | 17 -
.../DefaultPrimaryDataStoreLifeCycleImpl.java | 130 -----
.../lifecycle/PrimaryDataStoreLifeCycle.java | 39 --
.../DefaultPrimaryDataStoreManagerImpl.java | 56 ---
.../datastore/manager/PrimaryDataStoreManager.java | 28 --
.../DefaultPrimaryDatastoreProviderImpl.java | 81 ----
.../provider/PrimaryDataStoreProvider.java | 18 -
.../provider/PrimaryDataStoreProviderManager.java | 11 -
.../PrimaryDataStoreProviderManagerImpl.java | 103 ----
.../storage/datastore/type/DataStoreType.java | 23 -
.../cloudstack/storage/datastore/type/ISCSI.java | 32 --
.../storage/datastore/type/NetworkFileSystem.java | 32 --
.../storage/datastore/type/SharedMount.java | 30 --
.../storage/image/ImageOrchestrator.java | 29 --
.../cloudstack/storage/image/ImageService.java | 42 --
.../cloudstack/storage/image/ImageServiceImpl.java | 91 ----
.../cloudstack/storage/image/TemplateObject.java | 61 ---
.../storage/image/downloader/ImageDownloader.java | 25 -
.../storage/image/driver/ImageDataStoreDriver.java | 31 --
.../image/driver/ImageDataStoreDriverImpl.java | 52 --
.../image/manager/ImageDataStoreManager.java | 25 -
.../image/manager/ImageDataStoreManagerImpl.java | 42 --
.../image/motion/DefaultImageMotionStrategy.java | 51 --
.../image/motion/ImageMotionServiceImpl.java | 74 ---
.../storage/image/motion/ImageMotionStrategy.java | 30 --
.../provider/DefaultImageDataStoreProvider.java | 82 ----
.../image/provider/ImageDataStoreProvider.java | 33 --
.../provider/ImageDataStoreProviderManager.java | 39 --
.../ImageDataStoreProviderManagerImpl.java | 135 ------
.../storage/image/store/ImageDataStore.java | 39 --
.../storage/image/store/ImageDataStoreImpl.java | 104 ----
.../store/lifecycle/ImageDataStoreLifeCycle.java | 27 --
.../volume/TemplateOnPrimaryDataStoreObject.java | 67 ---
.../volume/TemplatePrimaryDataStoreManager.java | 28 --
.../TemplatePrimaryDataStoreManagerImpl.java | 62 ---
.../cloudstack/storage/volume/VolumeManager.java | 45 --
.../storage/volume/VolumeManagerImpl.java | 103 ----
.../storage/volume/VolumeMotionService.java | 23 -
.../cloudstack/storage/volume/VolumeObject.java | 143 ------
.../storage/volume/VolumeServiceImpl.java | 187 --------
.../apache/cloudstack/storage/test/AllTests.java | 29 --
.../apache/cloudstack/storage/test/AopTest.java | 14 -
.../cloudstack/storage/test/AopTestAdvice.java | 18 -
.../storage/test/ChildTestConfiguration.java | 28 --
.../storage/test/DirectAgentManagerImpl.java | 193 --------
.../apache/cloudstack/storage/test/Future2.java | 114 -----
.../apache/cloudstack/storage/test/SimpleTest.java | 41 --
.../storage/test/StorageFactoryBean.java | 42 --
.../cloudstack/storage/test/StorageTest.java | 20 -
.../cloudstack/storage/test/TestConfiguration.java | 21 -
.../cloudstack/storage/test/XenEndpoint.java | 5 -
.../cloudstack/storage/test/volumeServiceTest.java | 294 ------------
engine/storage/test/resource/storageContext.xml | 42 --
engine/storage/volume/pom.xml | 50 ++
.../storage/datastore/DataStoreStatus.java | 23 +
.../datastore/DefaultPrimaryDataStoreImpl.java | 171 +++++++
.../datastore/PrimaryDataStoreInfoImpl.java | 80 ++++
.../storage/datastore/db/PrimaryDataStoreDao.java | 116 +++++
.../datastore/db/PrimaryDataStoreDaoImpl.java | 365 +++++++++++++++
.../datastore/db/PrimaryDataStoreDetailVO.java | 79 ++++
.../datastore/db/PrimaryDataStoreDetailsDao.java | 28 ++
.../db/PrimaryDataStoreDetailsDaoImpl.java | 71 +++
.../datastore/db/PrimaryDataStoreProviderDao.java | 25 +
.../db/PrimaryDataStoreProviderDaoImpl.java | 38 ++
.../datastore/db/PrimaryDataStoreProviderVO.java | 49 ++
.../storage/datastore/db/PrimaryDataStoreVO.java | 256 ++++++++++
.../driver/DefaultPrimaryDataStoreDriverImpl.java | 112 +++++
.../datastore/driver/PrimaryDataStoreDriver.java | 17 +
.../DefaultPrimaryDataStoreLifeCycleImpl.java | 130 +++++
.../lifecycle/PrimaryDataStoreLifeCycle.java | 39 ++
.../DefaultPrimaryDataStoreManagerImpl.java | 56 +++
.../datastore/manager/PrimaryDataStoreManager.java | 28 ++
.../DefaultPrimaryDatastoreProviderImpl.java | 81 ++++
.../provider/PrimaryDataStoreProvider.java | 18 +
.../provider/PrimaryDataStoreProviderManager.java | 11 +
.../PrimaryDataStoreProviderManagerImpl.java | 103 ++++
.../storage/datastore/type/DataStoreType.java | 23 +
.../cloudstack/storage/datastore/type/ISCSI.java | 32 ++
.../storage/datastore/type/NetworkFileSystem.java | 32 ++
.../storage/datastore/type/SharedMount.java | 30 ++
.../volume/TemplateOnPrimaryDataStoreObject.java | 67 +++
.../volume/TemplatePrimaryDataStoreManager.java | 28 ++
.../TemplatePrimaryDataStoreManagerImpl.java | 62 +++
.../cloudstack/storage/volume/VolumeManager.java | 45 ++
.../storage/volume/VolumeManagerImpl.java | 103 ++++
.../storage/volume/VolumeMotionService.java | 23 +
.../cloudstack/storage/volume/VolumeObject.java | 143 ++++++
.../storage/volume/VolumeServiceImpl.java | 187 ++++++++
144 files changed, 4903 insertions(+), 4629 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/pom.xml
----------------------------------------------------------------------
diff --git a/engine/pom.xml b/engine/pom.xml
index f35c14b..38c1d6b 100644
--- a/engine/pom.xml
+++ b/engine/pom.xml
@@ -37,9 +37,14 @@
<module>compute</module>
<module>orchestration</module>
<module>storage</module>
+ <module>storage/volume</module>
+ <module>storage/image</module>
+ <module>storage/backup</module>
+ <module>storage/snapshot</module>
+ <module>storage/integration-test</module>
<module>components-api</module>
<module>schema</module>
<module>network</module>
<module>service</module>
</modules>
-</project>
\ No newline at end of file
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/backup/pom.xml
----------------------------------------------------------------------
diff --git a/engine/storage/backup/pom.xml b/engine/storage/backup/pom.xml
new file mode 100644
index 0000000..8b4fd27
--- /dev/null
+++ b/engine/storage/backup/pom.xml
@@ -0,0 +1,50 @@
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cloud-engine-storage-backup</artifactId>
+ <name>Apache CloudStack Engine Storage Backup Component</name>
+ <parent>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-storage</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>${cs.mysql.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <sourceDirectory>src</sourceDirectory>
+ <testSourceDirectory>test</testSourceDirectory>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/backup/src/org/apache/cloudstack/storage/backup/BackupMotionService.java
----------------------------------------------------------------------
diff --git a/engine/storage/backup/src/org/apache/cloudstack/storage/backup/BackupMotionService.java b/engine/storage/backup/src/org/apache/cloudstack/storage/backup/BackupMotionService.java
new file mode 100644
index 0000000..cb49027
--- /dev/null
+++ b/engine/storage/backup/src/org/apache/cloudstack/storage/backup/BackupMotionService.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.backup;
+
+public interface BackupMotionService {
+ boolean copySnapshot(String snapshotUri, String destSnapshotUri);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/backup/src/org/apache/cloudstack/storage/backup/BackupService.java
----------------------------------------------------------------------
diff --git a/engine/storage/backup/src/org/apache/cloudstack/storage/backup/BackupService.java b/engine/storage/backup/src/org/apache/cloudstack/storage/backup/BackupService.java
new file mode 100644
index 0000000..ebb4c9f
--- /dev/null
+++ b/engine/storage/backup/src/org/apache/cloudstack/storage/backup/BackupService.java
@@ -0,0 +1,25 @@
+/*
+ * 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.backup;
+
+public interface BackupService {
+ String grantAccessSnapshot(long snapshotId, long endpointId);
+
+ boolean revokeAccessSnapshot(long snapshotId, long endpointId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/pom.xml
----------------------------------------------------------------------
diff --git a/engine/storage/image/pom.xml b/engine/storage/image/pom.xml
new file mode 100644
index 0000000..c05714b
--- /dev/null
+++ b/engine/storage/image/pom.xml
@@ -0,0 +1,50 @@
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cloud-engine-storage-image</artifactId>
+ <name>Apache CloudStack Engine Storage Image Component</name>
+ <parent>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-storage</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>${cs.mysql.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <sourceDirectory>src</sourceDirectory>
+ <testSourceDirectory>test</testSourceDirectory>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageOrchestrator.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageOrchestrator.java
new file mode 100644
index 0000000..e4141f3
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageOrchestrator.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image;
+
+public interface ImageOrchestrator {
+ void registerTemplate(long templateId);
+
+ void registerSnapshot(long snapshotId);
+
+ void registerVolume(long volumeId);
+
+ void registerIso(long isoId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageService.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageService.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageService.java
new file mode 100644
index 0000000..d657715
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageService.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image;
+
+import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+
+public interface ImageService {
+ TemplateEntity registerTemplate(long templateId, long imageStoreId);
+
+ boolean deleteTemplate(long templateId);
+
+ long registerIso(String isoUrl, long accountId);
+
+ boolean deleteIso(long isoId);
+
+ boolean grantTemplateAccess(TemplateInfo template, EndPoint endpointId);
+
+ boolean revokeTemplateAccess(long templateId, long endpointId);
+
+ String grantIsoAccess(long isoId, long endpointId);
+
+ boolean revokeIsoAccess(long isoId, long endpointId);
+
+ TemplateEntity getTemplateEntity(long templateId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageServiceImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageServiceImpl.java
new file mode 100644
index 0000000..38f669b
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/ImageServiceImpl.java
@@ -0,0 +1,91 @@
+/*
+ * 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 javax.inject.Inject;
+
+import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
+import org.apache.cloudstack.storage.image.manager.ImageDataStoreManager;
+import org.apache.cloudstack.storage.image.provider.ImageDataStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ImageServiceImpl implements ImageService {
+ @Inject
+ ImageDataStoreProviderManager imageStoreProviderMgr;
+
+ @Override
+ public TemplateEntity registerTemplate(long templateId, long imageStoreId) {
+ ImageDataStore ids = imageStoreProviderMgr.getDataStore(imageStoreId);
+ TemplateObject to = ids.registerTemplate(templateId);
+ return new TemplateEntityImpl(to);
+ }
+
+ @Override
+ public boolean deleteTemplate(long templateId) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public long registerIso(String isoUrl, long accountId) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean deleteIso(long isoId) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean revokeTemplateAccess(long templateId, long endpointId) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String grantIsoAccess(long isoId, long endpointId) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean revokeIsoAccess(long isoId, long endpointId) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public TemplateEntity getTemplateEntity(long templateId) {
+ ImageDataStore dataStore = imageStoreProviderMgr.getDataStoreFromTemplateId(templateId);
+ TemplateObject to = dataStore.getTemplate(templateId);
+ return new TemplateEntityImpl(to);
+ }
+
+ @Override
+ public boolean grantTemplateAccess(TemplateInfo template, EndPoint endpointId) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateObject.java
new file mode 100644
index 0000000..5d65a3a
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateObject.java
@@ -0,0 +1,61 @@
+/*
+ * 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.disktype.VolumeDiskType;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTypeHelper;
+import org.apache.cloudstack.storage.image.db.ImageDataVO;
+import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
+
+public class TemplateObject implements TemplateInfo {
+ private ImageDataVO imageVO;
+ private ImageDataStoreInfo dataStore;
+
+ public TemplateObject(ImageDataVO template, ImageDataStoreInfo dataStore) {
+ this.imageVO = template;
+ this.dataStore = dataStore;
+ }
+
+ @Override
+ public ImageDataStoreInfo getImageDataStore() {
+ return this.dataStore;
+ }
+
+ @Override
+ public long getId() {
+ return this.imageVO.getId();
+ }
+
+ @Override
+ public VolumeDiskType getDiskType() {
+ return VolumeDiskTypeHelper.getDiskType(imageVO.getFormat());
+ }
+
+ @Override
+ public String getPath() {
+ //TODO: add installation path if it's downloaded to cache storage already
+ return this.imageVO.getUrl();
+ }
+
+ @Override
+ public String getUuid() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/downloader/ImageDownloader.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/downloader/ImageDownloader.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/downloader/ImageDownloader.java
new file mode 100644
index 0000000..adb247a
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/downloader/ImageDownloader.java
@@ -0,0 +1,25 @@
+/*
+ * 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.downloader;
+
+import org.apache.cloudstack.storage.image.TemplateInfo;
+
+public interface ImageDownloader {
+ public void downloadImage(TemplateInfo template);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriver.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriver.java
new file mode 100644
index 0000000..42e52e5
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriver.java
@@ -0,0 +1,31 @@
+/*
+ * 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.driver;
+
+import org.apache.cloudstack.storage.image.TemplateInfo;
+
+public interface ImageDataStoreDriver {
+ boolean registerTemplate(TemplateInfo template);
+
+ String grantAccess(long templateId, long endPointId);
+
+ boolean revokeAccess(long templateId, long endPointId);
+
+ boolean deleteTemplate(TemplateInfo template);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriverImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriverImpl.java
new file mode 100644
index 0000000..e395cf1
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/ImageDataStoreDriverImpl.java
@@ -0,0 +1,52 @@
+/*
+ * 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.driver;
+
+import org.apache.cloudstack.storage.image.TemplateInfo;
+
+public class ImageDataStoreDriverImpl implements ImageDataStoreDriver {
+
+ public ImageDataStoreDriverImpl() {
+ }
+
+ @Override
+ public boolean registerTemplate(TemplateInfo template) {
+ // TODO: check the availability of template
+ return true;
+ }
+
+ @Override
+ public String grantAccess(long templateId, long endPointId) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean revokeAccess(long templateId, long endPointId) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean deleteTemplate(TemplateInfo template) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManager.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManager.java
new file mode 100644
index 0000000..e1dce50
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManager.java
@@ -0,0 +1,25 @@
+/*
+ * 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.manager;
+
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+
+public interface ImageDataStoreManager {
+ ImageDataStore getImageDataStore(long dataStoreId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
new file mode 100644
index 0000000..8183958
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
@@ -0,0 +1,41 @@
+/*
+ * 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.manager;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
+import org.apache.cloudstack.storage.image.db.ImageDataDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+
+public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
+ @Inject
+ ImageDataStoreDao dataStoreDao;
+ @Inject
+ ImageDataDao imageDataDao;
+
+ @Override
+ public ImageDataStore getImageDataStore(long dataStoreId) {
+ ImageDataStoreVO dataStore = dataStoreDao.findById(dataStoreId);
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
new file mode 100644
index 0000000..625cdc9
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
@@ -0,0 +1,51 @@
+/*
+ * 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.motion;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.storage.command.CopyTemplateToPrimaryStorage;
+import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
+import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DefaultImageMotionStrategy implements ImageMotionStrategy {
+
+ @Override
+ public boolean canHandle(TemplateOnPrimaryDataStoreInfo templateStore) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ @Override
+ public EndPoint getEndPoint(TemplateOnPrimaryDataStoreInfo templateStore) {
+ PrimaryDataStoreInfo pdi = templateStore.getPrimaryDataStore();
+ return pdi.getEndPoints().get(0);
+ }
+
+ @Override
+ public boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore, EndPoint ep) {
+ ImageOnPrimayDataStoreTO imageTo = new ImageOnPrimayDataStoreTO(templateStore);
+ CopyTemplateToPrimaryStorage copyCommand = new CopyTemplateToPrimaryStorage(imageTo);
+ ep.sendMessage(copyCommand);
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
new file mode 100644
index 0000000..3cf5efc
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
@@ -0,0 +1,74 @@
+/*
+ * 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.motion;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.image.ImageService;
+import org.apache.cloudstack.storage.image.TemplateInfo;
+import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
+import org.apache.cloudstack.storage.volume.VolumeService;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+public class ImageMotionServiceImpl implements ImageMotionService {
+ @Inject
+ List<ImageMotionStrategy> motionStrategies;
+ @Inject
+ VolumeService volumeService;
+ @Inject
+ ImageService imageService;
+
+ @Override
+ public boolean copyIso(String isoUri, String destIsoUri) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore) {
+ ImageMotionStrategy ims = null;
+ for (ImageMotionStrategy strategy : motionStrategies) {
+ if (strategy.canHandle(templateStore)) {
+ ims = strategy;
+ break;
+ }
+ }
+
+ if (ims == null) {
+ throw new CloudRuntimeException("Can't find proper image motion strategy");
+ }
+
+ EndPoint ep = ims.getEndPoint(templateStore);
+
+ volumeService.grantAccess(templateStore, ep);
+ TemplateInfo template = templateStore.getTemplate();
+ imageService.grantTemplateAccess(template, ep);
+ return ims.copyTemplate(templateStore, ep);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/ImageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/ImageMotionStrategy.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/ImageMotionStrategy.java
new file mode 100644
index 0000000..e1df9e2
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/motion/ImageMotionStrategy.java
@@ -0,0 +1,30 @@
+/*
+ * 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.motion;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
+
+public interface ImageMotionStrategy {
+ public boolean canHandle(TemplateOnPrimaryDataStoreInfo templateStore);
+
+ public EndPoint getEndPoint(TemplateOnPrimaryDataStoreInfo templateStore);
+
+ public boolean copyTemplate(TemplateOnPrimaryDataStoreInfo templateStore, EndPoint ep);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/DefaultImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/DefaultImageDataStoreProvider.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/DefaultImageDataStoreProvider.java
new file mode 100644
index 0000000..585c54b
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/DefaultImageDataStoreProvider.java
@@ -0,0 +1,82 @@
+/*
+ * 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.provider;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreProviderDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreProviderVO;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
+import org.apache.cloudstack.storage.image.driver.ImageDataStoreDriver;
+import org.apache.cloudstack.storage.image.driver.ImageDataStoreDriverImpl;
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+import org.apache.cloudstack.storage.image.store.ImageDataStoreImpl;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.component.ComponentInject;
+
+@Component
+public class DefaultImageDataStoreProvider implements ImageDataStoreProvider {
+ private final String providerName = "DefaultProvider";
+ @Inject
+ ImageDataStoreProviderDao providerDao;
+ @Inject
+ ImageDataStoreDao imageStoreDao;
+ ImageDataStoreProviderVO provider;
+
+ @Override
+ public ImageDataStore getImageDataStore(long imageStoreId) {
+ ImageDataStoreVO idsv = imageStoreDao.findById(imageStoreId);
+ ImageDataStoreDriver driver = new ImageDataStoreDriverImpl();
+ ImageDataStore ids = new ImageDataStoreImpl(idsv, driver, false, null);
+ ids = ComponentInject.inject(ids);
+ return ids;
+ }
+
+ @Override
+ public String getName() {
+ return providerName;
+ }
+
+ @Override
+ public boolean register(long providerId) {
+ return true;
+ }
+
+ @Override
+ public boolean init() {
+ provider = providerDao.findByName(providerName);
+ return true;
+ }
+
+ @Override
+ public ImageDataStore registerDataStore(String name, Map<String, String> params) {
+ ImageDataStoreVO dataStore = imageStoreDao.findByName(name);
+ if (dataStore == null) {
+ dataStore = new ImageDataStoreVO();
+ dataStore.setName(name);
+ dataStore.setProvider(provider.getId());
+ dataStore = imageStoreDao.persist(dataStore);
+ }
+ return getImageDataStore(dataStore.getId());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
new file mode 100644
index 0000000..76ab340
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
@@ -0,0 +1,33 @@
+/*
+ * 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.provider;
+
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
+
+public interface ImageDataStoreProvider extends ImageDataStoreLifeCycle {
+ ImageDataStore getImageDataStore(long imageStoreId);
+ boolean register(long providerId);
+ public String getName();
+ /**
+ * @param providerId
+ * @return
+ */
+ boolean init();
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManager.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManager.java
new file mode 100644
index 0000000..f03a0e1
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManager.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.provider;
+
+import java.util.List;
+
+import org.apache.cloudstack.storage.image.TemplateObject;
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+
+import com.cloud.utils.component.Manager;
+
+public interface ImageDataStoreProviderManager extends Manager {
+ public ImageDataStoreProvider getProvider(long providerId);
+ public List<ImageDataStoreProvider> listProvider();
+ public ImageDataStore getDataStore(Long dataStoreId);
+
+ public ImageDataStore getDataStoreFromTemplateId(long templateId);
+ /**
+ * @param name
+ * @return
+ */
+ ImageDataStoreProvider getProvider(String name);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManagerImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManagerImpl.java
new file mode 100644
index 0000000..32f800c
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManagerImpl.java
@@ -0,0 +1,135 @@
+/*
+ * 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.provider;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.cloudstack.storage.image.db.ImageDataDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreProviderDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreProviderVO;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
+import org.apache.cloudstack.storage.image.db.ImageDataVO;
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ImageDataStoreProviderManagerImpl implements ImageDataStoreProviderManager {
+ @Inject
+ ImageDataStoreProviderDao providerDao;
+ @Inject
+ ImageDataStoreDao dataStoreDao;
+ @Inject
+ ImageDataDao imageDataDao;
+ @Inject
+ List<ImageDataStoreProvider> providers;
+
+ @Override
+ public ImageDataStoreProvider getProvider(long providerId) {
+
+ return null;
+ }
+
+ @Override
+ public ImageDataStoreProvider getProvider(String name) {
+ for (ImageDataStoreProvider provider : providers) {
+ if (provider.getName().equalsIgnoreCase(name)) {
+ return provider;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ImageDataStore getDataStore(Long dataStoreId) {
+ if (dataStoreId == null) {
+ return null;
+ }
+
+ ImageDataStoreVO idsv = dataStoreDao.findById(dataStoreId);
+ if (idsv == null) {
+ return null;
+ }
+
+ long providerId = idsv.getProvider();
+ ImageDataStoreProviderVO idspv = providerDao.findById(providerId);
+ ImageDataStoreProvider provider = getProvider(idspv.getName());
+ return provider.getImageDataStore(dataStoreId);
+ }
+
+ @Override
+ public ImageDataStore getDataStoreFromTemplateId(long templateId) {
+ ImageDataVO iddv = imageDataDao.findById(templateId);
+ return getDataStore(iddv.getImageDataStoreId());
+ }
+
+ @Override
+ public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+ List<ImageDataStoreProviderVO> existingProviders = providerDao.listAll();
+ //TODO: hold global lock
+ boolean foundExistingProvider = false;
+ for (ImageDataStoreProvider provider : providers) {
+ foundExistingProvider = false;
+ for (ImageDataStoreProviderVO existingProvider : existingProviders) {
+ if (provider.getName().equalsIgnoreCase(existingProvider.getName())) {
+ foundExistingProvider = true;
+ break;
+ }
+ }
+
+ if (!foundExistingProvider) {
+ //add a new provider into db
+ ImageDataStoreProviderVO nProvider = new ImageDataStoreProviderVO();
+ nProvider.setName(provider.getName());
+ nProvider = providerDao.persist(nProvider);
+ provider.register(nProvider.getId());
+ }
+ provider.init();
+ }
+
+ return true;
+ }
+
+ @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 List<ImageDataStoreProvider> listProvider() {
+ return providers;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStore.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStore.java
new file mode 100644
index 0000000..6e97c83
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStore.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.store;
+
+import org.apache.cloudstack.storage.image.TemplateInfo;
+import org.apache.cloudstack.storage.image.TemplateObject;
+import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
+
+public interface ImageDataStore extends ImageDataStoreInfo {
+ TemplateObject registerTemplate(long templateId);
+
+ String grantAccess(long templateId, long endPointId);
+
+ boolean revokeAccess(long templateId, long endPointId);
+
+ boolean deleteTemplate(long templateId);
+
+ boolean needDownloadToCacheStorage();
+
+ ImageDownloader getImageDownloader();
+
+ TemplateObject getTemplate(long templateId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStoreImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStoreImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStoreImpl.java
new file mode 100644
index 0000000..5ba91f7
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStoreImpl.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.store;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.storage.image.TemplateInfo;
+import org.apache.cloudstack.storage.image.TemplateObject;
+import org.apache.cloudstack.storage.image.db.ImageDataDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
+import org.apache.cloudstack.storage.image.db.ImageDataVO;
+import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
+import org.apache.cloudstack.storage.image.driver.ImageDataStoreDriver;
+
+public class ImageDataStoreImpl implements ImageDataStore {
+ @Inject
+ ImageDataDao imageDao;
+ ImageDataStoreDriver driver;
+ ImageDownloader downloader;
+ ImageDataStoreVO imageDataStoreVO;
+ boolean needDownloadToCacheStorage = false;
+
+ public ImageDataStoreImpl(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver driver, boolean needDownloadToCacheStorage, ImageDownloader downloader) {
+ this.driver = driver;
+ this.needDownloadToCacheStorage = needDownloadToCacheStorage;
+ this.downloader = downloader;
+ this.imageDataStoreVO = dataStoreVO;
+ }
+
+ /*
+ * @Override public TemplateInfo registerTemplate(long templateId) {
+ * ImageDataVO idv = imageDao.findById(templateId); TemplateInfo template =
+ * new TemplateInfo(this, idv); if (driver.registerTemplate(template)) {
+ * template.setImageDataStoreId(imageDataStoreVO.getId()); return template;
+ * } else { return null; } }
+ */
+
+ @Override
+ public String grantAccess(long templateId, long endPointId) {
+ ImageDataVO idv = imageDao.findById(templateId);
+ return idv.getUrl();
+ }
+
+ @Override
+ public boolean revokeAccess(long templateId, long endPointId) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean deleteTemplate(long templateId) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean needDownloadToCacheStorage() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public ImageDownloader getImageDownloader() {
+ return this.downloader;
+ }
+
+ @Override
+ public long getImageDataStoreId() {
+ return imageDataStoreVO.getId();
+ }
+
+ @Override
+ public TemplateObject registerTemplate(long templateId) {
+ ImageDataVO image = imageDao.findById(templateId);
+ image.setImageDataStoreId(this.getImageDataStoreId());
+ imageDao.update(templateId, image);
+ return getTemplate(templateId);
+ }
+
+ @Override
+ public TemplateObject getTemplate(long templateId) {
+ ImageDataVO image = imageDao.findById(templateId);
+ TemplateObject to = new TemplateObject(image, this);
+ return to;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/ImageDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/ImageDataStoreLifeCycle.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/ImageDataStoreLifeCycle.java
new file mode 100644
index 0000000..a96983c
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/ImageDataStoreLifeCycle.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.store.lifecycle;
+
+import java.util.Map;
+
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+
+public interface ImageDataStoreLifeCycle {
+ public ImageDataStore registerDataStore(String name, Map<String, String> params);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/integration-test/pom.xml
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/pom.xml b/engine/storage/integration-test/pom.xml
new file mode 100644
index 0000000..62e37a2
--- /dev/null
+++ b/engine/storage/integration-test/pom.xml
@@ -0,0 +1,85 @@
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cloud-engine-storage-integration-test</artifactId>
+ <name>Apache CloudStack Engine Storage integration test Component</name>
+ <parent>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-storage</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-storage-volume</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-storage-image</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>${cs.mysql.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <testSourceDirectory>test</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AllTests.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AllTests.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AllTests.java
new file mode 100644
index 0000000..dde4484
--- /dev/null
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AllTests.java
@@ -0,0 +1,29 @@
+/*
+ * 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 org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({ volumeServiceTest.class })
+public class AllTests {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AopTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AopTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AopTest.java
new file mode 100644
index 0000000..0c2a2ad
--- /dev/null
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AopTest.java
@@ -0,0 +1,14 @@
+package org.apache.cloudstack.storage.test;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+public @interface AopTest {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AopTestAdvice.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AopTestAdvice.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AopTestAdvice.java
new file mode 100644
index 0000000..ba356e3
--- /dev/null
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/AopTestAdvice.java
@@ -0,0 +1,18 @@
+package org.apache.cloudstack.storage.test;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+
+import com.cloud.utils.db.Transaction;
+
+public class AopTestAdvice {
+ public Object AopTestMethod(ProceedingJoinPoint call) throws Throwable {
+ Transaction txn = Transaction.open(call.getSignature().getName());
+ Object ret = null;
+ try {
+ ret = call.proceed();
+ } finally {
+ txn.close();
+ }
+ return ret;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
new file mode 100644
index 0000000..9077a5a
--- /dev/null
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
@@ -0,0 +1,28 @@
+package org.apache.cloudstack.storage.test;
+
+import org.mockito.Mockito;
+import org.springframework.context.annotation.Bean;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.host.dao.HostDao;
+
+public class ChildTestConfiguration extends TestConfiguration {
+
+ @Override
+ @Bean
+ public HostDao hostDao() {
+ HostDao dao = super.hostDao();
+ HostDao nDao = Mockito.spy(dao);
+ return nDao;
+ }
+
+ @Bean
+ public AgentManager agentMgr() {
+ return Mockito.mock(AgentManager.class);
+ }
+/* @Override
+ @Bean
+ public PrimaryDataStoreDao primaryDataStoreDao() {
+ return Mockito.mock(PrimaryDataStoreDaoImpl.class);
+ }*/
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerImpl.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerImpl.java
new file mode 100644
index 0000000..1345410
--- /dev/null
+++ b/engine/storage/integration-test/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<String, Object> params) throws ConfigurationException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean start() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean stop() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Answer easySend(Long hostId, Command cmd) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Answer send(Long hostId, Command cmd) throws AgentUnavailableException, OperationTimedoutException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Answer[] send(Long hostId, Commands cmds) throws AgentUnavailableException, OperationTimedoutException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Answer[] send(Long hostId, Commands cmds, int timeout) throws AgentUnavailableException, OperationTimedoutException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long send(Long hostId, Commands cmds, Listener listener) throws AgentUnavailableException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int registerForHostEvents(Listener listener, boolean connections, boolean commands, boolean priority) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int registerForInitialConnects(StartupCommandProcessor creator, boolean priority) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void unregisterForHostEvents(int id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean executeUserRequest(long hostId, Event event) throws AgentUnavailableException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Answer sendTo(Long dcId, HypervisorType type, Command cmd) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void sendToSecStorage(HostVO ssHost, Command cmd, Listener listener) throws AgentUnavailableException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Answer sendToSecStorage(HostVO ssHost, Command cmd) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean tapLoadingAgents(Long hostId, TapAgentsAction action) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean agentStatusTransitTo(HostVO host, Event e, long msId) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public AgentAttache findAttache(long hostId) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void disconnectWithoutInvestigation(long hostId, Event event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void pullAgentToMaintenance(long hostId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void pullAgentOutMaintenance(long hostId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean reconnect(long hostId) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Answer sendToSSVM(Long dcId, Command cmd) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/Future2.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/Future2.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/Future2.java
new file mode 100644
index 0000000..bc2fd7a
--- /dev/null
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/Future2.java
@@ -0,0 +1,114 @@
+/*
+ * 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.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+
+public class Future2<T> {
+
+ private Callable<T> callable;
+ private Callable<T> success;
+ private Callable<T> failed;
+ private ExecutorService executor = Executors.newFixedThreadPool(2);
+ private Future<T> f;
+
+ public class Func<T> implements Callable<T> {
+ private Callable<T> f;
+ private Callable<T> fs;
+ public T func() throws Exception {
+ return f.call();
+ }
+
+ public T success() throws Exception {
+ return fs.call();
+ }
+
+ public Func (Callable<T> f, Callable<T> s) {
+ this.f = f;
+ this.fs = s;
+ }
+
+
+ @Override
+ public T call() throws Exception {
+ func();
+ success();
+ return null;
+ }
+
+ }
+ public Future2 (Callable<T> callable) {
+ this.callable = callable;
+ }
+
+ public void onSuccess(Callable<T> s) {
+ this.success = s;
+ }
+
+ public void go() {
+ Func<T> ft = new Func<T>(this.callable, this.success);
+ f = executor.submit(ft);
+ }
+
+ public T get() {
+ try {
+ return this.f.get();
+ } catch (InterruptedException e) {
+ return null;
+ } catch (ExecutionException e) {
+ // TODO Auto-generated catch block
+ return null;
+ }
+ }
+
+ public void shutdown() {
+ this.executor.shutdown();
+ }
+
+ public static void main(String[] args) {
+ Callable<String> fun = new Callable<String> () {
+
+ @Override
+ public String call() throws Exception {
+ System.out.println("execing");
+ return "test";
+ }
+
+ };
+ Future2<String> f2 = new Future2<String>(fun);
+ f2.onSuccess(new Callable<String>() {
+
+ @Override
+ public String call() throws Exception {
+ Thread.sleep(1000);
+ System.out.println("success");
+ return null;
+ }
+ });
+
+ f2.go();
+ //f2.get();
+ f2.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/225ad3c2/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SimpleTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SimpleTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SimpleTest.java
new file mode 100644
index 0000000..a9b3f93
--- /dev/null
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/SimpleTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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 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();
+ }
+ }
+
+}