You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by tu...@apache.org on 2014/03/30 20:04:21 UTC

[6/7] git commit: updated refs/heads/docker to 2ab7524

add register Docker template


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

Branch: refs/heads/docker
Commit: 018215125b05f9e7c6a40ca2bdba612398f4d82b
Parents: 234831a
Author: tuna <ng...@gmail.com>
Authored: Sat Mar 29 14:16:02 2014 +0700
Committer: tuna <ng...@gmail.com>
Committed: Sat Mar 29 15:28:38 2014 +0700

----------------------------------------------------------------------
 .../template/HypervisorTemplateAdapter.java     | 29 +++++++++++++-------
 1 file changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01821512/server/src/com/cloud/template/HypervisorTemplateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/HypervisorTemplateAdapter.java b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
index 258528a..32f1287 100755
--- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java
+++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
@@ -28,7 +28,6 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
 import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
@@ -58,6 +57,8 @@ import com.cloud.event.EventTypes;
 import com.cloud.event.UsageEventUtils;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
+import com.cloud.hypervisor.Hypervisor;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.org.Grouping;
 import com.cloud.storage.ScopeType;
 import com.cloud.storage.Storage.ImageFormat;
@@ -126,17 +127,20 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
             throw new InvalidParameterValueException("Please specify a valid URL. URL:" + url + " is invalid");
         }
 
-        try {
-            checkFormat(cmd.getFormat(), url);
-        } catch (InvalidParameterValueException ex) {
-            checkFormat(cmd.getFormat(), path);
-        }
+//        Don't check with Docker template
+        if (!cmd.getHypervisor().equals(Hypervisor.HypervisorType.Docker)) {
+            try {
+                checkFormat(cmd.getFormat(), url);
+            } catch (InvalidParameterValueException ex) {
+                checkFormat(cmd.getFormat(), path);
+            }
 
-        UriUtils.validateUrl(url);
+            UriUtils.validateUrl(url);
+            // Check that the resource limit for secondary storage won't be exceeded
+            _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(cmd.getEntityOwnerId()), ResourceType.secondary_storage, UriUtils.getRemoteSize(url));
+
+        }
         profile.setUrl(url);
-        // Check that the resource limit for secondary storage won't be exceeded
-        _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(cmd.getEntityOwnerId()),
-                ResourceType.secondary_storage, UriUtils.getRemoteSize(url));
         return profile;
     }
 
@@ -183,6 +187,11 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
             throw new CloudRuntimeException("Unable to persist the template " + profile.getTemplate());
         }
 
+        //skip the rest in case of Docker
+        if (profile.getHypervisorType().equals(HypervisorType.Docker)) {
+            return template;
+        }
+
         // find all eligible image stores for this zone scope
         List<DataStore> imageStores = storeMgr.getImageStoresByScope(new ZoneScope(profile.getZoneId()));
         if ( imageStores == null || imageStores.size() == 0 ){