cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject git commit: updated refs/heads/master to 798d8f1
Date Sat, 10 Aug 2013 23:38:17 GMT
Updated Branches:
  refs/heads/master a6c6f4851 -> 798d8f1e4


cloudstack-4235

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/798d8f1e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/798d8f1e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/798d8f1e

Branch: refs/heads/master
Commit: 798d8f1e4b083a4ee862bd722f6359f31b242cf2
Parents: a6c6f48
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Sat Aug 10 17:37:43 2013 -0600
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Sat Aug 10 17:37:43 2013 -0600

----------------------------------------------------------------------
 .../xen/resource/CitrixResourceBase.java        | 28 +++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798d8f1e/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 610091e..978bfde 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -6462,11 +6462,6 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
         }
     }
 
-    // for about 1 GiB of physical size, about 4 MiB seems to be used for metadata
-    private long getMetadata(long physicalSize) {
-        return (long)(physicalSize * 0.00390625); // 1 GiB / 4 MiB = 0.00390625
-    }
-
     protected VDI handleSrAndVdiAttach(String iqn, String storageHostName,
             String chapInitiatorName, String chapInitiatorPassword) throws Types.XenAPIException,
XmlRpcException {
         VDI vdi = null;
@@ -6486,13 +6481,32 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             vdir.nameLabel = iqn;
             vdir.SR = sr;
             vdir.type = Types.VdiType.USER;
-            vdir.virtualSize = sr.getPhysicalSize(conn) - sr.getPhysicalUtilisation(conn)
- getMetadata(sr.getPhysicalSize(conn));
+
+            long totalSpace = sr.getPhysicalSize(conn);
+            long unavailableSpace = sr.getPhysicalUtilisation(conn);
+
+            vdir.virtualSize = totalSpace - unavailableSpace;
 
             if (vdir.virtualSize < 0) {
                 throw new CloudRuntimeException("VDI virtual size cannot be less than 0.");
             }
 
-            vdi = VDI.create(conn, vdir);
+            long maxNumberOfTries = (totalSpace / unavailableSpace >= 1) ? (totalSpace
/ unavailableSpace) : 1;
+            long tryNumber = 0;
+
+            while (tryNumber <= maxNumberOfTries) {
+                try {
+                    vdi = VDI.create(conn, vdir);
+
+                    break;
+                }
+                catch (Exception ex) {
+                    tryNumber++;
+
+                    vdir.virtualSize -= unavailableSpace;
+                }
+            }
+
         }
         else {
             vdi = sr.getVDIs(conn).iterator().next();


Mime
View raw message