cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [04/96] [abbrv] [partial] merge master
Date Mon, 13 May 2013 18:00:55 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/service/ServiceOfferingVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/service/ServiceOfferingVO.java b/engine/schema/src/com/cloud/service/ServiceOfferingVO.java
new file mode 100755
index 0000000..94a7351
--- /dev/null
+++ b/engine/schema/src/com/cloud/service/ServiceOfferingVO.java
@@ -0,0 +1,211 @@
+// 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.service;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import com.cloud.offering.ServiceOffering;
+import com.cloud.storage.DiskOfferingVO;
+import com.cloud.vm.VirtualMachine;
+
+@Entity
+@Table(name="service_offering")
+@DiscriminatorValue(value="Service")
+@PrimaryKeyJoinColumn(name="id")
+public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering {
+    @Column(name="cpu")
+	private int cpu;
+
+    @Column(name="speed")
+    private int speed;
+
+    @Column(name="ram_size")
+	private int ramSize;
+
+    @Column(name="nw_rate")
+    private Integer rateMbps;
+
+    @Column(name="mc_rate")
+    private Integer multicastRateMbps;
+
+    @Column(name="ha_enabled")
+    private boolean offerHA;
+
+    @Column(name="limit_cpu_use")
+    private boolean limitCpuUse;
+
+    @Column(name="is_volatile")
+    private boolean volatileVm;
+
+    @Column(name="host_tag")
+    private String hostTag;
+
+    @Column(name="default_use")
+    private boolean default_use;
+
+    @Column(name="vm_type")
+    private String vm_type;
+
+    @Column(name="sort_key")
+    int sortKey;
+
+    protected ServiceOfferingVO() {
+        super();
+    }
+
+    public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vm_type, boolean defaultUse) {
+        super(name, displayText, false, tags, recreatable, useLocalStorage, systemUse, true);
+        this.cpu = cpu;
+        this.ramSize = ramSize;
+        this.speed = speed;
+        this.rateMbps = rateMbps;
+        this.multicastRateMbps = multicastRateMbps;
+        this.offerHA = offerHA;
+        this.limitCpuUse = false;
+        this.volatileVm = false;
+        this.default_use = defaultUse;
+        this.vm_type = vm_type == null ? null : vm_type.toString().toLowerCase();
+    }
+
+    public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, boolean limitCpuUse, boolean volatileVm, String displayText, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vm_type, Long domainId) {
+        super(name, displayText, false, tags, recreatable, useLocalStorage, systemUse, true, domainId);
+        this.cpu = cpu;
+        this.ramSize = ramSize;
+        this.speed = speed;
+        this.rateMbps = rateMbps;
+        this.multicastRateMbps = multicastRateMbps;
+        this.offerHA = offerHA;
+        this.limitCpuUse = limitCpuUse;
+        this.volatileVm = volatileVm;
+        this.vm_type = vm_type == null ? null : vm_type.toString().toLowerCase();
+    }
+
+    public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, boolean limitResourceUse, boolean volatileVm, String displayText, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vm_type, Long domainId, String hostTag) {
+        this(name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, limitResourceUse, volatileVm, displayText, useLocalStorage, recreatable, tags, systemUse, vm_type, domainId);
+        this.hostTag = hostTag;
+    }
+
+    @Override
+	public boolean getOfferHA() {
+	    return offerHA;
+	}
+
+	public void setOfferHA(boolean offerHA) {
+		this.offerHA = offerHA;
+	}
+
+    @Override
+	public boolean getLimitCpuUse() {
+	    return limitCpuUse;
+	}
+
+	public void setLimitResourceUse(boolean limitCpuUse) {
+		this.limitCpuUse = limitCpuUse;
+	}
+
+	@Override
+    public boolean getDefaultUse() {
+        return default_use;
+    }
+
+	@Override
+    @Transient
+	public String[] getTagsArray() {
+	    String tags = getTags();
+	    if (tags == null || tags.length() == 0) {
+	        return new String[0];
+	    }
+
+	    return tags.split(",");
+	}
+
+	@Override
+	public int getCpu() {
+	    return cpu;
+	}
+
+	public void setCpu(int cpu) {
+		this.cpu = cpu;
+	}
+
+	public void setSpeed(int speed) {
+		this.speed = speed;
+	}
+
+	public void setRamSize(int ramSize) {
+		this.ramSize = ramSize;
+	}
+
+	@Override
+	public int getSpeed() {
+	    return speed;
+	}
+
+	@Override
+	public int getRamSize() {
+	    return ramSize;
+	}
+
+	public void setRateMbps(Integer rateMbps) {
+		this.rateMbps = rateMbps;
+	}
+
+	@Override
+    public Integer getRateMbps() {
+		return rateMbps;
+	}
+
+	public void setMulticastRateMbps(Integer multicastRateMbps) {
+		this.multicastRateMbps = multicastRateMbps;
+	}
+
+	@Override
+    public Integer getMulticastRateMbps() {
+		return multicastRateMbps;
+	}
+
+	public void setHostTag(String hostTag) {
+		this.hostTag = hostTag;
+	}
+
+	public String getHostTag() {
+		return hostTag;
+	}
+
+	public String getSystemVmType(){
+	    return vm_type;
+	}
+
+	public void setSortKey(int key) {
+		sortKey = key;
+	}
+
+	public int getSortKey() {
+		return sortKey;
+	}
+
+    @Override
+    public boolean getVolatileVm() {
+        return volatileVm;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java
new file mode 100644
index 0000000..589de7c
--- /dev/null
+++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.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.service.dao;
+
+import java.util.List;
+
+import com.cloud.service.ServiceOfferingVO;
+import com.cloud.utils.db.GenericDao;
+
+/*
+ * Data Access Object for service_offering table
+ */
+public interface ServiceOfferingDao extends GenericDao<ServiceOfferingVO, Long> {
+    ServiceOfferingVO findByName(String name);
+    ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO vo);
+	List<ServiceOfferingVO> findPublicServiceOfferings();
+	List<ServiceOfferingVO> findServiceOfferingByDomainId(Long domainId);
+    List<ServiceOfferingVO> findSystemOffering(Long domainId, Boolean isSystem, String vm_type);
+    ServiceOfferingVO persistDeafultServiceOffering(ServiceOfferingVO offering);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
new file mode 100644
index 0000000..062103e
--- /dev/null
+++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
@@ -0,0 +1,157 @@
+// 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.service.dao;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.ejb.Local;
+import javax.persistence.EntityExistsException;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.service.ServiceOfferingVO;
+import com.cloud.storage.DiskOfferingVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value={ServiceOfferingDao.class}) @DB(txn=false)
+public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO, Long> implements ServiceOfferingDao {
+    protected static final Logger s_logger = Logger.getLogger(ServiceOfferingDaoImpl.class);
+
+    protected final SearchBuilder<ServiceOfferingVO> UniqueNameSearch;
+    protected final SearchBuilder<ServiceOfferingVO> ServiceOfferingsByDomainIdSearch;
+    protected final SearchBuilder<ServiceOfferingVO> SystemServiceOffering;
+    protected final SearchBuilder<ServiceOfferingVO> ServiceOfferingsByKeywordSearch;
+    protected final SearchBuilder<ServiceOfferingVO> PublicServiceOfferingSearch;
+    
+    public ServiceOfferingDaoImpl() {
+        super();
+        
+        UniqueNameSearch = createSearchBuilder();
+        UniqueNameSearch.and("name", UniqueNameSearch.entity().getUniqueName(), SearchCriteria.Op.EQ);
+        UniqueNameSearch.and("system", UniqueNameSearch.entity().getSystemUse(), SearchCriteria.Op.EQ);
+        UniqueNameSearch.done();
+        
+        ServiceOfferingsByDomainIdSearch = createSearchBuilder();
+        ServiceOfferingsByDomainIdSearch.and("domainId", ServiceOfferingsByDomainIdSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
+        ServiceOfferingsByDomainIdSearch.done();
+        
+        SystemServiceOffering = createSearchBuilder();
+        SystemServiceOffering.and("domainId", SystemServiceOffering.entity().getDomainId(), SearchCriteria.Op.EQ);
+        SystemServiceOffering.and("system", SystemServiceOffering.entity().getSystemUse(), SearchCriteria.Op.EQ);
+        SystemServiceOffering.and("vm_type", SystemServiceOffering.entity().getSpeed(), SearchCriteria.Op.EQ);
+        SystemServiceOffering.and("removed", SystemServiceOffering.entity().getRemoved(), SearchCriteria.Op.NULL);
+        SystemServiceOffering.done();
+        
+        
+        PublicServiceOfferingSearch = createSearchBuilder();
+        PublicServiceOfferingSearch.and("domainId", PublicServiceOfferingSearch.entity().getDomainId(), SearchCriteria.Op.NULL);
+        PublicServiceOfferingSearch.and("system", PublicServiceOfferingSearch.entity().getSystemUse(), SearchCriteria.Op.EQ);
+        PublicServiceOfferingSearch.and("removed", PublicServiceOfferingSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
+        PublicServiceOfferingSearch.done();
+        
+        ServiceOfferingsByKeywordSearch = createSearchBuilder();
+        ServiceOfferingsByKeywordSearch.or("name", ServiceOfferingsByKeywordSearch.entity().getName(), SearchCriteria.Op.EQ);        
+        ServiceOfferingsByKeywordSearch.or("displayText", ServiceOfferingsByKeywordSearch.entity().getDisplayText(), SearchCriteria.Op.EQ);
+        ServiceOfferingsByKeywordSearch.done();
+    }
+    
+    @Override
+    public ServiceOfferingVO findByName(String name) {
+        SearchCriteria<ServiceOfferingVO> sc = UniqueNameSearch.create();
+        sc.setParameters("name", name);
+        sc.setParameters("system", true);
+        List<ServiceOfferingVO> vos = search(sc, null, null, false);
+        if (vos.size() == 0) {
+            return null;
+        }
+        
+        return vos.get(0);
+    }
+    
+    @Override @DB
+    public ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO offering) {
+        assert offering.getUniqueName() != null : "how are you going to find this later if you don't set it?";
+        ServiceOfferingVO vo = findByName(offering.getUniqueName());
+        if (vo != null) {
+        	// check invalid CPU speed in system service offering, set it to default value of 500 Mhz if 0 CPU speed is found
+        	if(vo.getSpeed() <= 0) {
+        		vo.setSpeed(500);
+        		update(vo.getId(), vo);
+        	}
+            return vo;
+        }
+        try {
+            return persist(offering);
+        } catch (EntityExistsException e) {
+            // Assume it's conflict on unique name
+            return findByName(offering.getUniqueName());
+        }
+    }
+    
+    @Override
+    public List<ServiceOfferingVO> findServiceOfferingByDomainId(Long domainId){
+    	SearchCriteria<ServiceOfferingVO> sc = ServiceOfferingsByDomainIdSearch.create();
+    	sc.setParameters("domainId", domainId);
+        return listBy(sc);    	
+    }
+    
+
+    @Override
+    public List<ServiceOfferingVO> findSystemOffering(Long domainId, Boolean isSystem, String vm_type){
+        SearchCriteria<ServiceOfferingVO> sc = SystemServiceOffering.create();
+        sc.setParameters("domainId", domainId);
+        sc.setParameters("system", isSystem);
+        sc.setParameters("vm_type", vm_type);
+        return listBy(sc);      
+    }
+    
+    @Override
+    public List<ServiceOfferingVO> findPublicServiceOfferings(){
+    	SearchCriteria<ServiceOfferingVO> sc = PublicServiceOfferingSearch.create();
+    	sc.setParameters("system", false);
+        return listBy(sc);    	
+    }
+    
+    @Override @DB
+    public ServiceOfferingVO persistDeafultServiceOffering(ServiceOfferingVO offering) {
+        assert offering.getUniqueName() != null : "unique name should be set for the service offering";
+        ServiceOfferingVO vo = findByName(offering.getUniqueName());
+        if (vo != null) {
+            return vo;
+        }
+        try {
+            return persist(offering);
+        } catch (EntityExistsException e) {
+            // Assume it's conflict on unique name
+            return findByName(offering.getUniqueName());
+        }
+    }
+    
+    @Override
+    public boolean remove(Long id) {
+        ServiceOfferingVO offering = createForUpdate();
+        offering.setRemoved(new Date());
+
+        return update(id, offering);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
new file mode 100755
index 0000000..909d7fe
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
@@ -0,0 +1,330 @@
+// 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.Date;
+import java.util.List;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.apache.cloudstack.api.Identity;
+import com.cloud.offering.DiskOffering;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="disk_offering")
+@Inheritance(strategy=InheritanceType.JOINED)
+@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
+public class DiskOfferingVO implements DiskOffering {
+    public enum Type {
+        Disk,
+        Service
+    };
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    long id;
+
+    @Column(name="domain_id")
+    Long domainId;
+
+    @Column(name="unique_name")
+    private String uniqueName;
+
+    @Column(name="name")
+    private String name = null;
+
+    @Column(name="display_text", length=4096)
+    private String displayText = null;
+
+    @Column(name="disk_size")
+    long diskSize;
+
+    @Column(name="tags", length=4096)
+    String tags;
+
+    @Column(name="type")
+    Type type;
+
+    @Column(name=GenericDao.REMOVED)
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date removed;
+
+    @Column(name=GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    @Column(name="recreatable")
+    private boolean recreatable;
+
+    @Column(name="use_local_storage")
+    private boolean useLocalStorage;
+
+    @Column(name="system_use")
+    private boolean systemUse;
+
+    @Column(name="customized")
+    private boolean customized;
+
+    @Column(name="uuid")
+    private String uuid;
+
+    @Column(name="sort_key")
+    int sortKey;
+
+    @Column(name="display_offering")
+    boolean displayOffering;
+
+    public DiskOfferingVO() {
+    	this.uuid = UUID.randomUUID().toString();
+    }
+
+    public DiskOfferingVO(Long domainId, String name, String displayText, long diskSize, String tags, boolean isCustomized) {
+        this.domainId = domainId;
+        this.name = name;
+        this.displayText = displayText;
+        this.diskSize = diskSize;
+        this.tags = tags;
+        this.recreatable = false;
+        this.type = Type.Disk;
+        this.useLocalStorage = false;
+        this.customized = isCustomized;
+    	this.uuid = UUID.randomUUID().toString();
+    }
+
+    public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage, boolean systemUse, boolean customized) {
+        this.domainId = null;
+        this.type = Type.Service;
+        this.name = name;
+        this.displayText = displayText;
+        this.tags = tags;
+        this.recreatable = recreatable;
+        this.useLocalStorage = useLocalStorage;
+        this.systemUse = systemUse;
+        this.customized = customized;
+    	this.uuid = UUID.randomUUID().toString();
+    }
+
+    //domain specific offerings constructor (null domainId implies public offering)
+    public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage, boolean systemUse, boolean customized, Long domainId) {
+        this.type = Type.Service;
+        this.name = name;
+        this.displayText = displayText;
+        this.tags = tags;
+        this.recreatable = recreatable;
+        this.useLocalStorage = useLocalStorage;
+        this.systemUse = systemUse;
+        this.customized = customized;
+        this.domainId = domainId;
+    	this.uuid = UUID.randomUUID().toString();
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public boolean isCustomized() {
+		return customized;
+	}
+
+	public void setCustomized(boolean customized) {
+		this.customized = customized;
+	}
+
+	@Override
+    public String getUniqueName() {
+        return uniqueName;
+    }
+
+    @Override
+    public boolean getUseLocalStorage() {
+        return useLocalStorage;
+    }
+
+    @Override
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public boolean isRecreatable() {
+        return recreatable;
+    }
+
+    public void setDomainId(Long domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+
+    @Override
+    public boolean getSystemUse() {
+        return systemUse;
+    }
+
+    public void setSystemUse(boolean systemUse) {
+        this.systemUse = systemUse;
+    }
+
+    @Override
+    public String getDisplayText() {
+        return displayText;
+    }
+    public void setDisplayText(String displayText) {
+        this.displayText = displayText;
+    }
+
+    @Override
+    public long getDiskSize(){
+    	return diskSize;
+    }
+
+    @Override
+    public void setDiskSize(long diskSize) {
+        this.diskSize = diskSize;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+	@Override
+    public Date getCreated() {
+		return created;
+	}
+
+    protected void setTags(String tags) {
+        this.tags = tags;
+    }
+
+    @Override
+    public String getTags() {
+        return tags;
+    }
+
+    public void setUniqueName(String name) {
+        this.uniqueName = name;
+    }
+
+    @Override
+    @Transient
+    public String[] getTagsArray() {
+        String tags = getTags();
+        if (tags == null || tags.isEmpty()) {
+            return new String[0];
+        }
+
+        return tags.split(",");
+    }
+
+    @Transient
+    public boolean containsTag(String... tags) {
+        if (this.tags == null) {
+            return false;
+        }
+
+        for (String tag : tags) {
+            if (!this.tags.matches(tag)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    @Transient
+    public void setTagsArray(List<String> newTags) {
+        if (newTags.isEmpty()) {
+            setTags(null);
+            return;
+        }
+
+        StringBuilder buf = new StringBuilder();
+        for (String tag : newTags) {
+            buf.append(tag).append(",");
+        }
+
+        buf.delete(buf.length() - 1, buf.length());
+
+        setTags(buf.toString());
+    }
+
+	public void setUseLocalStorage(boolean useLocalStorage) {
+		this.useLocalStorage = useLocalStorage;
+	}
+
+    public void setRemoved(Date removed) {
+        this.removed = removed;
+    }
+
+    @Override
+    public String getUuid() {
+    	return this.uuid;
+    }
+
+    public void setUuid(String uuid) {
+    	this.uuid = uuid;
+    }
+
+    public void setSortKey(int key) {
+    	sortKey = key;
+    }
+
+    public int getSortKey() {
+    	return sortKey;
+    }
+    
+    public void setRecreatable(boolean recreatable) {
+    	this.recreatable = recreatable;
+    }
+
+
+    public boolean getDisplayOffering() {
+        return displayOffering;
+    }
+
+    public void setDisplayOffering(boolean displayOffering) {
+        this.displayOffering = displayOffering;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/GuestOSCategoryVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/GuestOSCategoryVO.java b/engine/schema/src/com/cloud/storage/GuestOSCategoryVO.java
new file mode 100644
index 0000000..03a7479
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/GuestOSCategoryVO.java
@@ -0,0 +1,68 @@
+// 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_category")
+public class GuestOSCategoryVO implements GuestOsCategory {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    long id;
+
+    @Column(name="name")
+    String name;
+
+    @Column(name="uuid")
+    String uuid = UUID.randomUUID().toString();
+
+    @Override
+    public long getId() {
+    	return id;
+    }
+
+    @Override
+    public String getName() {
+    	return name;
+    }
+
+    @Override
+    public void setName(String name) {
+    	this.name = name;
+    }
+
+    @Override
+    public String getUuid() {
+    	return this.uuid;
+    }
+
+    public void setUuid(String uuid) {
+    	this.uuid = uuid;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/GuestOSVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/GuestOSVO.java b/engine/schema/src/com/cloud/storage/GuestOSVO.java
new file mode 100644
index 0000000..49e136d
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/GuestOSVO.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 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")
+public class GuestOSVO implements GuestOS {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    long id;
+
+    @Column(name="category_id")
+    private long categoryId;
+
+    @Column(name="name")
+    String name;
+
+    @Column(name="display_name")
+    String displayName;
+
+    @Column(name="uuid")
+    String uuid = UUID.randomUUID().toString();
+
+    @Override
+    public long getId() {
+    	return id;
+    }
+
+    public long getCategoryId() {
+    	return categoryId;
+    }
+
+    public void setCategoryId(long categoryId) {
+    	this.categoryId = categoryId;
+    }
+
+    @Override
+    public String getName() {
+    	return name;
+    }
+
+    public void setName(String name) {
+    	this.name = name;
+    }
+
+    @Override
+    public String getDisplayName() {
+    	return displayName;
+    }
+
+    public void setDisplayName(String displayName) {
+    	this.displayName = displayName;
+    }
+
+    @Override
+    public String getUuid() {
+    	return this.uuid;
+    }
+
+    public void setUuid(String uuid) {
+    	this.uuid = uuid;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/LaunchPermissionVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/LaunchPermissionVO.java b/engine/schema/src/com/cloud/storage/LaunchPermissionVO.java
new file mode 100644
index 0000000..992bac2
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/LaunchPermissionVO.java
@@ -0,0 +1,57 @@
+// 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.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="launch_permission")
+public class LaunchPermissionVO implements InternalIdentity {
+    @Id
+    @Column(name="id")
+    private Long id;
+
+    @Column(name="template_id")
+    private long templateId;
+
+    @Column(name="account_id")
+    private long accountId;
+
+    public LaunchPermissionVO() { }
+
+    public LaunchPermissionVO(long templateId, long accountId) {
+        this.templateId = templateId;
+        this.accountId = accountId;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getTemplateId() {
+        return templateId;
+    }
+
+    public long getAccountId() {
+        return accountId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/S3VO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/S3VO.java b/engine/schema/src/com/cloud/storage/S3VO.java
new file mode 100644
index 0000000..ec49bc9
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/S3VO.java
@@ -0,0 +1,209 @@
+/*
+ * 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 com.cloud.agent.api.to.S3TO;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.Identity;
+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;
+import java.util.Date;
+
+@Entity
+@Table(name = "s3")
+public class S3VO implements S3 {
+
+    public static final String ID_COLUMN_NAME = "id";
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = ID_COLUMN_NAME)
+    private long id;
+
+    @Column(name = "uuid")
+    private String uuid;
+
+    @Column(name = "access_key")
+    private String accessKey;
+
+    @Column(name = "secret_key")
+    private String secretKey;
+
+    @Column(name = "end_point")
+    private String endPoint;
+
+    @Column(name = "bucket")
+    private String bucketName;
+
+    @Column(name = "https")
+    private Integer httpsFlag;
+
+    @Column(name = "connection_timeout")
+    private Integer connectionTimeout;
+
+    @Column(name = "max_error_retry")
+    private Integer maxErrorRetry;
+
+    @Column(name = "socket_timeout")
+    private Integer socketTimeout;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    public S3VO() {
+        super();
+    }
+
+    public S3VO(final String uuid, final String accessKey,
+            final String secretKey, final String endPoint,
+            final String bucketName, final Boolean httpsFlag,
+            final Integer connectionTimeout, final Integer maxErrorRetry,
+            final Integer socketTimeout, final Date created) {
+
+        super();
+
+        this.uuid = uuid;
+        this.accessKey = accessKey;
+        this.secretKey = secretKey;
+        this.endPoint = endPoint;
+        this.bucketName = bucketName;
+
+        Integer value = null;
+        if (httpsFlag != null) {
+            value = httpsFlag == false ? 0 : 1;
+        }
+        this.httpsFlag = value;
+
+        this.connectionTimeout = connectionTimeout;
+        this.maxErrorRetry = maxErrorRetry;
+        this.socketTimeout = socketTimeout;
+        this.created = created;
+
+    }
+
+    @Override
+    public S3TO toS3TO() {
+
+        Boolean httpsFlag = null;
+        if (this.httpsFlag != null) {
+            httpsFlag = this.httpsFlag == 0 ? false : true;
+        }
+
+        return new S3TO(this.id, this.uuid, this.accessKey, this.secretKey,
+                this.endPoint, this.bucketName, httpsFlag,
+                this.connectionTimeout, this.maxErrorRetry, this.socketTimeout,
+                this.created);
+
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public void setId(final long id) {
+        this.id = id;
+    }
+
+    public String getUuid() {
+        return this.uuid;
+    }
+
+    public void setUuid(final String uuid) {
+        this.uuid = uuid;
+    }
+
+    public String getAccessKey() {
+        return this.accessKey;
+    }
+
+    public void setAccessKey(final String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getSecretKey() {
+        return this.secretKey;
+    }
+
+    public void setSecretKey(final String secretKey) {
+        this.secretKey = secretKey;
+    }
+
+    public String getEndPoint() {
+        return this.endPoint;
+    }
+
+    public void setEndPoint(final String endPoint) {
+        this.endPoint = endPoint;
+    }
+
+    public String getBucketName() {
+        return this.bucketName;
+    }
+
+    public void setBucketName(final String bucketName) {
+        this.bucketName = bucketName;
+    }
+
+    public Integer getHttpsFlag() {
+        return this.httpsFlag;
+    }
+
+    public void setHttpsFlag(final Integer httpsFlag) {
+        this.httpsFlag = httpsFlag;
+    }
+
+    public Integer getConnectionTimeout() {
+        return this.connectionTimeout;
+    }
+
+    public void setConnectionTimeout(final int connectionTimeout) {
+        this.connectionTimeout = connectionTimeout;
+    }
+
+    public Integer getMaxErrorRetry() {
+        return this.maxErrorRetry;
+    }
+
+    public void setMaxErrorRetry(final int maxErrorRetry) {
+        this.maxErrorRetry = maxErrorRetry;
+    }
+
+    public Integer getSocketTimeout() {
+        return this.socketTimeout;
+    }
+
+    public void setSocketTimeout(final int socketTimeout) {
+        this.socketTimeout = socketTimeout;
+    }
+
+    public Date getCreated() {
+        return this.created;
+    }
+
+    public void setCreated(final Date created) {
+        this.created = created;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/SnapshotPolicyVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/SnapshotPolicyVO.java b/engine/schema/src/com/cloud/storage/SnapshotPolicyVO.java
new file mode 100644
index 0000000..4eb4916
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/SnapshotPolicyVO.java
@@ -0,0 +1,133 @@
+// 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 com.cloud.storage.snapshot.SnapshotPolicy;
+import com.cloud.utils.DateUtil.IntervalType;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="snapshot_policy")
+public class SnapshotPolicyVO implements SnapshotPolicy {
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    long id;
+
+    @Column(name="volume_id")
+    long volumeId;
+
+    @Column(name="schedule")
+    String schedule;
+
+    @Column(name="timezone")
+    String timezone;
+
+    @Column(name="interval")
+    private short interval;
+
+    @Column(name="max_snaps")
+    private int maxSnaps;
+
+    @Column(name="active")
+    boolean active = false;
+
+    @Column(name="uuid")
+    String uuid;
+
+    public SnapshotPolicyVO() {
+    	this.uuid = UUID.randomUUID().toString();
+    }
+
+    public SnapshotPolicyVO(long volumeId, String schedule, String timezone, IntervalType intvType, int maxSnaps) {
+    	this.volumeId = volumeId;
+        this.schedule = schedule;
+        this.timezone = timezone;
+        this.interval = (short)intvType.ordinal();
+        this.maxSnaps = maxSnaps;
+        this.active = true;
+    	this.uuid = UUID.randomUUID().toString();
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getVolumeId() {
+		return volumeId;
+	}
+
+	public void setSchedule(String schedule) {
+        this.schedule = schedule;
+    }
+
+    public String getSchedule() {
+        return schedule;
+    }
+
+    public void setInterval(short interval) {
+        this.interval = interval;
+    }
+
+    public void setTimezone(String timezone) {
+        this.timezone = timezone;
+    }
+
+    public String getTimezone() {
+        return timezone;
+    }
+
+    public short getInterval() {
+        return interval;
+    }
+
+    public void setMaxSnaps(int maxSnaps) {
+        this.maxSnaps = maxSnaps;
+    }
+
+    public int getMaxSnaps() {
+        return maxSnaps;
+    }
+
+    public boolean isActive() {
+        return active;
+    }
+
+    public void setActive(boolean active) {
+        this.active = active;
+    }
+
+    @Override
+    public String getUuid() {
+    	return this.uuid;
+    }
+
+    public void setUuid(String uuid) {
+    	this.uuid = uuid;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/SnapshotScheduleVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/SnapshotScheduleVO.java b/engine/schema/src/com/cloud/storage/SnapshotScheduleVO.java
new file mode 100644
index 0000000..75757c6
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/SnapshotScheduleVO.java
@@ -0,0 +1,125 @@
+// 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.Date;
+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 javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.api.Identity;
+import com.cloud.storage.snapshot.SnapshotSchedule;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="snapshot_schedule")
+public class SnapshotScheduleVO implements SnapshotSchedule {
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+	@Column(name="id")
+	long id;
+
+    // DB constraint: For a given volume and policyId, there will only be one entry in this table.
+    @Column(name="volume_id")
+    long volumeId;
+
+    @Column(name="policy_id")
+    long policyId;
+
+    @Column(name="scheduled_timestamp")
+    @Temporal(value=TemporalType.TIMESTAMP)
+    Date scheduledTimestamp;
+
+    @Column(name="async_job_id")
+    Long asyncJobId;
+
+    @Column(name="snapshot_id")
+    Long snapshotId;
+
+    @Column(name="uuid")
+    String uuid = UUID.randomUUID().toString();
+
+    public SnapshotScheduleVO() { }
+
+    public SnapshotScheduleVO(long volumeId, long policyId, Date scheduledTimestamp) {
+        this.volumeId = volumeId;
+        this.policyId = policyId;
+        this.scheduledTimestamp = scheduledTimestamp;
+        this.snapshotId = null;
+        this.asyncJobId = null;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public Long getVolumeId() {
+        return volumeId;
+    }
+
+    public Long getPolicyId() {
+        return policyId;
+    }
+
+	public void setPolicyId(long policyId) {
+        this.policyId = policyId;
+    }
+
+    /**
+	 * @return the scheduledTimestamp
+	 */
+	public Date getScheduledTimestamp() {
+		return scheduledTimestamp;
+	}
+
+	public void setScheduledTimestamp(Date scheduledTimestamp) {
+        this.scheduledTimestamp = scheduledTimestamp;
+    }
+
+    public Long getAsyncJobId() {
+	    return asyncJobId;
+	}
+
+	public void setAsyncJobId(Long asyncJobId) {
+	    this.asyncJobId = asyncJobId;
+	}
+
+	public Long getSnapshotId() {
+	    return snapshotId;
+	}
+
+	public void setSnapshotId(Long snapshotId) {
+	    this.snapshotId = snapshotId;
+	}
+
+	@Override
+	public String getUuid() {
+		return this.uuid;
+	}
+
+	public void setUuid(String uuid) {
+		this.uuid = uuid;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/SnapshotVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/SnapshotVO.java b/engine/schema/src/com/cloud/storage/SnapshotVO.java
new file mode 100644
index 0000000..78b96ec
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/SnapshotVO.java
@@ -0,0 +1,298 @@
+// 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 com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.utils.db.GenericDao;
+import com.google.gson.annotations.Expose;
+
+import javax.persistence.*;
+import java.util.Date;
+import java.util.UUID;
+
+@Entity
+@Table(name="snapshots")
+public class SnapshotVO implements Snapshot {
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="data_center_id")
+    long dataCenterId;
+
+    @Column(name="account_id")
+    long accountId;
+
+    @Column(name="domain_id")
+    long domainId;
+
+    @Column(name="volume_id")
+    Long volumeId;
+
+    @Column(name="disk_offering_id")
+    Long diskOfferingId;
+
+    @Expose
+    @Column(name="path")
+    String path;
+
+    @Expose
+    @Column(name="name")
+    String name;
+
+    @Expose
+    @Column(name="status", updatable = true, nullable=false)
+    @Enumerated(value=EnumType.STRING)
+    private State state;
+
+    @Column(name="snapshot_type")
+    short snapshotType;
+
+    @Column(name="type_description")
+    String typeDescription;
+
+    @Column(name="size")
+    long size;
+
+    @Column(name=GenericDao.CREATED_COLUMN)
+    Date created;
+
+    @Column(name=GenericDao.REMOVED_COLUMN)
+    Date removed;
+
+    @Column(name="backup_snap_id")
+    String backupSnapshotId;
+
+    @Column(name="swift_id")
+    Long swiftId;
+
+    @Column(name="s3_id")
+    Long s3Id;
+
+    @Column(name="sechost_id")
+    Long secHostId;
+
+    @Column(name="prev_snap_id")
+    long prevSnapshotId;
+
+    @Column(name="hypervisor_type")
+    @Enumerated(value=EnumType.STRING)
+    HypervisorType  hypervisorType;
+
+    @Expose
+    @Column(name="version")
+    String version;
+
+    @Column(name="uuid")
+    String uuid;
+
+    public SnapshotVO() {
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+    public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String path, String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType ) {
+        this.dataCenterId = dcId;
+        this.accountId = accountId;
+        this.domainId = domainId;
+        this.volumeId = volumeId;
+        this.diskOfferingId = diskOfferingId;
+        this.path = path;
+        this.name = name;
+        this.snapshotType = snapshotType;
+        this.typeDescription = typeDescription;
+        this.size = size;
+        this.state = State.Allocated;
+        this.prevSnapshotId = 0;
+        this.hypervisorType = hypervisorType;
+        this.version = "2.2";
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    public long getDataCenterId() {
+        return dataCenterId;
+    }
+
+    @Override
+    public long getAccountId() {
+        return accountId;
+    }
+
+    @Override
+    public long getDomainId() {
+        return domainId;
+    }
+
+    @Override
+    public long getVolumeId() {
+        return volumeId;
+    }
+
+    public long getDiskOfferingId() {
+        return diskOfferingId;
+    }
+
+    public void setVolumeId(Long volumeId) {
+        this.volumeId = volumeId;
+    }
+
+    @Override
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+    @Override
+    public short getsnapshotType() {
+        return snapshotType;
+    }
+
+    @Override
+    public Type getRecurringType() {
+        if (snapshotType < 0 || snapshotType >= Type.values().length) {
+            return null;
+        }
+        return Type.values()[snapshotType];
+    }
+
+    public Long getSwiftId() {
+        return swiftId;
+    }
+
+    public void setSwiftId(Long swiftId) {
+        this.swiftId = swiftId;
+    }
+
+    public Long getSecHostId() {
+        return secHostId;
+    }
+
+    public void setSecHostId(Long secHostId) {
+        this.secHostId = secHostId;
+    }
+
+    @Override
+    public HypervisorType getHypervisorType() {
+        return hypervisorType;
+    }
+
+    public void setSnapshotType(short snapshotType) {
+        this.snapshotType = snapshotType;
+    }
+
+    @Override
+    public boolean isRecursive(){
+        if ( snapshotType >= Type.HOURLY.ordinal() && snapshotType <= Type.MONTHLY.ordinal() ) {
+            return true;
+        }
+        return false;
+    }
+
+    public long getSize() {
+        return size;
+    }
+
+    public String getTypeDescription() {
+        return typeDescription;
+    }
+    public void setTypeDescription(String typeDescription) {
+        this.typeDescription = typeDescription;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    @Override
+    public Date getCreated() {
+        return created;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    @Override
+    public State getState() {
+        return state;
+    }
+
+
+	public void setState(State state) {
+        this.state = state;
+    }
+
+    public String getBackupSnapshotId(){
+        return backupSnapshotId;
+    }
+
+    public long getPrevSnapshotId(){
+        return prevSnapshotId;
+    }
+
+    public void setBackupSnapshotId(String backUpSnapshotId){
+        this.backupSnapshotId = backUpSnapshotId;
+    }
+
+    public void setPrevSnapshotId(long prevSnapshotId){
+        this.prevSnapshotId = prevSnapshotId;
+    }
+
+    public static Type getSnapshotType(String snapshotType) {
+        for ( Type type : Type.values()) {
+            if ( type.equals(snapshotType)) {
+                return type;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public String getUuid() {
+        return this.uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public Long getS3Id() {
+        return s3Id;
+    }
+
+    public void setS3Id(Long s3Id) {
+        this.s3Id = s3Id;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/StoragePoolHostAssoc.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/StoragePoolHostAssoc.java b/engine/schema/src/com/cloud/storage/StoragePoolHostAssoc.java
new file mode 100644
index 0000000..34326d9
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/StoragePoolHostAssoc.java
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.storage;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import java.util.Date;
+
+public interface StoragePoolHostAssoc extends InternalIdentity {
+	
+	long getHostId();
+	
+	long getPoolId();
+	
+	String getLocalPath();
+
+	Date getCreated();
+
+	Date getLastUpdated();
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/StoragePoolHostVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/StoragePoolHostVO.java b/engine/schema/src/com/cloud/storage/StoragePoolHostVO.java
new file mode 100644
index 0000000..1b02f6d
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/StoragePoolHostVO.java
@@ -0,0 +1,109 @@
+// 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.Date;
+
+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 javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import com.cloud.utils.db.GenericDaoBase;
+
+/**
+ * Join table for storage pools and hosts
+ *
+ */
+@Entity
+@Table(name="storage_pool_host_ref")
+public class StoragePoolHostVO implements StoragePoolHostAssoc {
+	@Id
+	@GeneratedValue(strategy=GenerationType.IDENTITY)
+	private Long id;
+
+	@Column(name="pool_id")
+	private long poolId;
+
+	@Column(name="host_id")
+	private long hostId;
+
+	@Column(name="local_path")
+	private String localPath;
+
+	@Column(name=GenericDaoBase.CREATED_COLUMN)
+    private Date created = null;
+
+	@Column(name="last_updated")
+	@Temporal(value=TemporalType.TIMESTAMP)
+    private Date lastUpdated = null;
+
+
+	public StoragePoolHostVO() {
+		super();
+	}
+
+
+	public StoragePoolHostVO(long poolId, long hostId, String localPath) {
+		this.poolId = poolId;
+		this.hostId = hostId;
+		this.localPath = localPath;
+	}
+
+
+	@Override
+	public long getHostId() {
+		return hostId;
+	}
+
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+
+    @Override
+	public String getLocalPath() {
+		return localPath;
+	}
+
+	@Override
+	public long getPoolId() {
+		return poolId;
+	}
+
+	@Override
+	public Date getCreated() {
+		return created;
+	}
+
+	@Override
+	public Date getLastUpdated() {
+		return lastUpdated;
+	}
+
+
+	public void setLocalPath(String localPath) {
+		this.localPath = localPath;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/StoragePoolWorkVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/StoragePoolWorkVO.java b/engine/schema/src/com/cloud/storage/StoragePoolWorkVO.java
new file mode 100644
index 0000000..440065d
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/StoragePoolWorkVO.java
@@ -0,0 +1,118 @@
+// 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="storage_pool_work")
+public class StoragePoolWorkVO implements InternalIdentity {
+    
+    public long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getPoolId() {
+        return poolId;
+    }
+
+
+    public void setPoolId(Long poolId) {
+        this.poolId = poolId;
+    }
+
+
+    public boolean isStoppedForMaintenance() {
+        return stoppedForMaintenance;
+    }
+
+
+    public void setStoppedForMaintenance(boolean stoppedForMaintenance) {
+        this.stoppedForMaintenance = stoppedForMaintenance;
+    }
+
+
+    public boolean isStartedAfterMaintenance() {
+        return startedAfterMaintenance;
+    }
+
+    public void setStartedAfterMaintenance(boolean startedAfterMaintenance) {
+        this.startedAfterMaintenance = startedAfterMaintenance;
+    }
+
+    public Long getVmId() {
+        return vmId;
+    }
+
+    public void setVmId(Long vmId) {
+        this.vmId = vmId;
+    }
+    
+    public Long getManagementServerId() {
+        return managementServerId;
+    }
+
+    public void setManagementServerId(Long managementServerId) {
+        this.managementServerId = managementServerId;
+    }
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private Long id;
+    
+    @Column(name="pool_id")
+    private Long poolId;
+
+    @Column(name="vm_id")
+    private Long vmId;
+    
+    @Column(name="stopped_for_maintenance")
+    private boolean stoppedForMaintenance;
+    
+    @Column(name="started_after_maintenance")
+    private boolean startedAfterMaintenance;
+
+    @Column(name="mgmt_server_id")
+    private Long managementServerId;
+    
+
+    public StoragePoolWorkVO(long vmId, long poolId, boolean stoppedForMaintenance, boolean startedAfterMaintenance, long mgmtServerId) {
+        super();
+        this.vmId = vmId;
+        this.poolId = poolId;
+        this.stoppedForMaintenance = stoppedForMaintenance;
+        this.startedAfterMaintenance = startedAfterMaintenance;
+        this.managementServerId = mgmtServerId;
+    }
+    
+    public StoragePoolWorkVO() {
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/SwiftVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/SwiftVO.java b/engine/schema/src/com/cloud/storage/SwiftVO.java
new file mode 100644
index 0000000..c99f0ef
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/SwiftVO.java
@@ -0,0 +1,108 @@
+// 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.Date;
+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 com.cloud.agent.api.to.SwiftTO;
+import org.apache.cloudstack.api.Identity;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="swift")
+public class SwiftVO implements Swift, InternalIdentity {
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="url")
+    String url;
+
+    @Column(name="account")
+    String account;
+
+    @Column(name="username")
+    String userName;
+
+    @Column(name="key")
+    String key;
+
+    @Column(name="uuid")
+    String uuid = UUID.randomUUID().toString();
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    public SwiftVO() { }
+
+    public SwiftVO(String url, String account, String userName, String key) {
+        this.url = url;
+        this.account = account;
+        this.userName = userName;
+        this.key = key;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+    @Override
+    public String getUrl() {
+        return url;
+    }
+    @Override
+    public String getAccount() {
+        return account;
+    }
+    @Override
+    public String getUserName() {
+        return userName;
+    }
+    @Override
+    public String getKey() {
+        return key;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    @Override
+    public SwiftTO toSwiftTO() {
+        return new SwiftTO(getId(), getUrl(), getAccount(), getUserName(), getKey());
+    }
+
+    @Override
+    public String getUuid() {
+    	return this.uuid;
+    }
+
+    public void setUuid(String uuid) {
+    	this.uuid = uuid;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/UploadVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/UploadVO.java b/engine/schema/src/com/cloud/storage/UploadVO.java
new file mode 100755
index 0000000..d761bf1
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/UploadVO.java
@@ -0,0 +1,268 @@
+// 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.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.GenericDaoBase;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="upload")
+public class UploadVO implements Upload {
+	@Id
+	@GeneratedValue(strategy=GenerationType.IDENTITY)
+	long id;
+
+    @Column(name="uuid")
+	private String uuid;
+
+	@Column(name="host_id")
+	private long hostId;
+
+	@Column(name="type_id")
+	private long typeId;
+
+	@Column(name=GenericDaoBase.CREATED_COLUMN)
+	private Date created = null;
+
+	@Column(name="last_updated")
+	@Temporal(value=TemporalType.TIMESTAMP)
+	private Date lastUpdated = null;
+
+	@Column (name="upload_pct")
+	private int uploadPercent;
+
+	@Column (name="type")
+	@Enumerated(EnumType.STRING)
+	private Type type;
+
+	@Column (name="mode")
+    @Enumerated(EnumType.STRING)
+    private Mode mode = Mode.FTP_UPLOAD;
+
+	@Column (name="upload_state")
+	@Enumerated(EnumType.STRING)
+	private Status uploadState;
+
+	@Column (name="error_str")
+	private String errorString;
+
+	@Column (name="job_id")
+	private String jobId;
+
+	@Column (name="url")
+	private String uploadUrl;
+
+	@Column (name="install_path")
+	private String installPath;
+
+	@Override
+    public long getHostId() {
+		return hostId;
+	}
+
+	public void setHostId(long hostId) {
+		this.hostId = hostId;
+	}
+
+	@Override
+    public long getId() {
+		return id;
+	}
+
+
+	public String getUuid() {
+        return uuid;
+    }
+
+    @Override
+    public Date getCreated() {
+		return created;
+	}
+
+	@Override
+    public Date getLastUpdated() {
+		return lastUpdated;
+	}
+
+	public void setLastUpdated(Date date) {
+	    lastUpdated = date;
+	}
+
+	public UploadVO(long hostId, long templateId) {
+		super();
+		this.hostId = hostId;
+		this.typeId = templateId;
+		this.uuid = UUID.randomUUID().toString();
+	}
+
+	public UploadVO(long hostId, long typeId, Date lastUpdated,
+			Status uploadState, Type type,
+			String uploadUrl, Mode mode) {
+		super();
+		this.hostId = hostId;
+		this.typeId = typeId;
+		this.lastUpdated = lastUpdated;
+		this.uploadState = uploadState;
+		this.mode = mode;
+		this.type = type;
+		this.uploadUrl = uploadUrl;
+        this.uuid = UUID.randomUUID().toString();
+	}
+
+	public UploadVO(long hostId, long typeId, Date lastUpdated,
+            Status uploadState, int uploadPercent, Type type,
+            Mode mode) {
+        super();
+        this.hostId = hostId;
+        this.typeId = typeId;
+        this.lastUpdated = lastUpdated;
+        this.uploadState = uploadState;
+        this.uploadPercent = uploadPercent;
+        this.type = type;
+        this.mode = mode;
+        this.uuid = UUID.randomUUID().toString();
+
+    }
+
+	protected UploadVO() {
+	}
+
+	public UploadVO(Long uploadId) {
+		this.id = uploadId;
+	}
+
+	public void setErrorString(String errorString) {
+		this.errorString = errorString;
+	}
+
+	@Override
+    public String getErrorString() {
+		return errorString;
+	}
+
+	public void setJobId(String jobId) {
+		this.jobId = jobId;
+	}
+
+	@Override
+    public String getJobId() {
+		return jobId;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof UploadVO) {
+			UploadVO other = (UploadVO)obj;
+		   return (this.typeId==other.getTypeId() && this.hostId==other.getHostId() && this.type == other.getType());
+		}
+		return false;
+	}
+
+	@Override
+	public int hashCode() {
+		return NumbersUtil.hash(id);
+	}
+
+	@Override
+    public int getUploadPercent() {
+		return uploadPercent;
+	}
+
+	public void setUploadPercent(int uploadPercent) {
+		this.uploadPercent = uploadPercent;
+	}
+
+	@Override
+    public Status getUploadState() {
+		return uploadState;
+	}
+
+	public void setUploadState(Status uploadState) {
+		this.uploadState = uploadState;
+	}
+
+	@Override
+    public long getTypeId() {
+		return typeId;
+	}
+
+	public void setTypeId(long typeId) {
+		this.typeId = typeId;
+	}
+
+	@Override
+    public Type getType() {
+		return type;
+	}
+
+	public void setType(Type type) {
+		this.type = type;
+	}
+
+	@Override
+    public Mode getMode() {
+        return mode;
+    }
+
+    public void setMode(Mode mode) {
+        this.mode = mode;
+    }
+
+    @Override
+    public String getUploadUrl() {
+		return uploadUrl;
+	}
+
+	public void setUploadUrl(String uploadUrl) {
+		this.uploadUrl = uploadUrl;
+	}
+
+	@Override
+    public void setId(Long id) {
+		this.id = id;
+	}
+
+	@Override
+    public void setCreated(Date created) {
+		this.created = created;
+	}
+
+    @Override
+    public String getInstallPath() {
+        return installPath;
+    }
+
+    @Override
+    public void setInstallPath(String installPath) {
+        this.installPath = installPath;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/VMTemplateDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VMTemplateDetailVO.java b/engine/schema/src/com/cloud/storage/VMTemplateDetailVO.java
new file mode 100644
index 0000000..c007802
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/VMTemplateDetailVO.java
@@ -0,0 +1,84 @@
+// 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="vm_template_details")
+public class VMTemplateDetailVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+    
+    @Column(name="template_id")
+    private long templateId;
+    
+    @Column(name="name")
+    private String name;
+    
+    @Column(name="value", length=1024)
+    private String value;
+	
+    public VMTemplateDetailVO() {}
+    
+    public VMTemplateDetailVO(long templateId, String name, String value) {
+    	this.templateId = templateId;
+    	this.name = name;
+    	this.value = value;
+    }
+
+	public long getId() {
+		return id;
+	}
+
+	public long getTemplateId() {
+		return templateId;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public String getValue() {
+		return value;
+	}
+
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	public void setTemplateId(long templateId) {
+		this.templateId = templateId;
+	}
+
+	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/c11dbad9/engine/schema/src/com/cloud/storage/VMTemplateHostVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VMTemplateHostVO.java b/engine/schema/src/com/cloud/storage/VMTemplateHostVO.java
new file mode 100755
index 0000000..b8dfc41
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/VMTemplateHostVO.java
@@ -0,0 +1,322 @@
+// 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.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 com.cloud.utils.db.GenericDaoBase;
+
+/**
+ * Join table for storage hosts and templates
+ *
+ */
+@Entity
+@Table(name="template_host_ref")
+public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc, DataObjectInStore {
+	@Id
+	@GeneratedValue(strategy=GenerationType.IDENTITY)
+	Long id;
+	
+	@Column(name="host_id")
+	private long hostId;
+	
+	@Column(name="template_id")
+	private long templateId;
+	
+	@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;
+    
+    
+	@Override
+    public String getInstallPath() {
+		return installPath;
+	}
+
+	public long getHostId() {
+		return hostId;
+	}
+
+	public void setHostId(long hostId) {
+		this.hostId = hostId;
+	}
+
+	@Override
+    public long getTemplateId() {
+		return templateId;
+	}
+
+	@Override
+    public void setTemplateId(long templateId) {
+		this.templateId = templateId;
+	}
+
+	@Override
+    public int getDownloadPercent() {
+		return downloadPercent;
+	}
+
+	@Override
+    public void setDownloadPercent(int downloadPercent) {
+		this.downloadPercent = downloadPercent;
+	}
+
+	@Override
+    public void setDownloadState(Status downloadState) {
+		this.downloadState = downloadState;
+	}
+
+	@Override
+    public long getId() {
+		return id;
+	}
+
+	@Override
+    public Date getCreated() {
+		return created;
+	}
+
+	@Override
+    public Date getLastUpdated() {
+		return lastUpdated;
+	}
+	
+	@Override
+    public void setLastUpdated(Date date) {
+	    lastUpdated = date;
+	}
+	
+	@Override
+    public void setInstallPath(String installPath) {
+	    this.installPath = installPath;
+	}
+
+	@Override
+    public Status getDownloadState() {
+		return downloadState;
+	}
+
+	public VMTemplateHostVO(long hostId, long templateId) {
+		super();
+		this.hostId = hostId;
+		this.templateId = templateId;
+		this.state = ObjectInDataStoreStateMachine.State.Allocated;
+	}
+
+	public VMTemplateHostVO(long hostId, long templateId, Date lastUpdated,
+			int downloadPercent, Status downloadState,
+			String localDownloadPath, String errorString, String jobId,
+			String installPath, String downloadUrl) {
+		super();
+		this.hostId = hostId;
+		this.templateId = templateId;
+		this.lastUpdated = lastUpdated;
+		this.downloadPercent = downloadPercent;
+		this.downloadState = downloadState;
+		this.localDownloadPath = localDownloadPath;
+		this.errorString = errorString;
+		this.jobId = jobId;
+		this.installPath = installPath;
+		this.setDownloadUrl(downloadUrl);
+	}
+
+	protected VMTemplateHostVO() {
+		
+	}
+
+	@Override
+    public void setLocalDownloadPath(String localPath) {
+		this.localDownloadPath = localPath;
+	}
+
+	@Override
+    public String getLocalDownloadPath() {
+		return localDownloadPath;
+	}
+
+	@Override
+    public void setErrorString(String errorString) {
+		this.errorString = errorString;
+	}
+
+	@Override
+    public String getErrorString() {
+		return errorString;
+	}
+
+	@Override
+    public void setJobId(String jobId) {
+		this.jobId = jobId;
+	}
+
+	@Override
+    public String getJobId() {
+		return jobId;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof VMTemplateHostVO) {
+			VMTemplateHostVO other = (VMTemplateHostVO)obj;
+			return (this.templateId==other.getTemplateId() && this.hostId==other.getHostId());		   
+		}
+		return false;
+	}
+
+	@Override
+	public int hashCode() {
+		Long tid = new Long(templateId);
+		Long hid = new Long(hostId);
+		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;
+	}
+	
+	@Override
+    public long getTemplateSize() {
+	    return -1;
+	}
+	
+	@Override
+    public String toString() {
+	    return new StringBuilder("TmplHost[").append(id).append("-").append(templateId).append("-").append(hostId).append(installPath).append("]").toString();
+	}
+
+    @Override
+    public ObjectInDataStoreStateMachine.State getState() {
+        // TODO Auto-generated method stub
+        return this.state;
+    }
+    
+    public long getUpdatedCount() {
+        return this.updatedCount;
+    }
+    
+    public void incrUpdatedCount() {
+        this.updatedCount++;
+    }
+
+    public void decrUpdatedCount() {
+        this.updatedCount--;
+    }
+    
+    public Date getUpdated() {
+        return updated;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/engine/schema/src/com/cloud/storage/VMTemplateS3VO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VMTemplateS3VO.java b/engine/schema/src/com/cloud/storage/VMTemplateS3VO.java
new file mode 100644
index 0000000..02f3ff5
--- /dev/null
+++ b/engine/schema/src/com/cloud/storage/VMTemplateS3VO.java
@@ -0,0 +1,204 @@
+/*
+ * 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 com.cloud.utils.db.GenericDaoBase;
+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;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+@Entity
+@Table(name = "template_s3_ref")
+public class VMTemplateS3VO implements InternalIdentity {
+
+    public static final String S3_ID_COLUMN_NAME = "s3_id";
+
+    public static final String TEMPLATE_ID_COLUMN_NAME = "template_id";
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private long id;
+
+    @Column(name = S3_ID_COLUMN_NAME)
+    private long s3Id;
+
+    @Column(name = TEMPLATE_ID_COLUMN_NAME)
+    private long templateId;
+
+    @Column(name = GenericDaoBase.CREATED_COLUMN)
+    private Date created;
+
+    @Column(name = "size")
+    private Long size;
+
+    @Column(name = "physical_size")
+    private Long physicalSize;
+
+    public VMTemplateS3VO() {
+        super();
+    }
+
+    public VMTemplateS3VO(final long s3Id, final long templateId,
+            final Date created, final Long size, final Long physicalSize) {
+
+        super();
+
+        this.s3Id = s3Id;
+        this.templateId = templateId;
+        this.created = created;
+        this.size = size;
+        this.physicalSize = physicalSize;
+
+    }
+
+    @Override
+    public boolean equals(final Object thatObject) {
+
+        if (this == thatObject) {
+            return true;
+        }
+
+        if (thatObject == null || getClass() != thatObject.getClass()) {
+            return false;
+        }
+
+        final VMTemplateS3VO thatVMTemplateS3VO = (VMTemplateS3VO) thatObject;
+
+        if (this.id != thatVMTemplateS3VO.id) {
+            return false;
+        }
+
+        if (this.s3Id != thatVMTemplateS3VO.s3Id) {
+            return false;
+        }
+
+        if (this.templateId != thatVMTemplateS3VO.templateId) {
+            return false;
+        }
+
+        if (this.created != null ? !created.equals(thatVMTemplateS3VO.created)
+                : thatVMTemplateS3VO.created != null) {
+            return false;
+        }
+
+        if (this.physicalSize != null ? !physicalSize
+                .equals(thatVMTemplateS3VO.physicalSize)
+                : thatVMTemplateS3VO.physicalSize != null) {
+            return false;
+        }
+
+        if (this.size != null ? !size.equals(thatVMTemplateS3VO.size)
+                : thatVMTemplateS3VO.size != null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+
+        int result = (int) (this.id ^ (this.id >>> 32));
+
+        result = 31 * result + (int) (this.s3Id ^ (this.s3Id >>> 32));
+        result = 31 * result
+                + (int) (this.templateId ^ (this.templateId >>> 32));
+        result = 31 * result
+                + (this.created != null ? this.created.hashCode() : 0);
+        result = 31 * result + (this.size != null ? this.size.hashCode() : 0);
+        result = 31
+                * result
+                + (this.physicalSize != null ? this.physicalSize.hashCode() : 0);
+
+        return result;
+
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public void setId(final long id) {
+        this.id = id;
+    }
+
+    public long getS3Id() {
+        return this.s3Id;
+    }
+
+    public void setS3Id(final long s3Id) {
+        this.s3Id = s3Id;
+    }
+
+    public long getTemplateId() {
+        return this.templateId;
+    }
+
+    public void setTemplateId(final long templateId) {
+        this.templateId = templateId;
+    }
+
+    public Date getCreated() {
+        return this.created;
+    }
+
+    public void setCreated(final Date created) {
+        this.created = created;
+    }
+
+    public Long getSize() {
+        return this.size;
+    }
+
+    public void setSize(final Long size) {
+        this.size = size;
+    }
+
+    public Long getPhysicalSize() {
+        return this.physicalSize;
+    }
+
+    public void setPhysicalSize(final Long physicalSize) {
+        this.physicalSize = physicalSize;
+    }
+
+    @Override
+    public String toString() {
+
+        final StringBuilder stringBuilder = new StringBuilder(
+                "VMTemplateS3VO [ id: ").append(id).append(", created: ")
+                .append(DateFormat.getDateTimeInstance().format(created))
+                .append(", physicalSize: ").append(physicalSize)
+                .append(", size: ").append(size).append(", templateId: ")
+                .append(templateId).append(", s3Id: ").append(s3Id)
+                .append(" ]");
+
+        return stringBuilder.toString();
+
+    }
+
+}


Mime
View raw message