You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sa...@apache.org on 2013/12/30 13:03:32 UTC

git commit: updated refs/heads/4.3 to 68a0b27

Updated Branches:
  refs/heads/4.3 5a2e4fd0a -> 68a0b2792


CLOUDSTACK-3806: OS Preference can not be set.


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

Branch: refs/heads/4.3
Commit: 68a0b27929de4f581f0e3fc411d1e01e8b18f5ea
Parents: 5a2e4fd
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Mon Dec 30 17:09:05 2013 +0530
Committer: Sanjay Tripathi <sa...@citrix.com>
Committed: Mon Dec 30 17:10:52 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/resource/ResourceManagerImpl.java | 24 ++++++++++++--------
 ui/scripts/system.js                            |  2 +-
 2 files changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/68a0b279/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index d34c844..6c20644 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -1272,23 +1272,29 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
         if (guestOSCategoryId != null) {
             // Verify that the guest OS Category exists
-            if (guestOSCategoryId > 0) {
-                if (_guestOSCategoryDao.findById(guestOSCategoryId) == null) {
-                    throw new InvalidParameterValueException("Please specify a valid guest OS category.");
-                }
+            if (!(guestOSCategoryId > 0) || _guestOSCategoryDao.findById(guestOSCategoryId) == null) {
+                throw new InvalidParameterValueException("Please specify a valid guest OS category.");
             }
 
             GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
-            Map<String, String> hostDetails = _hostDetailsDao.findDetails(hostId);
+            DetailVO guestOSDetail = _hostDetailsDao.findDetail(hostId, "guest.os.category.id");
 
             if (guestOSCategory != null && !GuestOSCategoryVO.CATEGORY_NONE.equalsIgnoreCase(guestOSCategory.getName())) {
-                // Save a new entry for guest.os.category.id
-                hostDetails.put("guest.os.category.id", String.valueOf(guestOSCategory.getId()));
+                // Create/Update an entry for guest.os.category.id
+                if (guestOSDetail != null) {
+                    guestOSDetail.setValue(String.valueOf(guestOSCategory.getId()));
+                    _hostDetailsDao.update(guestOSDetail.getId(), guestOSDetail);
+                } else {
+                    Map<String, String> detail = new HashMap<String, String>();
+                    detail.put("guest.os.category.id", String.valueOf(guestOSCategory.getId()));
+                    _hostDetailsDao.persist(hostId, detail);
+                }
             } else {
                 // Delete any existing entry for guest.os.category.id
-                hostDetails.remove("guest.os.category.id");
+                if (guestOSDetail != null) {
+                    _hostDetailsDao.remove(guestOSDetail.getId());
+                }
             }
-            _hostDetailsDao.persist(hostId, hostDetails);
         }
 
         List<String> hostTags = cmd.getHostTags();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/68a0b279/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index be0c16e..6098768 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -13693,7 +13693,7 @@
                                                         var oscategoryObjs = json.listoscategoriesresponse.oscategory;
                                                         var items = [{
                                                             id: '',
-                                                            description: _l('label.none')
+                                                            description: _l('')
                                                         }];
                                                         $(oscategoryObjs).each(function() {
                                                             items.push({