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 02:03:17 UTC
[6/9] refactor api
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/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
deleted file mode 100644
index 62777f9..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProviderManagerImpl.java
+++ /dev/null
@@ -1,135 +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.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/a2f86003/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
new file mode 100644
index 0000000..3569fe8
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/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.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/a2f86003/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
deleted file mode 100644
index b1fabc7..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStore.java
+++ /dev/null
@@ -1,31 +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 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/a2f86003/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 355f793..014d61f 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,18 +18,26 @@
*/
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.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.image.TemplateObject;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
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;
@@ -37,107 +45,88 @@ public class ImageDataStoreImpl implements ImageDataStore {
ImageDataStoreVO imageDataStoreVO;
boolean needDownloadToCacheStorage = false;
- public ImageDataStoreImpl(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver driver, boolean needDownloadToCacheStorage) {
- this.driver = driver;
- this.needDownloadToCacheStorage = needDownloadToCacheStorage;
+ public ImageDataStoreImpl(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver imageDataStoreDriver) {
+ this.driver = imageDataStoreDriver;
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 boolean deleteTemplate(long templateId) {
+ public Set<TemplateInfo> listTemplates() {
// TODO Auto-generated method stub
- return false;
+ return null;
}
+
+
@Override
- public boolean needDownloadToCacheStorage() {
+ public DataStoreDriver getDriver() {
// TODO Auto-generated method stub
- return false;
+ return null;
}
- @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;
+ public DataStoreRole getRole() {
+ // TODO Auto-generated method stub
+ return null;
}
+
+
@Override
- public String getType() {
+ public long getId() {
// TODO Auto-generated method stub
- return null;
+ return 0;
}
+
+
@Override
public String getUri() {
// TODO Auto-generated method stub
return null;
}
- @Override
- public String grantAccess(VolumeInfo volume, EndPoint ep) {
- return null;
- }
+
@Override
- public boolean revokeAccess(VolumeInfo volume, EndPoint ep) {
+ public Scope getScope() {
// TODO Auto-generated method stub
- return false;
+ return null;
}
- @Override
- public String grantAccess(TemplateInfo template, EndPoint ep) {
- return this.driver.grantAccess((TemplateObject)template, ep);
- }
+
@Override
- public boolean revokeAccess(TemplateInfo template, EndPoint ep) {
+ public TemplateInfo getTemplate(long templateId) {
// TODO Auto-generated method stub
- return false;
+ return null;
}
+
+
@Override
- public String grantAccess(SnapshotInfo snapshot, EndPoint ep) {
+ public VolumeInfo getVolume(long volumeId) {
// TODO Auto-generated method stub
return null;
}
+
+
@Override
- public boolean revokeAccess(SnapshotInfo snapshot, EndPoint ep) {
+ public SnapshotInfo getSnapshot(long snapshotId) {
// TODO Auto-generated method stub
- return false;
+ return null;
}
- @Override
- public String getRole() {
- return "imageStore";
- }
+
@Override
- public long getId() {
+ public boolean exists(DataObject object) {
// TODO Auto-generated method stub
- return 0;
+ return false;
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/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
new file mode 100644
index 0000000..766ac45
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
@@ -0,0 +1,110 @@
+/*
+ * 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/a2f86003/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 071e175..c167ecb 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
@@ -4,35 +4,72 @@ 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 {
- protected ImageDataStoreProvider provider;
- protected ImageDataStoreProviderVO providerVO;
+ @Inject
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(ImageDataStoreProvider provider,
- ImageDataStoreProviderVO providerVO,
- ImageDataStoreDao dao) {
- this.provider = provider;
- this.providerVO = providerVO;
- this.imageStoreDao = dao;
+ public DefaultImageDataStoreLifeCycle() {
}
+
+ @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/a2f86003/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 a96983c..a368239 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,10 +18,7 @@
*/
package org.apache.cloudstack.storage.image.store.lifecycle;
-import java.util.Map;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
-import org.apache.cloudstack.storage.image.store.ImageDataStore;
-
-public interface ImageDataStoreLifeCycle {
- public ImageDataStore registerDataStore(String name, Map<String, String> params);
+public interface ImageDataStoreLifeCycle extends DataStoreLifeCycle {
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/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 fd6f193..6572b85 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,32 +18,29 @@
*/
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.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.command.CopyCmdAnswer;
+import org.apache.cloudstack.storage.endpoint.EndPointSelector;
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 {
-
- @Override
- public boolean canHandle(TemplateInfo templateStore) {
- // TODO Auto-generated method stub
- return true;
- }
-
-
-
+ @Inject
+ EndPointSelector selector;
private class CreateTemplateContext<T> extends AsyncRpcConext<T> {
private final TemplateOnPrimaryDataStoreInfo template;
public CreateTemplateContext(AsyncCompletionCallback<T> callback, TemplateOnPrimaryDataStoreInfo template) {
@@ -56,7 +53,7 @@ public class DefaultImageMotionStrategy implements ImageMotionStrategy {
}
}
-
+/*
@Override
public void copyTemplateAsync(String destUri, String srcUri, EndPoint ep, AsyncCompletionCallback<CommandResult> callback) {
@@ -85,12 +82,59 @@ 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 EndPoint getEndPoint(TemplateInfo destTemplate,
- TemplateInfo srcTemplate) {
+ 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);
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/a2f86003/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 0d007ed..0e3636e 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/a2f86003/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 037005d..7a47636 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,15 +18,7 @@
*/
package org.apache.cloudstack.storage.image.motion;
-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;
+import org.apache.cloudstack.storage.motion.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);
+public interface ImageMotionStrategy extends DataMotionStrategy {
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/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 371e6d0..20ac946 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,33 +18,25 @@
*/
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;
@@ -57,8 +49,6 @@ 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 {
@@ -149,7 +139,8 @@ public class DirectAgentTest extends CloudStackTestNGBase {
Mockito.when(template.getImageDataStore()).thenReturn(imageStore);
Mockito.when(image.getTemplate()).thenReturn(template);
- CopyTemplateToPrimaryStorageCmd cmd = new CopyTemplateToPrimaryStorageCmd(image);
+ //CopyTemplateToPrimaryStorageCmd cmd = new CopyTemplateToPrimaryStorageCmd(image);
+ Command cmd = null;
try {
agentMgr.send(hostId, cmd);
} catch (AgentUnavailableException e) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/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 6c5ee19..d698576 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,7 +18,6 @@
*/
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;
@@ -26,10 +25,6 @@ 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;
@@ -51,11 +46,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/a2f86003/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 2aec905..a81c546 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,75 +18,39 @@
*/
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.springframework.test.context.ContextConfiguration;
import org.mockito.Mockito;
-import org.mockito.Mockito.*;
-
+import org.springframework.test.context.ContextConfiguration;
+import org.testng.annotations.Test;
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;
@@ -96,8 +60,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
@@ -116,8 +80,8 @@ public class volumeServiceTest extends CloudStackTestNGBase {
DataCenterDao dcDao;
@Inject
PrimaryDataStoreDao primaryStoreDao;
- @Inject
- PrimaryDataStoreProviderManager primaryDataStoreProviderMgr;
+ //@Inject
+ //PrimaryDataStoreProviderManager primaryDataStoreProviderMgr;
@Inject
AgentManager agentMgr;
Long dcId;
@@ -210,7 +174,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);
@@ -225,15 +189,16 @@ 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;
- } catch (ConfigurationException e) {
+ return te;*/
+ return null;
+ } catch (Exception e) {
return null;
}
}
@@ -244,6 +209,7 @@ 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>());
@@ -266,7 +232,9 @@ public class volumeServiceTest extends CloudStackTestNGBase {
ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
lc.attachCluster(scope);
return primaryDataStoreInfo;
- } catch (ConfigurationException e) {
+ */
+ return null;
+ } catch (Exception e) {
return null;
}
}
@@ -284,7 +252,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();
}
@@ -293,7 +261,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();
}
@@ -311,7 +279,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()));
@@ -329,7 +297,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/a2f86003/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
new file mode 100644
index 0000000..487e2d5
--- /dev/null
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
@@ -0,0 +1,47 @@
+/*
+ * 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
new file mode 100644
index 0000000..49a9410
--- /dev/null
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
@@ -0,0 +1,98 @@
+/*
+ * 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 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.VolumeInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
+import org.apache.cloudstack.storage.snapshot.db.SnapshotVO;
+
+public class SnapshotObject implements SnapshotInfo {
+ private SnapshotVO snapshot;
+ private DataStore store;
+
+ public SnapshotObject(SnapshotVO snapshot, DataStore store) {
+ this.snapshot = snapshot;
+ this.store = store;
+ }
+
+ public DataStore getStore() {
+ return this.store;
+ }
+ @Override
+ public String getName() {
+ return this.snapshot.getName();
+ }
+
+ @Override
+ public SnapshotInfo getParent() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SnapshotInfo getChild() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public VolumeInfo getBaseVolume() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getId() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getUri() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public DataStore getDataStore() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getSize() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public DataObjectType getType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public DiskFormat getFormat() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2.java
new file mode 100644
index 0000000..d531ede
--- /dev/null
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2.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.snapshot.db;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface SnapshotDao2 extends GenericDao<SnapshotVO, Long> {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2Impl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2Impl.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2Impl.java
new file mode 100644
index 0000000..5e36e10
--- /dev/null
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotDao2Impl.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.snapshot.db;
+
+import com.cloud.utils.db.GenericDaoBase;
+
+public class SnapshotDao2Impl extends GenericDaoBase<SnapshotVO, Long> implements SnapshotDao2 {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotVO.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotVO.java
new file mode 100644
index 0000000..b0834be
--- /dev/null
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/db/SnapshotVO.java
@@ -0,0 +1,296 @@
+// 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.db;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.Snapshot.Status;
+import com.cloud.storage.Snapshot.Type;
+import com.cloud.utils.db.GenericDao;
+import com.google.gson.annotations.Expose;
+
+@Entity
+@Table(name="snapshots")
+public class SnapshotVO {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private final long id = -1;
+
+ @Column(name="data_center_id")
+ long dataCenterId;
+
+ @Column(name="account_id")
+ long accountId;
+
+ @Column(name="domain_id")
+ long domainId;
+
+ @Column(name="volume_id")
+ Long volumeId;
+
+ @Column(name="disk_offering_id")
+ Long diskOfferingId;
+
+ @Expose
+ @Column(name="path")
+ String path;
+
+ @Expose
+ @Column(name="name")
+ String name;
+
+ @Expose
+ @Column(name="status", updatable = true, nullable=false)
+ @Enumerated(value=EnumType.STRING)
+ private Status status;
+
+ @Column(name="snapshot_type")
+ short snapshotType;
+
+ @Column(name="type_description")
+ String typeDescription;
+
+ @Column(name="size")
+ long size;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ Date created;
+
+ @Column(name=GenericDao.REMOVED_COLUMN)
+ Date removed;
+
+ @Column(name="backup_snap_id")
+ String backupSnapshotId;
+
+ @Column(name="swift_id")
+ Long swiftId;
+
+ @Column(name="s3_id")
+ Long s3Id;
+
+ @Column(name="sechost_id")
+ Long secHostId;
+
+ @Column(name="prev_snap_id")
+ long prevSnapshotId;
+
+ @Column(name="hypervisor_type")
+ @Enumerated(value=EnumType.STRING)
+ HypervisorType hypervisorType;
+
+ @Expose
+ @Column(name="version")
+ String version;
+
+ @Column(name="uuid")
+ String uuid;
+
+ public SnapshotVO() {
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String path, String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType ) {
+ this.dataCenterId = dcId;
+ this.accountId = accountId;
+ this.domainId = domainId;
+ this.volumeId = volumeId;
+ this.diskOfferingId = diskOfferingId;
+ this.path = path;
+ this.name = name;
+ this.snapshotType = snapshotType;
+ this.typeDescription = typeDescription;
+ this.size = size;
+ this.status = Status.Creating;
+ this.prevSnapshotId = 0;
+ this.hypervisorType = hypervisorType;
+ this.version = "2.2";
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getDataCenterId() {
+ return dataCenterId;
+ }
+
+
+ public long getAccountId() {
+ return accountId;
+ }
+
+
+ public long getDomainId() {
+ return domainId;
+ }
+
+ public long getVolumeId() {
+ return volumeId;
+ }
+
+ public long getDiskOfferingId() {
+ return diskOfferingId;
+ }
+
+ public void setVolumeId(Long volumeId) {
+ this.volumeId = volumeId;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public short getsnapshotType() {
+ return snapshotType;
+ }
+
+ public Type getType() {
+ if (snapshotType < 0 || snapshotType >= Type.values().length) {
+ return null;
+ }
+ return Type.values()[snapshotType];
+ }
+
+ public Long getSwiftId() {
+ return swiftId;
+ }
+
+ public void setSwiftId(Long swiftId) {
+ this.swiftId = swiftId;
+ }
+
+ public Long getSecHostId() {
+ return secHostId;
+ }
+
+ public void setSecHostId(Long secHostId) {
+ this.secHostId = secHostId;
+ }
+
+ public HypervisorType getHypervisorType() {
+ return hypervisorType;
+ }
+
+ public void setSnapshotType(short snapshotType) {
+ this.snapshotType = snapshotType;
+ }
+
+ public boolean isRecursive(){
+ if ( snapshotType >= Type.HOURLY.ordinal() && snapshotType <= Type.MONTHLY.ordinal() ) {
+ return true;
+ }
+ return false;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public String getTypeDescription() {
+ return typeDescription;
+ }
+ public void setTypeDescription(String typeDescription) {
+ this.typeDescription = typeDescription;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ public String getBackupSnapshotId(){
+ return backupSnapshotId;
+ }
+
+ public long getPrevSnapshotId(){
+ return prevSnapshotId;
+ }
+
+ public void setBackupSnapshotId(String backUpSnapshotId){
+ this.backupSnapshotId = backUpSnapshotId;
+ }
+
+ public void setPrevSnapshotId(long prevSnapshotId){
+ this.prevSnapshotId = prevSnapshotId;
+ }
+
+ public static Type getSnapshotType(String snapshotType) {
+ for ( Type type : Type.values()) {
+ if ( type.equals(snapshotType)) {
+ return type;
+ }
+ }
+ return null;
+ }
+
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public Long getS3Id() {
+ return s3Id;
+ }
+
+ public void setS3Id(Long s3Id) {
+ this.s3Id = s3Id;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/EndPoint.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/EndPoint.java b/engine/storage/src/org/apache/cloudstack/storage/EndPoint.java
deleted file mode 100644
index e92877c..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/EndPoint.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.cloudstack.storage;
-
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-
-public interface EndPoint {
- public Answer sendMessage(Command cmd);
- public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback);
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/HypervisorHostEndPoint.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/HypervisorHostEndPoint.java b/engine/storage/src/org/apache/cloudstack/storage/HypervisorHostEndPoint.java
index a2e9ea9..c4ebfb2 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/HypervisorHostEndPoint.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/HypervisorHostEndPoint.java
@@ -20,6 +20,7 @@ package org.apache.cloudstack.storage;
import javax.inject.Inject;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.log4j.Logger;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java b/engine/storage/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
index b0b3299..8aaca94 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
@@ -18,17 +18,15 @@
*/
package org.apache.cloudstack.storage.command;
-import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
-
import com.cloud.agent.api.Command;
public class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
- private final PrimaryDataStoreTO dataStore;
- public AttachPrimaryDataStoreCmd(PrimaryDataStoreTO dataStore) {
- this.dataStore = dataStore;
+ private final String dataStore;
+ public AttachPrimaryDataStoreCmd(String uri) {
+ this.dataStore = uri;
}
- public PrimaryDataStoreTO getDataStore() {
+ public String getDataStore() {
return this.dataStore;
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/command/CommandResult.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/command/CommandResult.java b/engine/storage/src/org/apache/cloudstack/storage/command/CommandResult.java
deleted file mode 100644
index d152863..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/command/CommandResult.java
+++ /dev/null
@@ -1,49 +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.command;
-
-public class CommandResult {
- private boolean success;
- private String result;
-
- public CommandResult() {
- this.success = true;
- this.result = "";
- }
-
- public boolean isSuccess() {
- return this.success;
- }
-
- public void setSucess(boolean success) {
- this.success = success;
- }
-
- public String getResult() {
- return this.result;
- }
-
- public void setResult(String result) {
- this.result = result;
- if (result != null) {
- this.success = false;
- }
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java b/engine/storage/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java
new file mode 100644
index 0000000..d9781bb
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java
@@ -0,0 +1,17 @@
+package org.apache.cloudstack.storage.command;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+
+public class CopyCmdAnswer extends Answer {
+ private final String path;
+
+ public CopyCmdAnswer(Command cmd, String path) {
+ super(cmd);
+ this.path = path;
+ }
+
+ public String getPath() {
+ return this.path;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/command/CopyTemplateToPrimaryStorageAnswer.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/command/CopyTemplateToPrimaryStorageAnswer.java b/engine/storage/src/org/apache/cloudstack/storage/command/CopyTemplateToPrimaryStorageAnswer.java
deleted file mode 100644
index 773a3e4..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/command/CopyTemplateToPrimaryStorageAnswer.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.cloudstack.storage.command;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-
-public class CopyTemplateToPrimaryStorageAnswer extends Answer {
- private final String path;
-
- public CopyTemplateToPrimaryStorageAnswer(Command cmd, String path) {
- super(cmd);
- this.path = path;
- }
-
- public String getPath() {
- return this.path;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/command/CreateVolumeCommand.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/command/CreateVolumeCommand.java b/engine/storage/src/org/apache/cloudstack/storage/command/CreateVolumeCommand.java
index c44970e..db643fe 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/command/CreateVolumeCommand.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/command/CreateVolumeCommand.java
@@ -18,16 +18,14 @@
*/
package org.apache.cloudstack.storage.command;
-import org.apache.cloudstack.storage.to.VolumeTO;
-
import com.cloud.agent.api.Command;
public class CreateVolumeCommand extends Command implements StorageSubSystemCommand {
- protected VolumeTO volumeTO;
+ protected String volumeUri;
- public CreateVolumeCommand(VolumeTO volumeTO) {
+ public CreateVolumeCommand(String volumeUri) {
super();
- this.volumeTO = volumeTO;
+ this.volumeUri = volumeUri;
}
protected CreateVolumeCommand() {
@@ -40,8 +38,8 @@ public class CreateVolumeCommand extends Command implements StorageSubSystemComm
return false;
}
- public VolumeTO getVolume() {
- return this.volumeTO;
+ public String getVolume() {
+ return this.volumeUri;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/command/DeleteCommand.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/command/DeleteCommand.java b/engine/storage/src/org/apache/cloudstack/storage/command/DeleteCommand.java
new file mode 100644
index 0000000..5d948d1
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/command/DeleteCommand.java
@@ -0,0 +1,44 @@
+/*
+ * 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.command;
+
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+import com.cloud.agent.api.Command;
+
+public class DeleteCommand extends Command implements StorageSubSystemCommand {
+ private String uri;
+ public DeleteCommand(String uri) {
+ this.uri = uri;
+ }
+
+ protected DeleteCommand() {
+
+ }
+ @Override
+ public boolean executeInSequence() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public String getUri() {
+ return this.uri;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/command/DeleteVolumeCommand.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/command/DeleteVolumeCommand.java b/engine/storage/src/org/apache/cloudstack/storage/command/DeleteVolumeCommand.java
deleted file mode 100644
index a30a83b..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/command/DeleteVolumeCommand.java
+++ /dev/null
@@ -1,44 +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.command;
-
-import org.apache.cloudstack.storage.to.VolumeTO;
-
-import com.cloud.agent.api.Command;
-
-public class DeleteVolumeCommand extends Command implements StorageSubSystemCommand {
- private VolumeTO volume;
- public DeleteVolumeCommand(VolumeTO volume) {
- this.volume = volume;
- }
-
- protected DeleteVolumeCommand() {
-
- }
- @Override
- public boolean executeInSequence() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public VolumeTO getVolume() {
- return this.volume;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStore.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStore.java
deleted file mode 100644
index df21b6e..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStore.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.cloudstack.storage.datastore;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.storage.EndPoint;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
-
-public interface DataStore {
- String grantAccess(VolumeInfo volume, EndPoint ep);
- boolean revokeAccess(VolumeInfo volume, EndPoint ep);
- String grantAccess(TemplateInfo template, EndPoint ep);
- boolean revokeAccess(TemplateInfo template, EndPoint ep);
- String grantAccess(SnapshotInfo snapshot, EndPoint ep);
- boolean revokeAccess(SnapshotInfo snapshot, EndPoint ep);
- String getRole();
- long getId();
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManager.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManager.java
new file mode 100644
index 0000000..829be50
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManager.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.datastore;
+
+import java.util.Map;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
+
+public interface DataStoreManager {
+ public DataStore getDataStore(long storeId, DataStoreRole role);
+ public DataStore registerDataStore(Map<String, String> params, String providerUuid);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
new file mode 100644
index 0000000..6e7df92
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreManagerImpl.java
@@ -0,0 +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.datastore;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+public class DataStoreManagerImpl implements DataStoreManager {
+ @Inject
+ PrimaryDataStoreProviderManager primaryStorMgr;
+ @Inject
+ ImageDataStoreManager imageDataStoreMgr;
+ @Override
+ public DataStore getDataStore(long storeId, DataStoreRole role) {
+ if (role == DataStoreRole.Primary) {
+ return primaryStorMgr.getPrimaryDataStore(storeId);
+ } else if (role == DataStoreRole.Image) {
+ return imageDataStoreMgr.getImageDataStore(storeId);
+ }
+ throw new CloudRuntimeException("un recognized type" + role);
+ }
+ @Override
+ public DataStore registerDataStore(Map<String, String> params,
+ String providerUuid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
new file mode 100644
index 0000000..23551e4
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.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.datastore;
+
+public enum DataStoreStatus {
+ Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance, ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
+}