You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/07/29 19:54:46 UTC
[1/4] Removed schema from the dependency of many components
Updated Branches:
refs/heads/master 399c37345 -> a4cea4ebf
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
new file mode 100644
index 0000000..300df1e
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
@@ -0,0 +1,271 @@
+// 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.db;
+
+import java.util.Date;
+
+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 javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
+
+import com.cloud.storage.DataStoreRole;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.fsm.StateObject;
+
+/**
+ * Join table for image_data_store and snapshots
+ *
+ */
+@Entity
+@Table(name = "snapshot_store_ref")
+public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ Long id;
+
+ @Column(name = "store_id")
+ private long dataStoreId;
+
+ @Column(name = "store_role")
+ @Enumerated(EnumType.STRING)
+ private DataStoreRole role;
+
+ @Column(name = "snapshot_id")
+ private long snapshotId;
+
+ @Column(name = GenericDaoBase.CREATED_COLUMN)
+ private Date created = null;
+
+ @Column(name = "last_updated")
+ @Temporal(value = TemporalType.TIMESTAMP)
+ private Date lastUpdated = null;
+
+ @Column(name = "size")
+ private long size;
+
+ @Column(name = "physical_size")
+ private long physicalSize;
+
+ @Column(name = "parent_snapshot_id")
+ private long parentSnapshotId;
+
+ @Column(name = "job_id")
+ private String jobId;
+
+ @Column(name = "install_path")
+ private String installPath;
+
+ @Column(name = "update_count", updatable = true, nullable = false)
+ protected long updatedCount;
+
+ @Column(name = "updated")
+ @Temporal(value = TemporalType.TIMESTAMP)
+ Date updated;
+
+ @Column(name = "state")
+ @Enumerated(EnumType.STRING)
+ ObjectInDataStoreStateMachine.State state;
+
+ @Column(name = "ref_cnt")
+ Long refCnt = 0L;
+
+ @Column(name = "volume_id")
+ Long volumeId;
+
+ public String getInstallPath() {
+ return installPath;
+ }
+
+ @Override
+ public long getDataStoreId() {
+ return dataStoreId;
+ }
+
+ public void setDataStoreId(long storeId) {
+ this.dataStoreId = storeId;
+ }
+
+ public long getSnapshotId() {
+ return snapshotId;
+ }
+
+ public void setSnapshotId(long snapshotId) {
+ this.snapshotId = snapshotId;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(Date date) {
+ lastUpdated = date;
+ }
+
+ public void setInstallPath(String installPath) {
+ this.installPath = installPath;
+ }
+
+ public SnapshotDataStoreVO(long hostId, long snapshotId) {
+ super();
+ this.dataStoreId = hostId;
+ this.snapshotId = snapshotId;
+ this.state = ObjectInDataStoreStateMachine.State.Allocated;
+ }
+
+ public SnapshotDataStoreVO() {
+
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof SnapshotDataStoreVO) {
+ SnapshotDataStoreVO other = (SnapshotDataStoreVO) obj;
+ return (this.snapshotId == other.getSnapshotId() && this.dataStoreId == other.getDataStoreId());
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ Long tid = new Long(snapshotId);
+ Long hid = new Long(dataStoreId);
+ return tid.hashCode() + hid.hashCode();
+ }
+
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public void setPhysicalSize(long physicalSize) {
+ this.physicalSize = physicalSize;
+ }
+
+ public long getPhysicalSize() {
+ return physicalSize;
+ }
+
+ public long getVolumeSize() {
+ return -1;
+ }
+
+ public String toString() {
+ return new StringBuilder("VolumeHost[").append(id).append("-").append(snapshotId).append("-")
+ .append(dataStoreId).append(installPath).append("]").toString();
+ }
+
+ public long getUpdatedCount() {
+ return this.updatedCount;
+ }
+
+ public void incrUpdatedCount() {
+ this.updatedCount++;
+ }
+
+ public void decrUpdatedCount() {
+ this.updatedCount--;
+ }
+
+ public Date getUpdated() {
+ return updated;
+ }
+
+ @Override
+ public ObjectInDataStoreStateMachine.State getState() {
+ // TODO Auto-generated method stub
+ return this.state;
+ }
+
+ public void setState(ObjectInDataStoreStateMachine.State state) {
+ this.state = state;
+ }
+
+ @Override
+ public long getObjectId() {
+ return this.getSnapshotId();
+ }
+
+ public DataStoreRole getRole() {
+ return role;
+ }
+
+ public void setRole(DataStoreRole role) {
+ this.role = role;
+ }
+
+ @Override
+ public State getObjectInStoreState() {
+ return this.state;
+ }
+
+ public long getParentSnapshotId() {
+ return parentSnapshotId;
+ }
+
+ public void setParentSnapshotId(long parentSnapshotId) {
+ this.parentSnapshotId = parentSnapshotId;
+ }
+
+ public Long getRefCnt() {
+ return refCnt;
+ }
+
+ public void incrRefCnt() {
+ this.refCnt++;
+ }
+
+ public void decrRefCnt() {
+ this.refCnt--;
+ }
+
+ public Long getVolumeId() {
+ return volumeId;
+ }
+
+ public void setVolumeId(Long volumeId) {
+ this.volumeId = volumeId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
new file mode 100644
index 0000000..e51f3a3
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
@@ -0,0 +1,81 @@
+// 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.db;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "storage_pool_details")
+public class StoragePoolDetailVO implements InternalIdentity {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ long id;
+
+ @Column(name = "pool_id")
+ long poolId;
+
+ @Column(name = "name")
+ String name;
+
+ @Column(name = "value")
+ String value;
+
+ public StoragePoolDetailVO(long poolId, String name, String value) {
+ this.poolId = poolId;
+ this.name = name;
+ this.value = value;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getPoolId() {
+ return poolId;
+ }
+
+ public void setPoolId(long poolId) {
+ this.poolId = poolId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ protected StoragePoolDetailVO() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
new file mode 100644
index 0000000..49f4f19
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.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.datastore.db;
+
+import java.util.Map;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface StoragePoolDetailsDao extends GenericDao<StoragePoolDetailVO, Long> {
+
+ void update(long poolId, Map<String, String> details);
+
+ Map<String, String> getDetails(long poolId);
+
+ StoragePoolDetailVO findDetail(long poolId, String name);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
new file mode 100644
index 0000000..941b952
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
@@ -0,0 +1,346 @@
+// 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.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.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.storage.ScopeType;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.StoragePoolStatus;
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = "storage_pool")
+public class StoragePoolVO implements StoragePool {
+ @Id
+ @TableGenerator(name = "storage_pool_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value",
+ pkColumnValue = "storage_pool_seq", allocationSize = 1)
+ @Column(name = "id", updatable = false, nullable = false)
+ private long id;
+
+ @Column(name = "name", updatable = false, nullable = false, length = 255)
+ private String name = null;
+
+ @Column(name = "uuid", length = 255)
+ private String uuid = null;
+
+ @Column(name = "pool_type", updatable = false, nullable = false, length = 32)
+ @Enumerated(value = EnumType.STRING)
+ private StoragePoolType poolType;
+
+ @Column(name = GenericDao.CREATED_COLUMN)
+ Date created;
+
+ @Column(name = GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ @Column(name = "update_time", updatable = true)
+ @Temporal(value = TemporalType.TIMESTAMP)
+ private Date updateTime;
+
+ @Column(name = "data_center_id", updatable = true, nullable = false)
+ private long dataCenterId;
+
+ @Column(name = "pod_id", updatable = true)
+ private Long podId;
+
+ @Column(name = "used_bytes", updatable = true, nullable = true)
+ private long usedBytes;
+
+ @Column(name = "capacity_bytes", updatable = true, nullable = true)
+ private long capacityBytes;
+
+ @Column(name = "status", updatable = true, nullable = false)
+ @Enumerated(value = EnumType.STRING)
+ private StoragePoolStatus status;
+
+ @Column(name = "storage_provider_name", updatable = true, nullable = false)
+ private String storageProviderName;
+
+ @Column(name = "host_address")
+ private String hostAddress;
+
+ @Column(name = "path")
+ private String path;
+
+ @Column(name = "port")
+ private int port;
+
+ @Column(name = "user_info")
+ private String userInfo;
+
+ @Column(name = "cluster_id")
+ private Long clusterId;
+
+ @Column(name = "scope")
+ @Enumerated(value = EnumType.STRING)
+ private ScopeType scope;
+
+ @Column(name = "managed")
+ private boolean managed;
+
+ @Column(name = "capacity_iops", updatable = true, nullable = true)
+ private Long capacityIops;
+
+ @Column(name = "hypervisor")
+ @Enumerated(value = EnumType.STRING)
+ private HypervisorType hypervisor;
+
+ public long getId() {
+ return id;
+ }
+
+ public StoragePoolStatus getStatus() {
+ return status;
+ }
+
+ public StoragePoolVO() {
+ this.status = StoragePoolStatus.Initial;
+ }
+
+ public StoragePoolVO(long poolId, String name, String uuid, StoragePoolType type, long dataCenterId, Long podId,
+ long availableBytes, long capacityBytes, String hostAddress, int port, String hostPath) {
+ this.name = name;
+ this.id = poolId;
+ this.uuid = uuid;
+ this.poolType = type;
+ this.dataCenterId = dataCenterId;
+ this.usedBytes = availableBytes;
+ this.capacityBytes = capacityBytes;
+ this.hostAddress = hostAddress;
+ this.path = hostPath;
+ this.port = port;
+ this.podId = podId;
+ this.setStatus(StoragePoolStatus.Initial);
+ }
+
+ public StoragePoolVO(StoragePoolVO that) {
+ this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, that.podId, that.usedBytes,
+ that.capacityBytes, that.hostAddress, that.port, that.path);
+ }
+
+ public StoragePoolVO(StoragePoolType type, String hostAddress, int port, String path) {
+ this.poolType = type;
+ this.hostAddress = hostAddress;
+ this.port = port;
+ this.path = path;
+ this.setStatus(StoragePoolStatus.Initial);
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public StoragePoolType getPoolType() {
+ return poolType;
+ }
+
+ public void setPoolType(StoragePoolType protocol) {
+ this.poolType = protocol;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public Date getUpdateTime() {
+ return updateTime;
+ }
+
+ public long getDataCenterId() {
+ return dataCenterId;
+ }
+
+ public long getUsedBytes() {
+ return usedBytes;
+ }
+
+ public String getStorageProviderName() {
+ return storageProviderName;
+ }
+
+ public void setStorageProviderName(String providerName) {
+ storageProviderName = providerName;
+ }
+
+ public long getCapacityBytes() {
+ return capacityBytes;
+ }
+
+ public void setUsedBytes(long usedBytes) {
+ this.usedBytes = usedBytes;
+ }
+
+ public void setCapacityBytes(long capacityBytes) {
+ this.capacityBytes = capacityBytes;
+ }
+
+ public void setManaged(boolean managed) {
+ this.managed = managed;
+ }
+
+ public boolean isManaged() {
+ return managed;
+ }
+
+ public void setCapacityIops(Long capacityIops) {
+ this.capacityIops = capacityIops;
+ }
+
+ public Long getCapacityIops() {
+ return capacityIops;
+ }
+
+ public Long getClusterId() {
+ return clusterId;
+ }
+
+ public void setClusterId(Long clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ public String getHostAddress() {
+ return hostAddress;
+ }
+
+ public void setHostAddress(String host) {
+ this.hostAddress = host;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getUserInfo() {
+ return userInfo;
+ }
+
+ public void setStatus(StoragePoolStatus status) {
+ this.status = status;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public void setDataCenterId(long dcId) {
+ this.dataCenterId = dcId;
+ }
+
+ public void setPodId(Long podId) {
+ this.podId = podId;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public void setUserInfo(String userInfo) {
+ this.userInfo = userInfo;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public Long getPodId() {
+ return podId;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setScope(ScopeType scope) {
+ this.scope = scope;
+ }
+
+ public ScopeType getScope() {
+ return this.scope;
+ }
+
+ public HypervisorType getHypervisor() {
+ return hypervisor;
+ }
+
+ public void setHypervisor(HypervisorType hypervisor) {
+ this.hypervisor = hypervisor;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof StoragePoolVO) || obj == null) {
+ return false;
+ }
+ StoragePoolVO that = (StoragePoolVO) obj;
+ return this.id == that.id;
+ }
+
+ @Override
+ public int hashCode() {
+ return new Long(id).hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("Pool[").append(id).append("|").append(poolType).append("]").toString();
+ }
+
+ public boolean isShared() {
+ return this.scope == ScopeType.HOST ? false : true;
+ }
+
+ public boolean isLocal() {
+ return !isShared();
+ }
+
+ @Override
+ public boolean isInMaintenance() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
new file mode 100644
index 0000000..9350751
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
@@ -0,0 +1,65 @@
+// 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.db;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.VMTemplateStorageResourceAssoc;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Long>,
+StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
+
+ List<TemplateDataStoreVO> listByStoreId(long id);
+
+ List<TemplateDataStoreVO> listDestroyed(long storeId);
+
+ List<TemplateDataStoreVO> listActiveOnCache(long id);
+
+ void deletePrimaryRecordsForStore(long id);
+
+ void deletePrimaryRecordsForTemplate(long templateId);
+
+ List<TemplateDataStoreVO> listByTemplateStore(long templateId, long storeId);
+
+ List<TemplateDataStoreVO> listByTemplateStoreStatus(long templateId, long storeId, State... states);
+
+ List<TemplateDataStoreVO> listByTemplateStoreDownloadStatus(long templateId, long storeId,
+ VMTemplateStorageResourceAssoc.Status... status);
+
+ List<TemplateDataStoreVO> listByTemplateZoneDownloadStatus(long templateId, Long zoneId,
+ VMTemplateStorageResourceAssoc.Status... status);
+
+ TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId,
+ VMTemplateStorageResourceAssoc.Status... status);
+
+ TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId);
+
+ TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId, boolean lock);
+
+ TemplateDataStoreVO findByTemplate(long templateId, DataStoreRole role);
+
+ TemplateDataStoreVO findByTemplateZone(long templateId, Long zoneId, DataStoreRole role);
+
+ List<TemplateDataStoreVO> listByTemplate(long templateId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
new file mode 100755
index 0000000..b6af559
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
@@ -0,0 +1,372 @@
+// 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.db;
+
+import java.util.Date;
+
+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 javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
+
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.fsm.StateObject;
+
+/**
+ * Join table for image_data_store and templates
+ *
+ */
+@Entity
+@Table(name = "template_store_ref")
+public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ Long id;
+
+ @Column(name = "store_id")
+ private Long dataStoreId; // this can be null for baremetal templates
+
+ @Column(name = "template_id")
+ private long templateId;
+
+ @Column(name = "store_role")
+ @Enumerated(EnumType.STRING)
+ private DataStoreRole dataStoreRole;
+
+ @Column(name = GenericDaoBase.CREATED_COLUMN)
+ private Date created = null;
+
+ @Column(name = "last_updated")
+ @Temporal(value = TemporalType.TIMESTAMP)
+ private Date lastUpdated = null;
+
+ @Column(name = "download_pct")
+ private int downloadPercent;
+
+ @Column(name = "size")
+ private Long size;
+
+ @Column(name = "physical_size")
+ private long physicalSize;
+
+ @Column(name = "download_state")
+ @Enumerated(EnumType.STRING)
+ private Status downloadState;
+
+ @Column(name = "local_path")
+ private String localDownloadPath;
+
+ @Column(name = "error_str")
+ private String errorString;
+
+ @Column(name = "job_id")
+ private String jobId;
+
+ @Column(name = "install_path")
+ private String installPath;
+
+ @Column(name = "url")
+ private String downloadUrl;
+
+ @Column(name = "is_copy")
+ private boolean isCopy = false;
+
+ @Column(name = "destroyed")
+ boolean destroyed = false;
+
+ @Column(name = "update_count", updatable = true, nullable = false)
+ protected long updatedCount;
+
+ @Column(name = "updated")
+ @Temporal(value = TemporalType.TIMESTAMP)
+ Date updated;
+
+ @Column(name = "state")
+ @Enumerated(EnumType.STRING)
+ ObjectInDataStoreStateMachine.State state;
+
+ @Column(name = "ref_cnt")
+ Long refCnt = 0L;
+
+ public TemplateDataStoreVO(Long hostId, long templateId) {
+ super();
+ this.dataStoreId = hostId;
+ this.templateId = templateId;
+ this.state = ObjectInDataStoreStateMachine.State.Allocated;
+ this.refCnt = 0L;
+ }
+
+ public TemplateDataStoreVO(Long hostId, long templateId, Date lastUpdated, int downloadPercent,
+ Status downloadState, String localDownloadPath, String errorString, String jobId, String installPath,
+ String downloadUrl) {
+ super();
+ this.dataStoreId = hostId;
+ this.templateId = templateId;
+ this.lastUpdated = lastUpdated;
+ this.downloadPercent = downloadPercent;
+ this.downloadState = downloadState;
+ this.localDownloadPath = localDownloadPath;
+ this.errorString = errorString;
+ this.jobId = jobId;
+ this.refCnt = 0L;
+ this.installPath = installPath;
+ this.setDownloadUrl(downloadUrl);
+ switch (downloadState) {
+ case DOWNLOADED:
+ this.state = ObjectInDataStoreStateMachine.State.Ready;
+ break;
+ case CREATING:
+ case DOWNLOAD_IN_PROGRESS:
+ case UPLOAD_IN_PROGRESS:
+ this.state = ObjectInDataStoreStateMachine.State.Creating2;
+ break;
+ case DOWNLOAD_ERROR:
+ case UPLOAD_ERROR:
+ this.state = ObjectInDataStoreStateMachine.State.Failed;
+ break;
+ case ABANDONED:
+ this.state = ObjectInDataStoreStateMachine.State.Destroyed;
+ break;
+ default:
+ this.state = ObjectInDataStoreStateMachine.State.Allocated;
+ break;
+ }
+ }
+
+ public TemplateDataStoreVO() {
+ this.refCnt = 0L;
+ }
+
+ @Override
+ public String getInstallPath() {
+ return installPath;
+ }
+
+ @Override
+ public long getDataStoreId() {
+ return dataStoreId;
+ }
+
+ public void setDataStoreId(long storeId) {
+ this.dataStoreId = storeId;
+ }
+
+ public long getTemplateId() {
+ return templateId;
+ }
+
+ public void setTemplateId(long templateId) {
+ this.templateId = templateId;
+ }
+
+ public int getDownloadPercent() {
+ return downloadPercent;
+ }
+
+ public void setDownloadPercent(int downloadPercent) {
+ this.downloadPercent = downloadPercent;
+ }
+
+ public void setDownloadState(Status downloadState) {
+ this.downloadState = downloadState;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(Date date) {
+ lastUpdated = date;
+ }
+
+ @Override
+ public void setInstallPath(String installPath) {
+ this.installPath = installPath;
+ }
+
+ public Status getDownloadState() {
+ return downloadState;
+ }
+
+ public void setLocalDownloadPath(String localPath) {
+ this.localDownloadPath = localPath;
+ }
+
+ public String getLocalDownloadPath() {
+ return localDownloadPath;
+ }
+
+ public void setErrorString(String errorString) {
+ this.errorString = errorString;
+ }
+
+ public String getErrorString() {
+ return errorString;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof TemplateDataStoreVO) {
+ TemplateDataStoreVO other = (TemplateDataStoreVO) obj;
+ return (this.templateId == other.getTemplateId() && this.dataStoreId == other.getDataStoreId());
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ Long tid = new Long(templateId);
+ Long hid = new Long(dataStoreId);
+ return tid.hashCode() + hid.hashCode();
+ }
+
+ public void setSize(Long size) {
+ this.size = size;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public void setPhysicalSize(long physicalSize) {
+ this.physicalSize = physicalSize;
+ }
+
+ public long getPhysicalSize() {
+ return physicalSize;
+ }
+
+ public void setDestroyed(boolean destroyed) {
+ this.destroyed = destroyed;
+ }
+
+ public boolean getDestroyed() {
+ return destroyed;
+ }
+
+ public void setDownloadUrl(String downloadUrl) {
+ this.downloadUrl = downloadUrl;
+ }
+
+ public String getDownloadUrl() {
+ return downloadUrl;
+ }
+
+ public void setCopy(boolean isCopy) {
+ this.isCopy = isCopy;
+ }
+
+ public boolean isCopy() {
+ return isCopy;
+ }
+
+ public long getTemplateSize() {
+ return -1;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("TmplHost[").append(id).append("-").append(templateId).append("-").append(dataStoreId)
+ .append(installPath).append("]").toString();
+ }
+
+ @Override
+ public ObjectInDataStoreStateMachine.State getState() {
+ // TODO Auto-generated method stub
+ return this.state;
+ }
+
+ public void setState(ObjectInDataStoreStateMachine.State state) {
+ this.state = state;
+ }
+
+ public long getUpdatedCount() {
+ return this.updatedCount;
+ }
+
+ public void incrUpdatedCount() {
+ this.updatedCount++;
+ }
+
+ public void decrUpdatedCount() {
+ this.updatedCount--;
+ }
+
+ public Date getUpdated() {
+ return updated;
+ }
+
+ @Override
+ public long getObjectId() {
+ return this.getTemplateId();
+ }
+
+ @Override
+ public State getObjectInStoreState() {
+ return this.state;
+ }
+
+ public DataStoreRole getDataStoreRole() {
+ return dataStoreRole;
+ }
+
+ public void setDataStoreRole(DataStoreRole dataStoreRole) {
+ this.dataStoreRole = dataStoreRole;
+ }
+
+ public Long getRefCnt() {
+ return refCnt;
+ }
+
+ public void incrRefCnt() {
+ this.refCnt++;
+ }
+
+ public void decrRefCnt() {
+ this.refCnt--;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
new file mode 100644
index 0000000..698465f
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
@@ -0,0 +1,43 @@
+// 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.db;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
+StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
+
+ List<VolumeDataStoreVO> listByStoreId(long id);
+
+ List<VolumeDataStoreVO> listActiveOnCache(long id);
+
+ void deletePrimaryRecordsForStore(long id);
+
+ VolumeDataStoreVO findByVolume(long volumeId);
+
+ VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId);
+
+ VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId, boolean lock);
+
+ List<VolumeDataStoreVO> listDestroyed(long storeId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
new file mode 100755
index 0000000..a5d0830
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
@@ -0,0 +1,348 @@
+// 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.db;
+
+import java.util.Date;
+
+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 javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
+
+import com.cloud.storage.Storage;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.fsm.StateObject;
+
+/**
+ * Join table for image_data_store and volumes
+ *
+ */
+@Entity
+@Table(name = "volume_store_ref")
+public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ Long id;
+
+ @Column(name = "store_id")
+ private long dataStoreId;
+
+ @Column(name = "volume_id")
+ private long volumeId;
+
+ @Column(name = "zone_id")
+ private long zoneId;
+
+ @Column(name = GenericDaoBase.CREATED_COLUMN)
+ private Date created = null;
+
+ @Column(name = "last_updated")
+ @Temporal(value = TemporalType.TIMESTAMP)
+ private Date lastUpdated = null;
+
+ @Column(name = "download_pct")
+ private int downloadPercent;
+
+ @Column(name = "size")
+ private long size;
+
+ @Column(name = "physical_size")
+ private long physicalSize;
+
+ @Column(name = "download_state")
+ @Enumerated(EnumType.STRING)
+ private Status downloadState;
+
+ @Column(name = "checksum")
+ private String checksum;
+
+ @Column(name = "local_path")
+ private String localDownloadPath;
+
+ @Column(name = "error_str")
+ private String errorString;
+
+ @Column(name = "job_id")
+ private String jobId;
+
+ @Column(name = "install_path")
+ private String installPath;
+
+ @Column(name = "url")
+ private String downloadUrl;
+
+ @Column(name = "destroyed")
+ boolean destroyed = false;
+
+ @Column(name = "update_count", updatable = true, nullable = false)
+ protected long updatedCount;
+
+ @Column(name = "updated")
+ @Temporal(value = TemporalType.TIMESTAMP)
+ Date updated;
+
+ @Column(name = "state")
+ @Enumerated(EnumType.STRING)
+ ObjectInDataStoreStateMachine.State state;
+
+ @Column(name = "ref_cnt")
+ Long refCnt = 0L;
+
+ public String getInstallPath() {
+ return installPath;
+ }
+
+ @Override
+ public long getDataStoreId() {
+ return dataStoreId;
+ }
+
+ public void setDataStoreId(long storeId) {
+ this.dataStoreId = storeId;
+ }
+
+ public long getVolumeId() {
+ return volumeId;
+ }
+
+ public void setVolumeId(long volumeId) {
+ this.volumeId = volumeId;
+ }
+
+ public long getZoneId() {
+ return zoneId;
+ }
+
+ public void setZoneId(long zoneId) {
+ this.zoneId = zoneId;
+ }
+
+ public int getDownloadPercent() {
+ return downloadPercent;
+ }
+
+ public void setDownloadPercent(int downloadPercent) {
+ this.downloadPercent = downloadPercent;
+ }
+
+ public void setDownloadState(Status downloadState) {
+ this.downloadState = downloadState;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(Date date) {
+ lastUpdated = date;
+ }
+
+ public void setInstallPath(String installPath) {
+ this.installPath = installPath;
+ }
+
+ public Status getDownloadState() {
+ return downloadState;
+ }
+
+ public String getChecksum() {
+ return checksum;
+ }
+
+ public void setChecksum(String checksum) {
+ this.checksum = checksum;
+ }
+
+ public VolumeDataStoreVO(long hostId, long volumeId) {
+ super();
+ this.dataStoreId = hostId;
+ this.volumeId = volumeId;
+ this.state = ObjectInDataStoreStateMachine.State.Allocated;
+ this.refCnt = 0L;
+ }
+
+ public VolumeDataStoreVO(long hostId, long volumeId, Date lastUpdated, int downloadPercent, Status downloadState,
+ String localDownloadPath, String errorString, String jobId, String installPath, String downloadUrl,
+ String checksum) {
+ // super();
+ this.dataStoreId = hostId;
+ this.volumeId = volumeId;
+ // this.zoneId = zoneId;
+ this.lastUpdated = lastUpdated;
+ this.downloadPercent = downloadPercent;
+ this.downloadState = downloadState;
+ this.localDownloadPath = localDownloadPath;
+ this.errorString = errorString;
+ this.jobId = jobId;
+ this.installPath = installPath;
+ this.setDownloadUrl(downloadUrl);
+ this.checksum = checksum;
+ this.refCnt = 0L;
+ }
+
+ public VolumeDataStoreVO() {
+ this.refCnt = 0L;
+ }
+
+ public void setLocalDownloadPath(String localPath) {
+ this.localDownloadPath = localPath;
+ }
+
+ public String getLocalDownloadPath() {
+ return localDownloadPath;
+ }
+
+ public void setErrorString(String errorString) {
+ this.errorString = errorString;
+ }
+
+ public String getErrorString() {
+ return errorString;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof VolumeDataStoreVO) {
+ VolumeDataStoreVO other = (VolumeDataStoreVO) obj;
+ return (this.volumeId == other.getVolumeId() && this.dataStoreId == other.getDataStoreId());
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ Long tid = new Long(volumeId);
+ Long hid = new Long(dataStoreId);
+ return tid.hashCode() + hid.hashCode();
+ }
+
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public void setPhysicalSize(long physicalSize) {
+ this.physicalSize = physicalSize;
+ }
+
+ public long getPhysicalSize() {
+ return physicalSize;
+ }
+
+ public void setDestroyed(boolean destroyed) {
+ this.destroyed = destroyed;
+ }
+
+ public boolean getDestroyed() {
+ return destroyed;
+ }
+
+ public void setDownloadUrl(String downloadUrl) {
+ this.downloadUrl = downloadUrl;
+ }
+
+ public String getDownloadUrl() {
+ return downloadUrl;
+ }
+
+ public long getVolumeSize() {
+ return -1;
+ }
+
+ public String toString() {
+ return new StringBuilder("VolumeHost[").append(id).append("-").append(volumeId).append("-").append(dataStoreId)
+ .append(installPath).append("]").toString();
+ }
+
+ public long getUpdatedCount() {
+ return this.updatedCount;
+ }
+
+ public void incrUpdatedCount() {
+ this.updatedCount++;
+ }
+
+ public void decrUpdatedCount() {
+ this.updatedCount--;
+ }
+
+ public Date getUpdated() {
+ return updated;
+ }
+
+ @Override
+ public ObjectInDataStoreStateMachine.State getState() {
+ // TODO Auto-generated method stub
+ return this.state;
+ }
+
+ public void setState(ObjectInDataStoreStateMachine.State state) {
+ this.state = state;
+ }
+
+ @Override
+ public long getObjectId() {
+ return this.getVolumeId();
+ }
+
+ @Override
+ public State getObjectInStoreState() {
+ return this.state;
+ }
+
+ public Long getRefCnt() {
+ return refCnt;
+ }
+
+ public void incrRefCnt() {
+ this.refCnt++;
+ }
+
+ public void decrRefCnt() {
+ this.refCnt--;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/storage/cache/pom.xml
----------------------------------------------------------------------
diff --git a/engine/storage/cache/pom.xml b/engine/storage/cache/pom.xml
index 584d14d..66c8804 100644
--- a/engine/storage/cache/pom.xml
+++ b/engine/storage/cache/pom.xml
@@ -1,13 +1,12 @@
<!-- 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. -->
+ information regarding copyright ownership. The ASF licenses this file to you under
+ the Apache License, Version 2.0 (the "License"); you may not use this file except
+ in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software distributed under
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific language
+ governing permissions and limitations under the License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -22,6 +21,11 @@
<dependencies>
<dependency>
<groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-schema</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine-storage</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 60dd9f7..aa0173c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -180,7 +180,7 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${cs.mysql.version}</version>
- <scope>provided</scope>
+ <scope>provided,test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
@@ -276,12 +276,6 @@
</dependency>
<!-- Test dependency in mysql for db tests -->
<dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>${cs.mysql.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${cs.commons-io.version}</version>
@@ -297,11 +291,11 @@
<artifactId>esapi</artifactId>
<version>2.0.1</version>
</dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.persistence</artifactId>
- <version>${cs.jpa.version}</version>
- </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>javax.persistence</artifactId>
+ <version>${cs.jpa.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index b159b4d..9178f78 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -103,6 +103,11 @@
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-schema</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-framework-ipc</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/server/src/com/cloud/consoleproxy/ConsoleProxyBalanceAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyBalanceAllocator.java b/server/src/com/cloud/consoleproxy/ConsoleProxyBalanceAllocator.java
index 45f0faa..89a5f39 100644
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyBalanceAllocator.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyBalanceAllocator.java
@@ -26,7 +26,7 @@ import javax.ejb.Local;
import javax.naming.ConfigurationException;
import com.cloud.utils.component.AdapterBase;
-import com.cloud.vm.ConsoleProxyVO;
+import com.cloud.vm.ConsoleProxy;
import edu.emory.mathcs.backport.java.util.Collections;
@@ -36,40 +36,32 @@ public class ConsoleProxyBalanceAllocator extends AdapterBase implements Console
private final Random _rand = new Random(System.currentTimeMillis());
@Override
- public ConsoleProxyVO allocProxy(List<ConsoleProxyVO> candidates, final Map<Long, Integer> loadInfo, long dataCenterId) {
- if(candidates != null) {
+ public Long allocProxy(List<? extends ConsoleProxy> candidates, final Map<Long, Integer> loadInfo, long dataCenterId) {
+ List<ConsoleProxy> allocationList = new ArrayList<ConsoleProxy>(candidates);
- List<ConsoleProxyVO> allocationList = new ArrayList<ConsoleProxyVO>();
- for(ConsoleProxyVO proxy : candidates) {
- allocationList.add(proxy);
- }
-
- Collections.sort(candidates, new Comparator<ConsoleProxyVO> () {
- @Override
- public int compare(ConsoleProxyVO x, ConsoleProxyVO y) {
- Integer loadOfX = loadInfo.get(x.getId());
- Integer loadOfY = loadInfo.get(y.getId());
+ Collections.sort(candidates, new Comparator<ConsoleProxy>() {
+ @Override
+ public int compare(ConsoleProxy x, ConsoleProxy y) {
+ Integer loadOfX = loadInfo.get(x.getId());
+ Integer loadOfY = loadInfo.get(y.getId());
- if(loadOfX != null && loadOfY != null) {
- if(loadOfX < loadOfY)
- return -1;
- else if(loadOfX > loadOfY)
- return 1;
- return 0;
- } else if(loadOfX == null && loadOfY == null) {
- return 0;
- } else {
- if(loadOfX == null)
- return -1;
+ if (loadOfX != null && loadOfY != null) {
+ if (loadOfX < loadOfY)
+ return -1;
+ else if (loadOfX > loadOfY)
return 1;
- }
+ return 0;
+ } else if (loadOfX == null && loadOfY == null) {
+ return 0;
+ } else {
+ if (loadOfX == null)
+ return -1;
+ return 1;
}
- });
+ }
+ });
- if(allocationList.size() > 0)
- return allocationList.get(0);
- }
- return null;
+ return (allocationList.size() > 0) ? allocationList.get(0).getId() : null;
}
@Override
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index bae2405..e1c15dc 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -619,7 +619,12 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
}
}
}
- return allocator.allocProxy(runningList, loadInfo, dataCenterId);
+ Long allocated = allocator.allocProxy(runningList, loadInfo, dataCenterId);
+ if (allocated == null) {
+ s_logger.debug("Unable to find a console proxy ");
+ return null;
+ }
+ return _consoleProxyDao.findById(allocated);
} else {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Empty running proxy pool for now in data center : " + dataCenterId);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/usage/pom.xml
----------------------------------------------------------------------
diff --git a/usage/pom.xml b/usage/pom.xml
index 257359c..14a375f 100644
--- a/usage/pom.xml
+++ b/usage/pom.xml
@@ -39,6 +39,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-engine-schema</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
[2/4] Removed schema from the dependency of many components
Posted by ah...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
deleted file mode 100644
index 698465f..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java
+++ /dev/null
@@ -1,43 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.storage.datastore.db;
-
-import java.util.List;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
-
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateDao;
-
-public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
-StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
-
- List<VolumeDataStoreVO> listByStoreId(long id);
-
- List<VolumeDataStoreVO> listActiveOnCache(long id);
-
- void deletePrimaryRecordsForStore(long id);
-
- VolumeDataStoreVO findByVolume(long volumeId);
-
- VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId);
-
- VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId, boolean lock);
-
- List<VolumeDataStoreVO> listDestroyed(long storeId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
deleted file mode 100755
index a5d0830..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java
+++ /dev/null
@@ -1,348 +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.db;
-
-import java.util.Date;
-
-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 javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
-
-import com.cloud.storage.Storage;
-import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.fsm.StateObject;
-
-/**
- * Join table for image_data_store and volumes
- *
- */
-@Entity
-@Table(name = "volume_store_ref")
-public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- Long id;
-
- @Column(name = "store_id")
- private long dataStoreId;
-
- @Column(name = "volume_id")
- private long volumeId;
-
- @Column(name = "zone_id")
- private long zoneId;
-
- @Column(name = GenericDaoBase.CREATED_COLUMN)
- private Date created = null;
-
- @Column(name = "last_updated")
- @Temporal(value = TemporalType.TIMESTAMP)
- private Date lastUpdated = null;
-
- @Column(name = "download_pct")
- private int downloadPercent;
-
- @Column(name = "size")
- private long size;
-
- @Column(name = "physical_size")
- private long physicalSize;
-
- @Column(name = "download_state")
- @Enumerated(EnumType.STRING)
- private Status downloadState;
-
- @Column(name = "checksum")
- private String checksum;
-
- @Column(name = "local_path")
- private String localDownloadPath;
-
- @Column(name = "error_str")
- private String errorString;
-
- @Column(name = "job_id")
- private String jobId;
-
- @Column(name = "install_path")
- private String installPath;
-
- @Column(name = "url")
- private String downloadUrl;
-
- @Column(name = "destroyed")
- boolean destroyed = false;
-
- @Column(name = "update_count", updatable = true, nullable = false)
- protected long updatedCount;
-
- @Column(name = "updated")
- @Temporal(value = TemporalType.TIMESTAMP)
- Date updated;
-
- @Column(name = "state")
- @Enumerated(EnumType.STRING)
- ObjectInDataStoreStateMachine.State state;
-
- @Column(name = "ref_cnt")
- Long refCnt = 0L;
-
- public String getInstallPath() {
- return installPath;
- }
-
- @Override
- public long getDataStoreId() {
- return dataStoreId;
- }
-
- public void setDataStoreId(long storeId) {
- this.dataStoreId = storeId;
- }
-
- public long getVolumeId() {
- return volumeId;
- }
-
- public void setVolumeId(long volumeId) {
- this.volumeId = volumeId;
- }
-
- public long getZoneId() {
- return zoneId;
- }
-
- public void setZoneId(long zoneId) {
- this.zoneId = zoneId;
- }
-
- public int getDownloadPercent() {
- return downloadPercent;
- }
-
- public void setDownloadPercent(int downloadPercent) {
- this.downloadPercent = downloadPercent;
- }
-
- public void setDownloadState(Status downloadState) {
- this.downloadState = downloadState;
- }
-
- public long getId() {
- return id;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- public void setLastUpdated(Date date) {
- lastUpdated = date;
- }
-
- public void setInstallPath(String installPath) {
- this.installPath = installPath;
- }
-
- public Status getDownloadState() {
- return downloadState;
- }
-
- public String getChecksum() {
- return checksum;
- }
-
- public void setChecksum(String checksum) {
- this.checksum = checksum;
- }
-
- public VolumeDataStoreVO(long hostId, long volumeId) {
- super();
- this.dataStoreId = hostId;
- this.volumeId = volumeId;
- this.state = ObjectInDataStoreStateMachine.State.Allocated;
- this.refCnt = 0L;
- }
-
- public VolumeDataStoreVO(long hostId, long volumeId, Date lastUpdated, int downloadPercent, Status downloadState,
- String localDownloadPath, String errorString, String jobId, String installPath, String downloadUrl,
- String checksum) {
- // super();
- this.dataStoreId = hostId;
- this.volumeId = volumeId;
- // this.zoneId = zoneId;
- this.lastUpdated = lastUpdated;
- this.downloadPercent = downloadPercent;
- this.downloadState = downloadState;
- this.localDownloadPath = localDownloadPath;
- this.errorString = errorString;
- this.jobId = jobId;
- this.installPath = installPath;
- this.setDownloadUrl(downloadUrl);
- this.checksum = checksum;
- this.refCnt = 0L;
- }
-
- public VolumeDataStoreVO() {
- this.refCnt = 0L;
- }
-
- public void setLocalDownloadPath(String localPath) {
- this.localDownloadPath = localPath;
- }
-
- public String getLocalDownloadPath() {
- return localDownloadPath;
- }
-
- public void setErrorString(String errorString) {
- this.errorString = errorString;
- }
-
- public String getErrorString() {
- return errorString;
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof VolumeDataStoreVO) {
- VolumeDataStoreVO other = (VolumeDataStoreVO) obj;
- return (this.volumeId == other.getVolumeId() && this.dataStoreId == other.getDataStoreId());
- }
- return false;
- }
-
- public int hashCode() {
- Long tid = new Long(volumeId);
- Long hid = new Long(dataStoreId);
- return tid.hashCode() + hid.hashCode();
- }
-
- public void setSize(long size) {
- this.size = size;
- }
-
- public long getSize() {
- return size;
- }
-
- public void setPhysicalSize(long physicalSize) {
- this.physicalSize = physicalSize;
- }
-
- public long getPhysicalSize() {
- return physicalSize;
- }
-
- public void setDestroyed(boolean destroyed) {
- this.destroyed = destroyed;
- }
-
- public boolean getDestroyed() {
- return destroyed;
- }
-
- public void setDownloadUrl(String downloadUrl) {
- this.downloadUrl = downloadUrl;
- }
-
- public String getDownloadUrl() {
- return downloadUrl;
- }
-
- public long getVolumeSize() {
- return -1;
- }
-
- public String toString() {
- return new StringBuilder("VolumeHost[").append(id).append("-").append(volumeId).append("-").append(dataStoreId)
- .append(installPath).append("]").toString();
- }
-
- public long getUpdatedCount() {
- return this.updatedCount;
- }
-
- public void incrUpdatedCount() {
- this.updatedCount++;
- }
-
- public void decrUpdatedCount() {
- this.updatedCount--;
- }
-
- public Date getUpdated() {
- return updated;
- }
-
- @Override
- public ObjectInDataStoreStateMachine.State getState() {
- // TODO Auto-generated method stub
- return this.state;
- }
-
- public void setState(ObjectInDataStoreStateMachine.State state) {
- this.state = state;
- }
-
- @Override
- public long getObjectId() {
- return this.getVolumeId();
- }
-
- @Override
- public State getObjectInStoreState() {
- return this.state;
- }
-
- public Long getRefCnt() {
- return refCnt;
- }
-
- public void incrRefCnt() {
- this.refCnt++;
- }
-
- public void decrRefCnt() {
- this.refCnt--;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java b/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
deleted file mode 100644
index 0037ea5..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
+++ /dev/null
@@ -1,79 +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.to;
-
-import org.apache.cloudstack.storage.image.datastore.ImageStoreInfo;
-
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.storage.DataStoreRole;
-
-public class ImageStoreTO implements DataStoreTO {
- private String type;
- private String uri;
- private String providerName;
- private DataStoreRole role;
-
- public ImageStoreTO() {
-
- }
-
- public ImageStoreTO(ImageStoreInfo dataStore) {
- this.type = dataStore.getType();
- this.uri = dataStore.getUri();
- this.providerName = null;
- this.role = dataStore.getRole();
- }
-
- public String getProtocol() {
- return this.type;
- }
-
- public String getUri() {
- return this.uri;
- }
-
- public String getProviderName() {
- return providerName;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public void setUri(String uri) {
- this.uri = uri;
- }
-
- public void setProviderName(String providerName) {
- this.providerName = providerName;
- }
-
- public void setRole(DataStoreRole role) {
- this.role = role;
- }
-
- @Override
- public DataStoreRole getRole() {
- return this.role;
- }
-
- @Override
- public String toString() {
- return new StringBuilder("ImageStoreTO[type=").append(type).append("|provider=").append(providerName)
- .append("|role=").append(role).append("|uri=").append(uri).append("]").toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java b/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
deleted file mode 100644
index 5e870df..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
+++ /dev/null
@@ -1,103 +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.to;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
-
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.Storage.StoragePoolType;
-
-public class PrimaryDataStoreTO implements DataStoreTO {
- private final String uuid;
- private final String name;
- private String type;
- private final long id;
- private StoragePoolType poolType;
- private String host;
- private String path;
- private int port;
-
- public PrimaryDataStoreTO(PrimaryDataStoreInfo dataStore) {
- this.uuid = dataStore.getUuid();
- this.name = dataStore.getName();
- this.id = dataStore.getId();
- this.setPoolType(dataStore.getPoolType());
- this.setHost(dataStore.getHostAddress());
- this.setPath(dataStore.getPath());
- this.setPort(dataStore.getPort());
- }
-
- public long getId() {
- return this.id;
- }
-
- public String getUuid() {
- return this.uuid;
- }
-
- public String getName() {
- return this.name;
- }
-
- public String getType() {
- return this.type;
- }
-
- @Override
- public DataStoreRole getRole() {
- return DataStoreRole.Primary;
- }
-
- public StoragePoolType getPoolType() {
- return poolType;
- }
-
- public void setPoolType(StoragePoolType poolType) {
- this.poolType = poolType;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- @Override
- public String toString() {
- return new StringBuilder("PrimaryDataStoreTO[uuid=").append(uuid).append("|name=").append(name)
- .append("|id=").append(id).append("|pooltype=").append(poolType).append("]").toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
deleted file mode 100644
index d2cb72a..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
+++ /dev/null
@@ -1,128 +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.to;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
-
-import com.cloud.agent.api.to.DataObjectType;
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.agent.api.to.DataTO;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-
-public class SnapshotObjectTO implements DataTO {
- private String path;
- private VolumeObjectTO volume;
- private String parentSnapshotPath;
- private DataStoreTO dataStore;
- private String vmName;
- private String name;
- private HypervisorType hypervisorType;
- private long id;
-
- public SnapshotObjectTO() {
-
- }
-
- public SnapshotObjectTO(SnapshotInfo snapshot) {
- this.path = snapshot.getPath();
- this.setId(snapshot.getId());
- this.volume = (VolumeObjectTO) snapshot.getBaseVolume().getTO();
- this.setVmName(snapshot.getBaseVolume().getAttachedVmName());
- SnapshotInfo parentSnapshot = snapshot.getParent();
- if (parentSnapshot != null) {
- this.parentSnapshotPath = parentSnapshot.getPath();
- }
- this.dataStore = snapshot.getDataStore().getTO();
- this.setName(snapshot.getName());
- this.hypervisorType = snapshot.getHypervisorType();
- }
-
- @Override
- public DataObjectType getObjectType() {
- return DataObjectType.SNAPSHOT;
- }
-
- @Override
- public DataStoreTO getDataStore() {
- return this.dataStore;
- }
-
- @Override
- public String getPath() {
- return this.path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public VolumeObjectTO getVolume() {
- return volume;
- }
-
- public void setVolume(VolumeObjectTO volume) {
- this.volume = volume;
- }
-
- public String getParentSnapshotPath() {
- return parentSnapshotPath;
- }
-
- public void setParentSnapshotPath(String parentSnapshotPath) {
- this.parentSnapshotPath = parentSnapshotPath;
- }
-
- public String getVmName() {
- return vmName;
- }
-
- public void setVmName(String vmName) {
- this.vmName = vmName;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public HypervisorType getHypervisorType() {
- return hypervisorType;
- }
-
- public void setHypervisorType(HypervisorType hypervisorType) {
- this.hypervisorType = hypervisorType;
- }
-
- @Override
- public String toString() {
- return new StringBuilder("SnapshotTO[datastore=").append(dataStore).append("|volume=").append(volume).append("|path")
- .append(path).append("]").toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
deleted file mode 100644
index 2347de3..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
+++ /dev/null
@@ -1,208 +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.to;
-
-import com.cloud.hypervisor.Hypervisor;
-import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
-
-import com.cloud.agent.api.to.DataObjectType;
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.agent.api.to.DataTO;
-import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.template.VirtualMachineTemplate;
-
-public class TemplateObjectTO implements DataTO {
- private String path;
- private String origUrl;
- private String uuid;
- private long id;
- private ImageFormat format;
- private long accountId;
- private String checksum;
- private boolean hvm;
- private String displayText;
- private DataStoreTO imageDataStore;
- private String name;
- private String guestOsType;
- private Long size;
- private Hypervisor.HypervisorType hypervisorType;
-
- public TemplateObjectTO() {
-
- }
-
- public TemplateObjectTO(VirtualMachineTemplate template) {
- this.uuid = template.getUuid();
- this.id = template.getId();
- this.origUrl = template.getUrl();
- this.displayText = template.getDisplayText();
- this.checksum = template.getChecksum();
- this.hvm = template.isRequiresHvm();
- this.accountId = template.getAccountId();
- this.name = template.getUniqueName();
- this.format = template.getFormat();
- this.hypervisorType = template.getHypervisorType();
- }
-
- public TemplateObjectTO(TemplateInfo template) {
- this.path = template.getInstallPath();
- this.uuid = template.getUuid();
- this.id = template.getId();
- this.origUrl = template.getUrl();
- this.displayText = template.getDisplayText();
- this.checksum = template.getChecksum();
- this.hvm = template.isRequiresHvm();
- this.accountId = template.getAccountId();
- this.name = template.getUniqueName();
- this.format = template.getFormat();
- if (template.getDataStore() != null) {
- this.imageDataStore = template.getDataStore().getTO();
- }
- this.hypervisorType = template.getHypervisorType();
- }
-
- @Override
- public String getPath() {
- return this.path;
- }
-
- public String getUuid() {
- return this.uuid;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- public void setId(long id){
- this.id = id;
- }
-
- public ImageFormat getFormat() {
- return format;
- }
-
- public long getAccountId() {
- return accountId;
- }
-
- public String getChecksum() {
- return checksum;
- }
-
- public boolean isRequiresHvm() {
- return hvm;
- }
-
- public void setRequiresHvm(boolean hvm) {
- this.hvm = hvm;
- }
-
- public String getDescription() {
- return displayText;
- }
-
- public void setDescription(String desc) {
- this.displayText = desc;
- }
-
-
- @Override
- public DataObjectType getObjectType() {
- return DataObjectType.TEMPLATE;
- }
-
- @Override
- public DataStoreTO getDataStore() {
- return this.imageDataStore;
- }
-
- @Override
- public Hypervisor.HypervisorType getHypervisorType() {
- return this.hypervisorType;
- }
-
- public void setDataStore(DataStoreTO store){
- this.imageDataStore = store;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getOrigUrl() {
- return origUrl;
- }
-
- public void setOrigUrl(String origUrl) {
- this.origUrl = origUrl;
- }
-
- public void setFormat(ImageFormat format) {
- this.format = format;
- }
-
- public void setAccountId(long accountId) {
- this.accountId = accountId;
- }
-
- public void setChecksum(String checksum) {
- this.checksum = checksum;
- }
-
- public void setImageDataStore(DataStoreTO imageDataStore) {
- this.imageDataStore = imageDataStore;
- }
-
- public String getGuestOsType() {
- return guestOsType;
- }
-
- public void setGuestOsType(String guestOsType) {
- this.guestOsType = guestOsType;
- }
-
- public Long getSize() {
- return size;
- }
-
- public void setSize(Long size) {
- this.size = size;
- }
-
- @Override
- public String toString() {
- return new StringBuilder("TemplateTO[id=").append(id).append("|origUrl=").append(origUrl)
- .append("|name").append(name).append("]").toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
deleted file mode 100644
index 9f466ae..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
+++ /dev/null
@@ -1,223 +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.to;
-
-import com.cloud.hypervisor.Hypervisor;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-
-import com.cloud.agent.api.to.DataObjectType;
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.agent.api.to.DataTO;
-import com.cloud.storage.Storage;
-import com.cloud.storage.Volume;
-
-public class VolumeObjectTO implements DataTO {
- private String uuid;
- private Volume.Type volumeType;
- private DataStoreTO dataStore;
- private String name;
- private long size;
- private String path;
- private Long volumeId;
- private String vmName;
- private long accountId;
- private String chainInfo;
- private Storage.ImageFormat format;
- private long id;
- private Long bytesReadRate;
- private Long bytesWriteRate;
- private Long iopsReadRate;
- private Long iopsWriteRate;
- private Hypervisor.HypervisorType hypervisorType;
-
- public VolumeObjectTO() {
-
- }
-
- public VolumeObjectTO(VolumeInfo volume) {
- this.uuid = volume.getUuid();
- this.path = volume.getPath();
- this.accountId = volume.getAccountId();
- if (volume.getDataStore() != null) {
- this.dataStore = volume.getDataStore().getTO();
- } else {
- this.dataStore = null;
- }
- this.vmName = volume.getAttachedVmName();
- this.size = volume.getSize();
- this.setVolumeId(volume.getId());
- this.chainInfo = volume.getChainInfo();
- this.volumeType = volume.getVolumeType();
- this.name = volume.getName();
- this.setId(volume.getId());
- this.format = volume.getFormat();
- this.bytesReadRate = volume.getBytesReadRate();
- this.bytesWriteRate = volume.getBytesWriteRate();
- this.iopsReadRate = volume.getIopsReadRate();
- this.iopsWriteRate = volume.getIopsWriteRate();
- this.hypervisorType = volume.getHypervisorType();
- }
-
- public String getUuid() {
- return this.uuid;
- }
-
- @Override
- public String getPath() {
- return this.path;
- }
-
- public Volume.Type getVolumeType() {
- return this.volumeType;
- }
-
- @Override
- public DataStoreTO getDataStore() {
- return this.dataStore;
- }
-
- @Override
- public Hypervisor.HypervisorType getHypervisorType() {
- return this.hypervisorType;
- }
-
-
- public void setDataStore(DataStoreTO store){
- this.dataStore = store;
- }
-
- public void setDataStore(PrimaryDataStoreTO dataStore) {
- this.dataStore = dataStore;
- }
-
- public String getName() {
- return this.name;
- }
-
- public long getSize() {
- return this.size;
- }
-
- @Override
- public DataObjectType getObjectType() {
- return DataObjectType.VOLUME;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setSize(long size) {
- this.size = size;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public Long getVolumeId() {
- return volumeId;
- }
-
- public void setVolumeId(Long volumeId) {
- this.volumeId = volumeId;
- }
-
- public long getAccountId() {
- return accountId;
- }
-
- public void setAccountId(long accountId) {
- this.accountId = accountId;
- }
-
- public String getVmName() {
- return vmName;
- }
-
- public void setVmName(String vmName) {
- this.vmName = vmName;
- }
-
- public String getChainInfo() {
- return chainInfo;
- }
-
- public void setChainInfo(String chainInfo) {
- this.chainInfo = chainInfo;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public Storage.ImageFormat getFormat() {
- return format;
- }
-
- public void setFormat(Storage.ImageFormat format) {
- this.format = format;
- }
-
- @Override
- public String toString() {
- return new StringBuilder("volumeTO[uuid=").append(uuid).append("|path=").append(path)
- .append("|datastore=").append(dataStore).append("]").toString();
- }
-
- public void setBytesReadRate(Long bytesReadRate) {
- this.bytesReadRate = bytesReadRate;
- }
-
- public Long getBytesReadRate() {
- return bytesReadRate;
- }
-
- public void setBytesWriteRate(Long bytesWriteRate) {
- this.bytesWriteRate = bytesWriteRate;
- }
-
- public Long getBytesWriteRate() {
- return bytesWriteRate;
- }
-
- public void setIopsReadRate(Long iopsReadRate) {
- this.iopsReadRate = iopsReadRate;
- }
-
- public Long getIopsReadRate() {
- return iopsReadRate;
- }
-
- public void setIopsWriteRate(Long iopsWriteRate) {
- this.iopsWriteRate = iopsWriteRate;
- }
-
- public Long getIopsWriteRate() {
- return iopsWriteRate;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java b/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java
new file mode 100644
index 0000000..5ab3480
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java
@@ -0,0 +1,73 @@
+// 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 com.cloud.storage;
+
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="guest_os_hypervisor")
+public class GuestOSHypervisorVO implements GuestOSHypervisor {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ long id;
+
+ @Column(name="guest_os_id")
+ private long guestOsId;
+
+ @Column(name="guest_os_name")
+ String guestOsName;
+
+ @Column(name="hypervisor_type")
+ String hypervisorType;
+
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+
+ @Override
+ public String getHypervisorType() {
+ return hypervisorType;
+ }
+
+
+ @Override
+ public String getGuestOsName() {
+ return guestOsName;
+ }
+
+
+ @Override
+ public long getGuestOsId() {
+ return guestOsId;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/com/cloud/storage/VolumeDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VolumeDetailVO.java b/engine/schema/src/com/cloud/storage/VolumeDetailVO.java
new file mode 100644
index 0000000..b0c8c1d
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/VolumeDetailVO.java
@@ -0,0 +1,85 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.storage;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="volume_details")
+public class VolumeDetailVO implements InternalIdentity {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="volume_id")
+ private long volumeId;
+
+ @Column(name="name")
+ private String name;
+
+ @Column(name="value", length=1024)
+ private String value;
+
+ public VolumeDetailVO() {}
+
+ public VolumeDetailVO(long volumeId, String name, String value) {
+ this.volumeId = volumeId;
+ this.name = name;
+ this.value = value;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getVolumeId() {
+ return volumeId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public void setVolumeId(long volumeId) {
+ this.volumeId = volumeId;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
new file mode 100644
index 0000000..70e9bb3
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
@@ -0,0 +1,37 @@
+/*
+ * 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.db;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface ImageStoreDao extends GenericDao<ImageStoreVO, Long> {
+ ImageStoreVO findByName(String name);
+
+ List<ImageStoreVO> findByProvider(String provider);
+
+ List<ImageStoreVO> findByScope(ZoneScope scope);
+
+ List<ImageStoreVO> findImageCacheByScope(ZoneScope scope);
+
+ List<ImageStoreVO> listImageStores();
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java
new file mode 100644
index 0000000..b922148
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java
@@ -0,0 +1,82 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.storage.datastore.db;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "image_store_details")
+public class ImageStoreDetailVO implements InternalIdentity {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ long id;
+
+ @Column(name = "store_id")
+ long storeId;
+
+ @Column(name = "name")
+ String name;
+
+ @Column(name = "value")
+ String value;
+
+ public ImageStoreDetailVO() {
+ }
+
+ public ImageStoreDetailVO(long storeId, String name, String value) {
+ this.storeId = storeId;
+ this.name = name;
+ this.value = value;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getStoreId() {
+ return storeId;
+ }
+
+ public void setStoreId(long storeId) {
+ this.storeId = storeId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.java
new file mode 100644
index 0000000..91fff28
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.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.datastore.db;
+
+import java.util.Map;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface ImageStoreDetailsDao extends GenericDao<ImageStoreDetailVO, Long> {
+
+ void update(long storeId, Map<String, String> details);
+
+ Map<String, String> getDetails(long storeId);
+
+ void deleteDetails(long storeId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
new file mode 100644
index 0000000..5ed48a3
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.db;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.ImageStore;
+import com.cloud.storage.ScopeType;
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = "image_store")
+public class ImageStoreVO implements ImageStore {
+ @Id
+ @TableGenerator(name = "image_store_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value",
+ pkColumnValue = "image_store_seq", allocationSize = 1)
+ @Column(name = "id", nullable = false)
+ private long id;
+
+ @Column(name = "name", nullable = false)
+ private String name;
+
+ @Column(name = "uuid", nullable = false)
+ private String uuid;
+
+ @Column(name = "protocol", nullable = false)
+ private String protocol;
+
+ @Column(name = "url", nullable = false)
+ private String url;
+
+ @Column(name = "image_provider_name", nullable = false)
+ private String providerName;
+
+ @Column(name = "data_center_id")
+ private Long dcId;
+
+ @Column(name = "scope")
+ @Enumerated(value = EnumType.STRING)
+ private ScopeType scope;
+
+ @Column(name = GenericDao.CREATED_COLUMN)
+ private Date created;
+
+ @Column(name = GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ @Column(name = "role")
+ @Enumerated(value = EnumType.STRING)
+ private DataStoreRole role;
+
+ @Column(name = "parent")
+ private String parent;
+
+ @Column(name = "total_size")
+ private Long totalSize;
+
+ @Column(name = "used_bytes")
+ private Long usedBytes;
+
+ public DataStoreRole getRole() {
+ return role;
+ }
+
+ public void setRole(DataStoreRole role) {
+ this.role = role;
+ }
+
+ public long getId() {
+ return this.id;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getProviderName() {
+ return this.providerName;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setProviderName(String provider) {
+ this.providerName = provider;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getProtocol() {
+ return this.protocol;
+ }
+
+ public void setDataCenterId(Long dcId) {
+ this.dcId = dcId;
+ }
+
+ public Long getDataCenterId() {
+ return this.dcId;
+ }
+
+ public ScopeType getScope() {
+ return this.scope;
+ }
+
+ public void setScope(ScopeType scope) {
+ this.scope = scope;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public void setRemoved(Date removed) {
+ this.removed = removed;
+ }
+
+ public String getParent() {
+ return parent;
+ }
+
+ public void setParent(String parent) {
+ this.parent = parent;
+ }
+
+ public Long getTotalSize() {
+ return totalSize;
+ }
+
+ public void setTotalSize(Long totalSize) {
+ this.totalSize = totalSize;
+ }
+
+ public Long getUsedBytes() {
+ return usedBytes;
+ }
+
+ public void setUsedBytes(Long usedBytes) {
+ this.usedBytes = usedBytes;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
new file mode 100644
index 0000000..669dd25
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
@@ -0,0 +1,120 @@
+// 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.db;
+
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.ScopeType;
+import com.cloud.storage.StoragePoolStatus;
+import com.cloud.utils.db.GenericDao;
+
+/**
+ * Data Access Object for storage_pool table
+ */
+public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
+
+ /**
+ * @param datacenterId -- the id of the datacenter (availability zone)
+ */
+ List<StoragePoolVO> listByDataCenterId(long datacenterId);
+
+ /**
+ * @param datacenterId -- the id of the datacenter (availability zone)
+ */
+ List<StoragePoolVO> listBy(long datacenterId, Long podId, Long clusterId, ScopeType scope);
+
+ /**
+ * Set capacity of storage pool in bytes
+ * @param id pool id.
+ * @param capacity capacity in bytes
+ */
+ void updateCapacity(long id, long capacity);
+
+ /**
+ * Set available bytes of storage pool in bytes
+ *
+ * @param id
+ * pool id.
+ * @param available
+ * available capacity in bytes
+ */
+ void updateAvailable(long id, long available);
+
+ StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details);
+
+ /**
+ * Find pool by name.
+ *
+ * @param name
+ * name of pool.
+ * @return the single StoragePoolVO
+ */
+ List<StoragePoolVO> findPoolByName(String name);
+
+ /**
+ * Find pools by the pod that matches the details.
+ *
+ * @param podId
+ * pod id to find the pools in.
+ * @param details
+ * details to match. All must match for the pool to be returned.
+ * @return List of StoragePoolVO
+ */
+ List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details,
+ ScopeType scope);
+
+ List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags);
+
+ /**
+ * Find pool by UUID.
+ *
+ * @param uuid
+ * uuid of pool.
+ * @return the single StoragePoolVO
+ */
+ StoragePoolVO findPoolByUUID(String uuid);
+
+ List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp);
+
+ StoragePoolVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
+
+ List<StoragePoolVO> listPoolByHostPath(String host, String path);
+
+ void updateDetails(long poolId, Map<String, String> details);
+
+ Map<String, String> getDetails(long poolId);
+
+ List<String> searchForStoragePoolDetails(long poolId, String value);
+
+ List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid);
+
+ List<StoragePoolVO> listByStatus(StoragePoolStatus status);
+
+ long countPoolsByStatus(StoragePoolStatus... statuses);
+
+ List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status);
+
+ List<StoragePoolVO> listPoolsByCluster(long clusterId);
+
+ List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags);
+
+ List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags);
+
+ List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
new file mode 100644
index 0000000..1032526
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
@@ -0,0 +1,432 @@
+// 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.db;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import com.cloud.host.Status;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.ScopeType;
+import com.cloud.storage.StoragePoolStatus;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.SearchCriteria2;
+import com.cloud.utils.db.SearchCriteriaService;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Local(value = { PrimaryDataStoreDao.class })
+@DB(txn = false)
+public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> implements PrimaryDataStoreDao {
+ protected final SearchBuilder<StoragePoolVO> AllFieldSearch;
+ protected final SearchBuilder<StoragePoolVO> DcPodSearch;
+ protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch;
+ protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
+ protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
+
+ @Inject
+ protected StoragePoolDetailsDao _detailsDao;
+
+ private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.status = 'Up' and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and storage_pool.scope = ? and (";
+ private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
+ private final String ZoneWideDetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.status = 'Up' and storage_pool.data_center_id = ? and storage_pool.scope = ? and (";
+ private final String ZoneWideDetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
+
+ private final String FindPoolTagDetails = "SELECT storage_pool_details.name FROM storage_pool_details WHERE pool_id = ? and value = ?";
+
+ public PrimaryDataStoreDaoImpl() {
+ AllFieldSearch = createSearchBuilder();
+ AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("status", AllFieldSearch.entity().getStatus(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ);
+ AllFieldSearch.and("clusterId", AllFieldSearch.entity().getClusterId(), Op.EQ);
+ AllFieldSearch.done();
+
+ DcPodSearch = createSearchBuilder();
+ DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+ DcPodSearch.and("status", DcPodSearch.entity().getStatus(), SearchCriteria.Op.EQ);
+ DcPodSearch.and("scope", DcPodSearch.entity().getScope(), SearchCriteria.Op.EQ);
+ DcPodSearch.and().op("nullpod", DcPodSearch.entity().getPodId(), SearchCriteria.Op.NULL);
+ DcPodSearch.or("podId", DcPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
+ DcPodSearch.cp();
+ DcPodSearch.and().op("nullcluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.NULL);
+ DcPodSearch.or("cluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
+ DcPodSearch.cp();
+ DcPodSearch.done();
+
+ DcPodAnyClusterSearch = createSearchBuilder();
+ DcPodAnyClusterSearch.and("datacenterId", DcPodAnyClusterSearch.entity().getDataCenterId(),
+ SearchCriteria.Op.EQ);
+ DcPodAnyClusterSearch.and("status", DcPodAnyClusterSearch.entity().getStatus(), SearchCriteria.Op.EQ);
+ DcPodAnyClusterSearch.and("scope", DcPodAnyClusterSearch.entity().getScope(), SearchCriteria.Op.EQ);
+ DcPodAnyClusterSearch.and().op("nullpod", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.NULL);
+ DcPodAnyClusterSearch.or("podId", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.EQ);
+ DcPodAnyClusterSearch.cp();
+ DcPodAnyClusterSearch.done();
+
+ DeleteLvmSearch = createSearchBuilder();
+ DeleteLvmSearch.and("ids", DeleteLvmSearch.entity().getId(), SearchCriteria.Op.IN);
+ DeleteLvmSearch.and().op("LVM", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
+ DeleteLvmSearch.or("Filesystem", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
+ DeleteLvmSearch.cp();
+ DeleteLvmSearch.done();
+
+ StatusCountSearch = createSearchBuilder(Long.class);
+ StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
+ StatusCountSearch.select(null, Func.COUNT, null);
+ StatusCountSearch.done();
+
+ }
+
+ @Override
+ public List<StoragePoolVO> findPoolByName(String name) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("name", name);
+ return listIncludingRemovedBy(sc);
+ }
+
+ @Override
+ public StoragePoolVO findPoolByUUID(String uuid) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("uuid", uuid);
+ return findOneIncludingRemovedBy(sc);
+ }
+
+ @Override
+ public List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("uuid", uuid);
+ return listBy(sc);
+ }
+
+ @Override
+ public List<StoragePoolVO> listByDataCenterId(long datacenterId) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("datacenterId", datacenterId);
+ return listBy(sc);
+ }
+
+ @Override
+ public void updateAvailable(long id, long available) {
+ StoragePoolVO pool = createForUpdate(id);
+ pool.setUsedBytes(available);
+ update(id, pool);
+ }
+
+ @Override
+ public void updateCapacity(long id, long capacity) {
+ StoragePoolVO pool = createForUpdate(id);
+ pool.setCapacityBytes(capacity);
+ update(id, pool);
+
+ }
+
+ @Override
+ public List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("hostAddress", hostFqdnOrIp);
+ return listIncludingRemovedBy(sc);
+ }
+
+ @Override
+ public List<StoragePoolVO> listByStatus(StoragePoolStatus status) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("status", status);
+ return listBy(sc);
+ }
+
+ @Override
+ public List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("status", status);
+ sc.setParameters("datacenterId", dcId);
+ return listBy(sc);
+ }
+
+ @Override
+ public StoragePoolVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("hostAddress", host);
+ sc.setParameters("path", path);
+ sc.setParameters("datacenterId", datacenterId);
+ sc.setParameters("podId", podId);
+ sc.setParameters("uuid", uuid);
+
+ return findOneBy(sc);
+ }
+
+ @Override
+ public List<StoragePoolVO> listBy(long datacenterId, Long podId, Long clusterId, ScopeType scope) {
+ if (clusterId != null) {
+ SearchCriteria<StoragePoolVO> sc = DcPodSearch.create();
+ sc.setParameters("datacenterId", datacenterId);
+ sc.setParameters("podId", podId);
+ sc.setParameters("status", Status.Up);
+ sc.setParameters("scope", scope);
+
+ sc.setParameters("cluster", clusterId);
+ return listBy(sc);
+ } else {
+ SearchCriteria<StoragePoolVO> sc = DcPodAnyClusterSearch.create();
+ sc.setParameters("datacenterId", datacenterId);
+ sc.setParameters("podId", podId);
+ sc.setParameters("status", Status.Up);
+ sc.setParameters("scope", scope);
+ return listBy(sc);
+ }
+ }
+
+ @Override
+ public List<StoragePoolVO> listPoolByHostPath(String host, String path) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("hostAddress", host);
+ sc.setParameters("path", path);
+
+ return listBy(sc);
+ }
+
+ public StoragePoolVO listById(Integer id) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("id", id);
+
+ return findOneIncludingRemovedBy(sc);
+ }
+
+ @Override
+ @DB
+ public StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details) {
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ pool = super.persist(pool);
+ if (details != null) {
+ for (Map.Entry<String, String> detail : details.entrySet()) {
+ StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue());
+ _detailsDao.persist(vo);
+ }
+ }
+ txn.commit();
+ return pool;
+ }
+
+ @DB
+ @Override
+ public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details,
+ ScopeType scope) {
+ StringBuilder sql = new StringBuilder(DetailsSqlPrefix);
+ if (clusterId != null) {
+ sql.append("storage_pool.cluster_id = ? OR storage_pool.cluster_id IS NULL) AND (");
+ }
+
+ for (Map.Entry<String, String> detail : details.entrySet()) {
+ sql.append("((storage_pool_details.name='").append(detail.getKey())
+ .append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
+ }
+ sql.delete(sql.length() - 4, sql.length());
+ sql.append(DetailsSqlSuffix);
+ Transaction txn = Transaction.currentTxn();
+ PreparedStatement pstmt = null;
+ try {
+ pstmt = txn.prepareAutoCloseStatement(sql.toString());
+ int i = 1;
+ pstmt.setLong(i++, dcId);
+ pstmt.setLong(i++, podId);
+ pstmt.setString(i++, scope.toString());
+ if (clusterId != null) {
+ pstmt.setLong(i++, clusterId);
+ }
+ pstmt.setInt(i++, details.size());
+ ResultSet rs = pstmt.executeQuery();
+ List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
+ while (rs.next()) {
+ pools.add(toEntityBean(rs, false));
+ }
+ return pools;
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to execute " + pstmt, e);
+ }
+ }
+
+ protected Map<String, String> tagsToDetails(String[] tags) {
+ Map<String, String> details = new HashMap<String, String>(tags.length);
+ for (String tag : tags) {
+ details.put(tag, "true");
+ }
+ return details;
+ }
+
+ @Override
+ public List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags) {
+ List<StoragePoolVO> storagePools = null;
+ if (tags == null || tags.length == 0) {
+ storagePools = listBy(dcId, podId, clusterId, ScopeType.CLUSTER);
+ } else {
+ Map<String, String> details = tagsToDetails(tags);
+ storagePools = findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.CLUSTER);
+ }
+
+ return storagePools;
+ }
+
+ @Override
+ public List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags) {
+ List<StoragePoolVO> storagePools = null;
+ if (tags == null || tags.length == 0) {
+ storagePools = listBy(dcId, podId, clusterId, ScopeType.HOST);
+ } else {
+ Map<String, String> details = tagsToDetails(tags);
+ storagePools = findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.HOST);
+ }
+
+ return storagePools;
+ }
+
+ @Override
+ public List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags) {
+ List<StoragePoolVO> storagePools = null;
+ if (tags == null || tags.length == 0) {
+ SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc = SearchCriteria2.create(StoragePoolVO.class);
+ sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
+ sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
+ sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
+ return sc.list();
+ } else {
+ Map<String, String> details = tagsToDetails(tags);
+
+ StringBuilder sql = new StringBuilder(ZoneWideDetailsSqlPrefix);
+
+ for (Map.Entry<String, String> detail : details.entrySet()) {
+ sql.append("((storage_pool_details.name='").append(detail.getKey())
+ .append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
+ }
+ sql.delete(sql.length() - 4, sql.length());
+ sql.append(ZoneWideDetailsSqlSuffix);
+ Transaction txn = Transaction.currentTxn();
+ PreparedStatement pstmt = null;
+ try {
+ pstmt = txn.prepareAutoCloseStatement(sql.toString());
+ int i = 1;
+ pstmt.setLong(i++, dcId);
+ pstmt.setString(i++, ScopeType.ZONE.toString());
+ pstmt.setInt(i++, details.size());
+ ResultSet rs = pstmt.executeQuery();
+ List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
+ while (rs.next()) {
+ pools.add(toEntityBean(rs, false));
+ }
+ return pools;
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to execute " + pstmt, e);
+ }
+ }
+ }
+
+ @Override
+ @DB
+ public List<String> searchForStoragePoolDetails(long poolId, String value) {
+
+ StringBuilder sql = new StringBuilder(FindPoolTagDetails);
+
+ Transaction txn = Transaction.currentTxn();
+ PreparedStatement pstmt = null;
+ try {
+ pstmt = txn.prepareAutoCloseStatement(sql.toString());
+ pstmt.setLong(1, poolId);
+ pstmt.setString(2, value);
+
+ ResultSet rs = pstmt.executeQuery();
+ List<String> tags = new ArrayList<String>();
+
+ while (rs.next()) {
+ tags.add(rs.getString("name"));
+ }
+ return tags;
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
+ }
+
+ }
+
+ @Override
+ public void updateDetails(long poolId, Map<String, String> details) {
+ if (details != null) {
+ _detailsDao.update(poolId, details);
+ }
+ }
+
+ @Override
+ public Map<String, String> getDetails(long poolId) {
+ return _detailsDao.getDetails(poolId);
+ }
+
+ @Override
+ public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+ super.configure(name, params);
+ _detailsDao.configure("DetailsDao", params);
+ return true;
+ }
+
+ @Override
+ public long countPoolsByStatus(StoragePoolStatus... statuses) {
+ SearchCriteria<Long> sc = StatusCountSearch.create();
+
+ sc.setParameters("status", (Object[]) statuses);
+
+ List<Long> rs = customSearchIncludingRemoved(sc, null);
+ if (rs.size() == 0) {
+ return 0;
+ }
+
+ return rs.get(0);
+ }
+
+ @Override
+ public List<StoragePoolVO> listPoolsByCluster(long clusterId) {
+ SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+ sc.setParameters("clusterId", clusterId);
+
+ return listBy(sc);
+ }
+
+ @Override
+ public List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType) {
+ SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc = SearchCriteria2.create(StoragePoolVO.class);
+ sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dataCenterId);
+ sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
+ sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
+ sc.addAnd(sc.getEntity().getHypervisor(), Op.EQ, hypervisorType);
+ return sc.list();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
new file mode 100644
index 0000000..0d9af4b
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
@@ -0,0 +1,79 @@
+// 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.db;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "storage_pool_details")
+public class PrimaryDataStoreDetailVO {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ long id;
+
+ @Column(name = "pool_id")
+ long poolId;
+
+ @Column(name = "name")
+ String name;
+
+ @Column(name = "value")
+ String value;
+
+ public PrimaryDataStoreDetailVO(long poolId, String name, String value) {
+ this.poolId = poolId;
+ this.name = name;
+ this.value = value;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getPoolId() {
+ return poolId;
+ }
+
+ public void setPoolId(long poolId) {
+ this.poolId = poolId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ protected PrimaryDataStoreDetailVO() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
new file mode 100644
index 0000000..18e2f1c
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.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.datastore.db;
+
+import java.util.Map;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface PrimaryDataStoreDetailsDao extends GenericDao<PrimaryDataStoreDetailVO, Long> {
+
+ void update(long poolId, Map<String, String> details);
+
+ Map<String, String> getDetails(long poolId);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
new file mode 100644
index 0000000..f903715
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
@@ -0,0 +1,43 @@
+// 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.db;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+
+import com.cloud.storage.DataStoreRole;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Long>,
+StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
+
+ List<SnapshotDataStoreVO> listByStoreId(long id, DataStoreRole role);
+
+ List<SnapshotDataStoreVO> listActiveOnCache(long id);
+
+ void deletePrimaryRecordsForStore(long id, DataStoreRole role);
+
+ SnapshotDataStoreVO findByStoreSnapshot(DataStoreRole role, long storeId, long snapshotId);
+ SnapshotDataStoreVO findParent(DataStoreRole role, Long storeId, Long volumeId);
+
+ SnapshotDataStoreVO findBySnapshot(long snapshotId, DataStoreRole role);
+
+ List<SnapshotDataStoreVO> listDestroyed(long storeId);
+}
[3/4] Removed schema from the dependency of many components
Posted by ah...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java b/engine/api/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
deleted file mode 100644
index b536028..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
+++ /dev/null
@@ -1,38 +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 com.cloud.agent.api.Command;
-
-public final class CreatePrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
- private final String dataStore;
-
- public CreatePrimaryDataStoreCmd(String uri) {
- super();
- this.dataStore = uri;
- }
-
- public String getDataStore() {
- return this.dataStore;
- }
-
- @Override
- public boolean executeInSequence() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/DeleteCommand.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/DeleteCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/DeleteCommand.java
deleted file mode 100644
index 76696da..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/DeleteCommand.java
+++ /dev/null
@@ -1,45 +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 com.cloud.agent.api.Command;
-import com.cloud.agent.api.to.DataTO;
-
-public final class DeleteCommand extends Command implements StorageSubSystemCommand {
- private DataTO data;
-
- public DeleteCommand(DataTO data) {
- super();
- this.data = data;
- }
-
- protected DeleteCommand() {
- super();
- }
-
- @Override
- public boolean executeInSequence() {
- return false;
- }
-
- public DataTO getData() {
- return this.data;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/DettachAnswer.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/DettachAnswer.java b/engine/api/src/org/apache/cloudstack/storage/command/DettachAnswer.java
deleted file mode 100644
index 62ce246..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/DettachAnswer.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.command;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.to.DiskTO;
-
-public final class DettachAnswer extends Answer {
- private DiskTO disk;
-
- public DettachAnswer() {
- super(null);
- }
-
- public DettachAnswer(DiskTO disk) {
- super(null);
- this.setDisk(disk);
- }
-
- public DettachAnswer(String errMsg) {
- super(null, false, errMsg);
- }
-
- public DiskTO getDisk() {
- return disk;
- }
-
- public void setDisk(DiskTO disk) {
- this.disk = disk;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/DettachCommand.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/DettachCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/DettachCommand.java
deleted file mode 100644
index 61cb88b..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/DettachCommand.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.command;
-
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.to.DiskTO;
-
-public class DettachCommand extends Command implements StorageSubSystemCommand {
- private DiskTO disk;
- private String vmName;
- private boolean _managed;
- private String _iScsiName;
- private String _storageHost;
- private int _storagePort;
-
- public DettachCommand(DiskTO disk, String vmName) {
- super();
- this.disk = disk;
- this.vmName = vmName;
- }
-
- @Override
- public boolean executeInSequence() {
- return false;
- }
-
- public DiskTO getDisk() {
- return disk;
- }
-
- public void setDisk(DiskTO disk) {
- this.disk = disk;
- }
-
- public String getVmName() {
- return vmName;
- }
-
- public void setVmName(String vmName) {
- this.vmName = vmName;
- }
-
- public void setManaged(boolean managed) {
- _managed = managed;
- }
-
- public boolean isManaged() {
- return _managed;
- }
-
- public void set_iScsiName(String iScsiName) {
- _iScsiName = iScsiName;
- }
-
- public String get_iScsiName() {
- return _iScsiName;
- }
-
- public void setStorageHost(String storageHost) {
- _storageHost = storageHost;
- }
-
- public String getStorageHost() {
- return _storageHost;
- }
-
- public void setStoragePort(int storagePort) {
- _storagePort = storagePort;
- }
-
- public int getStoragePort() {
- return _storagePort;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java
deleted file mode 100644
index d14161a..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.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.command;
-
-public interface StorageSubSystemCommand {
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
deleted file mode 100644
index 70e9bb3..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.datastore.db;
-
-import java.util.List;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface ImageStoreDao extends GenericDao<ImageStoreVO, Long> {
- ImageStoreVO findByName(String name);
-
- List<ImageStoreVO> findByProvider(String provider);
-
- List<ImageStoreVO> findByScope(ZoneScope scope);
-
- List<ImageStoreVO> findImageCacheByScope(ZoneScope scope);
-
- List<ImageStoreVO> listImageStores();
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java
deleted file mode 100644
index b922148..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailVO.java
+++ /dev/null
@@ -1,82 +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.db;
-
-import org.apache.cloudstack.api.InternalIdentity;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name = "image_store_details")
-public class ImageStoreDetailVO implements InternalIdentity {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- long id;
-
- @Column(name = "store_id")
- long storeId;
-
- @Column(name = "name")
- String name;
-
- @Column(name = "value")
- String value;
-
- public ImageStoreDetailVO() {
- }
-
- public ImageStoreDetailVO(long storeId, String name, String value) {
- this.storeId = storeId;
- this.name = name;
- this.value = value;
- }
-
- public long getId() {
- return id;
- }
-
- public long getStoreId() {
- return storeId;
- }
-
- public void setStoreId(long storeId) {
- this.storeId = storeId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.java
deleted file mode 100644
index 91fff28..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDetailsDao.java
+++ /dev/null
@@ -1,30 +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.db;
-
-import java.util.Map;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface ImageStoreDetailsDao extends GenericDao<ImageStoreDetailVO, Long> {
-
- void update(long storeId, Map<String, String> details);
-
- Map<String, String> getDetails(long storeId);
-
- void deleteDetails(long storeId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
deleted file mode 100644
index 5ed48a3..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java
+++ /dev/null
@@ -1,193 +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.db;
-
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.ImageStore;
-import com.cloud.storage.ScopeType;
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name = "image_store")
-public class ImageStoreVO implements ImageStore {
- @Id
- @TableGenerator(name = "image_store_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value",
- pkColumnValue = "image_store_seq", allocationSize = 1)
- @Column(name = "id", nullable = false)
- private long id;
-
- @Column(name = "name", nullable = false)
- private String name;
-
- @Column(name = "uuid", nullable = false)
- private String uuid;
-
- @Column(name = "protocol", nullable = false)
- private String protocol;
-
- @Column(name = "url", nullable = false)
- private String url;
-
- @Column(name = "image_provider_name", nullable = false)
- private String providerName;
-
- @Column(name = "data_center_id")
- private Long dcId;
-
- @Column(name = "scope")
- @Enumerated(value = EnumType.STRING)
- private ScopeType scope;
-
- @Column(name = GenericDao.CREATED_COLUMN)
- private Date created;
-
- @Column(name = GenericDao.REMOVED_COLUMN)
- private Date removed;
-
- @Column(name = "role")
- @Enumerated(value = EnumType.STRING)
- private DataStoreRole role;
-
- @Column(name = "parent")
- private String parent;
-
- @Column(name = "total_size")
- private Long totalSize;
-
- @Column(name = "used_bytes")
- private Long usedBytes;
-
- public DataStoreRole getRole() {
- return role;
- }
-
- public void setRole(DataStoreRole role) {
- this.role = role;
- }
-
- public long getId() {
- return this.id;
- }
-
- public String getName() {
- return this.name;
- }
-
- public String getProviderName() {
- return this.providerName;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setProviderName(String provider) {
- this.providerName = provider;
- }
-
- public void setProtocol(String protocol) {
- this.protocol = protocol;
- }
-
- public String getProtocol() {
- return this.protocol;
- }
-
- public void setDataCenterId(Long dcId) {
- this.dcId = dcId;
- }
-
- public Long getDataCenterId() {
- return this.dcId;
- }
-
- public ScopeType getScope() {
- return this.scope;
- }
-
- public void setScope(ScopeType scope) {
- this.scope = scope;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public String getUuid() {
- return this.uuid;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public void setCreated(Date created) {
- this.created = created;
- }
-
- public Date getRemoved() {
- return removed;
- }
-
- public void setRemoved(Date removed) {
- this.removed = removed;
- }
-
- public String getParent() {
- return parent;
- }
-
- public void setParent(String parent) {
- this.parent = parent;
- }
-
- public Long getTotalSize() {
- return totalSize;
- }
-
- public void setTotalSize(Long totalSize) {
- this.totalSize = totalSize;
- }
-
- public Long getUsedBytes() {
- return usedBytes;
- }
-
- public void setUsedBytes(Long usedBytes) {
- this.usedBytes = usedBytes;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
deleted file mode 100644
index 669dd25..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
+++ /dev/null
@@ -1,120 +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.db;
-
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.ScopeType;
-import com.cloud.storage.StoragePoolStatus;
-import com.cloud.utils.db.GenericDao;
-
-/**
- * Data Access Object for storage_pool table
- */
-public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
-
- /**
- * @param datacenterId -- the id of the datacenter (availability zone)
- */
- List<StoragePoolVO> listByDataCenterId(long datacenterId);
-
- /**
- * @param datacenterId -- the id of the datacenter (availability zone)
- */
- List<StoragePoolVO> listBy(long datacenterId, Long podId, Long clusterId, ScopeType scope);
-
- /**
- * Set capacity of storage pool in bytes
- * @param id pool id.
- * @param capacity capacity in bytes
- */
- void updateCapacity(long id, long capacity);
-
- /**
- * Set available bytes of storage pool in bytes
- *
- * @param id
- * pool id.
- * @param available
- * available capacity in bytes
- */
- void updateAvailable(long id, long available);
-
- StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details);
-
- /**
- * Find pool by name.
- *
- * @param name
- * name of pool.
- * @return the single StoragePoolVO
- */
- List<StoragePoolVO> findPoolByName(String name);
-
- /**
- * Find pools by the pod that matches the details.
- *
- * @param podId
- * pod id to find the pools in.
- * @param details
- * details to match. All must match for the pool to be returned.
- * @return List of StoragePoolVO
- */
- List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details,
- ScopeType scope);
-
- List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags);
-
- /**
- * Find pool by UUID.
- *
- * @param uuid
- * uuid of pool.
- * @return the single StoragePoolVO
- */
- StoragePoolVO findPoolByUUID(String uuid);
-
- List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp);
-
- StoragePoolVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
-
- List<StoragePoolVO> listPoolByHostPath(String host, String path);
-
- void updateDetails(long poolId, Map<String, String> details);
-
- Map<String, String> getDetails(long poolId);
-
- List<String> searchForStoragePoolDetails(long poolId, String value);
-
- List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid);
-
- List<StoragePoolVO> listByStatus(StoragePoolStatus status);
-
- long countPoolsByStatus(StoragePoolStatus... statuses);
-
- List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status);
-
- List<StoragePoolVO> listPoolsByCluster(long clusterId);
-
- List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags);
-
- List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags);
-
- List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
deleted file mode 100644
index 1032526..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
+++ /dev/null
@@ -1,432 +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.db;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import com.cloud.host.Status;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.ScopeType;
-import com.cloud.storage.StoragePoolStatus;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.SearchCriteria2;
-import com.cloud.utils.db.SearchCriteriaService;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Local(value = { PrimaryDataStoreDao.class })
-@DB(txn = false)
-public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> implements PrimaryDataStoreDao {
- protected final SearchBuilder<StoragePoolVO> AllFieldSearch;
- protected final SearchBuilder<StoragePoolVO> DcPodSearch;
- protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch;
- protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
- protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
-
- @Inject
- protected StoragePoolDetailsDao _detailsDao;
-
- private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.status = 'Up' and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and storage_pool.scope = ? and (";
- private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
- private final String ZoneWideDetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.status = 'Up' and storage_pool.data_center_id = ? and storage_pool.scope = ? and (";
- private final String ZoneWideDetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
-
- private final String FindPoolTagDetails = "SELECT storage_pool_details.name FROM storage_pool_details WHERE pool_id = ? and value = ?";
-
- public PrimaryDataStoreDaoImpl() {
- AllFieldSearch = createSearchBuilder();
- AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ);
- AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ);
- AllFieldSearch.and("datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- AllFieldSearch.and("hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
- AllFieldSearch.and("status", AllFieldSearch.entity().getStatus(), SearchCriteria.Op.EQ);
- AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ);
- AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ);
- AllFieldSearch.and("clusterId", AllFieldSearch.entity().getClusterId(), Op.EQ);
- AllFieldSearch.done();
-
- DcPodSearch = createSearchBuilder();
- DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- DcPodSearch.and("status", DcPodSearch.entity().getStatus(), SearchCriteria.Op.EQ);
- DcPodSearch.and("scope", DcPodSearch.entity().getScope(), SearchCriteria.Op.EQ);
- DcPodSearch.and().op("nullpod", DcPodSearch.entity().getPodId(), SearchCriteria.Op.NULL);
- DcPodSearch.or("podId", DcPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
- DcPodSearch.cp();
- DcPodSearch.and().op("nullcluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.NULL);
- DcPodSearch.or("cluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
- DcPodSearch.cp();
- DcPodSearch.done();
-
- DcPodAnyClusterSearch = createSearchBuilder();
- DcPodAnyClusterSearch.and("datacenterId", DcPodAnyClusterSearch.entity().getDataCenterId(),
- SearchCriteria.Op.EQ);
- DcPodAnyClusterSearch.and("status", DcPodAnyClusterSearch.entity().getStatus(), SearchCriteria.Op.EQ);
- DcPodAnyClusterSearch.and("scope", DcPodAnyClusterSearch.entity().getScope(), SearchCriteria.Op.EQ);
- DcPodAnyClusterSearch.and().op("nullpod", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.NULL);
- DcPodAnyClusterSearch.or("podId", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.EQ);
- DcPodAnyClusterSearch.cp();
- DcPodAnyClusterSearch.done();
-
- DeleteLvmSearch = createSearchBuilder();
- DeleteLvmSearch.and("ids", DeleteLvmSearch.entity().getId(), SearchCriteria.Op.IN);
- DeleteLvmSearch.and().op("LVM", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
- DeleteLvmSearch.or("Filesystem", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
- DeleteLvmSearch.cp();
- DeleteLvmSearch.done();
-
- StatusCountSearch = createSearchBuilder(Long.class);
- StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
- StatusCountSearch.select(null, Func.COUNT, null);
- StatusCountSearch.done();
-
- }
-
- @Override
- public List<StoragePoolVO> findPoolByName(String name) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("name", name);
- return listIncludingRemovedBy(sc);
- }
-
- @Override
- public StoragePoolVO findPoolByUUID(String uuid) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("uuid", uuid);
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- public List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("uuid", uuid);
- return listBy(sc);
- }
-
- @Override
- public List<StoragePoolVO> listByDataCenterId(long datacenterId) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("datacenterId", datacenterId);
- return listBy(sc);
- }
-
- @Override
- public void updateAvailable(long id, long available) {
- StoragePoolVO pool = createForUpdate(id);
- pool.setUsedBytes(available);
- update(id, pool);
- }
-
- @Override
- public void updateCapacity(long id, long capacity) {
- StoragePoolVO pool = createForUpdate(id);
- pool.setCapacityBytes(capacity);
- update(id, pool);
-
- }
-
- @Override
- public List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("hostAddress", hostFqdnOrIp);
- return listIncludingRemovedBy(sc);
- }
-
- @Override
- public List<StoragePoolVO> listByStatus(StoragePoolStatus status) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("status", status);
- return listBy(sc);
- }
-
- @Override
- public List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("status", status);
- sc.setParameters("datacenterId", dcId);
- return listBy(sc);
- }
-
- @Override
- public StoragePoolVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("hostAddress", host);
- sc.setParameters("path", path);
- sc.setParameters("datacenterId", datacenterId);
- sc.setParameters("podId", podId);
- sc.setParameters("uuid", uuid);
-
- return findOneBy(sc);
- }
-
- @Override
- public List<StoragePoolVO> listBy(long datacenterId, Long podId, Long clusterId, ScopeType scope) {
- if (clusterId != null) {
- SearchCriteria<StoragePoolVO> sc = DcPodSearch.create();
- sc.setParameters("datacenterId", datacenterId);
- sc.setParameters("podId", podId);
- sc.setParameters("status", Status.Up);
- sc.setParameters("scope", scope);
-
- sc.setParameters("cluster", clusterId);
- return listBy(sc);
- } else {
- SearchCriteria<StoragePoolVO> sc = DcPodAnyClusterSearch.create();
- sc.setParameters("datacenterId", datacenterId);
- sc.setParameters("podId", podId);
- sc.setParameters("status", Status.Up);
- sc.setParameters("scope", scope);
- return listBy(sc);
- }
- }
-
- @Override
- public List<StoragePoolVO> listPoolByHostPath(String host, String path) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("hostAddress", host);
- sc.setParameters("path", path);
-
- return listBy(sc);
- }
-
- public StoragePoolVO listById(Integer id) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("id", id);
-
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- @DB
- public StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
- pool = super.persist(pool);
- if (details != null) {
- for (Map.Entry<String, String> detail : details.entrySet()) {
- StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue());
- _detailsDao.persist(vo);
- }
- }
- txn.commit();
- return pool;
- }
-
- @DB
- @Override
- public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details,
- ScopeType scope) {
- StringBuilder sql = new StringBuilder(DetailsSqlPrefix);
- if (clusterId != null) {
- sql.append("storage_pool.cluster_id = ? OR storage_pool.cluster_id IS NULL) AND (");
- }
-
- for (Map.Entry<String, String> detail : details.entrySet()) {
- sql.append("((storage_pool_details.name='").append(detail.getKey())
- .append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
- }
- sql.delete(sql.length() - 4, sql.length());
- sql.append(DetailsSqlSuffix);
- Transaction txn = Transaction.currentTxn();
- PreparedStatement pstmt = null;
- try {
- pstmt = txn.prepareAutoCloseStatement(sql.toString());
- int i = 1;
- pstmt.setLong(i++, dcId);
- pstmt.setLong(i++, podId);
- pstmt.setString(i++, scope.toString());
- if (clusterId != null) {
- pstmt.setLong(i++, clusterId);
- }
- pstmt.setInt(i++, details.size());
- ResultSet rs = pstmt.executeQuery();
- List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
- while (rs.next()) {
- pools.add(toEntityBean(rs, false));
- }
- return pools;
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to execute " + pstmt, e);
- }
- }
-
- protected Map<String, String> tagsToDetails(String[] tags) {
- Map<String, String> details = new HashMap<String, String>(tags.length);
- for (String tag : tags) {
- details.put(tag, "true");
- }
- return details;
- }
-
- @Override
- public List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags) {
- List<StoragePoolVO> storagePools = null;
- if (tags == null || tags.length == 0) {
- storagePools = listBy(dcId, podId, clusterId, ScopeType.CLUSTER);
- } else {
- Map<String, String> details = tagsToDetails(tags);
- storagePools = findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.CLUSTER);
- }
-
- return storagePools;
- }
-
- @Override
- public List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long clusterId, String[] tags) {
- List<StoragePoolVO> storagePools = null;
- if (tags == null || tags.length == 0) {
- storagePools = listBy(dcId, podId, clusterId, ScopeType.HOST);
- } else {
- Map<String, String> details = tagsToDetails(tags);
- storagePools = findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.HOST);
- }
-
- return storagePools;
- }
-
- @Override
- public List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags) {
- List<StoragePoolVO> storagePools = null;
- if (tags == null || tags.length == 0) {
- SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc = SearchCriteria2.create(StoragePoolVO.class);
- sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
- sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
- sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
- return sc.list();
- } else {
- Map<String, String> details = tagsToDetails(tags);
-
- StringBuilder sql = new StringBuilder(ZoneWideDetailsSqlPrefix);
-
- for (Map.Entry<String, String> detail : details.entrySet()) {
- sql.append("((storage_pool_details.name='").append(detail.getKey())
- .append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
- }
- sql.delete(sql.length() - 4, sql.length());
- sql.append(ZoneWideDetailsSqlSuffix);
- Transaction txn = Transaction.currentTxn();
- PreparedStatement pstmt = null;
- try {
- pstmt = txn.prepareAutoCloseStatement(sql.toString());
- int i = 1;
- pstmt.setLong(i++, dcId);
- pstmt.setString(i++, ScopeType.ZONE.toString());
- pstmt.setInt(i++, details.size());
- ResultSet rs = pstmt.executeQuery();
- List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
- while (rs.next()) {
- pools.add(toEntityBean(rs, false));
- }
- return pools;
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to execute " + pstmt, e);
- }
- }
- }
-
- @Override
- @DB
- public List<String> searchForStoragePoolDetails(long poolId, String value) {
-
- StringBuilder sql = new StringBuilder(FindPoolTagDetails);
-
- Transaction txn = Transaction.currentTxn();
- PreparedStatement pstmt = null;
- try {
- pstmt = txn.prepareAutoCloseStatement(sql.toString());
- pstmt.setLong(1, poolId);
- pstmt.setString(2, value);
-
- ResultSet rs = pstmt.executeQuery();
- List<String> tags = new ArrayList<String>();
-
- while (rs.next()) {
- tags.add(rs.getString("name"));
- }
- return tags;
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
- }
-
- }
-
- @Override
- public void updateDetails(long poolId, Map<String, String> details) {
- if (details != null) {
- _detailsDao.update(poolId, details);
- }
- }
-
- @Override
- public Map<String, String> getDetails(long poolId) {
- return _detailsDao.getDetails(poolId);
- }
-
- @Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
- super.configure(name, params);
- _detailsDao.configure("DetailsDao", params);
- return true;
- }
-
- @Override
- public long countPoolsByStatus(StoragePoolStatus... statuses) {
- SearchCriteria<Long> sc = StatusCountSearch.create();
-
- sc.setParameters("status", (Object[]) statuses);
-
- List<Long> rs = customSearchIncludingRemoved(sc, null);
- if (rs.size() == 0) {
- return 0;
- }
-
- return rs.get(0);
- }
-
- @Override
- public List<StoragePoolVO> listPoolsByCluster(long clusterId) {
- SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
- sc.setParameters("clusterId", clusterId);
-
- return listBy(sc);
- }
-
- @Override
- public List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType) {
- SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc = SearchCriteria2.create(StoragePoolVO.class);
- sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dataCenterId);
- sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
- sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
- sc.addAnd(sc.getEntity().getHypervisor(), Op.EQ, hypervisorType);
- return sc.list();
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
deleted file mode 100644
index 0d9af4b..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
+++ /dev/null
@@ -1,79 +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.db;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name = "storage_pool_details")
-public class PrimaryDataStoreDetailVO {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- long id;
-
- @Column(name = "pool_id")
- long poolId;
-
- @Column(name = "name")
- String name;
-
- @Column(name = "value")
- String value;
-
- public PrimaryDataStoreDetailVO(long poolId, String name, String value) {
- this.poolId = poolId;
- this.name = name;
- this.value = value;
- }
-
- public long getId() {
- return id;
- }
-
- public long getPoolId() {
- return poolId;
- }
-
- public void setPoolId(long poolId) {
- this.poolId = poolId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- protected PrimaryDataStoreDetailVO() {
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
deleted file mode 100644
index 18e2f1c..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
+++ /dev/null
@@ -1,28 +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.db;
-
-import java.util.Map;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface PrimaryDataStoreDetailsDao extends GenericDao<PrimaryDataStoreDetailVO, Long> {
-
- void update(long poolId, Map<String, String> details);
-
- Map<String, String> getDetails(long poolId);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
deleted file mode 100644
index f903715..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
+++ /dev/null
@@ -1,43 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.storage.datastore.db;
-
-import java.util.List;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
-
-import com.cloud.storage.DataStoreRole;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateDao;
-
-public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Long>,
-StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
-
- List<SnapshotDataStoreVO> listByStoreId(long id, DataStoreRole role);
-
- List<SnapshotDataStoreVO> listActiveOnCache(long id);
-
- void deletePrimaryRecordsForStore(long id, DataStoreRole role);
-
- SnapshotDataStoreVO findByStoreSnapshot(DataStoreRole role, long storeId, long snapshotId);
- SnapshotDataStoreVO findParent(DataStoreRole role, Long storeId, Long volumeId);
-
- SnapshotDataStoreVO findBySnapshot(long snapshotId, DataStoreRole role);
-
- List<SnapshotDataStoreVO> listDestroyed(long storeId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
deleted file mode 100644
index 300df1e..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java
+++ /dev/null
@@ -1,271 +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.db;
-
-import java.util.Date;
-
-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 javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
-
-import com.cloud.storage.DataStoreRole;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.fsm.StateObject;
-
-/**
- * Join table for image_data_store and snapshots
- *
- */
-@Entity
-@Table(name = "snapshot_store_ref")
-public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- Long id;
-
- @Column(name = "store_id")
- private long dataStoreId;
-
- @Column(name = "store_role")
- @Enumerated(EnumType.STRING)
- private DataStoreRole role;
-
- @Column(name = "snapshot_id")
- private long snapshotId;
-
- @Column(name = GenericDaoBase.CREATED_COLUMN)
- private Date created = null;
-
- @Column(name = "last_updated")
- @Temporal(value = TemporalType.TIMESTAMP)
- private Date lastUpdated = null;
-
- @Column(name = "size")
- private long size;
-
- @Column(name = "physical_size")
- private long physicalSize;
-
- @Column(name = "parent_snapshot_id")
- private long parentSnapshotId;
-
- @Column(name = "job_id")
- private String jobId;
-
- @Column(name = "install_path")
- private String installPath;
-
- @Column(name = "update_count", updatable = true, nullable = false)
- protected long updatedCount;
-
- @Column(name = "updated")
- @Temporal(value = TemporalType.TIMESTAMP)
- Date updated;
-
- @Column(name = "state")
- @Enumerated(EnumType.STRING)
- ObjectInDataStoreStateMachine.State state;
-
- @Column(name = "ref_cnt")
- Long refCnt = 0L;
-
- @Column(name = "volume_id")
- Long volumeId;
-
- public String getInstallPath() {
- return installPath;
- }
-
- @Override
- public long getDataStoreId() {
- return dataStoreId;
- }
-
- public void setDataStoreId(long storeId) {
- this.dataStoreId = storeId;
- }
-
- public long getSnapshotId() {
- return snapshotId;
- }
-
- public void setSnapshotId(long snapshotId) {
- this.snapshotId = snapshotId;
- }
-
- public long getId() {
- return id;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- public void setLastUpdated(Date date) {
- lastUpdated = date;
- }
-
- public void setInstallPath(String installPath) {
- this.installPath = installPath;
- }
-
- public SnapshotDataStoreVO(long hostId, long snapshotId) {
- super();
- this.dataStoreId = hostId;
- this.snapshotId = snapshotId;
- this.state = ObjectInDataStoreStateMachine.State.Allocated;
- }
-
- public SnapshotDataStoreVO() {
-
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof SnapshotDataStoreVO) {
- SnapshotDataStoreVO other = (SnapshotDataStoreVO) obj;
- return (this.snapshotId == other.getSnapshotId() && this.dataStoreId == other.getDataStoreId());
- }
- return false;
- }
-
- public int hashCode() {
- Long tid = new Long(snapshotId);
- Long hid = new Long(dataStoreId);
- return tid.hashCode() + hid.hashCode();
- }
-
- public void setSize(long size) {
- this.size = size;
- }
-
- public long getSize() {
- return size;
- }
-
- public void setPhysicalSize(long physicalSize) {
- this.physicalSize = physicalSize;
- }
-
- public long getPhysicalSize() {
- return physicalSize;
- }
-
- public long getVolumeSize() {
- return -1;
- }
-
- public String toString() {
- return new StringBuilder("VolumeHost[").append(id).append("-").append(snapshotId).append("-")
- .append(dataStoreId).append(installPath).append("]").toString();
- }
-
- public long getUpdatedCount() {
- return this.updatedCount;
- }
-
- public void incrUpdatedCount() {
- this.updatedCount++;
- }
-
- public void decrUpdatedCount() {
- this.updatedCount--;
- }
-
- public Date getUpdated() {
- return updated;
- }
-
- @Override
- public ObjectInDataStoreStateMachine.State getState() {
- // TODO Auto-generated method stub
- return this.state;
- }
-
- public void setState(ObjectInDataStoreStateMachine.State state) {
- this.state = state;
- }
-
- @Override
- public long getObjectId() {
- return this.getSnapshotId();
- }
-
- public DataStoreRole getRole() {
- return role;
- }
-
- public void setRole(DataStoreRole role) {
- this.role = role;
- }
-
- @Override
- public State getObjectInStoreState() {
- return this.state;
- }
-
- public long getParentSnapshotId() {
- return parentSnapshotId;
- }
-
- public void setParentSnapshotId(long parentSnapshotId) {
- this.parentSnapshotId = parentSnapshotId;
- }
-
- public Long getRefCnt() {
- return refCnt;
- }
-
- public void incrRefCnt() {
- this.refCnt++;
- }
-
- public void decrRefCnt() {
- this.refCnt--;
- }
-
- public Long getVolumeId() {
- return volumeId;
- }
-
- public void setVolumeId(Long volumeId) {
- this.volumeId = volumeId;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
deleted file mode 100644
index e51f3a3..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
+++ /dev/null
@@ -1,81 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.storage.datastore.db;
-
-import org.apache.cloudstack.api.InternalIdentity;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name = "storage_pool_details")
-public class StoragePoolDetailVO implements InternalIdentity {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- long id;
-
- @Column(name = "pool_id")
- long poolId;
-
- @Column(name = "name")
- String name;
-
- @Column(name = "value")
- String value;
-
- public StoragePoolDetailVO(long poolId, String name, String value) {
- this.poolId = poolId;
- this.name = name;
- this.value = value;
- }
-
- public long getId() {
- return id;
- }
-
- public long getPoolId() {
- return poolId;
- }
-
- public void setPoolId(long poolId) {
- this.poolId = poolId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- protected StoragePoolDetailVO() {
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
deleted file mode 100644
index 49f4f19..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
+++ /dev/null
@@ -1,30 +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.db;
-
-import java.util.Map;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface StoragePoolDetailsDao extends GenericDao<StoragePoolDetailVO, Long> {
-
- void update(long poolId, Map<String, String> details);
-
- Map<String, String> getDetails(long poolId);
-
- StoragePoolDetailVO findDetail(long poolId, String name);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
deleted file mode 100644
index 941b952..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java
+++ /dev/null
@@ -1,346 +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.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.Id;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.Storage.StoragePoolType;
-import com.cloud.storage.ScopeType;
-import com.cloud.storage.StoragePool;
-import com.cloud.storage.StoragePoolStatus;
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name = "storage_pool")
-public class StoragePoolVO implements StoragePool {
- @Id
- @TableGenerator(name = "storage_pool_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value",
- pkColumnValue = "storage_pool_seq", allocationSize = 1)
- @Column(name = "id", updatable = false, nullable = false)
- private long id;
-
- @Column(name = "name", updatable = false, nullable = false, length = 255)
- private String name = null;
-
- @Column(name = "uuid", length = 255)
- private String uuid = null;
-
- @Column(name = "pool_type", updatable = false, nullable = false, length = 32)
- @Enumerated(value = EnumType.STRING)
- private StoragePoolType poolType;
-
- @Column(name = GenericDao.CREATED_COLUMN)
- Date created;
-
- @Column(name = GenericDao.REMOVED_COLUMN)
- private Date removed;
-
- @Column(name = "update_time", updatable = true)
- @Temporal(value = TemporalType.TIMESTAMP)
- private Date updateTime;
-
- @Column(name = "data_center_id", updatable = true, nullable = false)
- private long dataCenterId;
-
- @Column(name = "pod_id", updatable = true)
- private Long podId;
-
- @Column(name = "used_bytes", updatable = true, nullable = true)
- private long usedBytes;
-
- @Column(name = "capacity_bytes", updatable = true, nullable = true)
- private long capacityBytes;
-
- @Column(name = "status", updatable = true, nullable = false)
- @Enumerated(value = EnumType.STRING)
- private StoragePoolStatus status;
-
- @Column(name = "storage_provider_name", updatable = true, nullable = false)
- private String storageProviderName;
-
- @Column(name = "host_address")
- private String hostAddress;
-
- @Column(name = "path")
- private String path;
-
- @Column(name = "port")
- private int port;
-
- @Column(name = "user_info")
- private String userInfo;
-
- @Column(name = "cluster_id")
- private Long clusterId;
-
- @Column(name = "scope")
- @Enumerated(value = EnumType.STRING)
- private ScopeType scope;
-
- @Column(name = "managed")
- private boolean managed;
-
- @Column(name = "capacity_iops", updatable = true, nullable = true)
- private Long capacityIops;
-
- @Column(name = "hypervisor")
- @Enumerated(value = EnumType.STRING)
- private HypervisorType hypervisor;
-
- public long getId() {
- return id;
- }
-
- public StoragePoolStatus getStatus() {
- return status;
- }
-
- public StoragePoolVO() {
- this.status = StoragePoolStatus.Initial;
- }
-
- public StoragePoolVO(long poolId, String name, String uuid, StoragePoolType type, long dataCenterId, Long podId,
- long availableBytes, long capacityBytes, String hostAddress, int port, String hostPath) {
- this.name = name;
- this.id = poolId;
- this.uuid = uuid;
- this.poolType = type;
- this.dataCenterId = dataCenterId;
- this.usedBytes = availableBytes;
- this.capacityBytes = capacityBytes;
- this.hostAddress = hostAddress;
- this.path = hostPath;
- this.port = port;
- this.podId = podId;
- this.setStatus(StoragePoolStatus.Initial);
- }
-
- public StoragePoolVO(StoragePoolVO that) {
- this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, that.podId, that.usedBytes,
- that.capacityBytes, that.hostAddress, that.port, that.path);
- }
-
- public StoragePoolVO(StoragePoolType type, String hostAddress, int port, String path) {
- this.poolType = type;
- this.hostAddress = hostAddress;
- this.port = port;
- this.path = path;
- this.setStatus(StoragePoolStatus.Initial);
- this.uuid = UUID.randomUUID().toString();
- }
-
- public String getName() {
- return name;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public StoragePoolType getPoolType() {
- return poolType;
- }
-
- public void setPoolType(StoragePoolType protocol) {
- this.poolType = protocol;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public Date getRemoved() {
- return removed;
- }
-
- public Date getUpdateTime() {
- return updateTime;
- }
-
- public long getDataCenterId() {
- return dataCenterId;
- }
-
- public long getUsedBytes() {
- return usedBytes;
- }
-
- public String getStorageProviderName() {
- return storageProviderName;
- }
-
- public void setStorageProviderName(String providerName) {
- storageProviderName = providerName;
- }
-
- public long getCapacityBytes() {
- return capacityBytes;
- }
-
- public void setUsedBytes(long usedBytes) {
- this.usedBytes = usedBytes;
- }
-
- public void setCapacityBytes(long capacityBytes) {
- this.capacityBytes = capacityBytes;
- }
-
- public void setManaged(boolean managed) {
- this.managed = managed;
- }
-
- public boolean isManaged() {
- return managed;
- }
-
- public void setCapacityIops(Long capacityIops) {
- this.capacityIops = capacityIops;
- }
-
- public Long getCapacityIops() {
- return capacityIops;
- }
-
- public Long getClusterId() {
- return clusterId;
- }
-
- public void setClusterId(Long clusterId) {
- this.clusterId = clusterId;
- }
-
- public String getHostAddress() {
- return hostAddress;
- }
-
- public void setHostAddress(String host) {
- this.hostAddress = host;
- }
-
- public String getPath() {
- return path;
- }
-
- public String getUserInfo() {
- return userInfo;
- }
-
- public void setStatus(StoragePoolStatus status) {
- this.status = status;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public void setDataCenterId(long dcId) {
- this.dataCenterId = dcId;
- }
-
- public void setPodId(Long podId) {
- this.podId = podId;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public void setUserInfo(String userInfo) {
- this.userInfo = userInfo;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public Long getPodId() {
- return podId;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setScope(ScopeType scope) {
- this.scope = scope;
- }
-
- public ScopeType getScope() {
- return this.scope;
- }
-
- public HypervisorType getHypervisor() {
- return hypervisor;
- }
-
- public void setHypervisor(HypervisorType hypervisor) {
- this.hypervisor = hypervisor;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof StoragePoolVO) || obj == null) {
- return false;
- }
- StoragePoolVO that = (StoragePoolVO) obj;
- return this.id == that.id;
- }
-
- @Override
- public int hashCode() {
- return new Long(id).hashCode();
- }
-
- @Override
- public String toString() {
- return new StringBuilder("Pool[").append(id).append("|").append(poolType).append("]").toString();
- }
-
- public boolean isShared() {
- return this.scope == ScopeType.HOST ? false : true;
- }
-
- public boolean isLocal() {
- return !isShared();
- }
-
- @Override
- public boolean isInMaintenance() {
- // TODO Auto-generated method stub
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
deleted file mode 100644
index 9350751..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
+++ /dev/null
@@ -1,65 +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.db;
-
-import java.util.List;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
-
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.VMTemplateStorageResourceAssoc;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateDao;
-
-public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Long>,
-StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
-
- List<TemplateDataStoreVO> listByStoreId(long id);
-
- List<TemplateDataStoreVO> listDestroyed(long storeId);
-
- List<TemplateDataStoreVO> listActiveOnCache(long id);
-
- void deletePrimaryRecordsForStore(long id);
-
- void deletePrimaryRecordsForTemplate(long templateId);
-
- List<TemplateDataStoreVO> listByTemplateStore(long templateId, long storeId);
-
- List<TemplateDataStoreVO> listByTemplateStoreStatus(long templateId, long storeId, State... states);
-
- List<TemplateDataStoreVO> listByTemplateStoreDownloadStatus(long templateId, long storeId,
- VMTemplateStorageResourceAssoc.Status... status);
-
- List<TemplateDataStoreVO> listByTemplateZoneDownloadStatus(long templateId, Long zoneId,
- VMTemplateStorageResourceAssoc.Status... status);
-
- TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId,
- VMTemplateStorageResourceAssoc.Status... status);
-
- TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId);
-
- TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId, boolean lock);
-
- TemplateDataStoreVO findByTemplate(long templateId, DataStoreRole role);
-
- TemplateDataStoreVO findByTemplateZone(long templateId, Long zoneId, DataStoreRole role);
-
- List<TemplateDataStoreVO> listByTemplate(long templateId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
deleted file mode 100755
index b6af559..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java
+++ /dev/null
@@ -1,372 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.storage.datastore.db;
-
-import java.util.Date;
-
-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 javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
-import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
-
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.fsm.StateObject;
-
-/**
- * Join table for image_data_store and templates
- *
- */
-@Entity
-@Table(name = "template_store_ref")
-public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- Long id;
-
- @Column(name = "store_id")
- private Long dataStoreId; // this can be null for baremetal templates
-
- @Column(name = "template_id")
- private long templateId;
-
- @Column(name = "store_role")
- @Enumerated(EnumType.STRING)
- private DataStoreRole dataStoreRole;
-
- @Column(name = GenericDaoBase.CREATED_COLUMN)
- private Date created = null;
-
- @Column(name = "last_updated")
- @Temporal(value = TemporalType.TIMESTAMP)
- private Date lastUpdated = null;
-
- @Column(name = "download_pct")
- private int downloadPercent;
-
- @Column(name = "size")
- private Long size;
-
- @Column(name = "physical_size")
- private long physicalSize;
-
- @Column(name = "download_state")
- @Enumerated(EnumType.STRING)
- private Status downloadState;
-
- @Column(name = "local_path")
- private String localDownloadPath;
-
- @Column(name = "error_str")
- private String errorString;
-
- @Column(name = "job_id")
- private String jobId;
-
- @Column(name = "install_path")
- private String installPath;
-
- @Column(name = "url")
- private String downloadUrl;
-
- @Column(name = "is_copy")
- private boolean isCopy = false;
-
- @Column(name = "destroyed")
- boolean destroyed = false;
-
- @Column(name = "update_count", updatable = true, nullable = false)
- protected long updatedCount;
-
- @Column(name = "updated")
- @Temporal(value = TemporalType.TIMESTAMP)
- Date updated;
-
- @Column(name = "state")
- @Enumerated(EnumType.STRING)
- ObjectInDataStoreStateMachine.State state;
-
- @Column(name = "ref_cnt")
- Long refCnt = 0L;
-
- public TemplateDataStoreVO(Long hostId, long templateId) {
- super();
- this.dataStoreId = hostId;
- this.templateId = templateId;
- this.state = ObjectInDataStoreStateMachine.State.Allocated;
- this.refCnt = 0L;
- }
-
- public TemplateDataStoreVO(Long hostId, long templateId, Date lastUpdated, int downloadPercent,
- Status downloadState, String localDownloadPath, String errorString, String jobId, String installPath,
- String downloadUrl) {
- super();
- this.dataStoreId = hostId;
- this.templateId = templateId;
- this.lastUpdated = lastUpdated;
- this.downloadPercent = downloadPercent;
- this.downloadState = downloadState;
- this.localDownloadPath = localDownloadPath;
- this.errorString = errorString;
- this.jobId = jobId;
- this.refCnt = 0L;
- this.installPath = installPath;
- this.setDownloadUrl(downloadUrl);
- switch (downloadState) {
- case DOWNLOADED:
- this.state = ObjectInDataStoreStateMachine.State.Ready;
- break;
- case CREATING:
- case DOWNLOAD_IN_PROGRESS:
- case UPLOAD_IN_PROGRESS:
- this.state = ObjectInDataStoreStateMachine.State.Creating2;
- break;
- case DOWNLOAD_ERROR:
- case UPLOAD_ERROR:
- this.state = ObjectInDataStoreStateMachine.State.Failed;
- break;
- case ABANDONED:
- this.state = ObjectInDataStoreStateMachine.State.Destroyed;
- break;
- default:
- this.state = ObjectInDataStoreStateMachine.State.Allocated;
- break;
- }
- }
-
- public TemplateDataStoreVO() {
- this.refCnt = 0L;
- }
-
- @Override
- public String getInstallPath() {
- return installPath;
- }
-
- @Override
- public long getDataStoreId() {
- return dataStoreId;
- }
-
- public void setDataStoreId(long storeId) {
- this.dataStoreId = storeId;
- }
-
- public long getTemplateId() {
- return templateId;
- }
-
- public void setTemplateId(long templateId) {
- this.templateId = templateId;
- }
-
- public int getDownloadPercent() {
- return downloadPercent;
- }
-
- public void setDownloadPercent(int downloadPercent) {
- this.downloadPercent = downloadPercent;
- }
-
- public void setDownloadState(Status downloadState) {
- this.downloadState = downloadState;
- }
-
- public long getId() {
- return id;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- public void setLastUpdated(Date date) {
- lastUpdated = date;
- }
-
- @Override
- public void setInstallPath(String installPath) {
- this.installPath = installPath;
- }
-
- public Status getDownloadState() {
- return downloadState;
- }
-
- public void setLocalDownloadPath(String localPath) {
- this.localDownloadPath = localPath;
- }
-
- public String getLocalDownloadPath() {
- return localDownloadPath;
- }
-
- public void setErrorString(String errorString) {
- this.errorString = errorString;
- }
-
- public String getErrorString() {
- return errorString;
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof TemplateDataStoreVO) {
- TemplateDataStoreVO other = (TemplateDataStoreVO) obj;
- return (this.templateId == other.getTemplateId() && this.dataStoreId == other.getDataStoreId());
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- Long tid = new Long(templateId);
- Long hid = new Long(dataStoreId);
- return tid.hashCode() + hid.hashCode();
- }
-
- public void setSize(Long size) {
- this.size = size;
- }
-
- public long getSize() {
- return size;
- }
-
- public void setPhysicalSize(long physicalSize) {
- this.physicalSize = physicalSize;
- }
-
- public long getPhysicalSize() {
- return physicalSize;
- }
-
- public void setDestroyed(boolean destroyed) {
- this.destroyed = destroyed;
- }
-
- public boolean getDestroyed() {
- return destroyed;
- }
-
- public void setDownloadUrl(String downloadUrl) {
- this.downloadUrl = downloadUrl;
- }
-
- public String getDownloadUrl() {
- return downloadUrl;
- }
-
- public void setCopy(boolean isCopy) {
- this.isCopy = isCopy;
- }
-
- public boolean isCopy() {
- return isCopy;
- }
-
- public long getTemplateSize() {
- return -1;
- }
-
- @Override
- public String toString() {
- return new StringBuilder("TmplHost[").append(id).append("-").append(templateId).append("-").append(dataStoreId)
- .append(installPath).append("]").toString();
- }
-
- @Override
- public ObjectInDataStoreStateMachine.State getState() {
- // TODO Auto-generated method stub
- return this.state;
- }
-
- public void setState(ObjectInDataStoreStateMachine.State state) {
- this.state = state;
- }
-
- public long getUpdatedCount() {
- return this.updatedCount;
- }
-
- public void incrUpdatedCount() {
- this.updatedCount++;
- }
-
- public void decrUpdatedCount() {
- this.updatedCount--;
- }
-
- public Date getUpdated() {
- return updated;
- }
-
- @Override
- public long getObjectId() {
- return this.getTemplateId();
- }
-
- @Override
- public State getObjectInStoreState() {
- return this.state;
- }
-
- public DataStoreRole getDataStoreRole() {
- return dataStoreRole;
- }
-
- public void setDataStoreRole(DataStoreRole dataStoreRole) {
- this.dataStoreRole = dataStoreRole;
- }
-
- public Long getRefCnt() {
- return refCnt;
- }
-
- public void incrRefCnt() {
- this.refCnt++;
- }
-
- public void decrRefCnt() {
- this.refCnt--;
- }
-
-}
[4/4] git commit: updated refs/heads/master to a4cea4e
Posted by ah...@apache.org.
Removed schema from the dependency of many components
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a4cea4eb
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a4cea4eb
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a4cea4eb
Branch: refs/heads/master
Commit: a4cea4ebf2aa549a1b278fedbf1706357f5b4724
Parents: 399c373
Author: Alex Huang <al...@citrix.com>
Authored: Mon Jul 29 10:55:00 2013 -0700
Committer: Alex Huang <al...@citrix.com>
Committed: Mon Jul 29 10:55:19 2013 -0700
----------------------------------------------------------------------
.../consoleproxy/ConsoleProxyAllocator.java | 34 ++
client/tomcatconf/log4j-cloud.xml.in | 4 +-
core/pom.xml | 19 +-
.../consoleproxy/ConsoleProxyAllocator.java | 27 --
.../com/cloud/storage/GuestOSHypervisorVO.java | 73 ----
core/src/com/cloud/storage/VolumeDetailVO.java | 85 ----
.../storage/command/AttachAnswer.java | 47 ++
.../storage/command/AttachCommand.java | 126 ++++++
.../command/AttachPrimaryDataStoreAnswer.java | 56 +++
.../command/AttachPrimaryDataStoreCmd.java | 39 ++
.../storage/command/CopyCmdAnswer.java | 37 ++
.../cloudstack/storage/command/CopyCommand.java | 58 +++
.../storage/command/CreateObjectAnswer.java | 43 ++
.../storage/command/CreateObjectCommand.java | 45 ++
.../command/CreatePrimaryDataStoreCmd.java | 38 ++
.../storage/command/DeleteCommand.java | 45 ++
.../storage/command/DettachAnswer.java | 47 ++
.../storage/command/DettachCommand.java | 90 ++++
.../command/StorageSubSystemCommand.java | 23 +
.../cloudstack/storage/to/ImageStoreTO.java | 79 ++++
.../storage/to/PrimaryDataStoreTO.java | 103 +++++
.../cloudstack/storage/to/SnapshotObjectTO.java | 128 ++++++
.../cloudstack/storage/to/TemplateObjectTO.java | 208 +++++++++
.../cloudstack/storage/to/VolumeObjectTO.java | 223 ++++++++++
.../com/cloud/agent/transport/RequestTest.java | 22 +-
.../storage/command/AttachAnswer.java | 47 --
.../storage/command/AttachCommand.java | 126 ------
.../command/AttachPrimaryDataStoreAnswer.java | 56 ---
.../command/AttachPrimaryDataStoreCmd.java | 39 --
.../storage/command/CopyCmdAnswer.java | 37 --
.../cloudstack/storage/command/CopyCommand.java | 58 ---
.../storage/command/CreateObjectAnswer.java | 43 --
.../storage/command/CreateObjectCommand.java | 45 --
.../command/CreatePrimaryDataStoreCmd.java | 38 --
.../storage/command/DeleteCommand.java | 45 --
.../storage/command/DettachAnswer.java | 47 --
.../storage/command/DettachCommand.java | 90 ----
.../command/StorageSubSystemCommand.java | 23 -
.../storage/datastore/db/ImageStoreDao.java | 37 --
.../datastore/db/ImageStoreDetailVO.java | 82 ----
.../datastore/db/ImageStoreDetailsDao.java | 30 --
.../storage/datastore/db/ImageStoreVO.java | 193 ---------
.../datastore/db/PrimaryDataStoreDao.java | 120 ------
.../datastore/db/PrimaryDataStoreDaoImpl.java | 432 -------------------
.../datastore/db/PrimaryDataStoreDetailVO.java | 79 ----
.../db/PrimaryDataStoreDetailsDao.java | 28 --
.../datastore/db/SnapshotDataStoreDao.java | 43 --
.../datastore/db/SnapshotDataStoreVO.java | 271 ------------
.../datastore/db/StoragePoolDetailVO.java | 81 ----
.../datastore/db/StoragePoolDetailsDao.java | 30 --
.../storage/datastore/db/StoragePoolVO.java | 346 ---------------
.../datastore/db/TemplateDataStoreDao.java | 65 ---
.../datastore/db/TemplateDataStoreVO.java | 372 ----------------
.../datastore/db/VolumeDataStoreDao.java | 43 --
.../storage/datastore/db/VolumeDataStoreVO.java | 348 ---------------
.../cloudstack/storage/to/ImageStoreTO.java | 79 ----
.../storage/to/PrimaryDataStoreTO.java | 103 -----
.../cloudstack/storage/to/SnapshotObjectTO.java | 128 ------
.../cloudstack/storage/to/TemplateObjectTO.java | 208 ---------
.../cloudstack/storage/to/VolumeObjectTO.java | 223 ----------
.../com/cloud/storage/GuestOSHypervisorVO.java | 73 ++++
.../src/com/cloud/storage/VolumeDetailVO.java | 85 ++++
.../storage/datastore/db/ImageStoreDao.java | 37 ++
.../datastore/db/ImageStoreDetailVO.java | 82 ++++
.../datastore/db/ImageStoreDetailsDao.java | 30 ++
.../storage/datastore/db/ImageStoreVO.java | 193 +++++++++
.../datastore/db/PrimaryDataStoreDao.java | 120 ++++++
.../datastore/db/PrimaryDataStoreDaoImpl.java | 432 +++++++++++++++++++
.../datastore/db/PrimaryDataStoreDetailVO.java | 79 ++++
.../db/PrimaryDataStoreDetailsDao.java | 28 ++
.../datastore/db/SnapshotDataStoreDao.java | 43 ++
.../datastore/db/SnapshotDataStoreVO.java | 271 ++++++++++++
.../datastore/db/StoragePoolDetailVO.java | 81 ++++
.../datastore/db/StoragePoolDetailsDao.java | 30 ++
.../storage/datastore/db/StoragePoolVO.java | 346 +++++++++++++++
.../datastore/db/TemplateDataStoreDao.java | 65 +++
.../datastore/db/TemplateDataStoreVO.java | 372 ++++++++++++++++
.../datastore/db/VolumeDataStoreDao.java | 43 ++
.../storage/datastore/db/VolumeDataStoreVO.java | 348 +++++++++++++++
engine/storage/cache/pom.xml | 20 +-
pom.xml | 18 +-
server/pom.xml | 5 +
.../ConsoleProxyBalanceAllocator.java | 52 +--
.../consoleproxy/ConsoleProxyManagerImpl.java | 7 +-
usage/pom.xml | 5 +
85 files changed, 4303 insertions(+), 4296 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/api/src/com/cloud/consoleproxy/ConsoleProxyAllocator.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/consoleproxy/ConsoleProxyAllocator.java b/api/src/com/cloud/consoleproxy/ConsoleProxyAllocator.java
new file mode 100644
index 0000000..25d9d28
--- /dev/null
+++ b/api/src/com/cloud/consoleproxy/ConsoleProxyAllocator.java
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.consoleproxy;
+
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.utils.component.Adapter;
+import com.cloud.vm.ConsoleProxy;
+
+public interface ConsoleProxyAllocator extends Adapter {
+ /**
+ * Finds the least loaded console proxy.
+ * @param candidates
+ * @param loadInfo
+ * @param dataCenterId
+ * @return id of the console proxy to use or null if none.
+ */
+ public Long allocProxy(List<? extends ConsoleProxy> candidates, Map<Long, Integer> loadInfo, long dataCenterId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/client/tomcatconf/log4j-cloud.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/log4j-cloud.xml.in b/client/tomcatconf/log4j-cloud.xml.in
index 1207aa7..d439b77 100755
--- a/client/tomcatconf/log4j-cloud.xml.in
+++ b/client/tomcatconf/log4j-cloud.xml.in
@@ -71,7 +71,7 @@ under the License.
<param name="SyslogHost" value="localhost"/>
<param name="Facility" value="LOCAL6"/>
<layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%-5p [%c{1.}] (%t:%x) %m%n"/>
+ <param name="ConversionPattern" value="%-5p [%c{3}] (%t:%x) %m%n"/>
</layout>
</appender>
@@ -110,7 +110,7 @@ under the License.
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>
- <layout class="org.apache.log4j.PatternLayout">
+ <layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern" value="%-5p [%c{1.}] (%t:%x) %m%n"/>
</layout>
</appender>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index a2d487e..76cdd12 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -35,30 +35,17 @@
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine-api</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>
+ <!--
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine-schema</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>${cs.httpclient.version}</version>
- <exclusions>
- <exclusion>
- <artifactId>commons-codec</artifactId>
- <groupId>commons-codec</groupId>
- </exclusion>
- </exclusions>
- </dependency>
+ -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
- <version>${cs.codec.version}</version>
</dependency>
</dependencies>
- <build>
- <defaultGoal>install</defaultGoal>
- </build>
</project>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/com/cloud/consoleproxy/ConsoleProxyAllocator.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/consoleproxy/ConsoleProxyAllocator.java b/core/src/com/cloud/consoleproxy/ConsoleProxyAllocator.java
deleted file mode 100644
index d6acf6d..0000000
--- a/core/src/com/cloud/consoleproxy/ConsoleProxyAllocator.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 com.cloud.consoleproxy;
-
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.utils.component.Adapter;
-import com.cloud.vm.ConsoleProxyVO;
-
-public interface ConsoleProxyAllocator extends Adapter {
- public ConsoleProxyVO allocProxy(List<ConsoleProxyVO> candidates, Map<Long, Integer> loadInfo, long dataCenterId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/com/cloud/storage/GuestOSHypervisorVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/GuestOSHypervisorVO.java b/core/src/com/cloud/storage/GuestOSHypervisorVO.java
deleted file mode 100644
index 5ab3480..0000000
--- a/core/src/com/cloud/storage/GuestOSHypervisorVO.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.storage;
-
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.api.InternalIdentity;
-
-@Entity
-@Table(name="guest_os_hypervisor")
-public class GuestOSHypervisorVO implements GuestOSHypervisor {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- long id;
-
- @Column(name="guest_os_id")
- private long guestOsId;
-
- @Column(name="guest_os_name")
- String guestOsName;
-
- @Column(name="hypervisor_type")
- String hypervisorType;
-
-
- @Override
- public long getId() {
- return id;
- }
-
-
- @Override
- public String getHypervisorType() {
- return hypervisorType;
- }
-
-
- @Override
- public String getGuestOsName() {
- return guestOsName;
- }
-
-
- @Override
- public long getGuestOsId() {
- return guestOsId;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/com/cloud/storage/VolumeDetailVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/VolumeDetailVO.java b/core/src/com/cloud/storage/VolumeDetailVO.java
deleted file mode 100644
index b0c8c1d..0000000
--- a/core/src/com/cloud/storage/VolumeDetailVO.java
+++ /dev/null
@@ -1,85 +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 com.cloud.storage;
-
-import org.apache.cloudstack.api.InternalIdentity;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="volume_details")
-public class VolumeDetailVO implements InternalIdentity {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="volume_id")
- private long volumeId;
-
- @Column(name="name")
- private String name;
-
- @Column(name="value", length=1024)
- private String value;
-
- public VolumeDetailVO() {}
-
- public VolumeDetailVO(long volumeId, String name, String value) {
- this.volumeId = volumeId;
- this.name = name;
- this.value = value;
- }
-
- public long getId() {
- return id;
- }
-
- public long getVolumeId() {
- return volumeId;
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public void setVolumeId(long volumeId) {
- this.volumeId = volumeId;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/AttachAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/AttachAnswer.java b/core/src/org/apache/cloudstack/storage/command/AttachAnswer.java
new file mode 100644
index 0000000..5a26d4a
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/AttachAnswer.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.command;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.to.DiskTO;
+
+public class AttachAnswer extends Answer {
+ private DiskTO disk;
+
+ public AttachAnswer() {
+ super(null);
+ }
+
+ public AttachAnswer(DiskTO disk) {
+ super(null);
+ this.setDisk(disk);
+ }
+
+ public AttachAnswer(String errMsg) {
+ super(null, false, errMsg);
+ }
+
+ public DiskTO getDisk() {
+ return disk;
+ }
+
+ public void setDisk(DiskTO disk) {
+ this.disk = disk;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/AttachCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/AttachCommand.java b/core/src/org/apache/cloudstack/storage/command/AttachCommand.java
new file mode 100644
index 0000000..44bce91
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/AttachCommand.java
@@ -0,0 +1,126 @@
+/*
+ * 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 com.cloud.agent.api.Command;
+import com.cloud.agent.api.to.DiskTO;
+
+public final class AttachCommand extends Command implements StorageSubSystemCommand {
+ private DiskTO disk;
+ private String vmName;
+ private String _storageHost;
+ private int _storagePort;
+ private boolean _managed;
+ private String _iScsiName;
+ private String _chapInitiatorUsername;
+ private String _chapInitiatorPassword;
+ private String _chapTargetUsername;
+ private String _chapTargetPassword;
+
+ public AttachCommand(DiskTO disk, String vmName) {
+ super();
+ this.disk = disk;
+ this.vmName = vmName;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+ public DiskTO getDisk() {
+ return disk;
+ }
+
+ public void setDisk(DiskTO disk) {
+ this.disk = disk;
+ }
+
+ public String getVmName() {
+ return vmName;
+ }
+
+ public void setVmName(String vmName) {
+ this.vmName = vmName;
+ }
+
+ public void setStorageHost(String storageHost) {
+ _storageHost = storageHost;
+ }
+
+ public String getStorageHost() {
+ return _storageHost;
+ }
+
+ public void setStoragePort(int storagePort) {
+ _storagePort = storagePort;
+ }
+
+ public int getStoragePort() {
+ return _storagePort;
+ }
+
+ public void setManaged(boolean managed) {
+ _managed = managed;
+ }
+
+ public boolean isManaged() {
+ return _managed;
+ }
+
+ public void set_iScsiName(String iScsiName) {
+ this._iScsiName = iScsiName;
+ }
+
+ public String get_iScsiName() {
+ return _iScsiName;
+ }
+
+ public void setChapInitiatorUsername(String chapInitiatorUsername) {
+ _chapInitiatorUsername = chapInitiatorUsername;
+ }
+
+ public String getChapInitiatorUsername() {
+ return _chapInitiatorUsername;
+ }
+
+ public void setChapInitiatorPassword(String chapInitiatorPassword) {
+ _chapInitiatorPassword = chapInitiatorPassword;
+ }
+
+ public String getChapInitiatorPassword() {
+ return _chapInitiatorPassword;
+ }
+
+ public void setChapTargetUsername(String chapTargetUsername) {
+ _chapTargetUsername = chapTargetUsername;
+ }
+
+ public String getChapTargetUsername() {
+ return _chapTargetUsername;
+ }
+
+ public void setChapTargetPassword(String chapTargetPassword) {
+ _chapTargetPassword = chapTargetPassword;
+ }
+
+ public String getChapTargetPassword() {
+ return _chapTargetPassword;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreAnswer.java b/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreAnswer.java
new file mode 100644
index 0000000..6d5bbaf
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreAnswer.java
@@ -0,0 +1,56 @@
+/*
+ * 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 com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+
+public class AttachPrimaryDataStoreAnswer extends Answer {
+ private String uuid;
+ private long capacity;
+ private long avail;
+
+ public AttachPrimaryDataStoreAnswer(Command cmd) {
+ super(cmd);
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public void setCapacity(long capacity) {
+ this.capacity = capacity;
+ }
+
+ public long getCapacity() {
+ return this.capacity;
+ }
+
+ public void setAvailable(long avail) {
+ this.avail = avail;
+ }
+
+ public long getAvailable() {
+ return this.avail;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java b/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
new file mode 100644
index 0000000..2083876
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.command;
+
+import com.cloud.agent.api.Command;
+
+public final class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
+ private final String dataStore;
+
+ public AttachPrimaryDataStoreCmd(String uri) {
+ super();
+ this.dataStore = uri;
+ }
+
+ public String getDataStore() {
+ return this.dataStore;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java b/core/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java
new file mode 100644
index 0000000..95c0e89
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java
@@ -0,0 +1,37 @@
+// 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 com.cloud.agent.api.Answer;
+import com.cloud.agent.api.to.DataTO;
+
+public class CopyCmdAnswer extends Answer {
+ private DataTO newData;
+
+ public CopyCmdAnswer(DataTO newData) {
+ super(null);
+ this.newData = newData;
+ }
+
+ public DataTO getNewData() {
+ return this.newData;
+ }
+
+ public CopyCmdAnswer(String errMsg) {
+ super(null, false, errMsg);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/CopyCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/CopyCommand.java b/core/src/org/apache/cloudstack/storage/command/CopyCommand.java
new file mode 100644
index 0000000..f14f37e
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/CopyCommand.java
@@ -0,0 +1,58 @@
+// 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 com.cloud.agent.api.Command;
+import com.cloud.agent.api.to.DataTO;
+
+public final class CopyCommand extends Command implements StorageSubSystemCommand {
+ private DataTO srcTO;
+ private DataTO destTO;
+ private DataTO cacheTO;
+ boolean executeInSequence = false;
+
+
+ public CopyCommand(DataTO srcData, DataTO destData, int timeout, boolean executeInSequence) {
+ super();
+ this.srcTO = srcData;
+ this.destTO = destData;
+ this.setWait(timeout);
+ this.executeInSequence = executeInSequence;
+ }
+
+ public DataTO getDestTO() {
+ return this.destTO;
+ }
+
+ public DataTO getSrcTO() {
+ return this.srcTO;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return executeInSequence;
+ }
+
+ public DataTO getCacheTO() {
+ return cacheTO;
+ }
+
+ public void setCacheTO(DataTO cacheTO) {
+ this.cacheTO = cacheTO;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/CreateObjectAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/CreateObjectAnswer.java b/core/src/org/apache/cloudstack/storage/command/CreateObjectAnswer.java
new file mode 100644
index 0000000..b0c4744
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/CreateObjectAnswer.java
@@ -0,0 +1,43 @@
+/*
+ * 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 com.cloud.agent.api.Answer;
+import com.cloud.agent.api.to.DataTO;
+
+public final class CreateObjectAnswer extends Answer {
+ private DataTO data;
+
+ protected CreateObjectAnswer() {
+ super();
+ }
+
+ public CreateObjectAnswer(DataTO data) {
+ super();
+ this.data = data;
+ }
+
+ public DataTO getData() {
+ return this.data;
+ }
+
+ public CreateObjectAnswer(String errMsg) {
+ super(null, false, errMsg);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java b/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
new file mode 100644
index 0000000..121a7ee
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
@@ -0,0 +1,45 @@
+/*
+ * 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 com.cloud.agent.api.Command;
+import com.cloud.agent.api.to.DataTO;
+
+public final class CreateObjectCommand extends Command implements StorageSubSystemCommand {
+ private DataTO data;
+
+ public CreateObjectCommand(DataTO obj) {
+ super();
+ this.data = obj;
+ }
+
+ protected CreateObjectCommand() {
+ super();
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+ public DataTO getData() {
+ return this.data;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java b/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
new file mode 100644
index 0000000..b536028
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
@@ -0,0 +1,38 @@
+// 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 com.cloud.agent.api.Command;
+
+public final class CreatePrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
+ private final String dataStore;
+
+ public CreatePrimaryDataStoreCmd(String uri) {
+ super();
+ this.dataStore = uri;
+ }
+
+ public String getDataStore() {
+ return this.dataStore;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java b/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java
new file mode 100644
index 0000000..76696da
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java
@@ -0,0 +1,45 @@
+/*
+ * 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 com.cloud.agent.api.Command;
+import com.cloud.agent.api.to.DataTO;
+
+public final class DeleteCommand extends Command implements StorageSubSystemCommand {
+ private DataTO data;
+
+ public DeleteCommand(DataTO data) {
+ super();
+ this.data = data;
+ }
+
+ protected DeleteCommand() {
+ super();
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+ public DataTO getData() {
+ return this.data;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/DettachAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/DettachAnswer.java b/core/src/org/apache/cloudstack/storage/command/DettachAnswer.java
new file mode 100644
index 0000000..62ce246
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/DettachAnswer.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.command;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.to.DiskTO;
+
+public final class DettachAnswer extends Answer {
+ private DiskTO disk;
+
+ public DettachAnswer() {
+ super(null);
+ }
+
+ public DettachAnswer(DiskTO disk) {
+ super(null);
+ this.setDisk(disk);
+ }
+
+ public DettachAnswer(String errMsg) {
+ super(null, false, errMsg);
+ }
+
+ public DiskTO getDisk() {
+ return disk;
+ }
+
+ public void setDisk(DiskTO disk) {
+ this.disk = disk;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/DettachCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/DettachCommand.java b/core/src/org/apache/cloudstack/storage/command/DettachCommand.java
new file mode 100644
index 0000000..61cb88b
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/DettachCommand.java
@@ -0,0 +1,90 @@
+/*
+ * 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 com.cloud.agent.api.Command;
+import com.cloud.agent.api.to.DiskTO;
+
+public class DettachCommand extends Command implements StorageSubSystemCommand {
+ private DiskTO disk;
+ private String vmName;
+ private boolean _managed;
+ private String _iScsiName;
+ private String _storageHost;
+ private int _storagePort;
+
+ public DettachCommand(DiskTO disk, String vmName) {
+ super();
+ this.disk = disk;
+ this.vmName = vmName;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+ public DiskTO getDisk() {
+ return disk;
+ }
+
+ public void setDisk(DiskTO disk) {
+ this.disk = disk;
+ }
+
+ public String getVmName() {
+ return vmName;
+ }
+
+ public void setVmName(String vmName) {
+ this.vmName = vmName;
+ }
+
+ public void setManaged(boolean managed) {
+ _managed = managed;
+ }
+
+ public boolean isManaged() {
+ return _managed;
+ }
+
+ public void set_iScsiName(String iScsiName) {
+ _iScsiName = iScsiName;
+ }
+
+ public String get_iScsiName() {
+ return _iScsiName;
+ }
+
+ public void setStorageHost(String storageHost) {
+ _storageHost = storageHost;
+ }
+
+ public String getStorageHost() {
+ return _storageHost;
+ }
+
+ public void setStoragePort(int storagePort) {
+ _storagePort = storagePort;
+ }
+
+ public int getStoragePort() {
+ return _storagePort;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java b/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java
new file mode 100644
index 0000000..d14161a
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.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.command;
+
+public interface StorageSubSystemCommand {
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/to/ImageStoreTO.java b/core/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
new file mode 100644
index 0000000..0037ea5
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/to/ImageStoreTO.java
@@ -0,0 +1,79 @@
+// 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.to;
+
+import org.apache.cloudstack.storage.image.datastore.ImageStoreInfo;
+
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.storage.DataStoreRole;
+
+public class ImageStoreTO implements DataStoreTO {
+ private String type;
+ private String uri;
+ private String providerName;
+ private DataStoreRole role;
+
+ public ImageStoreTO() {
+
+ }
+
+ public ImageStoreTO(ImageStoreInfo dataStore) {
+ this.type = dataStore.getType();
+ this.uri = dataStore.getUri();
+ this.providerName = null;
+ this.role = dataStore.getRole();
+ }
+
+ public String getProtocol() {
+ return this.type;
+ }
+
+ public String getUri() {
+ return this.uri;
+ }
+
+ public String getProviderName() {
+ return providerName;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public void setProviderName(String providerName) {
+ this.providerName = providerName;
+ }
+
+ public void setRole(DataStoreRole role) {
+ this.role = role;
+ }
+
+ @Override
+ public DataStoreRole getRole() {
+ return this.role;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("ImageStoreTO[type=").append(type).append("|provider=").append(providerName)
+ .append("|role=").append(role).append("|uri=").append(uri).append("]").toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java b/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
new file mode 100644
index 0000000..5e870df
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
@@ -0,0 +1,103 @@
+// 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.to;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.Storage.StoragePoolType;
+
+public class PrimaryDataStoreTO implements DataStoreTO {
+ private final String uuid;
+ private final String name;
+ private String type;
+ private final long id;
+ private StoragePoolType poolType;
+ private String host;
+ private String path;
+ private int port;
+
+ public PrimaryDataStoreTO(PrimaryDataStoreInfo dataStore) {
+ this.uuid = dataStore.getUuid();
+ this.name = dataStore.getName();
+ this.id = dataStore.getId();
+ this.setPoolType(dataStore.getPoolType());
+ this.setHost(dataStore.getHostAddress());
+ this.setPath(dataStore.getPath());
+ this.setPort(dataStore.getPort());
+ }
+
+ public long getId() {
+ return this.id;
+ }
+
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ @Override
+ public DataStoreRole getRole() {
+ return DataStoreRole.Primary;
+ }
+
+ public StoragePoolType getPoolType() {
+ return poolType;
+ }
+
+ public void setPoolType(StoragePoolType poolType) {
+ this.poolType = poolType;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("PrimaryDataStoreTO[uuid=").append(uuid).append("|name=").append(name)
+ .append("|id=").append(id).append("|pooltype=").append(poolType).append("]").toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java b/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
new file mode 100644
index 0000000..d2cb72a
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
@@ -0,0 +1,128 @@
+// 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.to;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
+
+import com.cloud.agent.api.to.DataObjectType;
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.agent.api.to.DataTO;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+
+public class SnapshotObjectTO implements DataTO {
+ private String path;
+ private VolumeObjectTO volume;
+ private String parentSnapshotPath;
+ private DataStoreTO dataStore;
+ private String vmName;
+ private String name;
+ private HypervisorType hypervisorType;
+ private long id;
+
+ public SnapshotObjectTO() {
+
+ }
+
+ public SnapshotObjectTO(SnapshotInfo snapshot) {
+ this.path = snapshot.getPath();
+ this.setId(snapshot.getId());
+ this.volume = (VolumeObjectTO) snapshot.getBaseVolume().getTO();
+ this.setVmName(snapshot.getBaseVolume().getAttachedVmName());
+ SnapshotInfo parentSnapshot = snapshot.getParent();
+ if (parentSnapshot != null) {
+ this.parentSnapshotPath = parentSnapshot.getPath();
+ }
+ this.dataStore = snapshot.getDataStore().getTO();
+ this.setName(snapshot.getName());
+ this.hypervisorType = snapshot.getHypervisorType();
+ }
+
+ @Override
+ public DataObjectType getObjectType() {
+ return DataObjectType.SNAPSHOT;
+ }
+
+ @Override
+ public DataStoreTO getDataStore() {
+ return this.dataStore;
+ }
+
+ @Override
+ public String getPath() {
+ return this.path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public VolumeObjectTO getVolume() {
+ return volume;
+ }
+
+ public void setVolume(VolumeObjectTO volume) {
+ this.volume = volume;
+ }
+
+ public String getParentSnapshotPath() {
+ return parentSnapshotPath;
+ }
+
+ public void setParentSnapshotPath(String parentSnapshotPath) {
+ this.parentSnapshotPath = parentSnapshotPath;
+ }
+
+ public String getVmName() {
+ return vmName;
+ }
+
+ public void setVmName(String vmName) {
+ this.vmName = vmName;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public HypervisorType getHypervisorType() {
+ return hypervisorType;
+ }
+
+ public void setHypervisorType(HypervisorType hypervisorType) {
+ this.hypervisorType = hypervisorType;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("SnapshotTO[datastore=").append(dataStore).append("|volume=").append(volume).append("|path")
+ .append(path).append("]").toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java b/core/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
new file mode 100644
index 0000000..2347de3
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
@@ -0,0 +1,208 @@
+// 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.to;
+
+import com.cloud.hypervisor.Hypervisor;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
+
+import com.cloud.agent.api.to.DataObjectType;
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.agent.api.to.DataTO;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.template.VirtualMachineTemplate;
+
+public class TemplateObjectTO implements DataTO {
+ private String path;
+ private String origUrl;
+ private String uuid;
+ private long id;
+ private ImageFormat format;
+ private long accountId;
+ private String checksum;
+ private boolean hvm;
+ private String displayText;
+ private DataStoreTO imageDataStore;
+ private String name;
+ private String guestOsType;
+ private Long size;
+ private Hypervisor.HypervisorType hypervisorType;
+
+ public TemplateObjectTO() {
+
+ }
+
+ public TemplateObjectTO(VirtualMachineTemplate template) {
+ this.uuid = template.getUuid();
+ this.id = template.getId();
+ this.origUrl = template.getUrl();
+ this.displayText = template.getDisplayText();
+ this.checksum = template.getChecksum();
+ this.hvm = template.isRequiresHvm();
+ this.accountId = template.getAccountId();
+ this.name = template.getUniqueName();
+ this.format = template.getFormat();
+ this.hypervisorType = template.getHypervisorType();
+ }
+
+ public TemplateObjectTO(TemplateInfo template) {
+ this.path = template.getInstallPath();
+ this.uuid = template.getUuid();
+ this.id = template.getId();
+ this.origUrl = template.getUrl();
+ this.displayText = template.getDisplayText();
+ this.checksum = template.getChecksum();
+ this.hvm = template.isRequiresHvm();
+ this.accountId = template.getAccountId();
+ this.name = template.getUniqueName();
+ this.format = template.getFormat();
+ if (template.getDataStore() != null) {
+ this.imageDataStore = template.getDataStore().getTO();
+ }
+ this.hypervisorType = template.getHypervisorType();
+ }
+
+ @Override
+ public String getPath() {
+ return this.path;
+ }
+
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id){
+ this.id = id;
+ }
+
+ public ImageFormat getFormat() {
+ return format;
+ }
+
+ public long getAccountId() {
+ return accountId;
+ }
+
+ public String getChecksum() {
+ return checksum;
+ }
+
+ public boolean isRequiresHvm() {
+ return hvm;
+ }
+
+ public void setRequiresHvm(boolean hvm) {
+ this.hvm = hvm;
+ }
+
+ public String getDescription() {
+ return displayText;
+ }
+
+ public void setDescription(String desc) {
+ this.displayText = desc;
+ }
+
+
+ @Override
+ public DataObjectType getObjectType() {
+ return DataObjectType.TEMPLATE;
+ }
+
+ @Override
+ public DataStoreTO getDataStore() {
+ return this.imageDataStore;
+ }
+
+ @Override
+ public Hypervisor.HypervisorType getHypervisorType() {
+ return this.hypervisorType;
+ }
+
+ public void setDataStore(DataStoreTO store){
+ this.imageDataStore = store;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getOrigUrl() {
+ return origUrl;
+ }
+
+ public void setOrigUrl(String origUrl) {
+ this.origUrl = origUrl;
+ }
+
+ public void setFormat(ImageFormat format) {
+ this.format = format;
+ }
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+ public void setChecksum(String checksum) {
+ this.checksum = checksum;
+ }
+
+ public void setImageDataStore(DataStoreTO imageDataStore) {
+ this.imageDataStore = imageDataStore;
+ }
+
+ public String getGuestOsType() {
+ return guestOsType;
+ }
+
+ public void setGuestOsType(String guestOsType) {
+ this.guestOsType = guestOsType;
+ }
+
+ public Long getSize() {
+ return size;
+ }
+
+ public void setSize(Long size) {
+ this.size = size;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("TemplateTO[id=").append(id).append("|origUrl=").append(origUrl)
+ .append("|name").append(name).append("]").toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java b/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
new file mode 100644
index 0000000..9f466ae
--- /dev/null
+++ b/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
@@ -0,0 +1,223 @@
+// 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.to;
+
+import com.cloud.hypervisor.Hypervisor;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+
+import com.cloud.agent.api.to.DataObjectType;
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.agent.api.to.DataTO;
+import com.cloud.storage.Storage;
+import com.cloud.storage.Volume;
+
+public class VolumeObjectTO implements DataTO {
+ private String uuid;
+ private Volume.Type volumeType;
+ private DataStoreTO dataStore;
+ private String name;
+ private long size;
+ private String path;
+ private Long volumeId;
+ private String vmName;
+ private long accountId;
+ private String chainInfo;
+ private Storage.ImageFormat format;
+ private long id;
+ private Long bytesReadRate;
+ private Long bytesWriteRate;
+ private Long iopsReadRate;
+ private Long iopsWriteRate;
+ private Hypervisor.HypervisorType hypervisorType;
+
+ public VolumeObjectTO() {
+
+ }
+
+ public VolumeObjectTO(VolumeInfo volume) {
+ this.uuid = volume.getUuid();
+ this.path = volume.getPath();
+ this.accountId = volume.getAccountId();
+ if (volume.getDataStore() != null) {
+ this.dataStore = volume.getDataStore().getTO();
+ } else {
+ this.dataStore = null;
+ }
+ this.vmName = volume.getAttachedVmName();
+ this.size = volume.getSize();
+ this.setVolumeId(volume.getId());
+ this.chainInfo = volume.getChainInfo();
+ this.volumeType = volume.getVolumeType();
+ this.name = volume.getName();
+ this.setId(volume.getId());
+ this.format = volume.getFormat();
+ this.bytesReadRate = volume.getBytesReadRate();
+ this.bytesWriteRate = volume.getBytesWriteRate();
+ this.iopsReadRate = volume.getIopsReadRate();
+ this.iopsWriteRate = volume.getIopsWriteRate();
+ this.hypervisorType = volume.getHypervisorType();
+ }
+
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ @Override
+ public String getPath() {
+ return this.path;
+ }
+
+ public Volume.Type getVolumeType() {
+ return this.volumeType;
+ }
+
+ @Override
+ public DataStoreTO getDataStore() {
+ return this.dataStore;
+ }
+
+ @Override
+ public Hypervisor.HypervisorType getHypervisorType() {
+ return this.hypervisorType;
+ }
+
+
+ public void setDataStore(DataStoreTO store){
+ this.dataStore = store;
+ }
+
+ public void setDataStore(PrimaryDataStoreTO dataStore) {
+ this.dataStore = dataStore;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public long getSize() {
+ return this.size;
+ }
+
+ @Override
+ public DataObjectType getObjectType() {
+ return DataObjectType.VOLUME;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public Long getVolumeId() {
+ return volumeId;
+ }
+
+ public void setVolumeId(Long volumeId) {
+ this.volumeId = volumeId;
+ }
+
+ public long getAccountId() {
+ return accountId;
+ }
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+ public String getVmName() {
+ return vmName;
+ }
+
+ public void setVmName(String vmName) {
+ this.vmName = vmName;
+ }
+
+ public String getChainInfo() {
+ return chainInfo;
+ }
+
+ public void setChainInfo(String chainInfo) {
+ this.chainInfo = chainInfo;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Storage.ImageFormat getFormat() {
+ return format;
+ }
+
+ public void setFormat(Storage.ImageFormat format) {
+ this.format = format;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("volumeTO[uuid=").append(uuid).append("|path=").append(path)
+ .append("|datastore=").append(dataStore).append("]").toString();
+ }
+
+ public void setBytesReadRate(Long bytesReadRate) {
+ this.bytesReadRate = bytesReadRate;
+ }
+
+ public Long getBytesReadRate() {
+ return bytesReadRate;
+ }
+
+ public void setBytesWriteRate(Long bytesWriteRate) {
+ this.bytesWriteRate = bytesWriteRate;
+ }
+
+ public Long getBytesWriteRate() {
+ return bytesWriteRate;
+ }
+
+ public void setIopsReadRate(Long iopsReadRate) {
+ this.iopsReadRate = iopsReadRate;
+ }
+
+ public Long getIopsReadRate() {
+ return iopsReadRate;
+ }
+
+ public void setIopsWriteRate(Long iopsWriteRate) {
+ this.iopsWriteRate = iopsWriteRate;
+ }
+
+ public Long getIopsWriteRate() {
+ return iopsWriteRate;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/core/test/com/cloud/agent/transport/RequestTest.java
----------------------------------------------------------------------
diff --git a/core/test/com/cloud/agent/transport/RequestTest.java b/core/test/com/cloud/agent/transport/RequestTest.java
index 510be91..973a799 100644
--- a/core/test/com/cloud/agent/transport/RequestTest.java
+++ b/core/test/com/cloud/agent/transport/RequestTest.java
@@ -20,17 +20,18 @@ import java.nio.ByteBuffer;
import junit.framework.TestCase;
-import org.apache.cloudstack.storage.command.DownloadCommand;
-import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Assert;
+import org.mockito.Mockito;
+
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.to.TemplateObjectTO;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.GetHostStatsCommand;
import com.cloud.agent.api.SecStorageFirewallCfgCommand;
-import com.cloud.agent.api.SecStorageSetupCommand;
import com.cloud.agent.api.UpdateHostPasswordCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
import com.cloud.agent.api.storage.ListTemplateCommand;
@@ -38,11 +39,11 @@ import com.cloud.agent.api.to.NfsTO;
import com.cloud.exception.UnsupportedVersionException;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.serializer.GsonHelper;
+import com.cloud.storage.DataStoreRole;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.VMTemplateVO;
+import com.cloud.template.VirtualMachineTemplate;
/**
*
@@ -165,8 +166,15 @@ public class RequestTest extends TestCase {
public void testDownload() {
s_logger.info("Testing Download answer");
- VMTemplateVO template = new VMTemplateVO(1, "templatename", ImageFormat.QCOW2, true, true, true, TemplateType.USER, "url", true, 32, 1, "chksum", "displayText", true, 30, true,
- HypervisorType.KVM, null);
+ VirtualMachineTemplate template = Mockito.mock(VirtualMachineTemplate.class);
+ Mockito.when(template.getId()).thenReturn(1L);
+ Mockito.when(template.getFormat()).thenReturn(ImageFormat.QCOW2);
+ Mockito.when(template.getName()).thenReturn("templatename");
+ Mockito.when(template.getTemplateType()).thenReturn(TemplateType.USER);
+ Mockito.when(template.getDisplayText()).thenReturn("displayText");
+ Mockito.when(template.getHypervisorType()).thenReturn(HypervisorType.KVM);
+ Mockito.when(template.getUrl()).thenReturn("url");
+
NfsTO nfs = new NfsTO("secUrl", DataStoreRole.Image);
TemplateObjectTO to = new TemplateObjectTO(template);
to.setImageDataStore(nfs);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/AttachAnswer.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/AttachAnswer.java b/engine/api/src/org/apache/cloudstack/storage/command/AttachAnswer.java
deleted file mode 100644
index 5a26d4a..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/AttachAnswer.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.command;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.to.DiskTO;
-
-public class AttachAnswer extends Answer {
- private DiskTO disk;
-
- public AttachAnswer() {
- super(null);
- }
-
- public AttachAnswer(DiskTO disk) {
- super(null);
- this.setDisk(disk);
- }
-
- public AttachAnswer(String errMsg) {
- super(null, false, errMsg);
- }
-
- public DiskTO getDisk() {
- return disk;
- }
-
- public void setDisk(DiskTO disk) {
- this.disk = disk;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/AttachCommand.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/AttachCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/AttachCommand.java
deleted file mode 100644
index 44bce91..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/AttachCommand.java
+++ /dev/null
@@ -1,126 +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 com.cloud.agent.api.Command;
-import com.cloud.agent.api.to.DiskTO;
-
-public final class AttachCommand extends Command implements StorageSubSystemCommand {
- private DiskTO disk;
- private String vmName;
- private String _storageHost;
- private int _storagePort;
- private boolean _managed;
- private String _iScsiName;
- private String _chapInitiatorUsername;
- private String _chapInitiatorPassword;
- private String _chapTargetUsername;
- private String _chapTargetPassword;
-
- public AttachCommand(DiskTO disk, String vmName) {
- super();
- this.disk = disk;
- this.vmName = vmName;
- }
-
- @Override
- public boolean executeInSequence() {
- return false;
- }
-
- public DiskTO getDisk() {
- return disk;
- }
-
- public void setDisk(DiskTO disk) {
- this.disk = disk;
- }
-
- public String getVmName() {
- return vmName;
- }
-
- public void setVmName(String vmName) {
- this.vmName = vmName;
- }
-
- public void setStorageHost(String storageHost) {
- _storageHost = storageHost;
- }
-
- public String getStorageHost() {
- return _storageHost;
- }
-
- public void setStoragePort(int storagePort) {
- _storagePort = storagePort;
- }
-
- public int getStoragePort() {
- return _storagePort;
- }
-
- public void setManaged(boolean managed) {
- _managed = managed;
- }
-
- public boolean isManaged() {
- return _managed;
- }
-
- public void set_iScsiName(String iScsiName) {
- this._iScsiName = iScsiName;
- }
-
- public String get_iScsiName() {
- return _iScsiName;
- }
-
- public void setChapInitiatorUsername(String chapInitiatorUsername) {
- _chapInitiatorUsername = chapInitiatorUsername;
- }
-
- public String getChapInitiatorUsername() {
- return _chapInitiatorUsername;
- }
-
- public void setChapInitiatorPassword(String chapInitiatorPassword) {
- _chapInitiatorPassword = chapInitiatorPassword;
- }
-
- public String getChapInitiatorPassword() {
- return _chapInitiatorPassword;
- }
-
- public void setChapTargetUsername(String chapTargetUsername) {
- _chapTargetUsername = chapTargetUsername;
- }
-
- public String getChapTargetUsername() {
- return _chapTargetUsername;
- }
-
- public void setChapTargetPassword(String chapTargetPassword) {
- _chapTargetPassword = chapTargetPassword;
- }
-
- public String getChapTargetPassword() {
- return _chapTargetPassword;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreAnswer.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreAnswer.java b/engine/api/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreAnswer.java
deleted file mode 100644
index 6d5bbaf..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreAnswer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.command;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-
-public class AttachPrimaryDataStoreAnswer extends Answer {
- private String uuid;
- private long capacity;
- private long avail;
-
- public AttachPrimaryDataStoreAnswer(Command cmd) {
- super(cmd);
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public String getUuid() {
- return this.uuid;
- }
-
- public void setCapacity(long capacity) {
- this.capacity = capacity;
- }
-
- public long getCapacity() {
- return this.capacity;
- }
-
- public void setAvailable(long avail) {
- this.avail = avail;
- }
-
- public long getAvailable() {
- return this.avail;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java b/engine/api/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
deleted file mode 100644
index 2083876..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
+++ /dev/null
@@ -1,39 +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 com.cloud.agent.api.Command;
-
-public final class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand {
- private final String dataStore;
-
- public AttachPrimaryDataStoreCmd(String uri) {
- super();
- this.dataStore = uri;
- }
-
- public String getDataStore() {
- return this.dataStore;
- }
-
- @Override
- public boolean executeInSequence() {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java b/engine/api/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java
deleted file mode 100644
index 95c0e89..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/CopyCmdAnswer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.storage.command;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.to.DataTO;
-
-public class CopyCmdAnswer extends Answer {
- private DataTO newData;
-
- public CopyCmdAnswer(DataTO newData) {
- super(null);
- this.newData = newData;
- }
-
- public DataTO getNewData() {
- return this.newData;
- }
-
- public CopyCmdAnswer(String errMsg) {
- super(null, false, errMsg);
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/CopyCommand.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/CopyCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/CopyCommand.java
deleted file mode 100644
index f14f37e..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/CopyCommand.java
+++ /dev/null
@@ -1,58 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.storage.command;
-
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.to.DataTO;
-
-public final class CopyCommand extends Command implements StorageSubSystemCommand {
- private DataTO srcTO;
- private DataTO destTO;
- private DataTO cacheTO;
- boolean executeInSequence = false;
-
-
- public CopyCommand(DataTO srcData, DataTO destData, int timeout, boolean executeInSequence) {
- super();
- this.srcTO = srcData;
- this.destTO = destData;
- this.setWait(timeout);
- this.executeInSequence = executeInSequence;
- }
-
- public DataTO getDestTO() {
- return this.destTO;
- }
-
- public DataTO getSrcTO() {
- return this.srcTO;
- }
-
- @Override
- public boolean executeInSequence() {
- return executeInSequence;
- }
-
- public DataTO getCacheTO() {
- return cacheTO;
- }
-
- public void setCacheTO(DataTO cacheTO) {
- this.cacheTO = cacheTO;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectAnswer.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectAnswer.java b/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectAnswer.java
deleted file mode 100644
index b0c4744..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectAnswer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.command;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.to.DataTO;
-
-public final class CreateObjectAnswer extends Answer {
- private DataTO data;
-
- protected CreateObjectAnswer() {
- super();
- }
-
- public CreateObjectAnswer(DataTO data) {
- super();
- this.data = data;
- }
-
- public DataTO getData() {
- return this.data;
- }
-
- public CreateObjectAnswer(String errMsg) {
- super(null, false, errMsg);
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4cea4eb/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
deleted file mode 100644
index 121a7ee..0000000
--- a/engine/api/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
+++ /dev/null
@@ -1,45 +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 com.cloud.agent.api.Command;
-import com.cloud.agent.api.to.DataTO;
-
-public final class CreateObjectCommand extends Command implements StorageSubSystemCommand {
- private DataTO data;
-
- public CreateObjectCommand(DataTO obj) {
- super();
- this.data = obj;
- }
-
- protected CreateObjectCommand() {
- super();
- }
-
- @Override
- public boolean executeInSequence() {
- return false;
- }
-
- public DataTO getData() {
- return this.data;
- }
-
-}