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
[4/9] refactor api
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/ImageDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/ImageDataStoreDriver.java b/engine/storage/src/org/apache/cloudstack/storage/image/ImageDataStoreDriver.java
new file mode 100644
index 0000000..d352d97
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/ImageDataStoreDriver.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+
+public interface ImageDataStoreDriver extends DataStoreDriver {
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/ImageService.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/ImageService.java b/engine/storage/src/org/apache/cloudstack/storage/image/ImageService.java
index feff9c6..319406d 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/ImageService.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/ImageService.java
@@ -18,25 +18,11 @@
*/
package org.apache.cloudstack.storage.image;
-import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
-import org.apache.cloudstack.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.framework.async.AsyncCallFuture;
public interface ImageService {
- TemplateEntity registerTemplate(long templateId, long imageStoreId);
-
- boolean deleteTemplate(long templateId);
-
- long registerIso(String isoUrl, long accountId);
-
- boolean deleteIso(long isoId);
-
- boolean grantTemplateAccess(TemplateInfo template, EndPoint endpointId);
-
- boolean revokeTemplateAccess(long templateId, long endpointId);
-
- String grantIsoAccess(long isoId, long endpointId);
-
- boolean revokeIsoAccess(long isoId, long endpointId);
-
- TemplateEntity getTemplateEntity(long templateId);
+ AsyncCallFuture<CommandResult> createTemplateAsync(TemplateInfo template, DataStore store);
+ AsyncCallFuture<CommandResult> deleteTemplateAsync(TemplateInfo template);
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
index a9998ae..4dc68f0 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
@@ -24,7 +24,7 @@ import java.util.List;
import java.util.Map;
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
-import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStoreInfo;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Storage.ImageFormat;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEvent.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEvent.java b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEvent.java
new file mode 100644
index 0000000..44d0005
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEvent.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image;
+
+public enum TemplateEvent {
+ CreateRequested,
+ OperationFailed,
+ OperationSucceeded,
+ DestroyRequested;
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/TemplateInfo.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateInfo.java b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateInfo.java
index 45fb515..45ec268 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateInfo.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateInfo.java
@@ -18,17 +18,19 @@
*/
package org.apache.cloudstack.storage.image;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
-import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-public interface TemplateInfo {
- ImageDataStoreInfo getDataStore();
+import com.cloud.utils.fsm.NoTransitionException;
+
+public interface TemplateInfo extends DataObject {
+ DataStore getDataStore();
long getId();
-
- VolumeDiskType getDiskType();
String getPath();
String getUuid();
+
+ boolean stateTransit(TemplateEvent e) throws NoTransitionException;
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/TemplateState.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateState.java b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateState.java
new file mode 100644
index 0000000..c5981e3
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateState.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image;
+
+public enum TemplateState {
+ Allocated,
+ Creating,
+ Destroying,
+ Destroyed,
+ Ready;
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStore.java b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStore.java
new file mode 100644
index 0000000..a443f39
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStore.java
@@ -0,0 +1,35 @@
+/*
+ * 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.datastore;
+
+import java.util.Set;
+
+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.VolumeInfo;
+import org.apache.cloudstack.storage.image.TemplateInfo;
+import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
+
+public interface ImageDataStore extends DataStore {
+ TemplateInfo getTemplate(long templateId);
+ VolumeInfo getVolume(long volumeId);
+ SnapshotInfo getSnapshot(long snapshotId);
+ boolean exists(DataObject object);
+ Set<TemplateInfo> listTemplates();
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreHelper.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreHelper.java b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreHelper.java
new file mode 100644
index 0000000..e888192
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreHelper.java
@@ -0,0 +1,53 @@
+/*
+ * 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.datastore;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+public class ImageDataStoreHelper {
+ @Inject
+ ImageDataStoreDao imageStoreDao;
+ public ImageDataStoreVO createImageDataStore(Map<String, String> params) {
+ ImageDataStoreVO store = new ImageDataStoreVO();
+ store.setName(params.get("name"));
+ store.setProtocol(params.get("protocol"));
+ store.setProvider(Long.parseLong(params.get("provider")));
+ store = imageStoreDao.persist(store);
+ return store;
+ }
+
+ public boolean deleteImageDataStore(long id) {
+ ImageDataStoreVO store = imageStoreDao.findById(id);
+ if (store == null) {
+ throw new CloudRuntimeException("can't find image store:" + id);
+ }
+
+ imageStoreDao.remove(id);
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreInfo.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreInfo.java b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreInfo.java
new file mode 100644
index 0000000..b6b9a2a
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreInfo.java
@@ -0,0 +1,26 @@
+/*
+ * 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.datastore;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+
+public interface ImageDataStoreInfo extends DataStore {
+ public long getImageDataStoreId();
+ public String getType();
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreManager.java b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreManager.java
new file mode 100644
index 0000000..2bd361f
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageDataStoreManager.java
@@ -0,0 +1,26 @@
+/*
+ * 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.datastore;
+
+import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
+
+public interface ImageDataStoreManager {
+ ImageDataStore getImageDataStore(long dataStoreId);
+ boolean registerDriver(String uuid, ImageDataStoreDriver driver);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDao.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDao.java
index 5f79e96..b5db164 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDao.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDao.java
@@ -22,6 +22,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.cloudstack.storage.image.TemplateEvent;
+import org.apache.cloudstack.storage.image.TemplateState;
+
import com.cloud.domain.DomainVO;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.projects.Project.ListProjectResourcesCriteria;
@@ -29,8 +32,9 @@ import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
-public interface ImageDataDao extends GenericDao<ImageDataVO, Long> {
+public interface ImageDataDao extends GenericDao<ImageDataVO, Long>, StateDao<TemplateState, TemplateEvent, ImageDataVO> {
public List<ImageDataVO> listByPublic();
public ImageDataVO findByName(String templateName);
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDaoImpl.java
index f710a2d..3dbc844 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataDaoImpl.java
@@ -31,6 +31,8 @@ import java.util.Set;
import javax.naming.ConfigurationException;
+import org.apache.cloudstack.storage.image.TemplateEvent;
+import org.apache.cloudstack.storage.image.TemplateState;
import org.apache.cloudstack.storage.image.format.ISO;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -924,4 +926,11 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
}
+ @Override
+ public boolean updateState(TemplateState currentState, TemplateEvent event,
+ TemplateState nextState, ImageDataVO vo, Object data) {
+ // TODO Auto-generated method stub
+ return 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/image/db/ImageDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataStoreVO.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataStoreVO.java
index 5b660ec..0eb7536 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataStoreVO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataStoreVO.java
@@ -34,10 +34,16 @@ public class ImageDataStoreVO {
@Column(name = "name", nullable = false)
private String name;
+
+ @Column(name = "protocol", nullable = false)
+ private String protocol;
@Column(name = "image_provider_id", nullable = false)
private long provider;
-
+
+ @Column(name = "data_center_id")
+ private long dcId;
+
public long getId() {
return this.id;
}
@@ -57,4 +63,20 @@ public class ImageDataStoreVO {
public void setProvider(long provider) {
this.provider = provider;
}
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getProtocol() {
+ return this.protocol;
+ }
+
+ public void setDcId(long dcId) {
+ this.dcId = dcId;
+ }
+
+ public long getDcId() {
+ return this.dcId;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataVO.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataVO.java
index e66b7bb..f7274c3 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataVO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/ImageDataVO.java
@@ -34,16 +34,18 @@ import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.storage.image.TemplateState;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.VMTemplateVO;
import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateObject;
@Entity
@Table(name = "vm_template")
-public class ImageDataVO implements Identity {
+public class ImageDataVO implements Identity, StateObject<TemplateState> {
@Id
@TableGenerator(name = "vm_template_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "vm_template_seq", allocationSize = 1)
@Column(name = "id", nullable = false)
@@ -132,6 +134,12 @@ public class ImageDataVO implements Identity {
@Column(name = "image_data_store_id")
private long imageDataStoreId;
+
+ @Column(name = "size")
+ private long size;
+
+ @Column(name = "state")
+ private TemplateState state;
@Transient
Map details;
@@ -146,6 +154,7 @@ public class ImageDataVO implements Identity {
public ImageDataVO() {
this.uuid = UUID.randomUUID().toString();
+ this.state = TemplateState.Allocated;
}
public boolean getEnablePassword() {
@@ -397,5 +406,17 @@ public class ImageDataVO implements Identity {
public void setImageDataStoreId(long dataStoreId) {
this.imageDataStoreId = dataStoreId;
}
+
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ public long getSize() {
+ return this.size;
+ }
+
+ public TemplateState getState() {
+ return this.state;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/motion/ImageMotionService.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/motion/ImageMotionService.java b/engine/storage/src/org/apache/cloudstack/storage/image/motion/ImageMotionService.java
index 89de552..422bc06 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/motion/ImageMotionService.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/motion/ImageMotionService.java
@@ -18,8 +18,8 @@
*/
package org.apache.cloudstack.storage.image.motion;
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
import org.apache.cloudstack.storage.image.TemplateInfo;
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/image/store/ImageDataStoreInfo.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/store/ImageDataStoreInfo.java b/engine/storage/src/org/apache/cloudstack/storage/image/store/ImageDataStoreInfo.java
deleted file mode 100644
index 4c55c08..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/image/store/ImageDataStoreInfo.java
+++ /dev/null
@@ -1,27 +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;
-
-public interface ImageDataStoreInfo extends DataStore {
- public long getImageDataStoreId();
- public String getType();
- public String getUri();
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionDriver.java b/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionDriver.java
new file mode 100644
index 0000000..3a59b21
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionDriver.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.motion;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+
+public interface DataMotionDriver {
+ public void copy(DataObject srcObj, DataObject destObj);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionService.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionService.java b/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionService.java
new file mode 100644
index 0000000..db36f64
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionService.java
@@ -0,0 +1,28 @@
+/*
+ * 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.motion;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+
+public interface DataMotionService {
+ public void copyAsync(DataObject srcData, DataObject destData,
+ AsyncCompletionCallback<CopyCommandResult> callback);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java b/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java
new file mode 100644
index 0000000..343140f
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.motion;
+
+import java.util.List;
+
+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.framework.async.AsyncCompletionCallback;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+public class DataMotionServiceImpl implements DataMotionService {
+ @Inject
+ List<DataMotionStrategy> strategies;
+
+ @Override
+ public void copyAsync(DataObject srcData, DataObject destData,
+ AsyncCompletionCallback<CopyCommandResult> callback) {
+
+ if (srcData.getDataStore().getDriver().canCopy(srcData, destData)) {
+ srcData.getDataStore().getDriver()
+ .copyAsync(srcData, destData, callback);
+ return;
+ } else if (destData.getDataStore().getDriver()
+ .canCopy(srcData, destData)) {
+ destData.getDataStore().getDriver()
+ .copyAsync(srcData, destData, callback);
+ return;
+ }
+
+ for (DataMotionStrategy strategy : strategies) {
+ if (strategy.canHandle(srcData, destData)) {
+ strategy.copyAsync(srcData, destData, callback);
+ return;
+ }
+ }
+ throw new CloudRuntimeException("can't find strategy to move data");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionStrategy.java b/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionStrategy.java
new file mode 100644
index 0000000..ba40c6d
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/motion/DataMotionStrategy.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.motion;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+
+public interface DataMotionStrategy {
+ public boolean canHandle(DataObject srcData, DataObject destData);
+
+ public Void copyAsync(DataObject srcData, DataObject destData,
+ AsyncCompletionCallback<CopyCommandResult> callback);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactory.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactory.java b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactory.java
new file mode 100644
index 0000000..22d328f
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactory.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;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+
+public interface SnapshotDataFactory {
+ public SnapshotInfo getSnapshot(long snapshotId, DataStore store);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotInfo.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotInfo.java b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotInfo.java
index 478fe3d..983ec4d 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotInfo.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotInfo.java
@@ -1,8 +1,9 @@
package org.apache.cloudstack.storage.snapshot;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-public interface SnapshotInfo {
+public interface SnapshotInfo extends DataObject {
public String getName();
public SnapshotInfo getParent();
public SnapshotInfo getChild();
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/to/ImageDataStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/ImageDataStoreTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/ImageDataStoreTO.java
index 9fd335a..9f59a4f 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/to/ImageDataStoreTO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/to/ImageDataStoreTO.java
@@ -1,6 +1,6 @@
package org.apache.cloudstack.storage.to;
-import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStoreInfo;
public class ImageDataStoreTO {
private final String type;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/to/ImageOnPrimayDataStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/ImageOnPrimayDataStoreTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/ImageOnPrimayDataStoreTO.java
index f7c2322..18743d7 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/to/ImageOnPrimayDataStoreTO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/to/ImageOnPrimayDataStoreTO.java
@@ -22,11 +22,11 @@ import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
public class ImageOnPrimayDataStoreTO {
private final String pathOnPrimaryDataStore;
- private final PrimaryDataStoreTO dataStore;
+ private PrimaryDataStoreTO dataStore;
private final TemplateTO template;
public ImageOnPrimayDataStoreTO(TemplateOnPrimaryDataStoreInfo template) {
this.pathOnPrimaryDataStore = template.getPath();
- this.dataStore = template.getPrimaryDataStore().getDataStoreTO();
+ //this.dataStore = template.getPrimaryDataStore().getDataStoreTO();
this.template = new TemplateTO(template.getTemplate());
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java
index e0d18db..26a523a 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java
@@ -1,19 +1,19 @@
package org.apache.cloudstack.storage.to;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.image.store.ImageDataStoreInfo;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStoreInfo;
public class TemplateTO {
private final String path;
private final String uuid;
- private final VolumeDiskType diskType;
+ private DiskFormat diskType;
private final ImageDataStoreTO imageDataStore;
public TemplateTO(TemplateInfo template) {
this.path = template.getPath();
this.uuid = template.getUuid();
- this.diskType = template.getDiskType();
+ //this.diskType = template.getDiskType();
this.imageDataStore = new ImageDataStoreTO((ImageDataStoreInfo)template.getDataStore());
}
@@ -25,7 +25,7 @@ public class TemplateTO {
return this.uuid;
}
- public VolumeDiskType getDiskType() {
+ public DiskFormat getDiskType() {
return this.diskType;
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java b/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java
index 8ec117c..4373bad 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java
@@ -1,28 +1,29 @@
package org.apache.cloudstack.storage.to;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
public class VolumeTO {
private final String uuid;
private final String path;
- private final VolumeType volumeType;
- private final VolumeDiskType diskType;
+ private VolumeType volumeType;
+ private DiskFormat diskType;
private PrimaryDataStoreTO dataStore;
- private final String name;
+ private String name;
private final long size;
public VolumeTO(VolumeInfo volume) {
this.uuid = volume.getUuid();
- this.path = volume.getPath();
- this.volumeType = volume.getType();
- this.diskType = volume.getDiskType();
+ this.path = volume.getUri();
+ //this.volumeType = volume.getType();
+ //this.diskType = volume.getDiskType();
if (volume.getDataStore() != null) {
- this.dataStore = new PrimaryDataStoreTO(volume.getDataStore());
+ this.dataStore = new PrimaryDataStoreTO((PrimaryDataStoreInfo)volume.getDataStore());
} else {
this.dataStore = null;
}
- this.name = volume.getName();
+ //this.name = volume.getName();
this.size = volume.getSize();
}
@@ -38,7 +39,7 @@ public class VolumeTO {
return this.volumeType;
}
- public VolumeDiskType getDiskType() {
+ public DiskFormat getDiskType() {
return this.diskType;
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/volume/ObjectInDataStoreStateMachine.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/ObjectInDataStoreStateMachine.java b/engine/storage/src/org/apache/cloudstack/storage/volume/ObjectInDataStoreStateMachine.java
index 11cf2ef..d0530d1 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/ObjectInDataStoreStateMachine.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/ObjectInDataStoreStateMachine.java
@@ -23,8 +23,11 @@ import com.cloud.utils.fsm.StateObject;
public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataStoreStateMachine.State> {
enum State {
Allocated("The initial state"),
- Creating("The template is being downloading to data store"),
+ Creating2("This is only used with createOnlyRequested event"),
+ Creating("The object is being creating on data store"),
+ Created("The object is created"),
Ready("Template downloading is complished"),
+ Copying("The object is being coping"),
Destroying("Template is destroying"),
Destroyed("Template is destroyed"),
Failed("Failed to download template");
@@ -41,8 +44,11 @@ public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataS
enum Event {
CreateRequested,
+ CreateOnlyRequested,
DestroyRequested,
OperationSuccessed,
OperationFailed,
+ CopyingRequested,
+
}
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/volume/PrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/PrimaryDataStoreDriver.java b/engine/storage/src/org/apache/cloudstack/storage/volume/PrimaryDataStoreDriver.java
new file mode 100644
index 0000000..60db60b
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/PrimaryDataStoreDriver.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.volume;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
+
+public interface PrimaryDataStoreDriver extends DataStoreDriver {
+ public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback);
+ public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java
deleted file mode 100644
index b90a6d6..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java
+++ /dev/null
@@ -1,246 +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.volume;
-
-import java.lang.reflect.Method;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
-import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
-import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
-import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
-import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
-import org.apache.cloudstack.framework.async.AsyncCallFuture;
-import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.datastore.PrimaryDataStoreEntityImpl;
-import org.apache.cloudstack.storage.image.TemplateEntityImpl;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.volume.VolumeService.VolumeApiResult;
-
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public class VolumeEntityImpl implements VolumeEntity {
- private VolumeInfo volumeInfo;
- private final VolumeService vs;
- private VolumeApiResult result;
-
- protected VolumeEntityImpl() {
- this.vs = null;
- }
-
- public VolumeEntityImpl(VolumeInfo volumeObject, VolumeService vs) {
- this.volumeInfo = volumeObject;
- this.vs = vs;
- }
-
- public VolumeInfo getVolumeInfo() {
- return volumeInfo;
- }
-
- @Override
- public String getUuid() {
- return volumeInfo.getUuid();
- }
-
- @Override
- public long getId() {
- return volumeInfo.getId();
- }
-
- public String getExternalId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getCurrentState() {
- return volumeInfo.getCurrentState().toString();
- }
-
- @Override
- public String getDesiredState() {
- return volumeInfo.getDesiredState().toString();
- }
-
- @Override
- public Date getCreatedTime() {
- return volumeInfo.getCreatedDate();
- }
-
- @Override
- public Date getLastUpdatedTime() {
- return volumeInfo.getUpdatedDate();
- }
-
- @Override
- public String getOwner() {
- return volumeInfo.getOwner();
- }
-
-
- @Override
- public List<Method> getApplicableActions() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SnapshotEntity takeSnapshotOf(boolean full) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String reserveForMigration(long expirationTime) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void migrate(String reservationToken) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public VolumeEntity setupForCopy() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void copy(VolumeEntity dest) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void attachTo(String vm, long deviceId) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void detachFrom() {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public long getSize() {
- return volumeInfo.getSize();
- }
-
- @Override
- public VolumeDiskType getDiskType() {
- return volumeInfo.getDiskType();
- }
-
- @Override
- public VolumeType getType() {
- return volumeInfo.getType();
- }
-
- @Override
- public StorageEntity getDataStore() {
- return new PrimaryDataStoreEntityImpl(volumeInfo.getDataStore());
- }
-
- @Override
- public boolean createVolumeFromTemplate(long dataStoreId, VolumeDiskType diskType, TemplateEntity template) {
- TemplateInfo ti = ((TemplateEntityImpl)template).getTemplateInfo();
-
- AsyncCallFuture<VolumeApiResult> future = vs.createVolumeFromTemplateAsync(volumeInfo, dataStoreId, diskType, ti);
- try {
- result = future.get();
- if (!result.isSuccess()) {
- throw new CloudRuntimeException("create volume from template failed: " + result.getResult());
- }
- return true;
- } catch (InterruptedException e) {
- throw new CloudRuntimeException("wait result failed", e);
- } catch (ExecutionException e) {
- throw new CloudRuntimeException("wait result failed", e);
- }
- }
-
- @Override
- public boolean createVolume(long dataStoreId, VolumeDiskType diskType) {
- AsyncCallFuture<VolumeApiResult> future = vs.createVolumeAsync(volumeInfo, dataStoreId, diskType);
- try {
- result = future.get();
- if (result.isSuccess()) {
- return true;
- } else {
- throw new CloudRuntimeException("Failed to create volume:" + result.getResult());
- }
- } catch (InterruptedException e) {
- throw new CloudRuntimeException("wait volume info failed", e);
- } catch (ExecutionException e) {
- throw new CloudRuntimeException("wait volume failed", e);
- }
- }
-
- @Override
- public void destroy() {
- AsyncCallFuture<VolumeApiResult> future = vs.deleteVolumeAsync(volumeInfo);
- try {
- result = future.get();
- if (!result.isSuccess()) {
- throw new CloudRuntimeException("Failed to create volume:" + result.getResult());
- }
- } catch (InterruptedException e) {
- throw new CloudRuntimeException("wait to delete volume info failed", e);
- } catch (ExecutionException e) {
- throw new CloudRuntimeException("wait to delete volume failed", e);
- }
- }
-
- @Override
- public Map<String, String> getDetails() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void addDetail(String name, String value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void delDetail(String name, String value) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void updateDetail(String name, String value) {
- // TODO Auto-generated method stub
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
index 2bd2127..19a4c3a 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
@@ -19,13 +19,13 @@
package org.apache.cloudstack.storage.volume;
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
import org.apache.cloudstack.framework.async.AsyncCallFuture;
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.image.TemplateInfo;
public interface VolumeService {
@@ -52,7 +52,7 @@ public interface VolumeService {
*
* @return the volume object
*/
- AsyncCallFuture<VolumeApiResult> createVolumeAsync(VolumeInfo volume, long dataStoreId, VolumeDiskType diskType);
+ AsyncCallFuture<VolumeApiResult> createVolumeAsync(VolumeInfo volume, long dataStoreId);
/**
* Delete volume
@@ -87,5 +87,5 @@ public interface VolumeService {
VolumeEntity getVolumeEntity(long volumeId);
- AsyncCallFuture<VolumeApiResult> createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId, VolumeDiskType diskType, TemplateInfo template);
+ AsyncCallFuture<VolumeApiResult> createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId, TemplateInfo template);
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
new file mode 100644
index 0000000..a7397e1
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java
@@ -0,0 +1,77 @@
+/*
+ * 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.volume.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.EndPoint;
+import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
+import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+public class PrimaryDataStoreHelper {
+ @Inject
+ private PrimaryDataStoreDao dataStoreDao;
+ public PrimaryDataStoreVO createPrimaryDataStore(Map<String, String> params) {
+ PrimaryDataStoreVO dataStoreVO = dataStoreDao.findPoolByUUID(params.get("uuid"));
+ if (dataStoreVO != null) {
+ throw new CloudRuntimeException("duplicate uuid: " + params.get("uuid"));
+ }
+
+ dataStoreVO = new PrimaryDataStoreVO();
+ dataStoreVO.setStorageProviderId(Long.parseLong(params.get("providerId")));
+ dataStoreVO.setHostAddress(params.get("server"));
+ dataStoreVO.setPath(params.get("path"));
+ dataStoreVO.setPoolType(params.get("protocol"));
+ dataStoreVO.setPort(Integer.parseInt(params.get("port")));
+ //dataStoreVO.setKey(params.get("key"));
+ dataStoreVO.setName(params.get("name"));
+ dataStoreVO.setUuid(params.get("uuid"));
+ dataStoreVO = dataStoreDao.persist(dataStoreVO);
+ return dataStoreVO;
+ }
+
+ public boolean deletePrimaryDataStore(long id) {
+ PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(id);
+ if (dataStoreVO == null) {
+ throw new CloudRuntimeException("can't find store: " + id);
+ }
+ dataStoreDao.remove(id);
+ return true;
+ }
+
+ public void attachCluster(DataStore dataStore) {
+ //send down AttachPrimaryDataStoreCmd command to all the hosts in the cluster
+ AttachPrimaryDataStoreCmd cmd = new AttachPrimaryDataStoreCmd(dataStore.getUri());
+ /*for (EndPoint ep : dataStore.getEndPoints()) {
+ ep.sendMessage(cmd);
+ } */
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
index ee1600d..da8234e 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
@@ -33,7 +33,7 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.Unknown;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Volume;
@@ -113,7 +113,7 @@ public class VolumeVO implements Identity, StateObject<Volume.State> {
StoragePoolType poolType;
@Column(name = "disk_type")
- String diskType = new Unknown().toString();
+ DiskFormat diskType;
@Column(name = GenericDao.REMOVED_COLUMN)
Date removed;
@@ -406,11 +406,11 @@ public class VolumeVO implements Identity, StateObject<Volume.State> {
this.uuid = uuid;
}
- public String getDiskType() {
+ public DiskFormat getDiskType() {
return diskType;
}
- public void setDiskType(String type) {
+ public void setDiskType(DiskFormat type) {
diskType = type;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
deleted file mode 100644
index 23551e4..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DataStoreStatus.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.datastore;
-
-public enum DataStoreStatus {
- Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance, ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
index 7cca8bc..a67a47c 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
@@ -1,51 +1,46 @@
package org.apache.cloudstack.storage.datastore;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
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.ScopeType;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.EndPoint;
-import org.apache.cloudstack.storage.HypervisorHostEndPoint;
-import org.apache.cloudstack.storage.command.CommandResult;
-import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
-import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
+import org.apache.cloudstack.storage.datastore.provider.DataStoreProvider;
+import org.apache.cloudstack.storage.image.ImageDataFactory;
import org.apache.cloudstack.storage.image.TemplateInfo;
+import org.apache.cloudstack.storage.snapshot.SnapshotDataFactory;
import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
-import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
-import org.apache.cloudstack.storage.to.VolumeTO;
-import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
-import org.apache.cloudstack.storage.volume.TemplatePrimaryDataStoreManager;
+import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
import org.apache.cloudstack.storage.volume.VolumeObject;
import org.apache.cloudstack.storage.volume.db.VolumeDao2;
import org.apache.cloudstack.storage.volume.db.VolumeVO;
-
import org.apache.log4j.Logger;
-import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.utils.component.ComponentInject;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-import edu.emory.mathcs.backport.java.util.Collections;
+import com.cloud.utils.component.ComponentContext;
public class DefaultPrimaryDataStore implements PrimaryDataStore {
- private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStore.class);
+ private static final Logger s_logger = Logger
+ .getLogger(DefaultPrimaryDataStore.class);
protected PrimaryDataStoreDriver driver;
protected PrimaryDataStoreVO pdsv;
protected PrimaryDataStoreLifeCycle lifeCycle;
- protected PrimaryDataStoreProvider provider;
- protected StorageProtocolTransformer protocalTransformer;
+ protected DataStoreProvider provider;
+ //protected StorageProtocolTransformer protocalTransformer;
private HypervisorType supportedHypervisor;
private boolean isLocalStorageSupported = false;
@Inject
@@ -55,43 +50,31 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
@Inject
private PrimaryDataStoreDao dataStoreDao;
@Inject
- private TemplatePrimaryDataStoreManager templatePrimaryStoreMgr;
-
- private DefaultPrimaryDataStore(PrimaryDataStoreVO pdsv) {
+ private ObjectInDataStoreManager objectInStoreMgr;
+ @Inject
+ ImageDataFactory imageDataFactory;
+ @Inject
+ SnapshotDataFactory snapshotFactory;
+
+ private DefaultPrimaryDataStore(PrimaryDataStoreVO pdsv,
+ PrimaryDataStoreDriver driver,
+ DataStoreProvider provider) {
this.pdsv = pdsv;
- }
-
- public void setDriver(PrimaryDataStoreDriver driver) {
- driver.setDataStore(this);
this.driver = driver;
- }
-
- public void setLifeCycle(PrimaryDataStoreLifeCycle lifeCycle) {
- lifeCycle.setDataStore(this);
- this.lifeCycle = lifeCycle;
- }
-
- public void setProvider(PrimaryDataStoreProvider provider) {
this.provider = provider;
}
-
- public void setProtocolTransFormer(StorageProtocolTransformer transformer) {
- this.protocalTransformer = transformer;
- }
-
- @Override
- public PrimaryDataStoreTO getDataStoreTO() {
- return this.protocalTransformer.getDataStoreTO(this);
- }
-
+
@Override
- public VolumeTO getVolumeTO(VolumeInfo volume) {
- return this.protocalTransformer.getVolumeTO(volume);
+ public PrimaryDataStoreDriver getDriver() {
+ return this.driver;
}
-
- public static DefaultPrimaryDataStore createDataStore(PrimaryDataStoreVO pdsv) {
- DefaultPrimaryDataStore dataStore = new DefaultPrimaryDataStore(pdsv);
- return ComponentInject.inject(dataStore);
+
+ public static DefaultPrimaryDataStore createDataStore(
+ PrimaryDataStoreVO pdsv,
+ PrimaryDataStoreDriver driver,
+ DataStoreProvider provider) {
+ DefaultPrimaryDataStore dataStore = new DefaultPrimaryDataStore(pdsv, driver, provider);
+ return ComponentContext.inject(dataStore);
}
@Override
@@ -111,16 +94,13 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
return volumeInfos;
}
- @Override
- public void deleteVolumeAsync(VolumeInfo volume, AsyncCompletionCallback<CommandResult> callback) {
- CommandResult result = new CommandResult();
- if (volume.isAttachedVM()) {
- result.setResult("Can't delete volume: " + volume.getId() + ", if it's attached to a VM");
- callback.complete(result);
- }
- this.driver.deleteVolumeAsync((VolumeObject)volume, callback);
+/* @Override
+ public void deleteAsync(DataObject volume,
+ AsyncCompletionCallback<CommandResult> callback) {
+ this.driver.deleteAsync((VolumeObject) volume, callback);
}
-
+*/
+ /*
@Override
public List<EndPoint> getEndPoints() {
Long clusterId = pdsv.getClusterId();
@@ -131,27 +111,28 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
return new ArrayList<EndPoint>();
}
}
-
+
List<EndPoint> endpoints = new ArrayList<EndPoint>();
List<HostVO> hosts = hostDao.findHypervisorHostInCluster(clusterId);
for (HostVO host : hosts) {
- HypervisorHostEndPoint ep = new HypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress());
+ HypervisorHostEndPoint ep = new HypervisorHostEndPoint(
+ host.getId(), host.getPrivateIpAddress());
ComponentInject.inject(ep);
endpoints.add(ep);
}
Collections.shuffle(endpoints);
return endpoints;
- }
+ }*/
public void setSupportedHypervisor(HypervisorType type) {
this.supportedHypervisor = type;
}
-
+
@Override
public boolean isHypervisorSupported(HypervisorType hypervisor) {
return (this.supportedHypervisor == hypervisor) ? true : false;
}
-
+
public void setLocalStorageFlag(boolean supported) {
this.isLocalStorageSupported = supported;
}
@@ -162,43 +143,53 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
}
@Override
- public boolean isVolumeDiskTypeSupported(VolumeDiskType diskType) {
+ public boolean isVolumeDiskTypeSupported(DiskFormat diskType) {
return true;
}
@Override
public long getCapacity() {
- return this.driver.getCapacity();
+ return 0;
}
@Override
public long getAvailableCapacity() {
- return this.driver.getAvailableCapacity();
+ //return this.driver.getAvailableCapacity();
+ return 0;
}
- @Override
- public void createVolumeAsync(VolumeInfo vi, VolumeDiskType diskType, AsyncCompletionCallback<CommandResult> callback) {
- if (!isVolumeDiskTypeSupported(diskType)) {
- throw new CloudRuntimeException("disk type " + diskType + " is not supported");
- }
- VolumeObject vo = (VolumeObject) vi;
- vo.setVolumeDiskType(diskType);
- this.driver.createVolumeAsync(vo, callback);
+/* @Override
+ public void createAsync(DataObject data,
+ AsyncCompletionCallback<CommandResult> callback) {
+ this.provider.getVolumeDriver().createAsync(data, callback);
+ }
+*/
+/* @Override
+ public void takeSnapshot(SnapshotInfo snapshot,
+ AsyncCompletionCallback<CommandResult> callback) {
+ this.provider.getSnapshotDriver().takeSnapshot(snapshot, callback);
+ }
+*/
+/* @Override
+ public void revertSnapshot(SnapshotInfo snapshot,
+ AsyncCompletionCallback<CommandResult> callback) {
+ this.provider.getSnapshotDriver().revertSnapshot(snapshot, callback);
}
@Override
- public boolean exists(VolumeInfo vi) {
- VolumeVO vol = volumeDao.findByVolumeIdAndPoolId(vi.getId(), this.getId());
- return (vol != null) ? true : false;
+ public void deleteSnapshot(SnapshotInfo snapshot,
+ AsyncCompletionCallback<CommandResult> callback) {
+ this.provider.getSnapshotDriver().deleteSnapshot(snapshot, callback);
}
-
+*/
@Override
- public boolean templateExists(TemplateInfo template) {
- return (templatePrimaryStoreMgr.findTemplateOnPrimaryDataStore(template, this) != null) ? true : false;
+ public boolean exists(DataObject data) {
+ return (objectInStoreMgr.findObject(data.getId(), data.getType(), this.getId(), this.getRole()) != null) ? true
+ : false;
}
@Override
- public VolumeDiskType getDefaultDiskType() {
+ public DiskFormat getDefaultDiskType() {
// TODO Auto-generated method stub
return null;
}
@@ -209,31 +200,19 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
}
@Override
- public TemplateOnPrimaryDataStoreInfo getTemplate(TemplateInfo template) {
- return templatePrimaryStoreMgr.findTemplateOnPrimaryDataStore(template, this);
+ public TemplateInfo getTemplate(long templateId) {
+ return imageDataFactory.getTemplate(templateId, this);
}
- @Override
- public VolumeInfo createVoluemFromBaseImage(VolumeInfo volume, TemplateOnPrimaryDataStoreInfo template) {
- VolumeObject vo = (VolumeObject) volume;
- vo.setVolumeDiskType(template.getTemplate().getDiskType());
- //this.driver.createVolumeFromBaseImage(vo, template);
- return volume;
- }
-
- @Override
- public void createVoluemFromBaseImageAsync(VolumeInfo volume, TemplateInfo templateStore, AsyncCompletionCallback<CommandResult> callback) {
+/* @Override
+ public void createVoluemFromBaseImageAsync(VolumeInfo volume,
+ TemplateInfo template,
+ AsyncCompletionCallback<CommandResult> callback) {
VolumeObject vo = (VolumeObject) volume;
- vo.setVolumeDiskType(templateStore.getDiskType());
- String templateUri = templateStore.getDataStore().grantAccess(templateStore, this.getEndPoints().get(0));
- this.driver.createVolumeFromBaseImageAsync(vo, templateUri, callback);
- }
-
- @Override
- public boolean installTemplate(TemplateOnPrimaryDataStoreInfo template) {
- // TODO Auto-generated method stub
- return true;
+ vo.setVolumeDiskType(template.getDiskType());
+ this.driver.createVolumeFromBaseImageAsync(vo, template, callback);
}
+*/
@Override
public String getUuid() {
@@ -255,56 +234,40 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
return this.pdsv.getPoolType();
}
- @Override
- public PrimaryDataStoreLifeCycle getLifeCycle() {
- return lifeCycle;
- }
-
- @Override
- public PrimaryDataStoreProvider getProvider() {
+ public DataStoreProvider getProvider() {
return this.provider;
}
@Override
- public String grantAccess(VolumeInfo volume, EndPoint ep) {
- return this.driver.grantAccess((VolumeObject)volume, ep);
+ public DataStoreRole getRole() {
+ return DataStoreRole.Primary;
}
@Override
- public boolean revokeAccess(VolumeInfo volume, EndPoint ep) {
- // TODO Auto-generated method stub
- return false;
+ public String getUri() {
+ return this.pdsv.getPoolType() + File.separator
+ + this.pdsv.getHostAddress() + File.separator
+ + this.pdsv.getPath();
}
@Override
- public String grantAccess(TemplateInfo template, EndPoint ep) {
- // TODO Auto-generated method stub
- return null;
+ public PrimaryDataStoreLifeCycle getLifeCycle() {
+ return this.lifeCycle;
}
@Override
- public boolean revokeAccess(TemplateInfo template, EndPoint ep) {
- // TODO Auto-generated method stub
- return false;
+ public SnapshotInfo getSnapshot(long snapshotId) {
+ return snapshotFactory.getSnapshot(snapshotId, this);
}
@Override
- public String grantAccess(SnapshotInfo snapshot, EndPoint ep) {
- // TODO Auto-generated method stub
+ public Scope getScope() {
+ if (pdsv.getScope() == ScopeType.CLUSTER) {
+ return new ClusterScope(pdsv.getClusterId(), pdsv.getPodId(), pdsv.getDataCenterId());
+ } else if (pdsv.getScope() == ScopeType.ZONE) {
+ return new ZoneScope(pdsv.getDataCenterId());
+ }
+
return null;
}
-
- @Override
- public boolean revokeAccess(SnapshotInfo snapshot, EndPoint ep) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public String getRole() {
- // TODO Auto-generated method stub
- return "volumeStore";
- }
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/AbstractPrimaryDataStoreConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/AbstractPrimaryDataStoreConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/AbstractPrimaryDataStoreConfigurator.java
deleted file mode 100644
index db1fbde..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/AbstractPrimaryDataStoreConfigurator.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.cloudstack.storage.datastore.configurator;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
-import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
-import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
-import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public abstract class AbstractPrimaryDataStoreConfigurator implements PrimaryDataStoreConfigurator {
- @Inject
- protected PrimaryDataStoreDao dataStoreDao;
-
- protected abstract PrimaryDataStoreLifeCycle getLifeCycle();
-
- protected abstract PrimaryDataStoreDriver getDriver();
-
- protected abstract boolean isLocalStorageSupported();
-
- @Override
- public PrimaryDataStore getDataStore(long dataStoreId) {
- PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(dataStoreId);
- if (dataStoreVO == null) {
- throw new CloudRuntimeException("Can't find primary data store: " + dataStoreId);
- }
-
- DefaultPrimaryDataStore dataStore = DefaultPrimaryDataStore.createDataStore(dataStoreVO);
- dataStore.setDriver(getDriver());
- dataStore.setLifeCycle(getLifeCycle());
- dataStore.setSupportedHypervisor(getSupportedHypervisor());
- dataStore.setLocalStorageFlag(isLocalStorageSupported());
- dataStore.setProtocolTransFormer(getProtocolTransformer());
- return dataStore;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/PrimaryDataStoreConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/PrimaryDataStoreConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/PrimaryDataStoreConfigurator.java
deleted file mode 100644
index e868b4e..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/PrimaryDataStoreConfigurator.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.datastore.configurator;
-
-import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
-import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.Storage.StoragePoolType;
-
-public interface PrimaryDataStoreConfigurator {
- public HypervisorType getSupportedHypervisor();
- public String getSupportedDataStoreType();
- public PrimaryDataStore getDataStore(long dataStoreId);
- public StorageProtocolTransformer getProtocolTransformer();
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/AbstractKvmConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/AbstractKvmConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/AbstractKvmConfigurator.java
deleted file mode 100644
index 008af85..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/AbstractKvmConfigurator.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.datastore.configurator.kvm;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
-import org.apache.cloudstack.storage.datastore.configurator.AbstractPrimaryDataStoreConfigurator;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
-import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
-import org.apache.cloudstack.storage.datastore.lifecycle.DefaultKvmPrimaryDataStoreLifeCycle;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-
-public abstract class AbstractKvmConfigurator extends AbstractPrimaryDataStoreConfigurator {
- @Inject
- PrimaryDataStoreDao dataStoreDao;
-
- @Override
- public HypervisorType getSupportedHypervisor() {
- return HypervisorType.KVM;
- }
-
- protected PrimaryDataStoreLifeCycle getLifeCycle() {
- return new DefaultKvmPrimaryDataStoreLifeCycle(dataStoreDao);
- }
-
- protected PrimaryDataStoreDriver getDriver() {
- return new DefaultPrimaryDataStoreDriverImpl();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2f86003/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.java
deleted file mode 100644
index f0b581f..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/kvm/KvmCLVMConfigurator.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.datastore.configurator.kvm;
-
-import org.apache.cloudstack.storage.datastore.configurator.validator.CLVMProtocolTransformer;
-import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
-
-@Component
-@Qualifier("defaultProvider")
-public class KvmCLVMConfigurator extends AbstractKvmConfigurator {
-
- @Override
- public String getSupportedDataStoreType() {
- return "clvm";
- }
-
- @Override
- public StorageProtocolTransformer getProtocolTransformer() {
- return new CLVMProtocolTransformer();
- }
-
- @Override
- protected boolean isLocalStorageSupported() {
- // TODO Auto-generated method stub
- return false;
- }
-
-
-}