http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/db/ImageDataVO.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/db/ImageDataVO.java 
b/platform/storage/src/org/apache/cloudstack/storage/image/db/ImageDataVO.java
new file mode 100644
index 0000000..d50be88
--- /dev/null
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/image/db/ImageDataVO.java
@@ -0,0 +1,381 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.db;
+
+import java.util.Date;
+import java.util.Map;
+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 javax.persistence.Transient;
+
+import com.cloud.api.Identity;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.Storage;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.Storage.TemplateType;
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name="vm_template")
+public class ImageDataVO implements Identity {
+    @Id
+    @TableGenerator(name="vm_template_sq", table="sequence", 
pkColumnName="name", valueColumnName="value", pkColumnValue="vm_template_seq", 
allocationSize=1)
+    @Column(name="id", nullable = false)
+    private long id;
+
+    @Column(name="format")
+    private String format;
+
+    @Column(name="unique_name")
+    private String uniqueName;
+
+    @Column(name="name")
+    private String name = null;
+
+    @Column(name="public")
+    private boolean publicTemplate = true;
+
+    @Column(name="featured")
+    private boolean featured;
+
+    @Column(name="type")
+    private Storage.TemplateType templateType;
+
+    @Column(name="url")
+    private String url = null;
+
+    @Column(name="hvm")
+    private boolean requiresHvm;
+
+    @Column(name="bits")
+    private int bits;
+
+    @Temporal(value=TemporalType.TIMESTAMP)
+    @Column(name=GenericDao.CREATED_COLUMN)
+    private Date created = null;
+
+    @Column(name=GenericDao.REMOVED)
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date removed;
+
+    @Column(name="account_id")
+    private long accountId;
+
+    @Column(name="checksum")
+    private String checksum;    
+
+    @Column(name="display_text", length=4096)
+    private String displayText;
+
+    @Column(name="enable_password")
+    private boolean enablePassword;
+
+    @Column(name="guest_os_id")
+    private long guestOSId;
+
+    @Column(name="bootable")
+    private boolean bootable = true;
+
+    @Column(name="prepopulate")
+    private boolean prepopulate = false;
+
+    @Column(name="cross_zones")
+    private boolean crossZones = false;
+
+    @Column(name="hypervisor_type")
+    @Enumerated(value=EnumType.STRING)
+    private HypervisorType hypervisorType;
+
+    @Column(name="extractable")
+    private boolean extractable = true;
+
+    @Column(name="source_template_id")
+    private Long sourceTemplateId;
+
+    @Column(name="template_tag")
+    private String templateTag;
+    
+    @Column(name="uuid")
+    private String uuid;
+    
+    @Column(name="sort_key")
+    private int sortKey;
+    
+    @Column(name="enable_sshkey")
+    private boolean enableSshKey;
+    
+    @Transient
+    Map details;
+
+
+    public String getUniqueName() {
+        return uniqueName;
+    }
+
+    public void setUniqueName(String uniqueName) {
+        this.uniqueName = uniqueName;
+    }
+
+    protected ImageDataVO() {
+       this.uuid = UUID.randomUUID().toString();
+    }
+
+    public boolean getEnablePassword() {
+        return enablePassword;
+    }
+
+    public String getFormat() {
+        return format;
+    }
+
+    public void setEnablePassword(boolean enablePassword) {
+        this.enablePassword = enablePassword;
+    }
+
+    public void setFormat(String format) {
+        this.format = format;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public TemplateType getTemplateType() {
+        return templateType;
+    }
+
+    public void setTemplateType(TemplateType type) {
+        this.templateType = type;
+    }
+
+    public boolean requiresHvm() {
+        return requiresHvm;
+    }
+
+    public int getBits() {
+        return bits;
+    }
+
+    public void setBits(int bits) {
+        this.bits = bits;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public boolean isPublicTemplate() {
+        return publicTemplate;
+    }
+
+    public void setPublicTemplate(boolean publicTemplate) {
+        this.publicTemplate = publicTemplate;
+    }
+
+    public boolean isFeatured() {
+        return featured;
+    }
+
+    public void setFeatured(boolean featured) {
+        this.featured = featured;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public long getAccountId() {
+        return accountId;
+    }
+
+    public String getChecksum() {
+        return checksum;
+    }
+
+    public void setChecksum(String checksum) {
+        this.checksum = checksum;
+    }
+
+    public String getDisplayText() {
+        return displayText;
+    }
+
+    public void setDisplayText(String displayText) {
+        this.displayText = displayText;
+    }
+
+    public long getGuestOSId() {
+        return guestOSId;
+    }
+
+    public void setGuestOSId(long guestOSId) {
+        this.guestOSId = guestOSId;
+    }
+
+    public boolean isBootable() {
+        return bootable;
+    }
+
+    public void setBootable(boolean bootable) {
+        this.bootable = bootable;
+    }
+
+    public void setPrepopulate(boolean prepopulate) {
+        this.prepopulate = prepopulate;
+    }
+
+    public boolean isPrepopulate() {
+        return prepopulate;
+    }
+
+    public void setCrossZones(boolean crossZones) {
+        this.crossZones = crossZones;
+    }
+
+    public boolean isCrossZones() {
+        return crossZones;
+    }
+
+    public HypervisorType getHypervisorType() {
+        return hypervisorType;
+    }
+
+    public void setHypervisorType(HypervisorType hyperType) {
+        hypervisorType = hyperType;
+    }
+
+    public boolean isExtractable() {
+        return extractable;
+    }
+
+    public void setExtractable(boolean extractable) {
+        this.extractable = extractable;
+    }
+
+    public Long getSourceTemplateId() {
+        return sourceTemplateId;
+    }
+
+    public void setSourceTemplateId(Long sourceTemplateId) {
+        this.sourceTemplateId = sourceTemplateId;
+    }
+
+    public String getTemplateTag() {
+        return templateTag;
+    }    
+
+    public void setTemplateTag(String templateTag) {
+        this.templateTag = templateTag;
+    }   
+
+    public long getDomainId() {
+        return -1;
+    }
+    
+    @Override
+    public String getUuid() {
+       return this.uuid;
+    }
+    
+    public void setUuid(String uuid) {
+       this.uuid = uuid;
+    }
+    
+    public Map getDetails() {
+       return this.details;
+    }
+    
+    public void setDetails(Map details) {
+       this.details = details;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that ) {
+            return true;
+        }
+        if (!(that instanceof VMTemplateVO)){
+            return false;
+        }
+        VMTemplateVO other = (VMTemplateVO)that;
+
+        return ((this.getUniqueName().equals(other.getUniqueName())));         
+    }
+
+    @Override
+    public int hashCode() {
+        return uniqueName.hashCode();
+    }
+
+    @Transient
+    String toString;
+    @Override
+    public String toString() {
+        if (toString == null) {
+            toString = new 
StringBuilder("Tmpl[").append(id).append("-").append(format).append("-").append(uniqueName).toString();
+        }
+        return toString;
+    }
+
+    public void setRemoved(Date removed) {
+        this.removed = removed;
+    }
+    
+    public void setSortKey(int key) {
+       sortKey = key;
+    }
+    
+    public int getSortKey() {
+       return sortKey;
+    }
+
+       public boolean getEnableSshKey() {
+               return enableSshKey;
+       }
+       
+       public void setEnableSshKey(boolean enable) {
+               enableSshKey = enable;
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/format/BAREMETAL.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/format/BAREMETAL.java
 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/BAREMETAL.java
new file mode 100644
index 0000000..c3de2f1
--- /dev/null
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/BAREMETAL.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.format;
+
+import org.apache.cloudstack.storage.BaseType;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BAREMETAL extends BaseType implements ImageFormat {
+       private final String type = "BAREMETAL";
+       @Override
+       public String toString() {
+               return type;
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/format/ISO.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/format/ISO.java 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/ISO.java
new file mode 100644
index 0000000..f27d16b
--- /dev/null
+++ b/platform/storage/src/org/apache/cloudstack/storage/image/format/ISO.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.format;
+
+import org.apache.cloudstack.storage.BaseType;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ISO extends BaseType implements ImageFormat {
+       private final String type = "ISO";
+       @Override
+       public String toString() {
+               return type;
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/format/ImageFormat.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/format/ImageFormat.java
 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/ImageFormat.java
new file mode 100644
index 0000000..f02694a
--- /dev/null
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/ImageFormat.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.image.format;
+
+public interface ImageFormat {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java
 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java
new file mode 100644
index 0000000..6ecb9b0
--- /dev/null
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.format;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class ImageFormatHelper {
+       private static List<ImageFormat> formats;
+       private static final ImageFormat defaultFormat = new Unknown();
+       @Inject
+       public void setFormats(List<ImageFormat> formats) {
+               ImageFormatHelper.formats = formats;
+       }
+       
+       public static ImageFormat getFormat(String format) {
+               for(ImageFormat fm : formats) {
+                       if (fm.equals(format)) {
+                               return fm;
+                       }
+               }
+               return ImageFormatHelper.defaultFormat;
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/format/OVA.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/format/OVA.java 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/OVA.java
new file mode 100644
index 0000000..46f77a0
--- /dev/null
+++ b/platform/storage/src/org/apache/cloudstack/storage/image/format/OVA.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.format;
+
+import org.apache.cloudstack.storage.BaseType;
+import org.springframework.stereotype.Component;
+
+@Component
+public class OVA extends BaseType implements ImageFormat {
+       private final String type = "OVA";
+       @Override
+       public String toString() {
+               return type;
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/format/QCOW2.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/format/QCOW2.java 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/QCOW2.java
new file mode 100644
index 0000000..9e13ebb
--- /dev/null
+++ b/platform/storage/src/org/apache/cloudstack/storage/image/format/QCOW2.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.format;
+
+import org.apache.cloudstack.storage.BaseType;
+import org.springframework.stereotype.Component;
+
+@Component("imageformat_qcow2")
+public class QCOW2 extends BaseType implements ImageFormat {
+       private final String type = "QCOW2";
+       @Override
+       public String toString() {
+               return type;
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/format/Unknown.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/format/Unknown.java 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/Unknown.java
new file mode 100644
index 0000000..341be64
--- /dev/null
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/Unknown.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.format;
+
+import org.apache.cloudstack.storage.BaseType;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Unknown extends BaseType implements ImageFormat {
+       private final String type = "Unknown";
+       
+       @Override
+       public String toString() {
+               return type;
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/format/VHD.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/format/VHD.java 
b/platform/storage/src/org/apache/cloudstack/storage/image/format/VHD.java
new file mode 100644
index 0000000..4a02e5f
--- /dev/null
+++ b/platform/storage/src/org/apache/cloudstack/storage/image/format/VHD.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.format;
+
+import org.apache.cloudstack.storage.BaseType;
+
+public class VHD extends BaseType implements ImageFormat {
+       private final String type = "VHD";
+       @Override
+       public String toString() {
+               return type;
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
 
b/platform/storage/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
new file mode 100644
index 0000000..42933f4
--- /dev/null
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/image/provider/ImageDataStoreProvider.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.image.provider;
+
+import org.apache.cloudstack.storage.image.store.ImageDataStore;
+
+public interface ImageDataStoreProvider {
+       ImageDataStore getImageDataStore(long imageStoreId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/image/store/ImageDataStore.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/image/store/ImageDataStore.java
 
b/platform/storage/src/org/apache/cloudstack/storage/image/store/ImageDataStore.java
new file mode 100644
index 0000000..db7c265
--- /dev/null
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/image/store/ImageDataStore.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.image.store;
+
+public interface ImageDataStore {
+       
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManagerImpl.java
 
b/platform/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManagerImpl.java
index 6faf6d7..2cae6a8 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManagerImpl.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/manager/PrimaryDataStoreManagerImpl.java
@@ -26,6 +26,7 @@ import 
org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
 import 
org.apache.cloudstack.platform.subsystem.api.storage.DataStore.StoreType;
 import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreLifeCycle;
 import org.apache.cloudstack.platform.subsystem.api.storage.StorageProvider;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
 
 import com.cloud.dc.ClusterVO;
 import com.cloud.dc.DataCenterVO;
@@ -126,4 +127,16 @@ public class PrimaryDataStoreManagerImpl implements 
PrimaryDataStoreManager {
         return spool;
        }
 
+       @Override
+       public PrimaryDataStore addDataStore(long zoneId, long podId, long 
clusterId, long hostId, String URI, String storageType, String poolName, String 
storageProviderName, Map<String, String> params) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public PrimaryDataStore getDataStore(String id) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/volume/Volume.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/volume/Volume.java 
b/platform/storage/src/org/apache/cloudstack/storage/volume/Volume.java
index fb1c37d..35eaa3b 100644
--- a/platform/storage/src/org/apache/cloudstack/storage/volume/Volume.java
+++ b/platform/storage/src/org/apache/cloudstack/storage/volume/Volume.java
@@ -2,19 +2,23 @@ package org.apache.cloudstack.storage.volume;
 
 import javax.inject.Inject;
 
-import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStoreInfo;
 import org.apache.cloudstack.storage.volume.db.VolumeDao;
 import org.apache.cloudstack.storage.volume.db.VolumeVO;
 import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
 import org.apache.cloudstack.storage.volume.disktype.VolumeDiskTypeHelper;
 import org.apache.cloudstack.storage.volume.type.VolumeType;
 import org.apache.cloudstack.storage.volume.type.VolumeTypeHelper;
+import org.apache.log4j.Logger;
 
-import com.cloud.utils.fsm.StateObject;
+import com.cloud.utils.fsm.NoTransitionException;
+import com.cloud.utils.fsm.StateMachine2;
 
-public class Volume implements StateObject<VolumeState> {
+public class Volume {
+       private static final Logger s_logger = Logger.getLogger(Volume.class);
        protected VolumeVO volumeVO;
+       private StateMachine2<VolumeState, VolumeEvent, VolumeVO> 
_volStateMachine;
        protected PrimaryDataStore dataStore;
        @Inject
        VolumeDiskTypeHelper diskTypeHelper;
@@ -28,7 +32,30 @@ public class Volume implements StateObject<VolumeState> {
                this.dataStore = dataStore;
        }
        
-       @Override
+       public String getUuid() {
+               return volumeVO.getUuid();
+       }
+       
+       public void setUuid(String uuid) {
+               volumeVO.setUuid(uuid);
+       }
+       
+       public String getPath() {
+               return volumeVO.getPath();
+       }
+       
+       public String getTemplateUuid() {
+               return null;
+       }
+       
+       public String getTemplatePath() {
+               return null;
+       }
+       
+       public PrimaryDataStoreInfo getDataStoreInfo() {
+               return dataStore.getDataStoreInfo();
+       }
+       
        public VolumeState getState() {
                return volumeVO.getState();
        }
@@ -49,10 +76,24 @@ public class Volume implements StateObject<VolumeState> {
                return volumeTypeHelper.getType(volumeVO.getVolumeType());
        }
        
+       public long getVolumeId() {
+               return volumeVO.getId();
+       }
+       
        public void setVolumeDiskType(VolumeDiskType type) {
                volumeVO.setDiskType(type.toString());
        }
        
+       public boolean stateTransit(VolumeEvent event) {
+               boolean result = false;
+               try {
+                       result = _volStateMachine.transitTo(volumeVO, event, 
null, volumeDao);
+               } catch (NoTransitionException e) {
+                       s_logger.debug("Failed to transit volume: " + 
this.getVolumeId() + ", due to: " + e.toString());
+               }
+               return result;
+       }
+       
        public void update() {
                volumeDao.update(volumeVO.getId(), volumeVO);
                volumeVO = volumeDao.findById(volumeVO.getId());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeInfo.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeInfo.java 
b/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeInfo.java
new file mode 100644
index 0000000..0c6981a
--- /dev/null
+++ b/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeInfo.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.volume;
+
+import org.apache.cloudstack.storage.datastore.PrimaryDataStoreInfo;
+import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
+import org.apache.cloudstack.storage.volume.type.VolumeType;
+
+public class VolumeInfo {
+       private long size;
+       private String uuid;
+       private String path;
+       private PrimaryDataStoreInfo dataStoreInfo;
+       private String baseTemplateUuid;
+       private String baseTemplatePath;
+       private VolumeType type;
+       private VolumeDiskType diskType;
+       
+       public VolumeInfo(Volume volume) {
+               this.size = volume.getSize();
+               this.uuid = volume.getUuid();
+               this.baseTemplatePath = volume.getTemplatePath();
+               this.baseTemplateUuid = volume.getTemplateUuid();
+               this.dataStoreInfo = volume.getDataStoreInfo();
+               this.diskType = volume.getDiskType();
+               this.type = volume.getType();
+       }
+       
+       public long getSize() {
+               return this.size;
+       }
+       
+       public String getUuid() {
+               return this.uuid;
+       }
+       
+       public String getPath() {
+               return this.path;
+       }
+       
+       public PrimaryDataStoreInfo getDataStore() {
+               return this.dataStoreInfo;
+       }
+       
+       public String getTemplateUuid() {
+               return this.baseTemplateUuid;
+       }
+       
+       public String getTemplatePath() {
+               return this.baseTemplatePath;
+       }
+       
+       public VolumeType getType() {
+               return this.type;
+       }
+       
+       public VolumeDiskType getDiskType() {
+               return this.diskType;
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java 
b/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
index 79aa645..63e247c 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeService.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cloudstack.storage.volume;
 
+import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
 import org.apache.cloudstack.storage.volume.type.VolumeType;
 
 public interface VolumeService {
@@ -34,7 +35,7 @@ public interface VolumeService {
      *            
      * @return the volume object
      */
-    Volume createVolume(long volumeId, long dataStoreId);
+    Volume createVolume(long volumeId, long dataStoreId, VolumeDiskType 
diskType);
 
     /**
      * Delete volume

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
 
b/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index a44f82d..145813f 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -20,7 +20,10 @@ package org.apache.cloudstack.storage.volume;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreManager;
 import org.apache.cloudstack.storage.volume.db.VolumeDao;
+import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
 import org.apache.cloudstack.storage.volume.type.VolumeType;
 import org.springframework.stereotype.Service;
 
@@ -30,10 +33,12 @@ import com.cloud.utils.db.DB;
 public class VolumeServiceImpl implements VolumeService {
        @Inject
        VolumeDao volDao;
+       @Inject
+       PrimaryDataStoreManager dataStoreMgr;
        @Override
-       public Volume createVolume(long volumeId, long dataStoreId) {
-               // TODO Auto-generated method stub
-               return null;
+       public Volume createVolume(long volumeId, long dataStoreId, 
VolumeDiskType diskType) {
+               PrimaryDataStore dataStore = 
dataStoreMgr.getPrimaryDataStore(dataStoreId);
+               return dataStore.createVolume(volumeId, diskType);
        }
 
        @DB

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeState.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeState.java 
b/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeState.java
index 6b81f00..f2ebafa 100644
--- a/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeState.java
+++ b/platform/storage/src/org/apache/cloudstack/storage/volume/VolumeState.java
@@ -18,6 +18,8 @@
  */
 package org.apache.cloudstack.storage.volume;
 
+import org.apache.cloudstack.storage.volume.db.VolumeVO;
+
 import com.cloud.utils.fsm.StateMachine2;
 
 public enum VolumeState {
@@ -36,7 +38,7 @@ public enum VolumeState {
         _description = description;
     }
 
-    public static StateMachine2<VolumeState, VolumeEvent, Volume> 
getStateMachine() {
+    public static StateMachine2<VolumeState, VolumeEvent, VolumeVO> 
getStateMachine() {
         return s_fsm;
     }
 
@@ -44,7 +46,7 @@ public enum VolumeState {
         return _description;
     }
 
-    private final static StateMachine2<VolumeState, VolumeEvent, Volume> s_fsm 
= new StateMachine2<VolumeState, VolumeEvent, Volume>();
+    private final static StateMachine2<VolumeState, VolumeEvent, VolumeVO> 
s_fsm = new StateMachine2<VolumeState, VolumeEvent, VolumeVO>();
     static {
         s_fsm.addTransition(Allocated, VolumeEvent.CreateRequested, Creating);
         s_fsm.addTransition(Allocated, VolumeEvent.DestroyRequested, Destroy);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java 
b/platform/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
index 7f2cede..48da123 100644
--- a/platform/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
+++ b/platform/storage/src/org/apache/cloudstack/storage/volume/db/VolumeVO.java
@@ -39,10 +39,11 @@ import com.cloud.api.Identity;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateObject;
 
 @Entity
 @Table(name = "volumes")
-public class VolumeVO implements Identity {
+public class VolumeVO implements Identity, StateObject<VolumeState>{
  @Id
  @TableGenerator(name = "volume_sq", table = "sequence", pkColumnName = 
"name", valueColumnName = "value", pkColumnValue = "volume_seq", allocationSize 
= 1)
  @GeneratedValue(strategy = GenerationType.TABLE)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/volume/disktype/VolumeDiskTypeHelper.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/volume/disktype/VolumeDiskTypeHelper.java
 
b/platform/storage/src/org/apache/cloudstack/storage/volume/disktype/VolumeDiskTypeHelper.java
index 666f89b..c51e25f 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/volume/disktype/VolumeDiskTypeHelper.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/volume/disktype/VolumeDiskTypeHelper.java
@@ -8,17 +8,22 @@ import org.springframework.stereotype.Component;
 
 @Component
 public class VolumeDiskTypeHelper {
+       
+       static private List<VolumeDiskType> diskTypes;
+       static final private VolumeDiskType defaultType = new Unknown();
+       
        @Inject
-       protected List<VolumeDiskType> diskTypes;
-       protected VolumeDiskType defaultType = new Unknown();
+       public void setDiskTypes(List<VolumeDiskType> diskTypes) {
+               VolumeDiskTypeHelper.diskTypes = diskTypes;
+       }
        
-       public VolumeDiskType getDiskType(String type) {
+       public static VolumeDiskType getDiskType(String type) {
                for (VolumeDiskType diskType : diskTypes) {
                        if (diskType.equals(type)) {
                                return diskType;
                        }
                }
                
-               return defaultType;
+               return VolumeDiskTypeHelper.defaultType;
        }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeType.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeType.java
 
b/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeType.java
index 6f11b09..e423a5e 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeType.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeType.java
@@ -19,5 +19,4 @@
 package org.apache.cloudstack.storage.volume.type;
 
 public interface VolumeType {
-       boolean equals(String type);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeTypeBase.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeTypeBase.java
 
b/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeTypeBase.java
index 3597517..830873c 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeTypeBase.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeTypeBase.java
@@ -4,12 +4,23 @@ public class VolumeTypeBase implements VolumeType {
        protected String type = "Unknown";
        
        @Override
-       public boolean equals(String type) {
-               if (this.type.equalsIgnoreCase(type)) {
+       public boolean equals(Object that) {
+               if (this == that) {
                        return true;
+               }
+               if (that instanceof String) {
+                       if (this.toString().equalsIgnoreCase((String)that)) {
+                               return true;
+                       }
+               } else if (that instanceof VolumeTypeBase) {
+                       VolumeTypeBase th = (VolumeTypeBase)that;
+                       if (this.toString().equalsIgnoreCase(th.toString())) {
+                               return true;
+                       }
                } else {
                        return false;
                }
+               return false;
        }
        
        @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeTypeHelper.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeTypeHelper.java
 
b/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeTypeHelper.java
index 8f56758..9443475 100644
--- 
a/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeTypeHelper.java
+++ 
b/platform/storage/src/org/apache/cloudstack/storage/volume/type/VolumeTypeHelper.java
@@ -8,17 +8,21 @@ import org.springframework.stereotype.Component;
 
 @Component
 public class VolumeTypeHelper {
+       static private List<VolumeType> types;
+       private static VolumeType defaultType = new Unknown();
+       
        @Inject
-       private List<VolumeType> types;
-       private VolumeType defaultType = new Unknown();
+       public void setTypes(List<VolumeType> types) {
+               VolumeTypeHelper.types = types;
+       }
        
-       public VolumeType getType(String type) {
+       public static VolumeType getType(String type) {
                for (VolumeType ty : types) {
                        if (ty.equals(type)) {
                                return ty;
                        }
                }
-               return defaultType;
+               return VolumeTypeHelper.defaultType;
        }
        
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/platform/storage/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
----------------------------------------------------------------------
diff --git 
a/platform/storage/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
 
b/platform/storage/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
index ca3a366..8771d02 100644
--- 
a/platform/storage/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
+++ 
b/platform/storage/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
@@ -28,12 +28,20 @@ import javax.inject.Inject;
 import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
 import 
org.apache.cloudstack.storage.datastore.provider.DefaultPrimaryDatastoreProviderImpl;
 import 
org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
+import org.apache.cloudstack.storage.image.format.ISO;
+import org.apache.cloudstack.storage.image.format.ImageFormat;
+import org.apache.cloudstack.storage.image.format.ImageFormatHelper;
+import org.apache.cloudstack.storage.image.format.OVA;
+import org.apache.cloudstack.storage.image.format.Unknown;
 import org.apache.cloudstack.storage.volume.VolumeMotionService;
 import org.apache.cloudstack.storage.volume.VolumeService;
 import org.apache.cloudstack.storage.volume.db.VolumeDao;
+import org.apache.cloudstack.storage.volume.disktype.QCOW2;
 import org.apache.cloudstack.storage.volume.disktype.VHD;
 import org.apache.cloudstack.storage.volume.disktype.VMDK;
+import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
 import org.apache.cloudstack.storage.volume.disktype.VolumeDiskTypeHelper;
+import org.apache.cloudstack.storage.volume.type.Iso;
 import org.apache.cloudstack.storage.volume.type.VolumeTypeHelper;
 import org.junit.Before;
 import org.junit.Test;
@@ -60,10 +68,6 @@ public class volumeServiceTest {
        protected VolumeDao volumeDao;
        @Autowired
        protected VolumeMotionService vmotion;
-       @Autowired
-       protected VolumeTypeHelper volTypeHelper;
-       @Inject
-       protected VolumeDiskTypeHelper volDiskTypeHelper;
        @Before
        public void setUp() {
                Mockito.when(vmotion.copyVolume(null, null)).thenReturn(false);
@@ -91,22 +95,34 @@ public class volumeServiceTest {
        
        @Test
        public void test1() {
-               System.out.println(volTypeHelper.getType("Root"));
-               System.out.println(volDiskTypeHelper.getDiskType("vmdk"));
+               System.out.println(VolumeTypeHelper.getType("Root"));
+               System.out.println(VolumeDiskTypeHelper.getDiskType("vmdk"));
+               System.out.println(ImageFormatHelper.getFormat("ova"));
                assertFalse(new VMDK().equals(new VHD()));
                VMDK vmdk = new VMDK();
                assertTrue(vmdk.equals(vmdk));
                VMDK newvmdk = new VMDK();
                assertTrue(vmdk.equals(newvmdk));
+               
+               ImageFormat ova = new OVA();
+               ImageFormat iso = new ISO();
+               assertTrue(ova.equals(new OVA()));
+               assertFalse(ova.equals(iso));
+               assertTrue(ImageFormatHelper.getFormat("test").equals(new 
Unknown()));
+               
+               VolumeDiskType qcow2 = new QCOW2();
+               ImageFormat qcow2format = new 
org.apache.cloudstack.storage.image.format.QCOW2();
+               assertFalse(qcow2.equals(qcow2format));
+               
        }
        
-       @Test
+       //@Test
        public void testStaticBean() {
                DefaultPrimaryDatastoreProviderImpl provider = 
ComponentInject.inject(DefaultPrimaryDatastoreProviderImpl.class);
                assertNotNull(provider.dataStoreDao);
                
                DefaultPrimaryDataStoreImpl dpdsi = new 
DefaultPrimaryDataStoreImpl(null, null, null);
                ComponentInject.inject(dpdsi);
-               assertNotNull(dpdsi.volumeDao);
+               //assertNotNull(dpdsi.volumeDao);
        }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/server/src/com/cloud/host/dao/HostDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/host/dao/HostDao.java 
b/server/src/com/cloud/host/dao/HostDao.java
index 58bd8be..4760035 100755
--- a/server/src/com/cloud/host/dao/HostDao.java
+++ b/server/src/com/cloud/host/dao/HostDao.java
@@ -68,6 +68,7 @@ public interface HostDao extends GenericDao<HostVO, Long>, 
StateDao<Status, Stat
        HostVO findByGuid(String guid);
        
        HostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type 
type);
+       List<HostVO> findHypervisorHostInCluster(long clusterId);
 
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3423c5d7/server/src/com/cloud/host/dao/HostDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/host/dao/HostDaoImpl.java 
b/server/src/com/cloud/host/dao/HostDaoImpl.java
index ab1e77e..990aef8 100755
--- a/server/src/com/cloud/host/dao/HostDaoImpl.java
+++ b/server/src/com/cloud/host/dao/HostDaoImpl.java
@@ -73,6 +73,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> 
implements HostDao
     protected final SearchBuilder<HostVO> IdStatusSearch;
     protected final SearchBuilder<HostVO> TypeDcSearch;
     protected final SearchBuilder<HostVO> TypeDcStatusSearch;
+    protected final SearchBuilder<HostVO> TypeClusterStatusSearch;
     protected final SearchBuilder<HostVO> MsStatusSearch;
     protected final SearchBuilder<HostVO> DcPrivateIpAddressSearch;
     protected final SearchBuilder<HostVO> DcStorageIpAddressSearch;
@@ -157,7 +158,14 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, 
Long> implements HostDao
         TypeDcStatusSearch.and("status", 
TypeDcStatusSearch.entity().getStatus(), SearchCriteria.Op.EQ);
         TypeDcStatusSearch.and("resourceState", 
TypeDcStatusSearch.entity().getResourceState(), SearchCriteria.Op.EQ);
         TypeDcStatusSearch.done();
-
+        
+        TypeClusterStatusSearch = createSearchBuilder();
+        TypeClusterStatusSearch.and("type", 
TypeClusterStatusSearch.entity().getType(), SearchCriteria.Op.EQ);
+        TypeClusterStatusSearch.and("cluster", 
TypeClusterStatusSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
+        TypeClusterStatusSearch.and("status", 
TypeClusterStatusSearch.entity().getStatus(), SearchCriteria.Op.EQ);
+        TypeClusterStatusSearch.and("resourceState", 
TypeClusterStatusSearch.entity().getResourceState(), SearchCriteria.Op.EQ);
+        TypeClusterStatusSearch.done();
+        
         IdStatusSearch = createSearchBuilder();
         IdStatusSearch.and("id", IdStatusSearch.entity().getId(), 
SearchCriteria.Op.EQ);
         IdStatusSearch.and("states", IdStatusSearch.entity().getStatus(), 
SearchCriteria.Op.IN);
@@ -764,4 +772,15 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, 
Long> implements HostDao
         return findOneBy(sc);
     }
 
+       @Override
+       public List<HostVO> findHypervisorHostInCluster(long clusterId) {
+                SearchCriteria<HostVO> sc = TypeClusterStatusSearch.create();
+                sc.setParameters("type", Host.Type.Routing);
+                sc.setParameters("cluster", clusterId);
+                sc.setParameters("status", Status.Up);
+                sc.setParameters("resourceState", ResourceState.Enabled);
+               
+               return listBy(sc);
+       }
+
 }

Reply via email to