cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/object_store to 1a74dfa
Date Thu, 18 Apr 2013 00:39:51 GMT
Updated Branches:
  refs/heads/object_store fe4f53bfc -> 1a74dfaa2


Move UpdateTemplate and UpdateIso methods from ManagerServerImpl to
TemplateManagerImpl.

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

Branch: refs/heads/object_store
Commit: 1a74dfaa270b86ef69beefd7bc34a836f04c9eb5
Parents: fe4f53b
Author: Min Chen <min.chen@citrix.com>
Authored: Wed Apr 17 17:39:33 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Wed Apr 17 17:39:33 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/server/ManagementService.java    |   11 +--
 api/src/com/cloud/template/TemplateApiService.java |    7 +-
 .../api/command/user/iso/UpdateIsoCmd.java         |    2 +-
 .../command/user/template/UpdateTemplateCmd.java   |    2 +-
 .../src/com/cloud/server/ManagementServerImpl.java |   92 --------------
 server/src/com/cloud/template/TemplateManager.java |    5 +
 .../com/cloud/template/TemplateManagerImpl.java    |   96 +++++++++++++++
 7 files changed, 110 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a74dfaa/api/src/com/cloud/server/ManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index 1e6ca8d..d58ea3e 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -123,21 +123,12 @@ public interface ManagementService {
     /**
      * Searches for servers by the specified search criteria Can search by: "name", "type",
"state", "dataCenterId",
      * "podId"
-     * 
+     *
      * @param cmd
      * @return List of Hosts
      */
     Pair<List<? extends Host>, Integer> searchForServers(ListHostsCmd cmd);
 
-    /**
-     * Creates a new template
-     *
-     * @param cmd
-     * @return updated template
-     */
-    VirtualMachineTemplate updateTemplate(UpdateIsoCmd cmd);
-
-    VirtualMachineTemplate updateTemplate(UpdateTemplateCmd cmd);
 
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a74dfaa/api/src/com/cloud/template/TemplateApiService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/template/TemplateApiService.java b/api/src/com/cloud/template/TemplateApiService.java
index 50373fe..e3906e1 100755
--- a/api/src/com/cloud/template/TemplateApiService.java
+++ b/api/src/com/cloud/template/TemplateApiService.java
@@ -24,11 +24,13 @@ import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoPermissionsCmd;
 import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.ExtractIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
+import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
 import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
+import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd;
 
 import com.cloud.exception.InternalErrorException;
 import com.cloud.exception.ResourceAllocationException;
@@ -90,11 +92,14 @@ public interface TemplateApiService {
     List<String> listTemplatePermissions(BaseListTemplateOrIsoPermissionsCmd cmd);
 
     boolean updateTemplateOrIsoPermissions(BaseUpdateTemplateOrIsoPermissionsCmd cmd);
-    
+
     VirtualMachineTemplate createPrivateTemplateRecord(CreateTemplateCmd cmd,
             Account templateOwner) throws ResourceAllocationException;
 
     VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command)
             throws CloudRuntimeException;
 
+    VirtualMachineTemplate updateTemplate(UpdateIsoCmd cmd);
+
+    VirtualMachineTemplate updateTemplate(UpdateTemplateCmd cmd);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a74dfaa/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java
index 37294e3..1384fa8 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java
@@ -66,7 +66,7 @@ public class UpdateIsoCmd extends BaseUpdateTemplateOrIsoCmd {
 
     @Override
     public void execute(){
-        VirtualMachineTemplate result = _mgr.updateTemplate(this);
+        VirtualMachineTemplate result = _templateService.updateTemplate(this);
         if (result != null) {
             TemplateResponse response = _responseGenerator.createIsoResponse(result);
             response.setResponseName(getCommandName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a74dfaa/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
index 3987dbe..e342fb1 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
@@ -66,7 +66,7 @@ public class UpdateTemplateCmd extends BaseUpdateTemplateOrIsoCmd {
 
     @Override
     public void execute(){
-        VirtualMachineTemplate result = _mgr.updateTemplate(this);
+        VirtualMachineTemplate result = _templateService.updateTemplate(this);
         if (result != null) {
             TemplateResponse response = _responseGenerator.createIsoResponse(result);
             response.setObjectName("template");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a74dfaa/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index ee0fbdb..ff60ce5 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -1275,99 +1275,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         return templateZonePairSet;
     }
 
-    @Override
-    public VMTemplateVO updateTemplate(UpdateIsoCmd cmd) {
-        return updateTemplateOrIso(cmd);
-    }
-
-    @Override
-    public VMTemplateVO updateTemplate(UpdateTemplateCmd cmd) {
-        return updateTemplateOrIso(cmd);
-    }
-
-    private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
-        Long id = cmd.getId();
-        String name = cmd.getTemplateName();
-        String displayText = cmd.getDisplayText();
-        String format = cmd.getFormat();
-        Long guestOSId = cmd.getOsTypeId();
-        Boolean passwordEnabled = cmd.isPasswordEnabled();
-        Boolean bootable = cmd.isBootable();
-        Integer sortKey = cmd.getSortKey();
-        Account account = UserContext.current().getCaller();
-
-        // verify that template exists
-        VMTemplateVO template = _templateDao.findById(id);
-        if (template == null || template.getRemoved() != null) {
-            InvalidParameterValueException ex = new InvalidParameterValueException("unable
to find template/iso with specified id");
-            ex.addProxyObject(template, id, "templateId");
-            throw ex;
-        }
-
-        // Don't allow to modify system template
-        if (id == Long.valueOf(1)) {
-            InvalidParameterValueException ex = new InvalidParameterValueException("Unable
to update template/iso of specified id");
-            ex.addProxyObject(template, id, "templateId");
-            throw ex;
-        }
-
-        // do a permission check
-        _accountMgr.checkAccess(account, AccessType.ModifyEntry, true, template);
-
-        boolean updateNeeded = !(name == null && displayText == null && format
== null && guestOSId == null && passwordEnabled == null
-                && bootable == null && sortKey == null);
-        if (!updateNeeded) {
-            return template;
-        }
-
-        template = _templateDao.createForUpdate(id);
-
-        if (name != null) {
-            template.setName(name);
-        }
-
-        if (displayText != null) {
-            template.setDisplayText(displayText);
-        }
-
-        if (sortKey != null) {
-            template.setSortKey(sortKey);
-        }
-
-        ImageFormat imageFormat = null;
-        if (format != null) {
-            try {
-                imageFormat = ImageFormat.valueOf(format.toUpperCase());
-            } catch (IllegalArgumentException e) {
-                throw new InvalidParameterValueException("Image format: " + format + " is
incorrect. Supported formats are "
-                        + EnumUtils.listValues(ImageFormat.values()));
-            }
-
-            template.setFormat(imageFormat);
-        }
-
-        if (guestOSId != null) {
-            GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
 
-            if (guestOS == null) {
-                throw new InvalidParameterValueException("Please specify a valid guest OS
ID.");
-            } else {
-                template.setGuestOSId(guestOSId);
-            }
-        }
-
-        if (passwordEnabled != null) {
-            template.setEnablePassword(passwordEnabled);
-        }
-
-        if (bootable != null) {
-            template.setBootable(bootable);
-        }
-
-        _templateDao.update(id, template);
-
-        return _templateDao.findById(id);
-    }
 
     @Override
     public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(ListPublicIpAddressesCmd
cmd) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a74dfaa/server/src/com/cloud/template/TemplateManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManager.java b/server/src/com/cloud/template/TemplateManager.java
index 7c80644..9ab51e5 100755
--- a/server/src/com/cloud/template/TemplateManager.java
+++ b/server/src/com/cloud/template/TemplateManager.java
@@ -18,6 +18,8 @@ package com.cloud.template;
 
 import java.util.List;
 
+import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
+import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
@@ -125,4 +127,7 @@ public interface TemplateManager extends TemplateApiService{
 
     List<DataStore> getImageStoreByTemplate(long templateId, Long zoneId);
 
+
+
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a74dfaa/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index 6640df2..9e52422 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -40,11 +40,13 @@ import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.api.BaseListTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
 import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoPermissionsCmd;
 import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.ExtractIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.ListIsoPermissionsCmd;
 import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
+import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.UpdateIsoPermissionsCmd;
 import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
@@ -52,6 +54,7 @@ import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.ListTemplatePermissionsCmd;
 import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
+import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.UpdateTemplatePermissionsCmd;
 import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
@@ -177,6 +180,7 @@ import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserAccountDao;
 import com.cloud.user.dao.UserDao;
 import com.cloud.uservm.UserVm;
+import com.cloud.utils.EnumUtils;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.AdapterBase;
@@ -2225,5 +2229,97 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         return stores;
     }
 
+    @Override
+    public VMTemplateVO updateTemplate(UpdateIsoCmd cmd) {
+        return updateTemplateOrIso(cmd);
+    }
+
+    @Override
+    public VMTemplateVO updateTemplate(UpdateTemplateCmd cmd) {
+        return updateTemplateOrIso(cmd);
+    }
+
+    private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
+        Long id = cmd.getId();
+        String name = cmd.getTemplateName();
+        String displayText = cmd.getDisplayText();
+        String format = cmd.getFormat();
+        Long guestOSId = cmd.getOsTypeId();
+        Boolean passwordEnabled = cmd.isPasswordEnabled();
+        Boolean bootable = cmd.isBootable();
+        Integer sortKey = cmd.getSortKey();
+        Account account = UserContext.current().getCaller();
+
+        // verify that template exists
+        VMTemplateVO template = _tmpltDao.findById(id);
+        if (template == null || template.getRemoved() != null) {
+            InvalidParameterValueException ex = new InvalidParameterValueException("unable
to find template/iso with specified id");
+            ex.addProxyObject(template, id, "templateId");
+            throw ex;
+        }
+
+        // Don't allow to modify system template
+        if (id == Long.valueOf(1)) {
+            InvalidParameterValueException ex = new InvalidParameterValueException("Unable
to update template/iso of specified id");
+            ex.addProxyObject(template, id, "templateId");
+            throw ex;
+        }
+
+        // do a permission check
+        _accountMgr.checkAccess(account, AccessType.ModifyEntry, true, template);
+
+        boolean updateNeeded = !(name == null && displayText == null && format
== null && guestOSId == null && passwordEnabled == null
+                && bootable == null && sortKey == null);
+        if (!updateNeeded) {
+            return template;
+        }
+
+        template = _tmpltDao.createForUpdate(id);
 
+        if (name != null) {
+            template.setName(name);
+        }
+
+        if (displayText != null) {
+            template.setDisplayText(displayText);
+        }
+
+        if (sortKey != null) {
+            template.setSortKey(sortKey);
+        }
+
+        ImageFormat imageFormat = null;
+        if (format != null) {
+            try {
+                imageFormat = ImageFormat.valueOf(format.toUpperCase());
+            } catch (IllegalArgumentException e) {
+                throw new InvalidParameterValueException("Image format: " + format + " is
incorrect. Supported formats are "
+                        + EnumUtils.listValues(ImageFormat.values()));
+            }
+
+            template.setFormat(imageFormat);
+        }
+
+        if (guestOSId != null) {
+            GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
+
+            if (guestOS == null) {
+                throw new InvalidParameterValueException("Please specify a valid guest OS
ID.");
+            } else {
+                template.setGuestOSId(guestOSId);
+            }
+        }
+
+        if (passwordEnabled != null) {
+            template.setEnablePassword(passwordEnabled);
+        }
+
+        if (bootable != null) {
+            template.setBootable(bootable);
+        }
+
+        _tmpltDao.update(id, template);
+
+        return _tmpltDao.findById(id);
+    }
 }


Mime
View raw message