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 2013/01/15 03:04:54 UTC
[29/44] Revert "Merge remote-tracking branch 'origin/javelin' into
javelin"
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
deleted file mode 100644
index 09303aa..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
+++ /dev/null
@@ -1,48 +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.manager;
-
-import org.apache.cloudstack.storage.image.TemplateEvent;
-import org.apache.cloudstack.storage.image.TemplateState;
-import org.apache.cloudstack.storage.image.db.ImageDataVO;
-
-import com.cloud.utils.fsm.StateMachine2;
-
-public class ImageDataManagerImpl implements ImageDataManager {
- private final static StateMachine2<TemplateState, TemplateEvent, ImageDataVO>
- stateMachine = new StateMachine2<TemplateState, TemplateEvent, ImageDataVO>();
-
- public ImageDataManagerImpl() {
- stateMachine.addTransition(TemplateState.Allocated, TemplateEvent.CreateRequested, TemplateState.Creating);
- stateMachine.addTransition(TemplateState.Creating, TemplateEvent.CreateRequested, TemplateState.Creating);
- stateMachine.addTransition(TemplateState.Creating, TemplateEvent.OperationSucceeded, TemplateState.Ready);
- stateMachine.addTransition(TemplateState.Creating, TemplateEvent.OperationFailed, TemplateState.Allocated);
- stateMachine.addTransition(TemplateState.Creating, TemplateEvent.DestroyRequested, TemplateState.Destroying);
- stateMachine.addTransition(TemplateState.Ready, TemplateEvent.DestroyRequested, TemplateState.Destroying);
- stateMachine.addTransition(TemplateState.Allocated, TemplateEvent.DestroyRequested, TemplateState.Destroying);
- stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.DestroyRequested, TemplateState.Destroying);
- stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.OperationFailed, TemplateState.Destroying);
- stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.OperationSucceeded, TemplateState.Destroyed);
- }
-
- @Override
- public StateMachine2<TemplateState, TemplateEvent, ImageDataVO> getStateMachine() {
- return stateMachine;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/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/110465b5/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
index 2a24f9b..8183958 100644
--- 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
@@ -18,52 +18,24 @@
*/
package org.apache.cloudstack.storage.image.manager;
-import java.util.HashMap;
-import java.util.Map;
-
import javax.inject.Inject;
-import org.apache.cloudstack.storage.datastore.provider.DataStoreProvider;
-import org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManager;
-import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
-import org.apache.cloudstack.storage.image.db.ImageDataDao;
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.ImageDataStoreImpl;
-import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
-import org.springframework.stereotype.Component;
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
-@Component
public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
@Inject
ImageDataStoreDao dataStoreDao;
@Inject
ImageDataDao imageDataDao;
- @Inject
- DataStoreProviderManager providerManager;
- Map<String, ImageDataStoreDriver> driverMaps = new HashMap<String, ImageDataStoreDriver>();
@Override
public ImageDataStore getImageDataStore(long dataStoreId) {
ImageDataStoreVO dataStore = dataStoreDao.findById(dataStoreId);
- long providerId = dataStore.getProvider();
- DataStoreProvider provider = providerManager.getDataStoreProviderById(providerId);
- ImageDataStore imgStore = new ImageDataStoreImpl(dataStore,
- driverMaps.get(provider.getUuid())
- );
// TODO Auto-generated method stub
- return imgStore;
- }
-
- @Override
- public boolean registerDriver(String uuid, ImageDataStoreDriver driver) {
- if (driverMaps.containsKey(uuid)) {
- return false;
- }
- driverMaps.put(uuid, driver);
- return true;
+ return null;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/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..363ed5f
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/DefaultImageDataStoreProvider.java
@@ -0,0 +1,75 @@
+/*
+ * 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 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.apache.cloudstack.storage.image.store.lifecycle.DefaultImageDataStoreLifeCycle;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.component.ComponentContext;
+
+@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);
+ ids = ComponentContext.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 ImageDataStoreLifeCycle getLifeCycle() {
+ return new DefaultImageDataStoreLifeCycle(this, provider, imageStoreDao);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/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..710153a
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.provider;
+
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
+
+public interface ImageDataStoreProvider {
+ ImageDataStore getImageDataStore(long imageStoreId);
+ boolean register(long providerId);
+ public String getName();
+ ImageDataStoreLifeCycle getLifeCycle();
+ /**
+ * @param providerId
+ * @return
+ */
+ boolean init();
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/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/110465b5/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..62777f9
--- /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 true;
+ }
+
+ @Override
+ public boolean stop() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ @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/110465b5/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java
deleted file mode 100644
index 3569fe8..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java
+++ /dev/null
@@ -1,75 +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.store;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
-import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
-import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
-import org.apache.cloudstack.storage.image.driver.DefaultImageDataStoreDriverImpl;
-import org.apache.cloudstack.storage.image.store.lifecycle.DefaultImageDataStoreLifeCycle;
-import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.component.ComponentContext;
-
-@Component
-public class DefaultImageDataStoreProvider implements ImageDataStoreProvider {
- private final String name = "default image data store";
- protected ImageDataStoreLifeCycle lifeCycle;
- protected ImageDataStoreDriver driver;
- @Inject
- ImageDataStoreManager storeMgr;
- long id;
- String uuid;
- @Override
- public DataStoreLifeCycle getLifeCycle() {
- return lifeCycle;
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- @Override
- public String getUuid() {
- return this.uuid;
- }
-
- @Override
- public long getId() {
- return this.id;
- }
-
- @Override
- public boolean configure(Map<String, Object> params) {
- lifeCycle = ComponentContext.inject(DefaultImageDataStoreLifeCycle.class);
- driver = ComponentContext.inject(DefaultImageDataStoreDriverImpl.class);
- uuid = (String)params.get("uuid");
- id = (Long)params.get("id");
- storeMgr.registerDriver(uuid, driver);
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/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..b1fabc7
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStore.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.store;
+
+import org.apache.cloudstack.storage.datastore.DataStore;
+import org.apache.cloudstack.storage.image.TemplateObject;
+
+public interface ImageDataStore extends ImageDataStoreInfo {
+ TemplateObject registerTemplate(long templateId);
+ boolean deleteTemplate(long templateId);
+
+ boolean needDownloadToCacheStorage();
+
+ TemplateObject getTemplate(long templateId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/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
index 014d61f..355f793 100644
--- 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
@@ -18,26 +18,18 @@
*/
package org.apache.cloudstack.storage.image.store;
-import java.util.Set;
-
import javax.inject.Inject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
-import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
+import org.apache.cloudstack.storage.EndPoint;
import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
+import org.apache.cloudstack.storage.image.TemplateObject;
import org.apache.cloudstack.storage.image.db.ImageDataDao;
import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
import org.apache.cloudstack.storage.image.db.ImageDataVO;
+import org.apache.cloudstack.storage.image.driver.ImageDataStoreDriver;
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
-
public class ImageDataStoreImpl implements ImageDataStore {
@Inject
ImageDataDao imageDao;
@@ -45,88 +37,107 @@ public class ImageDataStoreImpl implements ImageDataStore {
ImageDataStoreVO imageDataStoreVO;
boolean needDownloadToCacheStorage = false;
- public ImageDataStoreImpl(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver imageDataStoreDriver) {
- this.driver = imageDataStoreDriver;
+ public ImageDataStoreImpl(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver driver, boolean needDownloadToCacheStorage) {
+ this.driver = driver;
+ this.needDownloadToCacheStorage = needDownloadToCacheStorage;
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 Set<TemplateInfo> listTemplates() {
+ public boolean deleteTemplate(long templateId) {
// TODO Auto-generated method stub
- return null;
+ return false;
}
-
-
@Override
- public DataStoreDriver getDriver() {
+ public boolean needDownloadToCacheStorage() {
// TODO Auto-generated method stub
- return null;
+ return false;
}
-
-
@Override
- public DataStoreRole getRole() {
- // TODO Auto-generated method stub
- return null;
+ 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;
+ }
@Override
- public long getId() {
+ public String getType() {
// TODO Auto-generated method stub
- return 0;
+ return null;
}
-
-
@Override
public String getUri() {
// TODO Auto-generated method stub
return null;
}
-
-
@Override
- public Scope getScope() {
- // TODO Auto-generated method stub
+ public String grantAccess(VolumeInfo volume, EndPoint ep) {
return null;
}
-
-
@Override
- public TemplateInfo getTemplate(long templateId) {
+ public boolean revokeAccess(VolumeInfo volume, EndPoint ep) {
// TODO Auto-generated method stub
- return null;
+ return false;
}
-
+ @Override
+ public String grantAccess(TemplateInfo template, EndPoint ep) {
+ return this.driver.grantAccess((TemplateObject)template, ep);
+ }
@Override
- public VolumeInfo getVolume(long volumeId) {
+ public boolean revokeAccess(TemplateInfo template, EndPoint ep) {
// TODO Auto-generated method stub
- return null;
+ return false;
}
-
-
@Override
- public SnapshotInfo getSnapshot(long snapshotId) {
+ public String grantAccess(SnapshotInfo snapshot, EndPoint ep) {
// TODO Auto-generated method stub
return null;
}
+ @Override
+ public boolean revokeAccess(SnapshotInfo snapshot, EndPoint ep) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ @Override
+ public String getRole() {
+ return "imageStore";
+ }
@Override
- public boolean exists(DataObject object) {
+ public long getId() {
// TODO Auto-generated method stub
- return false;
+ return 0;
}
+
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
deleted file mode 100644
index 766ac45..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
+++ /dev/null
@@ -1,110 +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.store;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
-import org.apache.cloudstack.storage.image.TemplateEvent;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.image.db.ImageDataDao;
-import org.apache.cloudstack.storage.image.db.ImageDataVO;
-import org.apache.cloudstack.storage.image.manager.ImageDataManager;
-import org.apache.log4j.Logger;
-
-import com.cloud.utils.component.ComponentContext;
-import com.cloud.utils.fsm.NoTransitionException;
-
-public class TemplateObject implements TemplateInfo {
- private static final Logger s_logger = Logger.getLogger(TemplateObject.class);
- private ImageDataVO imageVO;
- private DataStore dataStore;
- @Inject
- ImageDataManager imageMgr;
- @Inject
- ImageDataDao imageDao;
-
- public TemplateObject(ImageDataVO template, DataStore dataStore) {
- this.imageVO = template;
- this.dataStore = dataStore;
- }
-
- public static TemplateObject getTemplate(ImageDataVO vo, DataStore store) {
- TemplateObject to = new TemplateObject(vo, store);
- return ComponentContext.inject(to);
- }
-
- public void setImageStoreId(long id) {
- this.imageVO.setImageDataStoreId(id);
- }
-
- public ImageDataVO getImage() {
- return this.imageVO;
- }
-
- @Override
- public DataStore getDataStore() {
- return this.dataStore;
- }
-
- @Override
- public long getId() {
- return this.imageVO.getId();
- }
-
- @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;
- }
-
- @Override
- public String getUri() {
- return this.dataStore.getUri() + "template/" + this.getPath();
- }
-
- @Override
- public long getSize() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public DataObjectType getType() {
- return DataObjectType.TEMPLATE;
- }
-
- @Override
- public DiskFormat getFormat() {
- return DiskFormat.getFormat(this.imageVO.getFormat());
- }
-
- @Override
- public boolean stateTransit(TemplateEvent e) throws NoTransitionException {
- return imageMgr.getStateMachine().transitTo(this.imageVO, e, null, imageDao);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
index c167ecb..3ced8d3 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
@@ -1,75 +1,54 @@
+// 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 javax.inject.Inject;
-import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreProviderVO;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
+import org.apache.cloudstack.storage.image.provider.ImageDataStoreProvider;
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
- @Inject
+ protected ImageDataStoreProvider provider;
+ protected ImageDataStoreProviderVO providerVO;
protected ImageDataStoreDao imageStoreDao;
+ @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(providerVO.getId());
+ dataStore = imageStoreDao.persist(dataStore);
+ }
+ return provider.getImageDataStore(dataStore.getId());
+ }
- public DefaultImageDataStoreLifeCycle() {
+ public DefaultImageDataStoreLifeCycle(ImageDataStoreProvider provider,
+ ImageDataStoreProviderVO providerVO,
+ ImageDataStoreDao dao) {
+ this.provider = provider;
+ this.providerVO = providerVO;
+ this.imageStoreDao = dao;
}
-
- @Override
- public boolean initialize(DataStore store, Map<String, String> dsInfos) {
- // TODO Auto-generated method stub
- return false;
- }
-
-
- @Override
- public boolean attachCluster(DataStore store, ClusterScope scope) {
- // TODO Auto-generated method stub
- return false;
- }
-
-
- @Override
- public boolean attachZone(DataStore dataStore, ZoneScope scope) {
- // TODO Auto-generated method stub
- return false;
- }
-
-
- @Override
- public boolean dettach() {
- // TODO Auto-generated method stub
- return false;
- }
-
-
- @Override
- public boolean unmanaged() {
- // TODO Auto-generated method stub
- return false;
- }
-
-
- @Override
- public boolean maintain() {
- // TODO Auto-generated method stub
- return false;
- }
-
-
- @Override
- public boolean cancelMaintain() {
- // TODO Auto-generated method stub
- return false;
- }
-
-
- @Override
- public boolean deleteDataStore() {
- // TODO Auto-generated method stub
- return false;
- }
-
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/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
index a368239..a96983c 100644
--- 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
@@ -18,7 +18,10 @@
*/
package org.apache.cloudstack.storage.image.store.lifecycle;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import java.util.Map;
-public interface ImageDataStoreLifeCycle extends DataStoreLifeCycle {
+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/110465b5/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
index 6572b85..fd6f193 100644
--- a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
+++ b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
@@ -18,29 +18,32 @@
*/
package org.apache.cloudstack.storage.image.motion;
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
-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.DataStoreRole;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext;
+import org.apache.cloudstack.storage.EndPoint;
+import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.command.CopyCmd;
-import org.apache.cloudstack.storage.command.CopyCmdAnswer;
-import org.apache.cloudstack.storage.endpoint.EndPointSelector;
+import org.apache.cloudstack.storage.command.CopyTemplateToPrimaryStorageAnswer;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.image.TemplateInfo;
+import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
import org.springframework.stereotype.Component;
import com.cloud.agent.api.Answer;
-//At least one of datastore is coming from image store or image cache store
@Component
public class DefaultImageMotionStrategy implements ImageMotionStrategy {
- @Inject
- EndPointSelector selector;
+
+ @Override
+ public boolean canHandle(TemplateInfo templateStore) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+
+
private class CreateTemplateContext<T> extends AsyncRpcConext<T> {
private final TemplateOnPrimaryDataStoreInfo template;
public CreateTemplateContext(AsyncCompletionCallback<T> callback, TemplateOnPrimaryDataStoreInfo template) {
@@ -53,7 +56,7 @@ public class DefaultImageMotionStrategy implements ImageMotionStrategy {
}
}
-/*
+
@Override
public void copyTemplateAsync(String destUri, String srcUri, EndPoint ep, AsyncCompletionCallback<CommandResult> callback) {
@@ -82,59 +85,12 @@ public class DefaultImageMotionStrategy implements ImageMotionStrategy {
parentCall.complete(result);
return null;
- }*/
-
- @Override
- public boolean canHandle(DataObject srcData, DataObject destData) {
- DataStore destStore = destData.getDataStore();
- DataStore srcStore = srcData.getDataStore();
- if (destStore.getRole() == DataStoreRole.Image || destStore.getRole() == DataStoreRole.ImageCache
- || srcStore.getRole() == DataStoreRole.Image
- || srcStore.getRole() == DataStoreRole.ImageCache) {
- return true;
- }
- return false;
}
@Override
- public Void copyAsync(DataObject srcData, DataObject destData,
- AsyncCompletionCallback<CopyCommandResult> callback) {
- DataStore destStore = destData.getDataStore();
- DataStore srcStore = srcData.getDataStore();
- EndPoint ep = selector.select(srcData, destData);
- CopyCommandResult result = new CopyCommandResult("");
- if (ep == null) {
- result.setResult("can't find end point");
- callback.complete(result);
- return null;
- }
-
- String srcUri = srcStore.getDriver().grantAccess(srcData, ep);
- String destUri = destStore.getDriver().grantAccess(destData, ep);
- CopyCmd cmd = new CopyCmd(srcUri, destUri);
-
- CreateTemplateContext<CopyCommandResult> context = new CreateTemplateContext<CopyCommandResult>(callback, null);
- AsyncCallbackDispatcher<DefaultImageMotionStrategy, Answer> caller = AsyncCallbackDispatcher.create(this);
- caller.setCallback(caller.getTarget().copyAsyncCallback(null, null))
- .setContext(context);
-
- ep.sendMessageAsync(cmd, caller);
+ public EndPoint getEndPoint(TemplateInfo destTemplate,
+ TemplateInfo srcTemplate) {
return null;
}
-
- protected Void copyAsyncCallback(AsyncCallbackDispatcher<DefaultImageMotionStrategy, Answer> callback, CreateTemplateContext<CopyCommandResult> context) {
- AsyncCompletionCallback<CopyCommandResult> parentCall = context.getParentCallback();
- CopyCmdAnswer answer = (CopyCmdAnswer)callback.getResult();
- if (!answer.getResult()) {
- CopyCommandResult result = new CopyCommandResult("");
- result.setResult(answer.getDetails());
- parentCall.complete(result);
- } else {
- CopyCommandResult result = new CopyCommandResult(answer.getPath());
- parentCall.complete(result);
- }
- return null;
-
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
index 0e3636e..0d007ed 100644
--- a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
+++ b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
@@ -22,9 +22,9 @@ import java.util.List;
import javax.inject.Inject;
-import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.EndPoint;
+import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
import org.apache.cloudstack.storage.image.ImageService;
import org.apache.cloudstack.storage.image.TemplateInfo;
@@ -53,7 +53,7 @@ public class ImageMotionServiceImpl implements ImageMotionService {
@Override
public void copyTemplateAsync(TemplateInfo destTemplate, TemplateInfo srcTemplate, AsyncCompletionCallback<CommandResult> callback) {
- /* ImageMotionStrategy ims = null;
+ ImageMotionStrategy ims = null;
for (ImageMotionStrategy strategy : motionStrategies) {
if (strategy.canHandle(srcTemplate)) {
ims = strategy;
@@ -69,7 +69,7 @@ public class ImageMotionServiceImpl implements ImageMotionService {
String srcUri = srcTemplate.getDataStore().grantAccess(srcTemplate, ep);
String destUri = destTemplate.getDataStore().grantAccess(destTemplate, ep);
- ims.copyTemplateAsync(destUri, srcUri, ep, callback);*/
+ ims.copyTemplateAsync(destUri, srcUri, ep, callback);
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionStrategy.java b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionStrategy.java
index 7a47636..037005d 100644
--- a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionStrategy.java
+++ b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionStrategy.java
@@ -18,7 +18,15 @@
*/
package org.apache.cloudstack.storage.image.motion;
-import org.apache.cloudstack.storage.motion.DataMotionStrategy;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.EndPoint;
+import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
+import org.apache.cloudstack.storage.command.CommandResult;
+import org.apache.cloudstack.storage.datastore.DataStore;
+import org.apache.cloudstack.storage.image.TemplateInfo;
-public interface ImageMotionStrategy extends DataMotionStrategy {
+public interface ImageMotionStrategy {
+ public boolean canHandle(TemplateInfo templateStore);
+ public EndPoint getEndPoint(TemplateInfo destTemplate, TemplateInfo srcTemplate);
+ public void copyTemplateAsync(String destUri, String sourceUri, EndPoint ep, AsyncCompletionCallback<CommandResult> callback);
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/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
index 0c2a2ad..bde5804 100644
--- 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
@@ -1,3 +1,19 @@
+// 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 java.lang.annotation.ElementType.METHOD;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/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
index ba356e3..63669c4 100644
--- 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
@@ -1,3 +1,19 @@
+// 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.aspectj.lang.ProceedingJoinPoint;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/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
index 69907bc..1b12b54 100644
--- 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
@@ -1,3 +1,19 @@
+// 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.apache.cloudstack.storage.HostEndpointRpcServer;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
index 5bc7c0d..dc7223c 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/CloudStackTestNGBase.java
@@ -1,3 +1,19 @@
+// 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.lang.reflect.Method;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentTest.java
index 20ac946..371e6d0 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentTest.java
@@ -18,25 +18,33 @@
*/
package org.apache.cloudstack.storage.test;
+import java.lang.reflect.Method;
import java.util.UUID;
import javax.inject.Inject;
+import org.apache.cloudstack.storage.command.CopyTemplateToPrimaryStorageCmd;
import org.apache.cloudstack.storage.to.ImageDataStoreTO;
import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
import org.apache.cloudstack.storage.to.TemplateTO;
+
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import com.cloud.agent.AgentManager;
-import com.cloud.agent.api.Command;
import com.cloud.agent.api.ReadyCommand;
import com.cloud.dc.ClusterVO;
-import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
+import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao;
@@ -49,6 +57,8 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.org.Cluster.ClusterType;
import com.cloud.org.Managed.ManagedState;
import com.cloud.resource.ResourceState;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Transaction;
@ContextConfiguration(locations="classpath:/storageContext.xml")
public class DirectAgentTest extends CloudStackTestNGBase {
@@ -139,8 +149,7 @@ public class DirectAgentTest extends CloudStackTestNGBase {
Mockito.when(template.getImageDataStore()).thenReturn(imageStore);
Mockito.when(image.getTemplate()).thenReturn(template);
- //CopyTemplateToPrimaryStorageCmd cmd = new CopyTemplateToPrimaryStorageCmd(image);
- Command cmd = null;
+ CopyTemplateToPrimaryStorageCmd cmd = new CopyTemplateToPrimaryStorageCmd(image);
try {
agentMgr.send(hostId, cmd);
} catch (AgentUnavailableException e) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHypervsiorHostEndPointRpcServer.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHypervsiorHostEndPointRpcServer.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHypervsiorHostEndPointRpcServer.java
index d698576..6c5ee19 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHypervsiorHostEndPointRpcServer.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockHypervsiorHostEndPointRpcServer.java
@@ -18,6 +18,7 @@
*/
package org.apache.cloudstack.storage.test;
+import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -25,6 +26,10 @@ import java.util.concurrent.TimeUnit;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.HostEndpointRpcServer;
import org.apache.cloudstack.storage.HypervisorHostEndPoint;
+import org.apache.cloudstack.storage.command.CopyTemplateToPrimaryStorageCmd;
+import org.apache.cloudstack.storage.command.CopyTemplateToPrimaryStorageAnswer;
+import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
+import org.apache.cloudstack.storage.command.CreateVolumeFromBaseImageCommand;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
@@ -46,11 +51,11 @@ public class MockHypervsiorHostEndPointRpcServer implements HostEndpointRpcServe
public void run() {
try {
Answer answer = new Answer(cmd, false, "unknown command");
- /*if (cmd instanceof CopyTemplateToPrimaryStorageCmd) {
+ if (cmd instanceof CopyTemplateToPrimaryStorageCmd) {
answer = new CopyTemplateToPrimaryStorageAnswer(cmd, UUID.randomUUID().toString());
} else if (cmd instanceof CreateVolumeFromBaseImageCommand) {
answer = new CreateVolumeAnswer(cmd, UUID.randomUUID().toString());
- }*/
+ }
callback.complete(answer);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockRpcCallBack.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockRpcCallBack.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockRpcCallBack.java
index 294cb1e..207cc52 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockRpcCallBack.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockRpcCallBack.java
@@ -1,3 +1,19 @@
+// 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 javax.inject.Inject;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/StorageFactoryBean.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/StorageFactoryBean.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/StorageFactoryBean.java
index 68952b1..2ac6dac 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/StorageFactoryBean.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/StorageFactoryBean.java
@@ -1,3 +1,19 @@
+// 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;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/StorageTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/StorageTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/StorageTest.java
index 2a285cb..0ee7fe0 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/StorageTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/StorageTest.java
@@ -1,3 +1,19 @@
+// 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.*;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestConfiguration.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestConfiguration.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestConfiguration.java
index de7944c..d3280c0 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestConfiguration.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestConfiguration.java
@@ -1,3 +1,19 @@
+// 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.springframework.context.annotation.Bean;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestNG.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestNG.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestNG.java
index 3da31e8..b3ecd3c 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestNG.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestNG.java
@@ -1,3 +1,19 @@
+// 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 junit.framework.Assert;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestNGAop.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestNGAop.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestNGAop.java
index 6cc2d20..130ecd2 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestNGAop.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestNGAop.java
@@ -1,3 +1,19 @@
+// 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.lang.reflect.Method;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/XenEndpoint.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/XenEndpoint.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/XenEndpoint.java
index a96d7ec..d0709d5 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/XenEndpoint.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/XenEndpoint.java
@@ -1,3 +1,19 @@
+// 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;
public class XenEndpoint {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
index a81c546..2aec905 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
@@ -18,39 +18,75 @@
*/
package org.apache.cloudstack.storage.test;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import org.testng.AssertJUnit;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
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.ClusterScope;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.QCOW2;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VHD;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VMDK;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTypeHelper;
import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk;
+import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper;
+import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
+import org.apache.cloudstack.storage.command.CreateVolumeFromBaseImageCommand;
+import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
+import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
import org.apache.cloudstack.storage.image.ImageService;
import org.apache.cloudstack.storage.image.db.ImageDataDao;
import org.apache.cloudstack.storage.image.db.ImageDataVO;
+import org.apache.cloudstack.storage.image.format.ISO;
+import org.apache.cloudstack.storage.image.format.ImageFormat;
+import org.apache.cloudstack.storage.image.format.ImageFormatHelper;
+import org.apache.cloudstack.storage.image.format.OVA;
+import org.apache.cloudstack.storage.image.format.Unknown;
+import org.apache.cloudstack.storage.image.provider.ImageDataStoreProvider;
+import org.apache.cloudstack.storage.image.provider.ImageDataStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
import org.apache.cloudstack.storage.volume.VolumeService;
import org.apache.cloudstack.storage.volume.db.VolumeDao2;
import org.apache.cloudstack.storage.volume.db.VolumeVO;
-import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
-import org.testng.annotations.Test;
+import org.mockito.Mockito;
+import org.mockito.Mockito.*;
+
import com.cloud.agent.AgentManager;
import com.cloud.dc.ClusterVO;
-import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
+import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao;
+import com.cloud.exception.AgentUnavailableException;
+import com.cloud.exception.OperationTimedoutException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
+import com.cloud.host.Status;
+import com.cloud.host.Status.Event;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.org.Cluster.ClusterType;
@@ -60,8 +96,8 @@ import com.cloud.storage.Storage.TemplateType;
@ContextConfiguration(locations="classpath:/storageContext.xml")
public class volumeServiceTest extends CloudStackTestNGBase {
- //@Inject
- //ImageDataStoreProviderManager imageProviderMgr;
+ @Inject
+ ImageDataStoreProviderManager imageProviderMgr;
@Inject
ImageService imageService;
@Inject
@@ -80,8 +116,8 @@ public class volumeServiceTest extends CloudStackTestNGBase {
DataCenterDao dcDao;
@Inject
PrimaryDataStoreDao primaryStoreDao;
- //@Inject
- //PrimaryDataStoreProviderManager primaryDataStoreProviderMgr;
+ @Inject
+ PrimaryDataStoreProviderManager primaryDataStoreProviderMgr;
@Inject
AgentManager agentMgr;
Long dcId;
@@ -174,7 +210,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
image.setFeatured(true);
image.setRequireHvm(true);
image.setBits(64);
- //image.setFormat(new VHD().toString());
+ image.setFormat(new VHD().toString());
image.setAccountId(1);
image.setEnablePassword(true);
image.setEnableSshKey(true);
@@ -189,16 +225,15 @@ public class volumeServiceTest extends CloudStackTestNGBase {
private TemplateEntity createTemplate() {
try {
- /*imageProviderMgr.configure("image Provider", new HashMap<String, Object>());
+ imageProviderMgr.configure("image Provider", new HashMap<String, Object>());
ImageDataVO image = createImageData();
ImageDataStoreProvider defaultProvider = imageProviderMgr.getProvider("DefaultProvider");
ImageDataStoreLifeCycle lifeCycle = defaultProvider.getLifeCycle();
ImageDataStore store = lifeCycle.registerDataStore("defaultHttpStore", new HashMap<String, String>());
imageService.registerTemplate(image.getId(), store.getImageDataStoreId());
TemplateEntity te = imageService.getTemplateEntity(image.getId());
- return te;*/
- return null;
- } catch (Exception e) {
+ return te;
+ } catch (ConfigurationException e) {
return null;
}
}
@@ -209,7 +244,6 @@ public class volumeServiceTest extends CloudStackTestNGBase {
private PrimaryDataStoreInfo createPrimaryDataStore() {
try {
- /*
PrimaryDataStoreProvider provider = primaryDataStoreProviderMgr.getDataStoreProvider("default primary data store provider");
primaryDataStoreProviderMgr.configure("primary data store mgr", new HashMap<String, Object>());
@@ -232,9 +266,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
lc.attachCluster(scope);
return primaryDataStoreInfo;
- */
- return null;
- } catch (Exception e) {
+ } catch (ConfigurationException e) {
return null;
}
}
@@ -252,7 +284,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
TemplateEntity te = createTemplate();
VolumeVO volume = createVolume(te.getId(), primaryStore.getId());
VolumeEntity ve = volumeService.getVolumeEntity(volume.getId());
- //ve.createVolumeFromTemplate(primaryStore.getId(), new VHD(), te);
+ ve.createVolumeFromTemplate(primaryStore.getId(), new VHD(), te);
ve.destroy();
}
@@ -261,7 +293,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
primaryStore = createPrimaryDataStore();
VolumeVO volume = createVolume(null, primaryStore.getId());
VolumeEntity ve = volumeService.getVolumeEntity(volume.getId());
- //ve.createVolume(primaryStore.getId(), new VHD());
+ ve.createVolume(primaryStore.getId(), new VHD());
ve.destroy();
}
@@ -279,7 +311,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
//@Test
@Test
public void test1() {
- /*System.out.println(VolumeTypeHelper.getType("Root"));
+ System.out.println(VolumeTypeHelper.getType("Root"));
System.out.println(VolumeDiskTypeHelper.getDiskType("vmdk"));
System.out.println(ImageFormatHelper.getFormat("ova"));
AssertJUnit.assertFalse(new VMDK().equals(new VHD()));
@@ -297,7 +329,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
VolumeDiskType qcow2 = new QCOW2();
ImageFormat qcow2format = new org.apache.cloudstack.storage.image.format.QCOW2();
AssertJUnit.assertFalse(qcow2.equals(qcow2format));
-*/
+
}
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/resource/storageContext.xml
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/resource/storageContext.xml b/engine/storage/integration-test/test/resource/storageContext.xml
index f5e343e..c81fe7d 100644
--- a/engine/storage/integration-test/test/resource/storageContext.xml
+++ b/engine/storage/integration-test/test/resource/storageContext.xml
@@ -1,3 +1,21 @@
+<!--
+ 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.
+-->
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/integration-test/test/resource/testng.xml
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/resource/testng.xml b/engine/storage/integration-test/test/resource/testng.xml
index 186c542..bf9f8f0 100644
--- a/engine/storage/integration-test/test/resource/testng.xml
+++ b/engine/storage/integration-test/test/resource/testng.xml
@@ -1,3 +1,21 @@
+<!--
+ 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.
+-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="1" verbose="1" name="storage test" annotations="JDK" parallel="classes">
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
deleted file mode 100644
index 487e2d5..0000000
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
+++ /dev/null
@@ -1,47 +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.snapshot;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.storage.datastore.DataStoreManager;
-import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
-import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
-import org.apache.cloudstack.storage.snapshot.db.SnapshotDao2;
-import org.apache.cloudstack.storage.snapshot.db.SnapshotVO;
-import org.springframework.stereotype.Component;
-
-@Component
-public class SnapshotDataFactoryImpl implements SnapshotDataFactory {
- @Inject
- SnapshotDao2 snapshotDao;
- @Inject
- ObjectInDataStoreManager objMap;
- @Inject
- DataStoreManager storeMgr;
- @Override
- public SnapshotInfo getSnapshot(long snapshotId, DataStore store) {
- SnapshotVO snapshot = snapshotDao.findById(snapshotId);
- ObjectInDataStoreVO obj = objMap.findObject(snapshotId, DataObjectType.SNAPSHOT, store.getId(), store.getRole());
- SnapshotObject so = new SnapshotObject(snapshot, store);
- return so;
- }
-}